Loading services/core/java/com/android/server/pm/AppsFilterImpl.java +5 −2 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import static com.android.internal.util.FrameworkStatsLog.PACKAGE_MANAGER_APPS_F import static com.android.internal.util.FrameworkStatsLog.PACKAGE_MANAGER_APPS_FILTER_CACHE_UPDATE_REPORTED__EVENT_TYPE__PACKAGE_DELETED; import static com.android.internal.util.FrameworkStatsLog.PACKAGE_MANAGER_APPS_FILTER_CACHE_UPDATE_REPORTED__EVENT_TYPE__PACKAGE_REPLACED; import static com.android.server.pm.AppsFilterUtils.canQueryAsInstaller; import static com.android.server.pm.AppsFilterUtils.canQueryAsUpdateOwner; import static com.android.server.pm.AppsFilterUtils.canQueryViaComponents; import static com.android.server.pm.AppsFilterUtils.canQueryViaPackage; import static com.android.server.pm.AppsFilterUtils.canQueryViaUsesLibrary; Loading Loading @@ -670,7 +671,8 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable, } } if (canQueryViaPackage(existingPkg, newPkg) || canQueryAsInstaller(existingSetting, newPkg)) { || canQueryAsInstaller(existingSetting, newPkg) || canQueryAsUpdateOwner(existingSetting, newPkg)) { synchronized (mQueriesViaPackageLock) { mQueriesViaPackage.add(existingSetting.getAppId(), newPkgSetting.getAppId()); Loading @@ -697,7 +699,8 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable, } } if (canQueryViaPackage(newPkg, existingPkg) || canQueryAsInstaller(newPkgSetting, existingPkg)) { || canQueryAsInstaller(newPkgSetting, existingPkg) || canQueryAsUpdateOwner(newPkgSetting, existingPkg)) { synchronized (mQueriesViaPackageLock) { mQueriesViaPackage.add(newPkgSetting.getAppId(), existingSetting.getAppId()); Loading services/core/java/com/android/server/pm/AppsFilterUtils.java +9 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,15 @@ final class AppsFilterUtils { return false; } public static boolean canQueryAsUpdateOwner(PackageStateInternal querying, AndroidPackage potentialTarget) { final InstallSource installSource = querying.getInstallSource(); if (potentialTarget.getPackageName().equals(installSource.mUpdateOwnerPackageName)) { return true; } return false; } public static boolean canQueryViaUsesLibrary(AndroidPackage querying, AndroidPackage potentialTarget) { if (potentialTarget.getLibraryNames().isEmpty()) { Loading services/tests/PackageManagerServiceTests/server/src/com/android/server/pm/AppsFilterImplTest.java +33 −4 Original line number Diff line number Diff line Loading @@ -283,7 +283,7 @@ public class AppsFilterImplTest { assertFalse( appsFilter.shouldFilterApplication(mSnapshot, DUMMY_CALLING_APPID, calling, target, SYSTEM_USER)); watcher.verifyNoChangeReported("shouldFilterAplication"); watcher.verifyNoChangeReported("shouldFilterApplication"); } @Test Loading Loading @@ -1081,7 +1081,7 @@ public class AppsFilterImplTest { assertTrue( appsFilter.shouldFilterApplication(mSnapshot, DUMMY_CALLING_APPID, calling, target, SYSTEM_USER)); watcher.verifyNoChangeReported("shouldFilterAplication"); watcher.verifyNoChangeReported("shouldFilterApplication"); } @Test Loading Loading @@ -1110,7 +1110,36 @@ public class AppsFilterImplTest { assertFalse( appsFilter.shouldFilterApplication(mSnapshot, DUMMY_CALLING_APPID, calling, target, SYSTEM_USER)); watcher.verifyNoChangeReported("shouldFilterAplication"); watcher.verifyNoChangeReported("shouldFilterApplication"); } @Test public void testUpdateOwner_DoesntFilter() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mFeatureConfigMock, new String[]{}, /* systemAppsQueryable */ false, /* overlayProvider */ null, mMockHandler); final WatchableTester watcher = new WatchableTester(appsFilter, "onChange"); watcher.register(); simulateAddBasicAndroid(appsFilter); watcher.verifyChangeReported("addBasicAndroid"); appsFilter.onSystemReady(mPmInternal); watcher.verifyChangeReported("systemReady"); PackageSetting target = simulateAddPackage(appsFilter, pkg("com.some.package"), DUMMY_TARGET_APPID); watcher.verifyChangeReported("add package"); PackageSetting calling = simulateAddPackage(appsFilter, pkg("com.some.other.package"), DUMMY_CALLING_APPID, withInstallSource(null /* initiatingPackageName */, null /* originatingPackageName */, null /* installerPackageName */, INVALID_UID, target.getPackageName(), null /* installerAttributionTag */, false /* isInitiatingPackageUninstalled */)); watcher.verifyChangeReported("add package"); assertFalse( appsFilter.shouldFilterApplication(mSnapshot, DUMMY_CALLING_APPID, calling, target, SYSTEM_USER)); watcher.verifyNoChangeReported("shouldFilterApplication"); } @Test Loading Loading @@ -1139,7 +1168,7 @@ public class AppsFilterImplTest { assertFalse( appsFilter.shouldFilterApplication(mSnapshot, DUMMY_TARGET_APPID, target, instrumentation, SYSTEM_USER)); watcher.verifyNoChangeReported("shouldFilterAplication"); watcher.verifyNoChangeReported("shouldFilterApplication"); } @Test Loading Loading
services/core/java/com/android/server/pm/AppsFilterImpl.java +5 −2 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import static com.android.internal.util.FrameworkStatsLog.PACKAGE_MANAGER_APPS_F import static com.android.internal.util.FrameworkStatsLog.PACKAGE_MANAGER_APPS_FILTER_CACHE_UPDATE_REPORTED__EVENT_TYPE__PACKAGE_DELETED; import static com.android.internal.util.FrameworkStatsLog.PACKAGE_MANAGER_APPS_FILTER_CACHE_UPDATE_REPORTED__EVENT_TYPE__PACKAGE_REPLACED; import static com.android.server.pm.AppsFilterUtils.canQueryAsInstaller; import static com.android.server.pm.AppsFilterUtils.canQueryAsUpdateOwner; import static com.android.server.pm.AppsFilterUtils.canQueryViaComponents; import static com.android.server.pm.AppsFilterUtils.canQueryViaPackage; import static com.android.server.pm.AppsFilterUtils.canQueryViaUsesLibrary; Loading Loading @@ -670,7 +671,8 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable, } } if (canQueryViaPackage(existingPkg, newPkg) || canQueryAsInstaller(existingSetting, newPkg)) { || canQueryAsInstaller(existingSetting, newPkg) || canQueryAsUpdateOwner(existingSetting, newPkg)) { synchronized (mQueriesViaPackageLock) { mQueriesViaPackage.add(existingSetting.getAppId(), newPkgSetting.getAppId()); Loading @@ -697,7 +699,8 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable, } } if (canQueryViaPackage(newPkg, existingPkg) || canQueryAsInstaller(newPkgSetting, existingPkg)) { || canQueryAsInstaller(newPkgSetting, existingPkg) || canQueryAsUpdateOwner(newPkgSetting, existingPkg)) { synchronized (mQueriesViaPackageLock) { mQueriesViaPackage.add(newPkgSetting.getAppId(), existingSetting.getAppId()); Loading
services/core/java/com/android/server/pm/AppsFilterUtils.java +9 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,15 @@ final class AppsFilterUtils { return false; } public static boolean canQueryAsUpdateOwner(PackageStateInternal querying, AndroidPackage potentialTarget) { final InstallSource installSource = querying.getInstallSource(); if (potentialTarget.getPackageName().equals(installSource.mUpdateOwnerPackageName)) { return true; } return false; } public static boolean canQueryViaUsesLibrary(AndroidPackage querying, AndroidPackage potentialTarget) { if (potentialTarget.getLibraryNames().isEmpty()) { Loading
services/tests/PackageManagerServiceTests/server/src/com/android/server/pm/AppsFilterImplTest.java +33 −4 Original line number Diff line number Diff line Loading @@ -283,7 +283,7 @@ public class AppsFilterImplTest { assertFalse( appsFilter.shouldFilterApplication(mSnapshot, DUMMY_CALLING_APPID, calling, target, SYSTEM_USER)); watcher.verifyNoChangeReported("shouldFilterAplication"); watcher.verifyNoChangeReported("shouldFilterApplication"); } @Test Loading Loading @@ -1081,7 +1081,7 @@ public class AppsFilterImplTest { assertTrue( appsFilter.shouldFilterApplication(mSnapshot, DUMMY_CALLING_APPID, calling, target, SYSTEM_USER)); watcher.verifyNoChangeReported("shouldFilterAplication"); watcher.verifyNoChangeReported("shouldFilterApplication"); } @Test Loading Loading @@ -1110,7 +1110,36 @@ public class AppsFilterImplTest { assertFalse( appsFilter.shouldFilterApplication(mSnapshot, DUMMY_CALLING_APPID, calling, target, SYSTEM_USER)); watcher.verifyNoChangeReported("shouldFilterAplication"); watcher.verifyNoChangeReported("shouldFilterApplication"); } @Test public void testUpdateOwner_DoesntFilter() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mFeatureConfigMock, new String[]{}, /* systemAppsQueryable */ false, /* overlayProvider */ null, mMockHandler); final WatchableTester watcher = new WatchableTester(appsFilter, "onChange"); watcher.register(); simulateAddBasicAndroid(appsFilter); watcher.verifyChangeReported("addBasicAndroid"); appsFilter.onSystemReady(mPmInternal); watcher.verifyChangeReported("systemReady"); PackageSetting target = simulateAddPackage(appsFilter, pkg("com.some.package"), DUMMY_TARGET_APPID); watcher.verifyChangeReported("add package"); PackageSetting calling = simulateAddPackage(appsFilter, pkg("com.some.other.package"), DUMMY_CALLING_APPID, withInstallSource(null /* initiatingPackageName */, null /* originatingPackageName */, null /* installerPackageName */, INVALID_UID, target.getPackageName(), null /* installerAttributionTag */, false /* isInitiatingPackageUninstalled */)); watcher.verifyChangeReported("add package"); assertFalse( appsFilter.shouldFilterApplication(mSnapshot, DUMMY_CALLING_APPID, calling, target, SYSTEM_USER)); watcher.verifyNoChangeReported("shouldFilterApplication"); } @Test Loading Loading @@ -1139,7 +1168,7 @@ public class AppsFilterImplTest { assertFalse( appsFilter.shouldFilterApplication(mSnapshot, DUMMY_TARGET_APPID, target, instrumentation, SYSTEM_USER)); watcher.verifyNoChangeReported("shouldFilterAplication"); watcher.verifyNoChangeReported("shouldFilterApplication"); } @Test Loading