@Override
 protected SmartLock doInBackground(SmartLock... smartLocks) {
   Log.v(TAG, "Connecting GoogleApiClient....");
   final SmartLock smartLock = smartLocks[0];
   GoogleApiClient client = smartLock.getCredentialClient();
   ConnectionResult result = client.blockingConnect(5, TimeUnit.SECONDS);
   if (!result.isSuccess()) {
     Log.e(TAG, "Failed to connect with GoogleApiClient with code " + result.getErrorCode());
   }
   return smartLock;
 }
 @Override
 protected void onPostExecute(SmartLock smartLock) {
   final Activity activity = this.activityRef.get();
   if (activity == null) {
     Log.w(TAG, "No activity or smart lock store found when trying to save credentials");
     smartLock.getCallback().onError(CredentialStoreCallback.CREDENTIAL_STORE_SAVE_FAILED, null);
     smartLock.clearCredentialStoreCallback();
     return;
   }
   GoogleApiClient client = smartLock.getCredentialClient();
   if (client.isConnected() && !isCancelled()) {
     onConnected(smartLock, activity);
   }
 }