Loading services/core/java/com/android/server/pm/ComputerEngine.java +6 −6 Original line number Diff line number Diff line Loading @@ -5244,10 +5244,11 @@ public class ComputerEngine implements Computer { if (packageName == null || alias == null) { return null; } final int callingUid = Binder.getCallingUid(); final int callingUserId = UserHandle.getUserId(callingUid); final AndroidPackage pkg = mPackages.get(packageName); if (pkg == null || shouldFilterApplication(getPackageStateInternal(pkg.getPackageName()), Binder.getCallingUid(), UserHandle.getCallingUserId())) { if (pkg == null || shouldFilterApplicationIncludingUninstalled( getPackageStateInternal(pkg.getPackageName()), callingUid, callingUserId)) { Slog.w(TAG, "KeySet requested for unknown package: " + packageName); throw new IllegalArgumentException("Unknown package: " + packageName); } Loading @@ -5264,9 +5265,8 @@ public class ComputerEngine implements Computer { final int callingUid = Binder.getCallingUid(); final int callingUserId = UserHandle.getUserId(callingUid); final AndroidPackage pkg = mPackages.get(packageName); if (pkg == null || shouldFilterApplication(getPackageStateInternal(pkg.getPackageName()), callingUid, callingUserId)) { if (pkg == null || shouldFilterApplicationIncludingUninstalled( getPackageStateInternal(pkg.getPackageName()), callingUid, callingUserId)) { Slog.w(TAG, "KeySet requested for unknown package: " + packageName + ", uid:" + callingUid); throw new IllegalArgumentException("Unknown package: " + packageName); Loading services/tests/PackageManagerServiceTests/appenumeration/src/com/android/server/pm/test/appenumeration/CrossUserPackageVisibilityTests.java +25 −0 Original line number Diff line number Diff line Loading @@ -126,6 +126,31 @@ public class CrossUserPackageVisibilityTests { CROSS_USER_TEST_PACKAGE_NAME, keySet)); } @Test public void testGetSigningKeySet_cannotDetectCrossUserPkg() { final IllegalArgumentException e1 = assertThrows(IllegalArgumentException.class, () -> mIPackageManager.getSigningKeySet(CROSS_USER_TEST_PACKAGE_NAME)); installPackageForUser(CROSS_USER_TEST_APK_FILE, mOtherUser); final IllegalArgumentException e2 = assertThrows(IllegalArgumentException.class, () -> mIPackageManager.getSigningKeySet(CROSS_USER_TEST_PACKAGE_NAME)); assertThat(e1.getMessage()).isEqualTo(e2.getMessage()); } @Test public void testGetKeySetByAlias_cannotDetectCrossUserPkg() { final String alias = CROSS_USER_TEST_PACKAGE_NAME + ".alias"; final IllegalArgumentException e1 = assertThrows(IllegalArgumentException.class, () -> mIPackageManager.getKeySetByAlias(CROSS_USER_TEST_PACKAGE_NAME, alias)); installPackageForUser(CROSS_USER_TEST_APK_FILE, mOtherUser); final IllegalArgumentException e2 = assertThrows(IllegalArgumentException.class, () -> mIPackageManager.getKeySetByAlias(CROSS_USER_TEST_PACKAGE_NAME, alias)); assertThat(e1.getMessage()).isEqualTo(e2.getMessage()); } private static void installPackageForUser(File apk, UserReference user) { assertThat(apk.exists()).isTrue(); final StringBuilder cmd = new StringBuilder("pm install --user "); Loading Loading
services/core/java/com/android/server/pm/ComputerEngine.java +6 −6 Original line number Diff line number Diff line Loading @@ -5244,10 +5244,11 @@ public class ComputerEngine implements Computer { if (packageName == null || alias == null) { return null; } final int callingUid = Binder.getCallingUid(); final int callingUserId = UserHandle.getUserId(callingUid); final AndroidPackage pkg = mPackages.get(packageName); if (pkg == null || shouldFilterApplication(getPackageStateInternal(pkg.getPackageName()), Binder.getCallingUid(), UserHandle.getCallingUserId())) { if (pkg == null || shouldFilterApplicationIncludingUninstalled( getPackageStateInternal(pkg.getPackageName()), callingUid, callingUserId)) { Slog.w(TAG, "KeySet requested for unknown package: " + packageName); throw new IllegalArgumentException("Unknown package: " + packageName); } Loading @@ -5264,9 +5265,8 @@ public class ComputerEngine implements Computer { final int callingUid = Binder.getCallingUid(); final int callingUserId = UserHandle.getUserId(callingUid); final AndroidPackage pkg = mPackages.get(packageName); if (pkg == null || shouldFilterApplication(getPackageStateInternal(pkg.getPackageName()), callingUid, callingUserId)) { if (pkg == null || shouldFilterApplicationIncludingUninstalled( getPackageStateInternal(pkg.getPackageName()), callingUid, callingUserId)) { Slog.w(TAG, "KeySet requested for unknown package: " + packageName + ", uid:" + callingUid); throw new IllegalArgumentException("Unknown package: " + packageName); Loading
services/tests/PackageManagerServiceTests/appenumeration/src/com/android/server/pm/test/appenumeration/CrossUserPackageVisibilityTests.java +25 −0 Original line number Diff line number Diff line Loading @@ -126,6 +126,31 @@ public class CrossUserPackageVisibilityTests { CROSS_USER_TEST_PACKAGE_NAME, keySet)); } @Test public void testGetSigningKeySet_cannotDetectCrossUserPkg() { final IllegalArgumentException e1 = assertThrows(IllegalArgumentException.class, () -> mIPackageManager.getSigningKeySet(CROSS_USER_TEST_PACKAGE_NAME)); installPackageForUser(CROSS_USER_TEST_APK_FILE, mOtherUser); final IllegalArgumentException e2 = assertThrows(IllegalArgumentException.class, () -> mIPackageManager.getSigningKeySet(CROSS_USER_TEST_PACKAGE_NAME)); assertThat(e1.getMessage()).isEqualTo(e2.getMessage()); } @Test public void testGetKeySetByAlias_cannotDetectCrossUserPkg() { final String alias = CROSS_USER_TEST_PACKAGE_NAME + ".alias"; final IllegalArgumentException e1 = assertThrows(IllegalArgumentException.class, () -> mIPackageManager.getKeySetByAlias(CROSS_USER_TEST_PACKAGE_NAME, alias)); installPackageForUser(CROSS_USER_TEST_APK_FILE, mOtherUser); final IllegalArgumentException e2 = assertThrows(IllegalArgumentException.class, () -> mIPackageManager.getKeySetByAlias(CROSS_USER_TEST_PACKAGE_NAME, alias)); assertThat(e1.getMessage()).isEqualTo(e2.getMessage()); } private static void installPackageForUser(File apk, UserReference user) { assertThat(apk.exists()).isTrue(); final StringBuilder cmd = new StringBuilder("pm install --user "); Loading