Loading services/core/java/com/android/server/accounts/AccountManagerService.java +4 −0 Original line number Diff line number Diff line Loading @@ -4429,6 +4429,10 @@ public class AccountManagerService && (type != null && !isAccountManagedByCaller(type, callingUid, userId))) { return EMPTY_ACCOUNT_ARRAY; } if (!UserHandle.isSameApp(callingUid, Process.SYSTEM_UID) && type == null) { return getAccountsAsUserForPackage(type, userId, packageName, packageUid, opPackageName, false /* includeUserManagedNotVisible */); } return getAccountsAsUserForPackage(type, userId, packageName, packageUid, opPackageName, true /* includeUserManagedNotVisible */); } Loading services/tests/servicestests/AndroidManifest.xml +4 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,10 @@ <uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" /> <uses-permission android:name="android.permission.DELETE_PACKAGES" /> <!-- Uses API introduced in O (26) --> <uses-sdk android:minSdkVersion="1" android:targetSdkVersion="26"/> <application> <uses-library android:name="android.test.runner" /> Loading services/tests/servicestests/src/com/android/server/accounts/AccountManagerServiceTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -1483,6 +1483,31 @@ public class AccountManagerServiceTest extends AndroidTestCase { assertNotNull(intent); } @SmallTest public void testGetAccountsByTypeForPackageWhenTypeIsNull() throws Exception { unlockSystemUser(); HashMap<String, Integer> visibility1 = new HashMap<>(); visibility1.put(AccountManagerServiceTestFixtures.CALLER_PACKAGE, AccountManager.VISIBILITY_USER_MANAGED_VISIBLE); HashMap<String, Integer> visibility2 = new HashMap<>(); visibility2.put(AccountManagerServiceTestFixtures.CALLER_PACKAGE, AccountManager.VISIBILITY_USER_MANAGED_NOT_VISIBLE); mAms.addAccountExplicitlyWithVisibility( AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS, "P11", null, visibility1); mAms.addAccountExplicitlyWithVisibility( AccountManagerServiceTestFixtures.ACCOUNT_INTERVENE, "P12", null, visibility2); Account[] accounts = mAms.getAccountsByTypeForPackage( null, "otherPackageName", AccountManagerServiceTestFixtures.CALLER_PACKAGE); // Only get the USER_MANAGED_NOT_VISIBLE account. assertEquals(1, accounts.length); assertEquals(AccountManagerServiceTestFixtures.ACCOUNT_NAME_SUCCESS, accounts[0].name); assertEquals(AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1, accounts[0].type); } @SmallTest public void testGetAuthTokenLabelWithNullAccountType() throws Exception { unlockSystemUser(); Loading Loading
services/core/java/com/android/server/accounts/AccountManagerService.java +4 −0 Original line number Diff line number Diff line Loading @@ -4429,6 +4429,10 @@ public class AccountManagerService && (type != null && !isAccountManagedByCaller(type, callingUid, userId))) { return EMPTY_ACCOUNT_ARRAY; } if (!UserHandle.isSameApp(callingUid, Process.SYSTEM_UID) && type == null) { return getAccountsAsUserForPackage(type, userId, packageName, packageUid, opPackageName, false /* includeUserManagedNotVisible */); } return getAccountsAsUserForPackage(type, userId, packageName, packageUid, opPackageName, true /* includeUserManagedNotVisible */); } Loading
services/tests/servicestests/AndroidManifest.xml +4 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,10 @@ <uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" /> <uses-permission android:name="android.permission.DELETE_PACKAGES" /> <!-- Uses API introduced in O (26) --> <uses-sdk android:minSdkVersion="1" android:targetSdkVersion="26"/> <application> <uses-library android:name="android.test.runner" /> Loading
services/tests/servicestests/src/com/android/server/accounts/AccountManagerServiceTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -1483,6 +1483,31 @@ public class AccountManagerServiceTest extends AndroidTestCase { assertNotNull(intent); } @SmallTest public void testGetAccountsByTypeForPackageWhenTypeIsNull() throws Exception { unlockSystemUser(); HashMap<String, Integer> visibility1 = new HashMap<>(); visibility1.put(AccountManagerServiceTestFixtures.CALLER_PACKAGE, AccountManager.VISIBILITY_USER_MANAGED_VISIBLE); HashMap<String, Integer> visibility2 = new HashMap<>(); visibility2.put(AccountManagerServiceTestFixtures.CALLER_PACKAGE, AccountManager.VISIBILITY_USER_MANAGED_NOT_VISIBLE); mAms.addAccountExplicitlyWithVisibility( AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS, "P11", null, visibility1); mAms.addAccountExplicitlyWithVisibility( AccountManagerServiceTestFixtures.ACCOUNT_INTERVENE, "P12", null, visibility2); Account[] accounts = mAms.getAccountsByTypeForPackage( null, "otherPackageName", AccountManagerServiceTestFixtures.CALLER_PACKAGE); // Only get the USER_MANAGED_NOT_VISIBLE account. assertEquals(1, accounts.length); assertEquals(AccountManagerServiceTestFixtures.ACCOUNT_NAME_SUCCESS, accounts[0].name); assertEquals(AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1, accounts[0].type); } @SmallTest public void testGetAuthTokenLabelWithNullAccountType() throws Exception { unlockSystemUser(); Loading