Billing debug statements get their own DEBUG flag

pull/14/head
Sam Bosley 12 years ago
parent e256017e86
commit e818fcc3bd

@ -15,7 +15,6 @@ import com.todoroo.astrid.billing.BillingConstants.PurchaseState;
import com.todoroo.astrid.billing.BillingConstants.ResponseCode; import com.todoroo.astrid.billing.BillingConstants.ResponseCode;
import com.todoroo.astrid.billing.BillingService.RequestPurchase; import com.todoroo.astrid.billing.BillingService.RequestPurchase;
import com.todoroo.astrid.billing.BillingService.RestoreTransactions; import com.todoroo.astrid.billing.BillingService.RestoreTransactions;
import com.todoroo.astrid.utility.Constants;
@SuppressWarnings("nls") @SuppressWarnings("nls")
public abstract class AstridPurchaseObserver extends PurchaseObserver { public abstract class AstridPurchaseObserver extends PurchaseObserver {
@ -37,7 +36,7 @@ public abstract class AstridPurchaseObserver extends PurchaseObserver {
@Override @Override
public void onBillingSupported(boolean supported, String type) { public void onBillingSupported(boolean supported, String type) {
if (Constants.DEBUG) { if (BillingConstants.DEBUG) {
Log.i(TAG, "supported: " + supported); Log.i(TAG, "supported: " + supported);
} }
if (type != null && type.equals(BillingConstants.ITEM_TYPE_SUBSCRIPTION)) { if (type != null && type.equals(BillingConstants.ITEM_TYPE_SUBSCRIPTION)) {
@ -60,7 +59,7 @@ public abstract class AstridPurchaseObserver extends PurchaseObserver {
@Override @Override
public void onPurchaseStateChange(PurchaseState purchaseState, final String itemId, public void onPurchaseStateChange(PurchaseState purchaseState, final String itemId,
int quantity, long purchaseTime, String developerPayload, final String purchaseToken) { int quantity, long purchaseTime, String developerPayload, final String purchaseToken) {
if (Constants.DEBUG) { if (BillingConstants.DEBUG) {
Log.i(TAG, "onPurchaseStateChange() itemId: " + itemId + " " + purchaseState); Log.i(TAG, "onPurchaseStateChange() itemId: " + itemId + " " + purchaseState);
} }
@ -113,19 +112,19 @@ public abstract class AstridPurchaseObserver extends PurchaseObserver {
@Override @Override
public void onRequestPurchaseResponse(RequestPurchase request, public void onRequestPurchaseResponse(RequestPurchase request,
ResponseCode responseCode) { ResponseCode responseCode) {
if (Constants.DEBUG) { if (BillingConstants.DEBUG) {
Log.d(TAG, request.mProductId + ": " + responseCode); Log.d(TAG, request.mProductId + ": " + responseCode);
} }
if (responseCode == ResponseCode.RESULT_OK) { if (responseCode == ResponseCode.RESULT_OK) {
if (Constants.DEBUG) { if (BillingConstants.DEBUG) {
Log.i(TAG, "purchase was successfully sent to server"); Log.i(TAG, "purchase was successfully sent to server");
} }
} else if (responseCode == ResponseCode.RESULT_USER_CANCELED) { } else if (responseCode == ResponseCode.RESULT_USER_CANCELED) {
if (Constants.DEBUG) { if (BillingConstants.DEBUG) {
Log.i(TAG, "user canceled purchase"); Log.i(TAG, "user canceled purchase");
} }
} else { } else {
if (Constants.DEBUG) { if (BillingConstants.DEBUG) {
Log.i(TAG, "purchase failed"); Log.i(TAG, "purchase failed");
} }
} }
@ -135,14 +134,14 @@ public abstract class AstridPurchaseObserver extends PurchaseObserver {
public void onRestoreTransactionsResponse(RestoreTransactions request, public void onRestoreTransactionsResponse(RestoreTransactions request,
ResponseCode responseCode) { ResponseCode responseCode) {
if (responseCode == ResponseCode.RESULT_OK) { if (responseCode == ResponseCode.RESULT_OK) {
if (Constants.DEBUG) { if (BillingConstants.DEBUG) {
Log.d(TAG, "completed RestoreTransactions request"); Log.d(TAG, "completed RestoreTransactions request");
} }
// Update the shared preferences so that we don't perform // Update the shared preferences so that we don't perform
// a RestoreTransactions again. // a RestoreTransactions again.
Preferences.setBoolean(BillingConstants.PREF_TRANSACTIONS_INITIALIZED, true); Preferences.setBoolean(BillingConstants.PREF_TRANSACTIONS_INITIALIZED, true);
} else { } else {
if (Constants.DEBUG) { if (BillingConstants.DEBUG) {
Log.d(TAG, "RestoreTransactions error: " + responseCode); Log.d(TAG, "RestoreTransactions error: " + responseCode);
} }
} }

@ -31,7 +31,6 @@ import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.andlib.utility.Preferences; import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService; import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.service.ThemeService; import com.todoroo.astrid.service.ThemeService;
import com.todoroo.astrid.utility.Constants;
public class BillingActivity extends FragmentActivity { public class BillingActivity extends FragmentActivity {
@ -246,7 +245,7 @@ public class BillingActivity extends FragmentActivity {
private Dialog createDialog(int titleId, int messageId) { private Dialog createDialog(int titleId, int messageId) {
String helpUrl = replaceLanguageAndRegion(getString(R.string.subscriptions_help_url)); String helpUrl = replaceLanguageAndRegion(getString(R.string.subscriptions_help_url));
if (Constants.DEBUG) { if (BillingConstants.DEBUG) {
Log.i("billing-activity-url", helpUrl); //$NON-NLS-1$ Log.i("billing-activity-url", helpUrl); //$NON-NLS-1$
} }
final Uri helpUri = Uri.parse(helpUrl); final Uri helpUri = Uri.parse(helpUrl);

@ -1,6 +1,7 @@
package com.todoroo.astrid.billing; package com.todoroo.astrid.billing;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService; import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.utility.Constants;
@SuppressWarnings("nls") @SuppressWarnings("nls")
@ -61,6 +62,8 @@ public class BillingConstants {
public static final char PUB_KEY_REPLACE_CHAR = 'B'; public static final char PUB_KEY_REPLACE_CHAR = 'B';
public static final String PUB_KEY_OBFUSCATED = "pubkey"; public static final String PUB_KEY_OBFUSCATED = "pubkey";
public static final boolean DEBUG = false || Constants.DEBUG;
// The response codes for a request, defined by Android Market. // The response codes for a request, defined by Android Market.
public enum ResponseCode { public enum ResponseCode {
RESULT_OK, RESULT_OK,

@ -6,7 +6,6 @@ import android.content.Intent;
import android.util.Log; import android.util.Log;
import com.todoroo.astrid.billing.BillingConstants.ResponseCode; import com.todoroo.astrid.billing.BillingConstants.ResponseCode;
import com.todoroo.astrid.utility.Constants;
public class BillingReceiver extends BroadcastReceiver { public class BillingReceiver extends BroadcastReceiver {
private static final String TAG = "billing-receiver"; //$NON-NLS-1$ private static final String TAG = "billing-receiver"; //$NON-NLS-1$
@ -27,7 +26,7 @@ public class BillingReceiver extends BroadcastReceiver {
purchaseStateChanged(context, signedData, signature); purchaseStateChanged(context, signedData, signature);
} else if (BillingConstants.ACTION_NOTIFY.equals(action)) { } else if (BillingConstants.ACTION_NOTIFY.equals(action)) {
String notifyId = intent.getStringExtra(BillingConstants.NOTIFICATION_ID); String notifyId = intent.getStringExtra(BillingConstants.NOTIFICATION_ID);
if (Constants.DEBUG) { if (BillingConstants.DEBUG) {
Log.i(TAG, "notifyId: " + notifyId); //$NON-NLS-1$ Log.i(TAG, "notifyId: " + notifyId); //$NON-NLS-1$
} }
notify(context, notifyId); notify(context, notifyId);

@ -19,7 +19,6 @@ import com.android.vending.billing.IMarketBillingService;
import com.todoroo.astrid.billing.BillingConstants.PurchaseState; import com.todoroo.astrid.billing.BillingConstants.PurchaseState;
import com.todoroo.astrid.billing.BillingConstants.ResponseCode; import com.todoroo.astrid.billing.BillingConstants.ResponseCode;
import com.todoroo.astrid.billing.Security.VerifiedPurchase; import com.todoroo.astrid.billing.Security.VerifiedPurchase;
import com.todoroo.astrid.utility.Constants;
@SuppressWarnings("nls") @SuppressWarnings("nls")
public class BillingService extends Service implements ServiceConnection { public class BillingService extends Service implements ServiceConnection {
@ -86,13 +85,13 @@ public class BillingService extends Service implements ServiceConnection {
* is not connected or there was an error when trying to use it * is not connected or there was an error when trying to use it
*/ */
public boolean runIfConnected() { public boolean runIfConnected() {
if (Constants.DEBUG) { if (BillingConstants.DEBUG) {
Log.d(TAG, getClass().getSimpleName()); Log.d(TAG, getClass().getSimpleName());
} }
if (mService != null) { if (mService != null) {
try { try {
mRequestId = run(); mRequestId = run();
if (Constants.DEBUG) { if (BillingConstants.DEBUG) {
Log.d(TAG, "request id: " + mRequestId); Log.d(TAG, "request id: " + mRequestId);
} }
if (mRequestId >= 0) { if (mRequestId >= 0) {
@ -143,7 +142,7 @@ public class BillingService extends Service implements ServiceConnection {
protected void logResponseCode(String method, Bundle response) { protected void logResponseCode(String method, Bundle response) {
ResponseCode responseCode = ResponseCode.valueOf( ResponseCode responseCode = ResponseCode.valueOf(
response.getInt(BillingConstants.BILLING_RESPONSE_RESPONSE_CODE)); response.getInt(BillingConstants.BILLING_RESPONSE_RESPONSE_CODE));
if (Constants.DEBUG) { if (BillingConstants.DEBUG) {
Log.e(TAG, method + " received " + responseCode.toString()); Log.e(TAG, method + " received " + responseCode.toString());
} }
} }
@ -198,7 +197,7 @@ public class BillingService extends Service implements ServiceConnection {
} }
Bundle response = mService.sendBillingRequest(request); Bundle response = mService.sendBillingRequest(request);
int responseCode = response.getInt(BillingConstants.BILLING_RESPONSE_RESPONSE_CODE); int responseCode = response.getInt(BillingConstants.BILLING_RESPONSE_RESPONSE_CODE);
if (Constants.DEBUG) { if (BillingConstants.DEBUG) {
Log.i(TAG, "CheckBillingSupported response code: " + Log.i(TAG, "CheckBillingSupported response code: " +
ResponseCode.valueOf(responseCode)); ResponseCode.valueOf(responseCode));
} }
@ -406,7 +405,7 @@ public class BillingService extends Service implements ServiceConnection {
if (intent == null) if (intent == null)
return; return;
String action = intent.getAction(); String action = intent.getAction();
if (Constants.DEBUG) { if (BillingConstants.DEBUG) {
Log.i(TAG, "handleCommand() action: " + action); Log.i(TAG, "handleCommand() action: " + action);
} }
if (BillingConstants.ACTION_CONFIRM_NOTIFICATION.equals(action)) { if (BillingConstants.ACTION_CONFIRM_NOTIFICATION.equals(action)) {
@ -435,7 +434,7 @@ public class BillingService extends Service implements ServiceConnection {
*/ */
private boolean bindToMarketBillingService() { private boolean bindToMarketBillingService() {
try { try {
if (Constants.DEBUG) { if (BillingConstants.DEBUG) {
Log.i(TAG, "binding to Market billing service"); Log.i(TAG, "binding to Market billing service");
} }
boolean bindResult = bindService( boolean bindResult = bindService(
@ -576,7 +575,7 @@ public class BillingService extends Service implements ServiceConnection {
private void checkResponseCode(long requestId, ResponseCode responseCode) { private void checkResponseCode(long requestId, ResponseCode responseCode) {
BillingRequest request = mSentRequests.get(requestId); BillingRequest request = mSentRequests.get(requestId);
if (request != null) { if (request != null) {
if (Constants.DEBUG) { if (BillingConstants.DEBUG) {
Log.d(TAG, request.getClass().getSimpleName() + ": " + responseCode); Log.d(TAG, request.getClass().getSimpleName() + ": " + responseCode);
} }
request.responseCodeReceived(responseCode); request.responseCodeReceived(responseCode);
@ -613,7 +612,7 @@ public class BillingService extends Service implements ServiceConnection {
// is not -1, then one of the requests started the service, so we can // is not -1, then one of the requests started the service, so we can
// stop it now. // stop it now.
if (maxStartId >= 0) { if (maxStartId >= 0) {
if (Constants.DEBUG) { if (BillingConstants.DEBUG) {
Log.i(TAG, "stopping service, startId: " + maxStartId); Log.i(TAG, "stopping service, startId: " + maxStartId);
} }
stopSelf(maxStartId); stopSelf(maxStartId);
@ -626,7 +625,7 @@ public class BillingService extends Service implements ServiceConnection {
*/ */
@Override @Override
public void onServiceConnected(ComponentName name, IBinder service) { public void onServiceConnected(ComponentName name, IBinder service) {
if (Constants.DEBUG) { if (BillingConstants.DEBUG) {
Log.d(TAG, "Billing service connected"); Log.d(TAG, "Billing service connected");
} }
mService = IMarketBillingService.Stub.asInterface(service); mService = IMarketBillingService.Stub.asInterface(service);

@ -12,7 +12,6 @@ import com.todoroo.astrid.billing.BillingConstants.PurchaseState;
import com.todoroo.astrid.billing.BillingConstants.ResponseCode; import com.todoroo.astrid.billing.BillingConstants.ResponseCode;
import com.todoroo.astrid.billing.BillingService.RequestPurchase; import com.todoroo.astrid.billing.BillingService.RequestPurchase;
import com.todoroo.astrid.billing.BillingService.RestoreTransactions; import com.todoroo.astrid.billing.BillingService.RestoreTransactions;
import com.todoroo.astrid.utility.Constants;
/** /**
* This class contains the methods that handle responses from Android Market. The * This class contains the methods that handle responses from Android Market. The
@ -75,7 +74,7 @@ public class ResponseHandler {
*/ */
public static void buyPageIntentResponse(PendingIntent pendingIntent, Intent intent) { public static void buyPageIntentResponse(PendingIntent pendingIntent, Intent intent) {
if (sPurchaseObserver == null) { if (sPurchaseObserver == null) {
if (Constants.DEBUG) { if (BillingConstants.DEBUG) {
Log.d(TAG, "UI is not running"); Log.d(TAG, "UI is not running");
} }
return; return;

@ -22,7 +22,6 @@ import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import com.todoroo.astrid.billing.BillingConstants.PurchaseState; import com.todoroo.astrid.billing.BillingConstants.PurchaseState;
import com.todoroo.astrid.utility.Constants;
/** /**
* Security-related methods. For a secure implementation, all of this code * Security-related methods. For a secure implementation, all of this code
@ -108,7 +107,7 @@ public class Security {
Log.e(TAG, "data is null"); Log.e(TAG, "data is null");
return null; return null;
} }
if (Constants.DEBUG) { if (BillingConstants.DEBUG) {
Log.i(TAG, "signedData: " + signedData); Log.i(TAG, "signedData: " + signedData);
} }
boolean verified = false; boolean verified = false;
@ -229,7 +228,7 @@ public class Security {
* @return true if the data and signature match * @return true if the data and signature match
*/ */
public static boolean verify(PublicKey publicKey, String signedData, String signature) { public static boolean verify(PublicKey publicKey, String signedData, String signature) {
if (Constants.DEBUG) { if (BillingConstants.DEBUG) {
Log.i(TAG, "signature: " + signature); Log.i(TAG, "signature: " + signature);
} }
Signature sig; Signature sig;

@ -41,7 +41,7 @@ public final class Constants {
/** /**
* Whether to turn on debugging logging and UI * Whether to turn on debugging logging and UI
*/ */
public static final boolean DEBUG = false; public static final boolean DEBUG = true;
/** /**
* Astrid Help URL * Astrid Help URL

Loading…
Cancel
Save