/**
   * Called after a {@link net.robotmedia.billing.BillingRequest} is sent.
   *
   * @param requestId the id the request.
   * @param request the billing request.
   */
  protected static void onRequestSent(long requestId, BillingRequest request) {
    debug("Request " + requestId + " of type " + request.getRequestType() + " sent");

    if (request.isSuccess()) {
      pendingRequests.put(requestId, request);
    } else if (request.hasNonce()) {
      Security.removeNonce(request.getNonce());
    }
  }
Пример #2
0
 /**
  * @see com.jdroid.android.billing.BillingManager#checkResponseCode(long,
  *     com.jdroid.android.billing.BillingResponseCode)
  */
 @Override
 public void checkResponseCode(long requestId, BillingResponseCode responseCode) {
   BillingRequest request = sentRequests.get(requestId);
   if (request != null) {
     Log.d(TAG, request.getClass().getSimpleName() + " response code: " + responseCode);
     request.responseCodeReceived(responseCode);
   }
   sentRequests.remove(requestId);
 }
  /**
   * Called after a {@link net.robotmedia.billing.BillingRequest} is sent.
   *
   * @param context
   * @param requestId the id of the request.
   * @param responseCode the response code.
   * @see net.robotmedia.billing.request.ResponseCode
   */
  protected static void onResponseCode(Context context, long requestId, int responseCode) {
    final BillingRequest.ResponseCode response = BillingRequest.ResponseCode.valueOf(responseCode);
    debug("Request " + requestId + " received response " + response);

    final BillingRequest request = pendingRequests.get(requestId);
    if (request != null) {
      pendingRequests.remove(requestId);
      request.onResponseCode(response);
    }
  }
 private void checkResponseCode(long requestId, ResponseCode responseCode) {
   BillingRequest request = (BillingRequest) mSentRequests.get(Long.valueOf(requestId));
   if (request != null) {
     Log.d(
         "Billing Service - [Don]",
         new StringBuilder(String.valueOf(request.getClass().getSimpleName()))
             .append(": ")
             .append(responseCode)
             .toString());
     request.responseCodeReceived(responseCode);
   }
   mSentRequests.remove(Long.valueOf(requestId));
 }
Пример #5
0
 /**
  * Runs any pending requests that are waiting for a connection to the service to be established.
  * This runs in the main UI thread.
  */
 private void runPendingRequests() {
   BillingRequest request;
   while ((request = pendingRequests.peek()) != null) {
     if (request.runIfConnected()) {
       // Remove the request
       pendingRequests.remove();
     } else {
       // The service crashed, so restart it. Note that this leaves the current request on the
       // queue.
       bindToMarketBillingService();
       return;
     }
   }
 }
Пример #6
0
 private void runRequest(BillingRequest request) {
   try {
     final long requestId = request.run(mService);
     BillingController.onRequestSent(requestId, request);
   } catch (RemoteException e) {
     Log.w(this.getClass().getSimpleName(), "Remote billing service crashed");
     // TODO: Retry?
   }
 }
Пример #7
0
 private void runPendingRequests() {
   BillingRequest request;
   int maxStartId = -1;
   while ((request = mPendingRequests.peek()) != null) {
     if (mService != null) {
       runRequest(request);
       mPendingRequests.remove();
       if (maxStartId < request.getStartId()) {
         maxStartId = request.getStartId();
       }
     } else {
       bindMarketBillingService();
       return;
     }
   }
   if (maxStartId >= 0) {
     stopSelf(maxStartId);
   }
 }
 private void runPendingRequests() {
   int maxStartId = -1;
   while (true) {
     BillingRequest request = (BillingRequest) mPendingRequests.peek();
     if (request == null) {
       if (maxStartId >= 0) {
         Log.i(
             TAG, new StringBuilder("stopping service, startId: ").append(maxStartId).toString());
         stopSelf(maxStartId);
         return;
       } else {
         return;
       }
     } else if (request.runIfConnected()) {
       mPendingRequests.remove();
       if (maxStartId < request.getStartId()) {
         maxStartId = request.getStartId();
       }
     } else {
       bindToMarketBillingService();
       return;
     }
   }
 }
Пример #9
0
 @Override
 protected void onRemoteException(RemoteException e) {
   super.onRemoteException(e);
   Security.removeNonce(nonce);
 }
 protected void onRemoteException(RemoteException e) {
   super.onRemoteException(e);
   Security.removeNonce(this.mNonce);
 }