Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9923f39c authored by Rhed Jao's avatar Rhed Jao
Browse files

Adds user id support to the checkSignatures API

The checkSignatures API return false if target packages do not
install in the current user. This cl fixes the instrumentation
cannot be launched if the target package does not install in
the system user.

NoNonSdkCheck: An equivalent api is available in PackageManager.

Bug: 229979568
Bug: 216113658
Test: atest CrossUserPackageVisibilityTests
Test: atest PackageManagerTest
Test: atest PackageManagerTests
Test: atest OverlayManagerServiceImplTests
Test: atest OverlayManagerServiceImplRebootTests
Test: atest ShortcutManagerMultiuserTest#testSecondaryUser
Change-Id: Idd6afe400453af3259547a069efaf9c86ff1da38
parent 948c25ff
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -960,7 +960,7 @@ public class ApplicationPackageManager extends PackageManager {
    @Override
    public int checkSignatures(String pkg1, String pkg2) {
        try {
            return mPM.checkSignatures(pkg1, pkg2);
            return mPM.checkSignatures(pkg1, pkg2, getUserId());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+1 −2
Original line number Diff line number Diff line
@@ -100,8 +100,7 @@ interface IPackageManager {

    boolean isProtectedBroadcast(String actionName);

    @UnsupportedAppUsage
    int checkSignatures(String pkg1, String pkg2);
    int checkSignatures(String pkg1, String pkg2, int userId);

    @UnsupportedAppUsage
    int checkUidSignatures(int uid1, int uid2);
+7 −2
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_UNAWARE;
import static android.content.pm.PackageManager.MATCH_SYSTEM_ONLY;
import static android.content.pm.PackageManager.MATCH_UNINSTALLED_PACKAGES;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.content.pm.PackageManager.SIGNATURE_NO_MATCH;
import static android.net.ConnectivityManager.BLOCKED_REASON_NONE;
import static android.os.FactoryTest.FACTORY_TEST_OFF;
import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_CRITICAL;
@@ -14506,8 +14507,12 @@ public class ActivityManagerService extends IActivityManager.Stub
                return false;
            }
            int match = mContext.getPackageManager().checkSignatures(
                    ii.targetPackage, ii.packageName);
            int match = SIGNATURE_NO_MATCH;
            try {
                match = AppGlobals.getPackageManager().checkSignatures(
                        ii.targetPackage, ii.packageName, userId);
            } catch (RemoteException e) {
            }
            if (match < 0 && match != PackageManager.SIGNATURE_FIRST_NOT_SIGNED) {
                if (Build.IS_DEBUGGABLE && (callingUid == Process.ROOT_UID)
                        && (flags & INSTR_FLAG_ALWAYS_CHECK_SIGNATURE) == 0) {
+1 −1
Original line number Diff line number Diff line
@@ -1255,7 +1255,7 @@ public final class OverlayManagerService extends SystemService {
            // to be installed for different users: ignore userId for now.
            try {
                return mPackageManager.checkSignatures(
                        packageName1, packageName2) == SIGNATURE_MATCH;
                        packageName1, packageName2, userId) == SIGNATURE_MATCH;
            } catch (RemoteException e) {
                // Intentionally left blank
            }
+1 −1
Original line number Diff line number Diff line
@@ -373,7 +373,7 @@ public interface Computer extends PackageDataSnapshot {
    PackageStateInternal getPackageStateFiltered(@NonNull String packageName, int callingUid,
            @UserIdInt int userId);

    int checkSignatures(@NonNull String pkg1, @NonNull String pkg2);
    int checkSignatures(@NonNull String pkg1, @NonNull String pkg2, int userId);

    int checkUidSignatures(int uid1, int uid2);

Loading