Update AccountManagerService side logic for .getAccountsByTypeForPackage with null type.
am: d62dc39dc5
Change-Id: Idf3475786676e9713e4fa5756ecce9c675da8c3e
This commit is contained in:
@@ -4428,6 +4428,10 @@ public class AccountManagerService
|
|||||||
&& (type != null && !isAccountManagedByCaller(type, callingUid, userId))) {
|
&& (type != null && !isAccountManagedByCaller(type, callingUid, userId))) {
|
||||||
return EMPTY_ACCOUNT_ARRAY;
|
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,
|
return getAccountsAsUserForPackage(type, userId,
|
||||||
packageName, packageUid, opPackageName, true /* includeUserManagedNotVisible */);
|
packageName, packageUid, opPackageName, true /* includeUserManagedNotVisible */);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,10 @@
|
|||||||
<uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" />
|
<uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" />
|
||||||
<uses-permission android:name="android.permission.DELETE_PACKAGES" />
|
<uses-permission android:name="android.permission.DELETE_PACKAGES" />
|
||||||
|
|
||||||
|
<!-- Uses API introduced in O (26) -->
|
||||||
|
<uses-sdk android:minSdkVersion="1"
|
||||||
|
android:targetSdkVersion="26"/>
|
||||||
|
|
||||||
<application>
|
<application>
|
||||||
<uses-library android:name="android.test.runner" />
|
<uses-library android:name="android.test.runner" />
|
||||||
|
|
||||||
|
|||||||
@@ -1483,6 +1483,31 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
assertNotNull(intent);
|
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
|
@SmallTest
|
||||||
public void testGetAuthTokenLabelWithNullAccountType() throws Exception {
|
public void testGetAuthTokenLabelWithNullAccountType() throws Exception {
|
||||||
unlockSystemUser();
|
unlockSystemUser();
|
||||||
|
|||||||
Reference in New Issue
Block a user