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); }
@Override public void onResponse(AddPublicKeysResponse response) { if (response.statusCode == 200) { removePublicKeys(response); CMAccountUtils.resetBackoff(mAuthClient.getEncryptionPreferences()); } else { handleError(); } synchronized (mNetworkRequestLock) { mNetworkRequestInProgress = false; } }
public GeneratePublicKeysTask(Context context) { mContext = context; mAuthClient = AuthClient.getInstance(context); }
private void scheduleRetry() { final Context context = mContext.getApplicationContext(); mIntent.putExtra(ECDHKeyService.EXTRA_RETRY, true); CMAccountUtils.scheduleRetry(context, mAuthClient.getEncryptionPreferences(), mIntent); }