Program: 23048
Project: 23048
Buggy source:
/** 
 * Gets an auth token of the specified type for a particular account, optionally raising a notification if the user must enter credentials. This method is intended for background tasks and services where the user should not be immediately interrupted with a password prompt. <p>If a previously generated auth token is cached for this account and type, then it will be returned.  Otherwise, if we have saved credentials the server accepts, it will be used to generate a new auth token. Otherwise, an Intent will be returned which, when started, will prompt the user for a password.  If the notifyAuthFailure parameter is set, the same Intent will be associated with a status bar notification, alerting the user that they need to enter a password at some point. <p>If the intent is left in a notification, you will need to wait until the user gets around to entering a password before trying again, which could be hours or days or never.  When it does happen, the account manager will broadcast the   {@link #LOGIN_ACCOUNTS_CHANGED_ACTION}{@link Intent}, which applications can use to trigger another attempt to fetch an auth token. <p>If notifications are not enabled, it is the application's responsibility to launch the returned intent at some point to let the user enter credentials.  In either case, the result from this call will not wait for user action. <p>The value of the auth token type depends on the authenticator. Some services use different tokens to access different functionality -- for example, Google uses different auth tokens to access Gmail and Google Calendar for the same account. <p>This method may be called from any thread, but the returned  {@link AccountManagerFuture} must not be used on the main thread.<p>This method requires the caller to hold the permission {@link android.Manifest.permission#USE_CREDENTIALS}.
 * @param account The account to fetch an auth token for
 * @param authTokenType The auth token type, an authenticator-dependentstring token, must not be null
 * @param options Authenticator-specific options for the request,may be null or empty
 * @param notifyAuthFailure True to add a notification to prompt theuser for a password if necessary, false to leave that to the caller
 * @param callback Callback to invoke when the request completes,null for no callback
 * @param handler {@link Handler} identifying the callback thread,null for the main thread
 * @return An {@link AccountManagerFuture} which resolves to a Bundle withat least the following fields on success: <ul> <li>  {@link #KEY_ACCOUNT_NAME} - the name of the account you supplied<li>  {@link #KEY_ACCOUNT_TYPE} - the type of the account<li>  {@link #KEY_AUTHTOKEN} - the auth token you wanted</ul> (Other authenticator-specific values may be returned.)  If the user must enter credentials, the returned Bundle contains only {@link #KEY_INTENT} with the {@link Intent} needed to launch a prompt.<p>If an error occurred,  {@link AccountManagerFuture#getResult()} throws:<ul> <li>  {@link AuthenticatorException} if the authenticator failed to respond<li>  {@link OperationCanceledException} if the operation is canceled forany reason, incluidng the user canceling a credential request <li>  {@link IOException} if the authenticator experienced an I/O problemcreating a new auth token, usually because of network trouble </ul>
 */
public AccountManagerFuture<Bundle> getAuthToken(final Account account,final String authTokenType,final boolean notifyAuthFailure,AccountManagerCallback<Bundle> callback,Handler handler){
  if (account == null)   throw new IllegalArgumentException("String_Node_Str");
  if (authTokenType == null)   throw new IllegalArgumentException("String_Node_Str");
  return new AmsTask(null,handler,callback){
    public void doWork() throws RemoteException {
      mService.getAuthToken(mResponse,account,authTokenType,notifyAuthFailure,false,null);
    }
  }
.start();
}

Fixed version (ground truth):
/** 
 * Gets an auth token of the specified type for a particular account, optionally raising a notification if the user must enter credentials. This method is intended for background tasks and services where the user should not be immediately interrupted with a password prompt. <p>If a previously generated auth token is cached for this account and type, then it will be returned.  Otherwise, if we have saved credentials the server accepts, it will be used to generate a new auth token. Otherwise, an Intent will be returned which, when started, will prompt the user for a password.  If the notifyAuthFailure parameter is set, the same Intent will be associated with a status bar notification, alerting the user that they need to enter a password at some point. <p>If the intent is left in a notification, you will need to wait until the user gets around to entering a password before trying again, which could be hours or days or never.  When it does happen, the account manager will broadcast the   {@link #LOGIN_ACCOUNTS_CHANGED_ACTION}{@link Intent}, which applications can use to trigger another attempt to fetch an auth token. <p>If notifications are not enabled, it is the application's responsibility to launch the returned intent at some point to let the user enter credentials.  In either case, the result from this call will not wait for user action. <p>The value of the auth token type depends on the authenticator. Some services use different tokens to access different functionality -- for example, Google uses different auth tokens to access Gmail and Google Calendar for the same account. <p>This method may be called from any thread, but the returned  {@link AccountManagerFuture} must not be used on the main thread.<p>This method requires the caller to hold the permission {@link android.Manifest.permission#USE_CREDENTIALS}.
 * @param account The account to fetch an auth token for
 * @param authTokenType The auth token type, an authenticator-dependentstring token, must not be null
 * @param notifyAuthFailure True to add a notification to prompt theuser for a password if necessary, false to leave that to the caller
 * @param callback Callback to invoke when the request completes,null for no callback
 * @param handler {@link Handler} identifying the callback thread,null for the main thread
 * @return An {@link AccountManagerFuture} which resolves to a Bundle withat least the following fields on success: <ul> <li>  {@link #KEY_ACCOUNT_NAME} - the name of the account you supplied<li>  {@link #KEY_ACCOUNT_TYPE} - the type of the account<li>  {@link #KEY_AUTHTOKEN} - the auth token you wanted</ul> (Other authenticator-specific values may be returned.)  If the user must enter credentials, the returned Bundle contains only {@link #KEY_INTENT} with the {@link Intent} needed to launch a prompt.<p>If an error occurred,  {@link AccountManagerFuture#getResult()} throws:<ul> <li>  {@link AuthenticatorException} if the authenticator failed to respond<li>  {@link OperationCanceledException} if the operation is canceled forany reason, incluidng the user canceling a credential request <li>  {@link IOException} if the authenticator experienced an I/O problemcreating a new auth token, usually because of network trouble </ul>
 */
public AccountManagerFuture<Bundle> getAuthToken(final Account account,final String authTokenType,final boolean notifyAuthFailure,AccountManagerCallback<Bundle> callback,Handler handler){
  if (account == null)   throw new IllegalArgumentException("String_Node_Str");
  if (authTokenType == null)   throw new IllegalArgumentException("String_Node_Str");
  return new AmsTask(null,handler,callback){
    public void doWork() throws RemoteException {
      mService.getAuthToken(mResponse,account,authTokenType,notifyAuthFailure,false,null);
    }
  }
.start();
}