Session(IAccountManagerResponse response, int userId, AuthenticatorInfo info, boolean expectActivityLaunch, boolean stripAuthTokenFromResult, String accountName, boolean authDetailsRequired, boolean updateLastAuthenticatedTime) { if (info == null) throw new IllegalArgumentException("accountType is null"); this.mStripAuthTokenFromResult = stripAuthTokenFromResult; this.mResponse = response; this.mUserId = userId; this.mAuthenticatorInfo = info; this.mExpectActivityLaunch = expectActivityLaunch; this.mCreationTime = SystemClock.elapsedRealtime(); this.mAccountName = accountName; this.mAuthDetailsRequired = authDetailsRequired; this.mUpdateLastAuthenticatedTime = updateLastAuthenticatedTime; synchronized (mSessions) { mSessions.put(toString(), this); } if (response != null) { try { response.asBinder().linkToDeath(this, 0 /* flags */); } catch (RemoteException e) { mResponse = null; binderDied(); } } }
response = mResponse; } else { response = getResponseAndClose();
void bind() { Log.v(TAG, "initiating bind to authenticator type " + mAuthenticatorInfo.desc.type); Intent intent = new Intent(); intent.setAction(AccountManager.ACTION_AUTHENTICATOR_INTENT); intent.setClassName(mAuthenticatorInfo.serviceInfo.packageName, mAuthenticatorInfo.serviceInfo.name); intent.putExtra("_VA_|_user_id_", mUserId); if (!mContext.bindService(intent, this, Context.BIND_AUTO_CREATE)) { Log.d(TAG, "bind attempt failed for " + toDebugString()); onError(AccountManager.ERROR_CODE_REMOTE_EXCEPTION, "bind failure"); } }
response = mResponse; } else { response = getResponseAndClose();
response = mResponse; } else { response = getResponseAndClose();
super.onResult(result);
super.onResult(result);
@Override public void onResult(Bundle result) throws RemoteException { if (result != null && result.containsKey(AccountManager.KEY_BOOLEAN_RESULT) && !result.containsKey(AccountManager.KEY_INTENT)) { final boolean removalAllowed = result.getBoolean(AccountManager.KEY_BOOLEAN_RESULT); if (removalAllowed) { removeAccountInternal(userId, account); } IAccountManagerResponse response = getResponseAndClose(); if (response != null) { Log.v(TAG, getClass().getSimpleName() + " calling onResult() on response " + response); Bundle result2 = new Bundle(); result2.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, removalAllowed); try { response.onResult(result2); } catch (RemoteException e) { e.printStackTrace(); } } } super.onResult(result); }
Session(IAccountManagerResponse response, int userId, AuthenticatorInfo info, boolean expectActivityLaunch, boolean stripAuthTokenFromResult, String accountName, boolean authDetailsRequired, boolean updateLastAuthenticatedTime) { if (info == null) throw new IllegalArgumentException("accountType is null"); this.mStripAuthTokenFromResult = stripAuthTokenFromResult; this.mResponse = response; this.mUserId = userId; this.mAuthenticatorInfo = info; this.mExpectActivityLaunch = expectActivityLaunch; this.mCreationTime = SystemClock.elapsedRealtime(); this.mAccountName = accountName; this.mAuthDetailsRequired = authDetailsRequired; this.mUpdateLastAuthenticatedTime = updateLastAuthenticatedTime; synchronized (mSessions) { mSessions.put(toString(), this); } if (response != null) { try { response.asBinder().linkToDeath(this, 0 /* flags */); } catch (RemoteException e) { mResponse = null; binderDied(); } } }
Session(IAccountManagerResponse response, int userId, AuthenticatorInfo info, boolean expectActivityLaunch, boolean stripAuthTokenFromResult, String accountName, boolean authDetailsRequired, boolean updateLastAuthenticatedTime) { if (info == null) throw new IllegalArgumentException("accountType is null"); this.mStripAuthTokenFromResult = stripAuthTokenFromResult; this.mResponse = response; this.mUserId = userId; this.mAuthenticatorInfo = info; this.mExpectActivityLaunch = expectActivityLaunch; this.mCreationTime = SystemClock.elapsedRealtime(); this.mAccountName = accountName; this.mAuthDetailsRequired = authDetailsRequired; this.mUpdateLastAuthenticatedTime = updateLastAuthenticatedTime; synchronized (mSessions) { mSessions.put(toString(), this); } if (response != null) { try { response.asBinder().linkToDeath(this, 0 /* flags */); } catch (RemoteException e) { mResponse = null; binderDied(); } } }
@Override public void onResult(Bundle result) throws RemoteException { if (result != null && result.containsKey(AccountManager.KEY_BOOLEAN_RESULT) && !result.containsKey(AccountManager.KEY_INTENT)) { final boolean removalAllowed = result.getBoolean(AccountManager.KEY_BOOLEAN_RESULT); if (removalAllowed) { removeAccountInternal(userId, account); } IAccountManagerResponse response = getResponseAndClose(); if (response != null) { Log.v(TAG, getClass().getSimpleName() + " calling onResult() on response " + response); Bundle result2 = new Bundle(); result2.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, removalAllowed); try { response.onResult(result2); } catch (RemoteException e) { e.printStackTrace(); } } } super.onResult(result); }
@Override public void onError(int errorCode, String errorMessage) { mNumErrors++; IAccountManagerResponse response = getResponseAndClose(); if (response != null) { Log.v(TAG, getClass().getSimpleName() + " calling onError() on response " + response); try { response.onError(errorCode, errorMessage); } catch (RemoteException e) { Log.v(TAG, "Session.onError: caught RemoteException while responding", e); } } else { Log.v(TAG, "Session.onError: already closed"); } }
@Override public void onError(int errorCode, String errorMessage) { mNumErrors++; IAccountManagerResponse response = getResponseAndClose(); if (response != null) { Log.v(TAG, getClass().getSimpleName() + " calling onError() on response " + response); try { response.onError(errorCode, errorMessage); } catch (RemoteException e) { Log.v(TAG, "Session.onError: caught RemoteException while responding", e); } } else { Log.v(TAG, "Session.onError: already closed"); } }
private void close() { synchronized (mSessions) { if (mSessions.remove(toString()) == null) { // the session was already closed, so bail out now return; } } if (mResponse != null) { // stop listening for response deaths mResponse.asBinder().unlinkToDeath(this, 0 /* flags */); // clear this so that we don't accidentally send any further results mResponse = null; } unbind(); }
protected String toDebugString() { return toDebugString(SystemClock.elapsedRealtime()); }
@Override public void onServiceDisconnected(ComponentName name) { mAuthenticator = null; IAccountManagerResponse response = getResponseAndClose(); if (response != null) { try { response.onError(AccountManager.ERROR_CODE_REMOTE_EXCEPTION, "disconnected"); } catch (RemoteException e) { Log.v(TAG, "Session.onServiceDisconnected: " + "caught RemoteException while responding", e); } } }
private void close() { synchronized (mSessions) { if (mSessions.remove(toString()) == null) { // the session was already closed, so bail out now return; } } if (mResponse != null) { // stop listening for response deaths mResponse.asBinder().unlinkToDeath(this, 0 /* flags */); // clear this so that we don't accidentally send any further results mResponse = null; } unbind(); }
protected String toDebugString() { return toDebugString(SystemClock.elapsedRealtime()); }
@Override public void onServiceDisconnected(ComponentName name) { mAuthenticator = null; IAccountManagerResponse response = getResponseAndClose(); if (response != null) { try { response.onError(AccountManager.ERROR_CODE_REMOTE_EXCEPTION, "disconnected"); } catch (RemoteException e) { Log.v(TAG, "Session.onServiceDisconnected: " + "caught RemoteException while responding", e); } } }
@Override protected String toDebugString(long now) { return super.toDebugString(now) + ", getAccountsByTypeAndFeatures" + ", " + (mFeatures != null ? TextUtils.join(",", mFeatures) : null); } }