Merge "Add visibility special casing for sdk sandbox" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f598205c2d
@@ -321,6 +321,9 @@ public abstract class AppsFilterBase implements AppsFilterSnapshot {
|
|||||||
|| targetPkgSetting.getAppId() < Process.FIRST_APPLICATION_UID
|
|| targetPkgSetting.getAppId() < Process.FIRST_APPLICATION_UID
|
||||||
|| callingAppId == targetPkgSetting.getAppId()) {
|
|| callingAppId == targetPkgSetting.getAppId()) {
|
||||||
return false;
|
return false;
|
||||||
|
} else if (Process.isSdkSandboxUid(callingAppId)) {
|
||||||
|
// we only allow sdk sandbox processes access to forcequeryable packages
|
||||||
|
return !isForceQueryable(targetPkgSetting.getAppId());
|
||||||
}
|
}
|
||||||
if (mCacheReady) { // use cache
|
if (mCacheReady) { // use cache
|
||||||
if (!shouldFilterApplicationUsingCache(callingUid,
|
if (!shouldFilterApplicationUsingCache(callingUid,
|
||||||
|
|||||||
@@ -1336,6 +1336,46 @@ public class AppsFilterImplTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSdkSandbox_canSeeForceQueryable() throws Exception {
|
||||||
|
final AppsFilterImpl appsFilter =
|
||||||
|
new AppsFilterImpl(mFeatureConfigMock, new String[]{}, false, null,
|
||||||
|
mMockHandler);
|
||||||
|
simulateAddBasicAndroid(appsFilter);
|
||||||
|
appsFilter.onSystemReady(mPmInternal);
|
||||||
|
|
||||||
|
PackageSetting target = simulateAddPackage(appsFilter,
|
||||||
|
pkg("com.some.package").setForceQueryable(true), DUMMY_TARGET_APPID,
|
||||||
|
setting -> setting.setPkgFlags(ApplicationInfo.FLAG_SYSTEM));
|
||||||
|
|
||||||
|
int callingUid = 20123;
|
||||||
|
assertTrue(Process.isSdkSandboxUid(callingUid));
|
||||||
|
|
||||||
|
assertFalse(
|
||||||
|
appsFilter.shouldFilterApplication(mSnapshot, callingUid,
|
||||||
|
null /* callingSetting */, target, SYSTEM_USER));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSdkSandbox_cannotSeeNonForceQueryable() throws Exception {
|
||||||
|
final AppsFilterImpl appsFilter =
|
||||||
|
new AppsFilterImpl(mFeatureConfigMock, new String[]{}, false, null,
|
||||||
|
mMockHandler);
|
||||||
|
simulateAddBasicAndroid(appsFilter);
|
||||||
|
appsFilter.onSystemReady(mPmInternal);
|
||||||
|
|
||||||
|
PackageSetting target = simulateAddPackage(appsFilter,
|
||||||
|
pkg("com.some.package"), DUMMY_TARGET_APPID,
|
||||||
|
setting -> setting.setPkgFlags(ApplicationInfo.FLAG_SYSTEM));
|
||||||
|
|
||||||
|
int callingUid = 20123;
|
||||||
|
assertTrue(Process.isSdkSandboxUid(callingUid));
|
||||||
|
|
||||||
|
assertTrue(
|
||||||
|
appsFilter.shouldFilterApplication(mSnapshot, callingUid,
|
||||||
|
null /* callingSetting */, target, SYSTEM_USER));
|
||||||
|
}
|
||||||
|
|
||||||
private List<Integer> toList(int[] array) {
|
private List<Integer> toList(int[] array) {
|
||||||
ArrayList<Integer> ret = new ArrayList<>(array.length);
|
ArrayList<Integer> ret = new ArrayList<>(array.length);
|
||||||
for (int i = 0; i < array.length; i++) {
|
for (int i = 0; i < array.length; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user