Only allow system apps to be forceQueryable

This change ensures that only system apps can declare themselves
forceQueryable via manifest.

Fixes: 166780599
Fixes: 169739214
Test: atest AppEnumerationTests
Change-Id: Ib217ade392500f97a7ff5a08b781cc99e60838ff
Merged-In: Ib217ade392500f97a7ff5a08b781cc99e60838ff
This commit is contained in:
Patrick Baumann
2020-09-30 09:25:51 -07:00
parent 27b40fc234
commit 9fdc1bfc0c
2 changed files with 22 additions and 4 deletions

View File

@@ -547,9 +547,9 @@ public class AppsFilter {
final boolean newIsForceQueryable =
mForceQueryable.contains(newPkgSetting.appId)
/* shared user that is already force queryable */
|| newPkg.isForceQueryable()
|| newPkgSetting.forceQueryableOverride
|| newPkgSetting.forceQueryableOverride /* adb override */
|| (newPkgSetting.isSystem() && (mSystemAppsQueryable
|| newPkg.isForceQueryable()
|| ArrayUtils.contains(mForceQueryableByDevicePackageNames,
newPkg.getPackageName())));
if (newIsForceQueryable

View File

@@ -365,7 +365,25 @@ public class AppsFilterTest {
}
@Test
public void testForceQueryable_DoesntFilter() throws Exception {
public void testForceQueryable_SystemDoesntFilter() throws Exception {
final AppsFilter appsFilter =
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
simulateAddBasicAndroid(appsFilter);
appsFilter.onSystemReady();
PackageSetting target = simulateAddPackage(appsFilter,
pkg("com.some.package").setForceQueryable(true), DUMMY_TARGET_APPID,
setting -> setting.setPkgFlags(ApplicationInfo.FLAG_SYSTEM));
PackageSetting calling = simulateAddPackage(appsFilter,
pkg("com.some.other.package"), DUMMY_CALLING_APPID);
assertFalse(appsFilter.shouldFilterApplication(DUMMY_CALLING_APPID, calling, target,
SYSTEM_USER));
}
@Test
public void testForceQueryable_NonSystemFilters() throws Exception {
final AppsFilter appsFilter =
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
simulateAddBasicAndroid(appsFilter);
@@ -376,7 +394,7 @@ public class AppsFilterTest {
PackageSetting calling = simulateAddPackage(appsFilter,
pkg("com.some.other.package"), DUMMY_CALLING_APPID);
assertFalse(appsFilter.shouldFilterApplication(DUMMY_CALLING_APPID, calling, target,
assertTrue(appsFilter.shouldFilterApplication(DUMMY_CALLING_APPID, calling, target,
SYSTEM_USER));
}