|
|
|
@ -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);
|
|
|
|
|