Loading core/java/android/accounts/AccountManager.java +32 −44 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.annotation.SdkConstant.SdkConstantType; import android.annotation.Size; import android.annotation.SystemApi; import android.annotation.SystemService; import android.annotation.UserHandleAware; import android.app.Activity; import android.compat.annotation.UnsupportedAppUsage; import android.content.BroadcastReceiver; Loading @@ -40,6 +41,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.os.Parcelable; import android.os.Process; import android.os.RemoteException; import android.os.UserHandle; import android.text.TextUtils; Loading Loading @@ -528,12 +530,9 @@ public class AccountManager { * authenticator known to the AccountManager service. Empty (never * null) if no authenticators are known. */ @UserHandleAware public AuthenticatorDescription[] getAuthenticatorTypes() { try { return mService.getAuthenticatorTypes(UserHandle.getCallingUserId()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getAuthenticatorTypesAsUser(mContext.getUserId()); } /** Loading Loading @@ -584,13 +583,10 @@ public class AccountManager { * @return An array of {@link Account}, one for each account. Empty (never null) if no accounts * have been added. */ @UserHandleAware @NonNull public Account[] getAccounts() { try { return mService.getAccounts(null, mContext.getOpPackageName()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getAccountsAsUser(mContext.getUserId()); } /** Loading Loading @@ -708,6 +704,7 @@ public class AccountManager { * @return An array of {@link Account}, one per matching account. Empty (never null) if no * accounts of the specified type have been added. */ @UserHandleAware @NonNull public Account[] getAccountsByType(String type) { return getAccountsByTypeAsUser(type, mContext.getUser()); Loading Loading @@ -1183,23 +1180,11 @@ public class AccountManager { * {@link #removeAccount(Account, Activity, AccountManagerCallback, Handler)} * instead */ @UserHandleAware @Deprecated public AccountManagerFuture<Boolean> removeAccount(final Account account, AccountManagerCallback<Boolean> callback, Handler handler) { if (account == null) throw new IllegalArgumentException("account is null"); return new Future2Task<Boolean>(handler, callback) { @Override public void doWork() throws RemoteException { mService.removeAccount(mResponse, account, false); } @Override public Boolean bundleToResult(Bundle bundle) throws AuthenticatorException { if (!bundle.containsKey(KEY_BOOLEAN_RESULT)) { throw new AuthenticatorException("no result in response"); } return bundle.getBoolean(KEY_BOOLEAN_RESULT); } }.start(); return removeAccountAsUser(account, callback, handler, mContext.getUser()); } /** Loading Loading @@ -1243,15 +1228,10 @@ public class AccountManager { * adding accounts (of this type) has been disabled by policy * </ul> */ @UserHandleAware public AccountManagerFuture<Bundle> removeAccount(final Account account, final Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) { if (account == null) throw new IllegalArgumentException("account is null"); return new AmsTask(activity, handler, callback) { @Override public void doWork() throws RemoteException { mService.removeAccount(mResponse, account, activity != null); } }.start(); return removeAccountAsUser(account, activity, callback, handler, mContext.getUser()); } /** Loading Loading @@ -1841,10 +1821,12 @@ public class AccountManager { * creating a new account, usually because of network trouble * </ul> */ @UserHandleAware public AccountManagerFuture<Bundle> addAccount(final String accountType, final String authTokenType, final String[] requiredFeatures, final Bundle addAccountOptions, final Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) { if (Process.myUserHandle().equals(mContext.getUser())) { if (accountType == null) throw new IllegalArgumentException("accountType is null"); final Bundle optionsIn = new Bundle(); if (addAccountOptions != null) { Loading @@ -1859,6 +1841,10 @@ public class AccountManager { requiredFeatures, activity != null, optionsIn); } }.start(); } else { return addAccountAsUser(accountType, authTokenType, requiredFeatures, addAccountOptions, activity, callback, handler, mContext.getUser()); } } /** Loading Loading @@ -2002,6 +1988,7 @@ public class AccountManager { * verifying the password, usually because of network trouble * </ul> */ @UserHandleAware public AccountManagerFuture<Bundle> confirmCredentials(final Account account, final Bundle options, final Activity activity, Loading Loading @@ -3209,6 +3196,7 @@ public class AccountManager { * </ul> * @see #startAddAccountSession and #startUpdateCredentialsSession */ @UserHandleAware public AccountManagerFuture<Bundle> finishSession( final Bundle sessionBundle, final Activity activity, Loading core/java/android/accounts/IAccountManager.aidl +0 −3 Original line number Diff line number Diff line Loading @@ -34,7 +34,6 @@ interface IAccountManager { String getPassword(in Account account); String getUserData(in Account account, String key); AuthenticatorDescription[] getAuthenticatorTypes(int userId); Account[] getAccounts(String accountType, String opPackageName); Account[] getAccountsForPackage(String packageName, int uid, String opPackageName); Account[] getAccountsByTypeForPackage(String type, String packageName, String opPackageName); Account[] getAccountsAsUser(String accountType, int userId, String opPackageName); Loading @@ -45,8 +44,6 @@ interface IAccountManager { void getAccountsByFeatures(in IAccountManagerResponse response, String accountType, in String[] features, String opPackageName); boolean addAccountExplicitly(in Account account, String password, in Bundle extras); void removeAccount(in IAccountManagerResponse response, in Account account, boolean expectActivityLaunch); void removeAccountAsUser(in IAccountManagerResponse response, in Account account, boolean expectActivityLaunch, int userId); boolean removeAccountExplicitly(in Account account); Loading services/core/java/com/android/server/accounts/AccountManagerService.java +0 −16 Original line number Diff line number Diff line Loading @@ -2128,16 +2128,6 @@ public class AccountManagerService return userInfo != null && userInfo.canHaveProfile(); } @Override public void removeAccount(IAccountManagerResponse response, Account account, boolean expectActivityLaunch) { removeAccountAsUser( response, account, expectActivityLaunch, UserHandle.getCallingUserId()); } @Override public void removeAccountAsUser(IAccountManagerResponse response, Account account, boolean expectActivityLaunch, int userId) { Loading Loading @@ -4452,12 +4442,6 @@ public class AccountManagerService } } @Override @NonNull public Account[] getAccounts(String type, String opPackageName) { return getAccountsAsUser(type, UserHandle.getCallingUserId(), opPackageName); } @Override @NonNull public Account[] getAccountsForPackage(String packageName, int uid, String opPackageName) { Loading services/tests/servicestests/src/com/android/server/accounts/AccountManagerServiceTest.java +12 −8 Original line number Diff line number Diff line Loading @@ -212,7 +212,8 @@ public class AccountManagerServiceTest extends AndroidTestCase { String[] list = new String[]{AccountManagerServiceTestFixtures.CALLER_PACKAGE}; when(mMockPackageManager.getPackagesForUid(anyInt())).thenReturn(list); Account[] accounts = mAms.getAccounts(null, mContext.getOpPackageName()); Account[] accounts = mAms.getAccountsAsUser(null, UserHandle.getCallingUserId(), mContext.getOpPackageName()); Arrays.sort(accounts, new AccountSorter()); assertEquals(6, accounts.length); assertEquals(a11, accounts[0]); Loading @@ -222,8 +223,8 @@ public class AccountManagerServiceTest extends AndroidTestCase { assertEquals(a22, accounts[4]); assertEquals(a32, accounts[5]); accounts = mAms.getAccounts(AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1, mContext.getOpPackageName()); accounts = mAms.getAccountsAsUser(AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1, UserHandle.getCallingUserId(), mContext.getOpPackageName()); Arrays.sort(accounts, new AccountSorter()); assertEquals(3, accounts.length); assertEquals(a11, accounts[0]); Loading @@ -232,8 +233,8 @@ public class AccountManagerServiceTest extends AndroidTestCase { mAms.removeAccountInternal(a21); accounts = mAms.getAccounts(AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1, mContext.getOpPackageName()); accounts = mAms.getAccountsAsUser(AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1, UserHandle.getCallingUserId(), mContext.getOpPackageName()); Arrays.sort(accounts, new AccountSorter()); assertEquals(2, accounts.length); assertEquals(a11, accounts[0]); Loading Loading @@ -373,7 +374,8 @@ public class AccountManagerServiceTest extends AndroidTestCase { unlockSystemUser(); String[] list = new String[]{AccountManagerServiceTestFixtures.CALLER_PACKAGE}; when(mMockPackageManager.getPackagesForUid(anyInt())).thenReturn(list); Account[] accounts = mAms.getAccounts(null, mContext.getOpPackageName()); Account[] accounts = mAms.getAccountsAsUser(null, UserHandle.getCallingUserId(), mContext.getOpPackageName()); assertEquals("1 account should be migrated", 1, accounts.length); assertEquals(PreNTestDatabaseHelper.ACCOUNT_NAME, accounts[0].name); assertEquals(PreNTestDatabaseHelper.ACCOUNT_PASSWORD, mAms.getPassword(accounts[0])); Loading Loading @@ -2980,7 +2982,8 @@ public class AccountManagerServiceTest extends AndroidTestCase { Log.d(TAG, logPrefix + " getAccounts started"); long ti = System.currentTimeMillis(); try { Account[] accounts = mAms.getAccounts(null, mContext.getOpPackageName()); Account[] accounts = mAms.getAccountsAsUser(null, UserHandle.getCallingUserId(), mContext.getOpPackageName()); if (accounts == null || accounts.length != 1 || !AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1.equals( accounts[0].type)) { Loading Loading @@ -3051,7 +3054,8 @@ public class AccountManagerServiceTest extends AndroidTestCase { Log.d(TAG, logPrefix + " getAccounts started"); long ti = System.currentTimeMillis(); try { Account[] accounts = mAms.getAccounts(null, mContext.getOpPackageName()); Account[] accounts = mAms.getAccountsAsUser(null, UserHandle.getCallingUserId(), mContext.getOpPackageName()); if (accounts == null || accounts.length != 1 || !AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1.equals( accounts[0].type)) { Loading Loading
core/java/android/accounts/AccountManager.java +32 −44 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.annotation.SdkConstant.SdkConstantType; import android.annotation.Size; import android.annotation.SystemApi; import android.annotation.SystemService; import android.annotation.UserHandleAware; import android.app.Activity; import android.compat.annotation.UnsupportedAppUsage; import android.content.BroadcastReceiver; Loading @@ -40,6 +41,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.os.Parcelable; import android.os.Process; import android.os.RemoteException; import android.os.UserHandle; import android.text.TextUtils; Loading Loading @@ -528,12 +530,9 @@ public class AccountManager { * authenticator known to the AccountManager service. Empty (never * null) if no authenticators are known. */ @UserHandleAware public AuthenticatorDescription[] getAuthenticatorTypes() { try { return mService.getAuthenticatorTypes(UserHandle.getCallingUserId()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getAuthenticatorTypesAsUser(mContext.getUserId()); } /** Loading Loading @@ -584,13 +583,10 @@ public class AccountManager { * @return An array of {@link Account}, one for each account. Empty (never null) if no accounts * have been added. */ @UserHandleAware @NonNull public Account[] getAccounts() { try { return mService.getAccounts(null, mContext.getOpPackageName()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getAccountsAsUser(mContext.getUserId()); } /** Loading Loading @@ -708,6 +704,7 @@ public class AccountManager { * @return An array of {@link Account}, one per matching account. Empty (never null) if no * accounts of the specified type have been added. */ @UserHandleAware @NonNull public Account[] getAccountsByType(String type) { return getAccountsByTypeAsUser(type, mContext.getUser()); Loading Loading @@ -1183,23 +1180,11 @@ public class AccountManager { * {@link #removeAccount(Account, Activity, AccountManagerCallback, Handler)} * instead */ @UserHandleAware @Deprecated public AccountManagerFuture<Boolean> removeAccount(final Account account, AccountManagerCallback<Boolean> callback, Handler handler) { if (account == null) throw new IllegalArgumentException("account is null"); return new Future2Task<Boolean>(handler, callback) { @Override public void doWork() throws RemoteException { mService.removeAccount(mResponse, account, false); } @Override public Boolean bundleToResult(Bundle bundle) throws AuthenticatorException { if (!bundle.containsKey(KEY_BOOLEAN_RESULT)) { throw new AuthenticatorException("no result in response"); } return bundle.getBoolean(KEY_BOOLEAN_RESULT); } }.start(); return removeAccountAsUser(account, callback, handler, mContext.getUser()); } /** Loading Loading @@ -1243,15 +1228,10 @@ public class AccountManager { * adding accounts (of this type) has been disabled by policy * </ul> */ @UserHandleAware public AccountManagerFuture<Bundle> removeAccount(final Account account, final Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) { if (account == null) throw new IllegalArgumentException("account is null"); return new AmsTask(activity, handler, callback) { @Override public void doWork() throws RemoteException { mService.removeAccount(mResponse, account, activity != null); } }.start(); return removeAccountAsUser(account, activity, callback, handler, mContext.getUser()); } /** Loading Loading @@ -1841,10 +1821,12 @@ public class AccountManager { * creating a new account, usually because of network trouble * </ul> */ @UserHandleAware public AccountManagerFuture<Bundle> addAccount(final String accountType, final String authTokenType, final String[] requiredFeatures, final Bundle addAccountOptions, final Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) { if (Process.myUserHandle().equals(mContext.getUser())) { if (accountType == null) throw new IllegalArgumentException("accountType is null"); final Bundle optionsIn = new Bundle(); if (addAccountOptions != null) { Loading @@ -1859,6 +1841,10 @@ public class AccountManager { requiredFeatures, activity != null, optionsIn); } }.start(); } else { return addAccountAsUser(accountType, authTokenType, requiredFeatures, addAccountOptions, activity, callback, handler, mContext.getUser()); } } /** Loading Loading @@ -2002,6 +1988,7 @@ public class AccountManager { * verifying the password, usually because of network trouble * </ul> */ @UserHandleAware public AccountManagerFuture<Bundle> confirmCredentials(final Account account, final Bundle options, final Activity activity, Loading Loading @@ -3209,6 +3196,7 @@ public class AccountManager { * </ul> * @see #startAddAccountSession and #startUpdateCredentialsSession */ @UserHandleAware public AccountManagerFuture<Bundle> finishSession( final Bundle sessionBundle, final Activity activity, Loading
core/java/android/accounts/IAccountManager.aidl +0 −3 Original line number Diff line number Diff line Loading @@ -34,7 +34,6 @@ interface IAccountManager { String getPassword(in Account account); String getUserData(in Account account, String key); AuthenticatorDescription[] getAuthenticatorTypes(int userId); Account[] getAccounts(String accountType, String opPackageName); Account[] getAccountsForPackage(String packageName, int uid, String opPackageName); Account[] getAccountsByTypeForPackage(String type, String packageName, String opPackageName); Account[] getAccountsAsUser(String accountType, int userId, String opPackageName); Loading @@ -45,8 +44,6 @@ interface IAccountManager { void getAccountsByFeatures(in IAccountManagerResponse response, String accountType, in String[] features, String opPackageName); boolean addAccountExplicitly(in Account account, String password, in Bundle extras); void removeAccount(in IAccountManagerResponse response, in Account account, boolean expectActivityLaunch); void removeAccountAsUser(in IAccountManagerResponse response, in Account account, boolean expectActivityLaunch, int userId); boolean removeAccountExplicitly(in Account account); Loading
services/core/java/com/android/server/accounts/AccountManagerService.java +0 −16 Original line number Diff line number Diff line Loading @@ -2128,16 +2128,6 @@ public class AccountManagerService return userInfo != null && userInfo.canHaveProfile(); } @Override public void removeAccount(IAccountManagerResponse response, Account account, boolean expectActivityLaunch) { removeAccountAsUser( response, account, expectActivityLaunch, UserHandle.getCallingUserId()); } @Override public void removeAccountAsUser(IAccountManagerResponse response, Account account, boolean expectActivityLaunch, int userId) { Loading Loading @@ -4452,12 +4442,6 @@ public class AccountManagerService } } @Override @NonNull public Account[] getAccounts(String type, String opPackageName) { return getAccountsAsUser(type, UserHandle.getCallingUserId(), opPackageName); } @Override @NonNull public Account[] getAccountsForPackage(String packageName, int uid, String opPackageName) { Loading
services/tests/servicestests/src/com/android/server/accounts/AccountManagerServiceTest.java +12 −8 Original line number Diff line number Diff line Loading @@ -212,7 +212,8 @@ public class AccountManagerServiceTest extends AndroidTestCase { String[] list = new String[]{AccountManagerServiceTestFixtures.CALLER_PACKAGE}; when(mMockPackageManager.getPackagesForUid(anyInt())).thenReturn(list); Account[] accounts = mAms.getAccounts(null, mContext.getOpPackageName()); Account[] accounts = mAms.getAccountsAsUser(null, UserHandle.getCallingUserId(), mContext.getOpPackageName()); Arrays.sort(accounts, new AccountSorter()); assertEquals(6, accounts.length); assertEquals(a11, accounts[0]); Loading @@ -222,8 +223,8 @@ public class AccountManagerServiceTest extends AndroidTestCase { assertEquals(a22, accounts[4]); assertEquals(a32, accounts[5]); accounts = mAms.getAccounts(AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1, mContext.getOpPackageName()); accounts = mAms.getAccountsAsUser(AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1, UserHandle.getCallingUserId(), mContext.getOpPackageName()); Arrays.sort(accounts, new AccountSorter()); assertEquals(3, accounts.length); assertEquals(a11, accounts[0]); Loading @@ -232,8 +233,8 @@ public class AccountManagerServiceTest extends AndroidTestCase { mAms.removeAccountInternal(a21); accounts = mAms.getAccounts(AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1, mContext.getOpPackageName()); accounts = mAms.getAccountsAsUser(AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1, UserHandle.getCallingUserId(), mContext.getOpPackageName()); Arrays.sort(accounts, new AccountSorter()); assertEquals(2, accounts.length); assertEquals(a11, accounts[0]); Loading Loading @@ -373,7 +374,8 @@ public class AccountManagerServiceTest extends AndroidTestCase { unlockSystemUser(); String[] list = new String[]{AccountManagerServiceTestFixtures.CALLER_PACKAGE}; when(mMockPackageManager.getPackagesForUid(anyInt())).thenReturn(list); Account[] accounts = mAms.getAccounts(null, mContext.getOpPackageName()); Account[] accounts = mAms.getAccountsAsUser(null, UserHandle.getCallingUserId(), mContext.getOpPackageName()); assertEquals("1 account should be migrated", 1, accounts.length); assertEquals(PreNTestDatabaseHelper.ACCOUNT_NAME, accounts[0].name); assertEquals(PreNTestDatabaseHelper.ACCOUNT_PASSWORD, mAms.getPassword(accounts[0])); Loading Loading @@ -2980,7 +2982,8 @@ public class AccountManagerServiceTest extends AndroidTestCase { Log.d(TAG, logPrefix + " getAccounts started"); long ti = System.currentTimeMillis(); try { Account[] accounts = mAms.getAccounts(null, mContext.getOpPackageName()); Account[] accounts = mAms.getAccountsAsUser(null, UserHandle.getCallingUserId(), mContext.getOpPackageName()); if (accounts == null || accounts.length != 1 || !AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1.equals( accounts[0].type)) { Loading Loading @@ -3051,7 +3054,8 @@ public class AccountManagerServiceTest extends AndroidTestCase { Log.d(TAG, logPrefix + " getAccounts started"); long ti = System.currentTimeMillis(); try { Account[] accounts = mAms.getAccounts(null, mContext.getOpPackageName()); Account[] accounts = mAms.getAccountsAsUser(null, UserHandle.getCallingUserId(), mContext.getOpPackageName()); if (accounts == null || accounts.length != 1 || !AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1.equals( accounts[0].type)) { Loading