Only allow system apps to be forceQueryable

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

Fixes: 166780599
Test: atest AppEnumerationTests
Change-Id: Ib217ade392500f97a7ff5a08b781cc99e60838ff
This commit is contained in:
Patrick Baumann
2020-08-28 16:09:48 +00:00
parent 5be7e28816
commit 3438afa806
2 changed files with 23 additions and 4 deletions

View File

@@ -560,9 +560,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

@@ -379,7 +379,26 @@ 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,
mMockExecutor);
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,
mMockExecutor);
@@ -391,7 +410,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));
}