@@ -1773,8 +1773,7 @@ public void onResult(Bundle result) {
17731773 // Create a Session for the target user and pass in the bundle
17741774 completeCloningAccount (response , result , account , toAccounts , userFrom );
17751775 } else {
1776- // Bundle format is not defined.
1777- super .onResultSkipSanitization (result );
1776+ super .onResult (result );
17781777 }
17791778 }
17801779 }.bind ();
@@ -1861,8 +1860,7 @@ public void onResult(Bundle result) {
18611860 // account to avoid retries?
18621861 // TODO: what we do with the visibility?
18631862
1864- // Bundle format is not defined.
1865- super .onResultSkipSanitization (result );
1863+ super .onResult (result );
18661864 }
18671865
18681866 @ Override
@@ -2108,7 +2106,6 @@ public void run() throws RemoteException {
21082106 @ Override
21092107 public void onResult (Bundle result ) {
21102108 Bundle .setDefusable (result , true );
2111- result = sanitizeBundle (result );
21122109 IAccountManagerResponse response = getResponseAndClose ();
21132110 if (response != null ) {
21142111 try {
@@ -2462,7 +2459,6 @@ public void run() throws RemoteException {
24622459 @ Override
24632460 public void onResult (Bundle result ) {
24642461 Bundle .setDefusable (result , true );
2465- result = sanitizeBundle (result );
24662462 if (result != null && result .containsKey (AccountManager .KEY_BOOLEAN_RESULT )
24672463 && !result .containsKey (AccountManager .KEY_INTENT )) {
24682464 final boolean removalAllowed = result .getBoolean (AccountManager .KEY_BOOLEAN_RESULT );
@@ -2977,7 +2973,6 @@ public void run() throws RemoteException {
29772973 @ Override
29782974 public void onResult (Bundle result ) {
29792975 Bundle .setDefusable (result , true );
2980- result = sanitizeBundle (result );
29812976 if (result != null ) {
29822977 String label = result .getString (AccountManager .KEY_AUTH_TOKEN_LABEL );
29832978 Bundle bundle = new Bundle ();
@@ -3155,7 +3150,6 @@ public void run() throws RemoteException {
31553150 @ Override
31563151 public void onResult (Bundle result ) {
31573152 Bundle .setDefusable (result , true );
3158- result = sanitizeBundle (result );
31593153 if (result != null ) {
31603154 if (result .containsKey (AccountManager .KEY_AUTH_TOKEN_LABEL )) {
31613155 Intent intent = newGrantCredentialsPermissionIntent (
@@ -3627,12 +3621,6 @@ public StartAccountSession(
36273621 @ Override
36283622 public void onResult (Bundle result ) {
36293623 Bundle .setDefusable (result , true );
3630- Bundle sessionBundle = null ;
3631- if (result != null ) {
3632- // Session bundle will be removed from result.
3633- sessionBundle = result .getBundle (AccountManager .KEY_ACCOUNT_SESSION_BUNDLE );
3634- }
3635- result = sanitizeBundle (result );
36363624 mNumResults ++;
36373625 Intent intent = null ;
36383626 if (result != null ) {
@@ -3694,6 +3682,7 @@ public void onResult(Bundle result) {
36943682 // bundle contains data necessary for finishing the session
36953683 // later. The session bundle will be encrypted here and
36963684 // decrypted later when trying to finish the session.
3685+ Bundle sessionBundle = result .getBundle (AccountManager .KEY_ACCOUNT_SESSION_BUNDLE );
36973686 if (sessionBundle != null ) {
36983687 String accountType = sessionBundle .getString (AccountManager .KEY_ACCOUNT_TYPE );
36993688 if (TextUtils .isEmpty (accountType )
@@ -4081,7 +4070,6 @@ public void run() throws RemoteException {
40814070 @ Override
40824071 public void onResult (Bundle result ) {
40834072 Bundle .setDefusable (result , true );
4084- result = sanitizeBundle (result );
40854073 IAccountManagerResponse response = getResponseAndClose ();
40864074 if (response == null ) {
40874075 return ;
@@ -4395,7 +4383,6 @@ public void checkAccount() {
43954383 @ Override
43964384 public void onResult (Bundle result ) {
43974385 Bundle .setDefusable (result , true );
4398- result = sanitizeBundle (result );
43994386 mNumResults ++;
44004387 if (result == null ) {
44014388 onError (AccountManager .ERROR_CODE_INVALID_RESPONSE , "null bundle" );
@@ -4952,68 +4939,6 @@ public void onShellCommand(FileDescriptor in, FileDescriptor out,
49524939 callback , resultReceiver );
49534940 }
49544941
4955-
4956- // All keys for Strings passed from AbstractAccountAuthenticator using Bundle.
4957- private static final String [] sStringBundleKeys = new String [] {
4958- AccountManager .KEY_ACCOUNT_NAME ,
4959- AccountManager .KEY_ACCOUNT_TYPE ,
4960- AccountManager .KEY_AUTHTOKEN ,
4961- AccountManager .KEY_AUTH_TOKEN_LABEL ,
4962- AccountManager .KEY_ERROR_MESSAGE ,
4963- AccountManager .KEY_PASSWORD ,
4964- AccountManager .KEY_ACCOUNT_STATUS_TOKEN };
4965-
4966- /**
4967- * Keep only documented fields in a Bundle received from AbstractAccountAuthenticator.
4968- */
4969- protected static Bundle sanitizeBundle (Bundle bundle ) {
4970- if (bundle == null ) {
4971- return null ;
4972- }
4973- Bundle sanitizedBundle = new Bundle ();
4974- Bundle .setDefusable (sanitizedBundle , true );
4975- int updatedKeysCount = 0 ;
4976- for (String stringKey : sStringBundleKeys ) {
4977- if (bundle .containsKey (stringKey )) {
4978- String value = bundle .getString (stringKey );
4979- sanitizedBundle .putString (stringKey , value );
4980- updatedKeysCount ++;
4981- }
4982- }
4983- String key = AbstractAccountAuthenticator .KEY_CUSTOM_TOKEN_EXPIRY ;
4984- if (bundle .containsKey (key )) {
4985- long expiryMillis = bundle .getLong (key , 0L );
4986- sanitizedBundle .putLong (key , expiryMillis );
4987- updatedKeysCount ++;
4988- }
4989- key = AccountManager .KEY_BOOLEAN_RESULT ;
4990- if (bundle .containsKey (key )) {
4991- boolean booleanResult = bundle .getBoolean (key , false );
4992- sanitizedBundle .putBoolean (key , booleanResult );
4993- updatedKeysCount ++;
4994- }
4995- key = AccountManager .KEY_ERROR_CODE ;
4996- if (bundle .containsKey (key )) {
4997- int errorCode = bundle .getInt (key , 0 );
4998- sanitizedBundle .putInt (key , errorCode );
4999- updatedKeysCount ++;
5000- }
5001- key = AccountManager .KEY_INTENT ;
5002- if (bundle .containsKey (key )) {
5003- Intent intent = bundle .getParcelable (key , Intent .class );
5004- sanitizedBundle .putParcelable (key , intent );
5005- updatedKeysCount ++;
5006- }
5007- if (bundle .containsKey (AccountManager .KEY_ACCOUNT_SESSION_BUNDLE )) {
5008- // The field is not copied in sanitized bundle.
5009- updatedKeysCount ++;
5010- }
5011- if (updatedKeysCount != bundle .size ()) {
5012- Log .w (TAG , "Size mismatch after sanitizeBundle call." );
5013- }
5014- return sanitizedBundle ;
5015- }
5016-
50174942 private abstract class Session extends IAccountAuthenticatorResponse .Stub
50184943 implements IBinder .DeathRecipient , ServiceConnection {
50194944 private final Object mSessionLock = new Object ();
@@ -5304,14 +5229,9 @@ public void onTimedOut() {
53045229 }
53055230 }
53065231 }
5232+
53075233 @ Override
53085234 public void onResult (Bundle result ) {
5309- Bundle .setDefusable (result , true );
5310- result = sanitizeBundle (result );
5311- onResultSkipSanitization (result );
5312- }
5313-
5314- public void onResultSkipSanitization (Bundle result ) {
53155235 Bundle .setDefusable (result , true );
53165236 mNumResults ++;
53175237 Intent intent = null ;
0 commit comments