diff --git a/astrid/src/com/todoroo/astrid/billing/AstridPurchaseObserver.java b/astrid/src/com/todoroo/astrid/billing/AstridPurchaseObserver.java index 61ecad7ae..fa52efad8 100644 --- a/astrid/src/com/todoroo/astrid/billing/AstridPurchaseObserver.java +++ b/astrid/src/com/todoroo/astrid/billing/AstridPurchaseObserver.java @@ -15,7 +15,6 @@ import com.todoroo.astrid.billing.BillingConstants.PurchaseState; import com.todoroo.astrid.billing.BillingConstants.ResponseCode; import com.todoroo.astrid.billing.BillingService.RequestPurchase; import com.todoroo.astrid.billing.BillingService.RestoreTransactions; -import com.todoroo.astrid.utility.Constants; @SuppressWarnings("nls") public abstract class AstridPurchaseObserver extends PurchaseObserver { @@ -37,7 +36,7 @@ public abstract class AstridPurchaseObserver extends PurchaseObserver { @Override public void onBillingSupported(boolean supported, String type) { - if (Constants.DEBUG) { + if (BillingConstants.DEBUG) { Log.i(TAG, "supported: " + supported); } if (type != null && type.equals(BillingConstants.ITEM_TYPE_SUBSCRIPTION)) { @@ -60,7 +59,7 @@ public abstract class AstridPurchaseObserver extends PurchaseObserver { @Override public void onPurchaseStateChange(PurchaseState purchaseState, final String itemId, int quantity, long purchaseTime, String developerPayload, final String purchaseToken) { - if (Constants.DEBUG) { + if (BillingConstants.DEBUG) { Log.i(TAG, "onPurchaseStateChange() itemId: " + itemId + " " + purchaseState); } @@ -113,19 +112,19 @@ public abstract class AstridPurchaseObserver extends PurchaseObserver { @Override public void onRequestPurchaseResponse(RequestPurchase request, ResponseCode responseCode) { - if (Constants.DEBUG) { + if (BillingConstants.DEBUG) { Log.d(TAG, request.mProductId + ": " + responseCode); } if (responseCode == ResponseCode.RESULT_OK) { - if (Constants.DEBUG) { + if (BillingConstants.DEBUG) { Log.i(TAG, "purchase was successfully sent to server"); } } else if (responseCode == ResponseCode.RESULT_USER_CANCELED) { - if (Constants.DEBUG) { + if (BillingConstants.DEBUG) { Log.i(TAG, "user canceled purchase"); } } else { - if (Constants.DEBUG) { + if (BillingConstants.DEBUG) { Log.i(TAG, "purchase failed"); } } @@ -135,14 +134,14 @@ public abstract class AstridPurchaseObserver extends PurchaseObserver { public void onRestoreTransactionsResponse(RestoreTransactions request, ResponseCode responseCode) { if (responseCode == ResponseCode.RESULT_OK) { - if (Constants.DEBUG) { + if (BillingConstants.DEBUG) { Log.d(TAG, "completed RestoreTransactions request"); } // Update the shared preferences so that we don't perform // a RestoreTransactions again. Preferences.setBoolean(BillingConstants.PREF_TRANSACTIONS_INITIALIZED, true); } else { - if (Constants.DEBUG) { + if (BillingConstants.DEBUG) { Log.d(TAG, "RestoreTransactions error: " + responseCode); } } diff --git a/astrid/src/com/todoroo/astrid/billing/BillingActivity.java b/astrid/src/com/todoroo/astrid/billing/BillingActivity.java index bd912fbe8..9732e8ba9 100644 --- a/astrid/src/com/todoroo/astrid/billing/BillingActivity.java +++ b/astrid/src/com/todoroo/astrid/billing/BillingActivity.java @@ -31,7 +31,6 @@ import com.todoroo.andlib.utility.DialogUtilities; import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.actfm.sync.ActFmPreferenceService; import com.todoroo.astrid.service.ThemeService; -import com.todoroo.astrid.utility.Constants; public class BillingActivity extends FragmentActivity { @@ -246,7 +245,7 @@ public class BillingActivity extends FragmentActivity { private Dialog createDialog(int titleId, int messageId) { String helpUrl = replaceLanguageAndRegion(getString(R.string.subscriptions_help_url)); - if (Constants.DEBUG) { + if (BillingConstants.DEBUG) { Log.i("billing-activity-url", helpUrl); //$NON-NLS-1$ } final Uri helpUri = Uri.parse(helpUrl); diff --git a/astrid/src/com/todoroo/astrid/billing/BillingConstants.java b/astrid/src/com/todoroo/astrid/billing/BillingConstants.java index b9a416951..b382e5aff 100644 --- a/astrid/src/com/todoroo/astrid/billing/BillingConstants.java +++ b/astrid/src/com/todoroo/astrid/billing/BillingConstants.java @@ -1,6 +1,7 @@ package com.todoroo.astrid.billing; import com.todoroo.astrid.actfm.sync.ActFmPreferenceService; +import com.todoroo.astrid.utility.Constants; @SuppressWarnings("nls") @@ -61,6 +62,8 @@ public class BillingConstants { public static final char PUB_KEY_REPLACE_CHAR = 'B'; 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. public enum ResponseCode { RESULT_OK, diff --git a/astrid/src/com/todoroo/astrid/billing/BillingReceiver.java b/astrid/src/com/todoroo/astrid/billing/BillingReceiver.java index fec87f70c..81602c520 100644 --- a/astrid/src/com/todoroo/astrid/billing/BillingReceiver.java +++ b/astrid/src/com/todoroo/astrid/billing/BillingReceiver.java @@ -6,7 +6,6 @@ import android.content.Intent; import android.util.Log; import com.todoroo.astrid.billing.BillingConstants.ResponseCode; -import com.todoroo.astrid.utility.Constants; public class BillingReceiver extends BroadcastReceiver { private static final String TAG = "billing-receiver"; //$NON-NLS-1$ @@ -27,7 +26,7 @@ public class BillingReceiver extends BroadcastReceiver { purchaseStateChanged(context, signedData, signature); } else if (BillingConstants.ACTION_NOTIFY.equals(action)) { String notifyId = intent.getStringExtra(BillingConstants.NOTIFICATION_ID); - if (Constants.DEBUG) { + if (BillingConstants.DEBUG) { Log.i(TAG, "notifyId: " + notifyId); //$NON-NLS-1$ } notify(context, notifyId); diff --git a/astrid/src/com/todoroo/astrid/billing/BillingService.java b/astrid/src/com/todoroo/astrid/billing/BillingService.java index 6d5227c70..a00bb0c4f 100644 --- a/astrid/src/com/todoroo/astrid/billing/BillingService.java +++ b/astrid/src/com/todoroo/astrid/billing/BillingService.java @@ -19,7 +19,6 @@ import com.android.vending.billing.IMarketBillingService; import com.todoroo.astrid.billing.BillingConstants.PurchaseState; import com.todoroo.astrid.billing.BillingConstants.ResponseCode; import com.todoroo.astrid.billing.Security.VerifiedPurchase; -import com.todoroo.astrid.utility.Constants; @SuppressWarnings("nls") 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 */ public boolean runIfConnected() { - if (Constants.DEBUG) { + if (BillingConstants.DEBUG) { Log.d(TAG, getClass().getSimpleName()); } if (mService != null) { try { mRequestId = run(); - if (Constants.DEBUG) { + if (BillingConstants.DEBUG) { Log.d(TAG, "request id: " + mRequestId); } if (mRequestId >= 0) { @@ -143,7 +142,7 @@ public class BillingService extends Service implements ServiceConnection { protected void logResponseCode(String method, Bundle response) { ResponseCode responseCode = ResponseCode.valueOf( response.getInt(BillingConstants.BILLING_RESPONSE_RESPONSE_CODE)); - if (Constants.DEBUG) { + if (BillingConstants.DEBUG) { Log.e(TAG, method + " received " + responseCode.toString()); } } @@ -198,7 +197,7 @@ public class BillingService extends Service implements ServiceConnection { } Bundle response = mService.sendBillingRequest(request); int responseCode = response.getInt(BillingConstants.BILLING_RESPONSE_RESPONSE_CODE); - if (Constants.DEBUG) { + if (BillingConstants.DEBUG) { Log.i(TAG, "CheckBillingSupported response code: " + ResponseCode.valueOf(responseCode)); } @@ -406,7 +405,7 @@ public class BillingService extends Service implements ServiceConnection { if (intent == null) return; String action = intent.getAction(); - if (Constants.DEBUG) { + if (BillingConstants.DEBUG) { Log.i(TAG, "handleCommand() action: " + action); } if (BillingConstants.ACTION_CONFIRM_NOTIFICATION.equals(action)) { @@ -435,7 +434,7 @@ public class BillingService extends Service implements ServiceConnection { */ private boolean bindToMarketBillingService() { try { - if (Constants.DEBUG) { + if (BillingConstants.DEBUG) { Log.i(TAG, "binding to Market billing service"); } boolean bindResult = bindService( @@ -576,7 +575,7 @@ public class BillingService extends Service implements ServiceConnection { private void checkResponseCode(long requestId, ResponseCode responseCode) { BillingRequest request = mSentRequests.get(requestId); if (request != null) { - if (Constants.DEBUG) { + if (BillingConstants.DEBUG) { Log.d(TAG, request.getClass().getSimpleName() + ": " + 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 // stop it now. if (maxStartId >= 0) { - if (Constants.DEBUG) { + if (BillingConstants.DEBUG) { Log.i(TAG, "stopping service, startId: " + maxStartId); } stopSelf(maxStartId); @@ -626,7 +625,7 @@ public class BillingService extends Service implements ServiceConnection { */ @Override public void onServiceConnected(ComponentName name, IBinder service) { - if (Constants.DEBUG) { + if (BillingConstants.DEBUG) { Log.d(TAG, "Billing service connected"); } mService = IMarketBillingService.Stub.asInterface(service); diff --git a/astrid/src/com/todoroo/astrid/billing/ResponseHandler.java b/astrid/src/com/todoroo/astrid/billing/ResponseHandler.java index 5d346d57e..fccfbd3e3 100644 --- a/astrid/src/com/todoroo/astrid/billing/ResponseHandler.java +++ b/astrid/src/com/todoroo/astrid/billing/ResponseHandler.java @@ -12,7 +12,6 @@ import com.todoroo.astrid.billing.BillingConstants.PurchaseState; import com.todoroo.astrid.billing.BillingConstants.ResponseCode; import com.todoroo.astrid.billing.BillingService.RequestPurchase; 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 @@ -75,7 +74,7 @@ public class ResponseHandler { */ public static void buyPageIntentResponse(PendingIntent pendingIntent, Intent intent) { if (sPurchaseObserver == null) { - if (Constants.DEBUG) { + if (BillingConstants.DEBUG) { Log.d(TAG, "UI is not running"); } return; diff --git a/astrid/src/com/todoroo/astrid/billing/Security.java b/astrid/src/com/todoroo/astrid/billing/Security.java index 57b5eacd2..f39045605 100644 --- a/astrid/src/com/todoroo/astrid/billing/Security.java +++ b/astrid/src/com/todoroo/astrid/billing/Security.java @@ -22,7 +22,6 @@ import android.text.TextUtils; import android.util.Log; import com.todoroo.astrid.billing.BillingConstants.PurchaseState; -import com.todoroo.astrid.utility.Constants; /** * Security-related methods. For a secure implementation, all of this code @@ -108,7 +107,7 @@ public class Security { Log.e(TAG, "data is null"); return null; } - if (Constants.DEBUG) { + if (BillingConstants.DEBUG) { Log.i(TAG, "signedData: " + signedData); } boolean verified = false; @@ -229,7 +228,7 @@ public class Security { * @return true if the data and signature match */ public static boolean verify(PublicKey publicKey, String signedData, String signature) { - if (Constants.DEBUG) { + if (BillingConstants.DEBUG) { Log.i(TAG, "signature: " + signature); } Signature sig; diff --git a/astrid/src/com/todoroo/astrid/utility/Constants.java b/astrid/src/com/todoroo/astrid/utility/Constants.java index 13647ee28..2bedc6ae1 100644 --- a/astrid/src/com/todoroo/astrid/utility/Constants.java +++ b/astrid/src/com/todoroo/astrid/utility/Constants.java @@ -41,7 +41,7 @@ public final class Constants { /** * Whether to turn on debugging logging and UI */ - public static final boolean DEBUG = false; + public static final boolean DEBUG = true; /** * Astrid Help URL