コード例 #1
0
  private void uploadKeyPairs() {
    List<ECKeyPair> keyPairs = getKeyPairs();
    if (keyPairs.size() == 0) {
      CMAccountUtils.resetBackoff(mAuthClient.getEncryptionPreferences());
      if (CMAccount.DEBUG) Log.d(TAG, "No keys to upload.");
      return;
    }

    if (CMAccountUtils.getCMAccountAccount(mContext) == null) {
      CMAccountUtils.resetBackoff(mAuthClient.getEncryptionPreferences());
      if (CMAccount.DEBUG) Log.d(TAG, "No CMAccount Configured!");
      return;
    }

    synchronized (mNetworkRequestLock) {
      if (mNetworkRequestInProgress) {
        if (CMAccount.DEBUG)
          Log.d(TAG, "Another network request is in progress, scheduling retry.");
        scheduleRetry();
        return;
      }
      mNetworkRequestInProgress = true;
    }
    AddPublicKeysRequestBody requestBody = new AddPublicKeysRequestBody(mContext, keyPairs);
    mAuthClient.addPublicKeys(requestBody, this, this);
  }
コード例 #2
0
 @Override
 public void onResponse(AddPublicKeysResponse response) {
   if (response.statusCode == 200) {
     removePublicKeys(response);
     CMAccountUtils.resetBackoff(mAuthClient.getEncryptionPreferences());
   } else {
     handleError();
   }
   synchronized (mNetworkRequestLock) {
     mNetworkRequestInProgress = false;
   }
 }
コード例 #3
0
 public GeneratePublicKeysTask(Context context) {
   mContext = context;
   mAuthClient = AuthClient.getInstance(context);
 }
コード例 #4
0
 private void scheduleRetry() {
   final Context context = mContext.getApplicationContext();
   mIntent.putExtra(ECDHKeyService.EXTRA_RETRY, true);
   CMAccountUtils.scheduleRetry(context, mAuthClient.getEncryptionPreferences(), mIntent);
 }