@@ -189,6 +189,7 @@ public class AccountManager {
189189 public static final String KEY_ERROR_CODE = "errorCode" ;
190190 public static final String KEY_ERROR_MESSAGE = "errorMessage" ;
191191 public static final String KEY_USERDATA = "userdata" ;
192+
192193 /**
193194 * Authenticators using 'customTokens' option will also get the UID of the
194195 * caller
@@ -814,11 +815,13 @@ public AccountManagerFuture<Bundle> getAuthToken(
814815 final Activity activity , AccountManagerCallback <Bundle > callback , Handler handler ) {
815816 if (account == null ) throw new IllegalArgumentException ("account is null" );
816817 if (authTokenType == null ) throw new IllegalArgumentException ("authTokenType is null" );
818+ final Bundle optionsIn = options == null ? new Bundle () : options ;
819+ optionsIn .putString (KEY_ANDROID_PACKAGE_NAME , mContext .getPackageName ());
817820 return new AmsTask (activity , handler , callback ) {
818821 public void doWork () throws RemoteException {
819822 mService .getAuthToken (mResponse , account , authTokenType ,
820823 false /* notifyOnAuthFailure */ , true /* expectActivityLaunch */ ,
821- options );
824+ optionsIn );
822825 }
823826 }.start ();
824827 }
@@ -895,16 +898,11 @@ public void doWork() throws RemoteException {
895898 */
896899 @ Deprecated
897900 public AccountManagerFuture <Bundle > getAuthToken (
898- final Account account , final String authTokenType , final boolean notifyAuthFailure ,
901+ final Account account , final String authTokenType ,
902+ final boolean notifyAuthFailure ,
899903 AccountManagerCallback <Bundle > callback , Handler handler ) {
900- if (account == null ) throw new IllegalArgumentException ("account is null" );
901- if (authTokenType == null ) throw new IllegalArgumentException ("authTokenType is null" );
902- return new AmsTask (null , handler , callback ) {
903- public void doWork () throws RemoteException {
904- mService .getAuthToken (mResponse , account , authTokenType ,
905- notifyAuthFailure , false /* expectActivityLaunch */ , null /* options */ );
906- }
907- }.start ();
904+ return getAuthToken (account , authTokenType , null , notifyAuthFailure , callback ,
905+ handler );
908906 }
909907
910908 /**
@@ -978,15 +976,18 @@ public void doWork() throws RemoteException {
978976 * account before requesting an auth token.
979977 */
980978 public AccountManagerFuture <Bundle > getAuthToken (
981- final Account account , final String authTokenType ,
982- final Bundle options , final boolean notifyAuthFailure ,
979+ final Account account , final String authTokenType , final Bundle options ,
980+ final boolean notifyAuthFailure ,
983981 AccountManagerCallback <Bundle > callback , Handler handler ) {
982+
984983 if (account == null ) throw new IllegalArgumentException ("account is null" );
985984 if (authTokenType == null ) throw new IllegalArgumentException ("authTokenType is null" );
985+ final Bundle optionsIn = options == null ? new Bundle () : options ;
986+ optionsIn .putString (KEY_ANDROID_PACKAGE_NAME , mContext .getPackageName ());
986987 return new AmsTask (null , handler , callback ) {
987988 public void doWork () throws RemoteException {
988989 mService .getAuthToken (mResponse , account , authTokenType ,
989- notifyAuthFailure , false /* expectActivityLaunch */ , options );
990+ notifyAuthFailure , false /* expectActivityLaunch */ , optionsIn );
990991 }
991992 }.start ();
992993 }
@@ -1044,10 +1045,14 @@ public AccountManagerFuture<Bundle> addAccount(final String accountType,
10441045 final Bundle addAccountOptions ,
10451046 final Activity activity , AccountManagerCallback <Bundle > callback , Handler handler ) {
10461047 if (accountType == null ) throw new IllegalArgumentException ("accountType is null" );
1048+ final Bundle options = (addAccountOptions == null ) ? new Bundle () :
1049+ addAccountOptions ;
1050+ options .putString (KEY_ANDROID_PACKAGE_NAME , mContext .getPackageName ());
1051+
10471052 return new AmsTask (activity , handler , callback ) {
10481053 public void doWork () throws RemoteException {
10491054 mService .addAcount (mResponse , accountType , authTokenType ,
1050- requiredFeatures , activity != null , addAccountOptions );
1055+ requiredFeatures , activity != null , options );
10511056 }
10521057 }.start ();
10531058 }
0 commit comments