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

Commit baade694 authored by Rhed Jao's avatar Rhed Jao Committed by Android (Google) Code Review
Browse files

Merge "Fix cross user package visibility leakage for queryInstrumentation"

parents 6738d00a 744a05e9
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -425,7 +425,8 @@ public class Instrument {
            if (cn == null) throw new IllegalArgumentException("Bad component name: " + cnArg);
            return cn;
        } else {
            List<InstrumentationInfo> infos = mPm.queryInstrumentation(null, 0).getList();
            List<InstrumentationInfo> infos = mPm.queryInstrumentationAsUser(
                    null, 0, userId).getList();

            final int numInfos = infos == null ? 0: infos.size();
            ArrayList<ComponentName> cns = new ArrayList<>();
+6 −3
Original line number Diff line number Diff line
@@ -6854,9 +6854,12 @@ public final class ActivityThread extends ClientTransactionHandler
    private InstrumentationInfo prepareInstrumentation(AppBindData data) {
        final InstrumentationInfo ii;
        try {
            ii = new ApplicationPackageManager(null, getPackageManager())
                    .getInstrumentationInfo(data.instrumentationName, 0);
        } catch (PackageManager.NameNotFoundException e) {
            ii = getPackageManager().getInstrumentationInfoAsUser(data.instrumentationName,
                    0 /* flags */, UserHandle.myUserId());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
        if (ii == null) {
            throw new RuntimeException(
                    "Unable to find instrumentation info for: " + data.instrumentationName);
        }
+3 −3
Original line number Diff line number Diff line
@@ -1695,8 +1695,8 @@ public class ApplicationPackageManager extends PackageManager {
        ComponentName className, int flags)
            throws NameNotFoundException {
        try {
            InstrumentationInfo ii = mPM.getInstrumentationInfo(
                className, flags);
            InstrumentationInfo ii = mPM.getInstrumentationInfoAsUser(
                    className, flags, getUserId());
            if (ii != null) {
                return ii;
            }
@@ -1713,7 +1713,7 @@ public class ApplicationPackageManager extends PackageManager {
        String targetPackage, int flags) {
        try {
            ParceledListSlice<InstrumentationInfo> parceledList =
                    mPM.queryInstrumentation(targetPackage, flags);
                    mPM.queryInstrumentationAsUser(targetPackage, flags, getUserId());
            if (parceledList == null) {
                return Collections.emptyList();
            }
+4 −6
Original line number Diff line number Diff line
@@ -201,13 +201,11 @@ interface IPackageManager {
    ParceledListSlice queryContentProviders(
            String processName, int uid, long flags, String metaDataKey);

    @UnsupportedAppUsage
    InstrumentationInfo getInstrumentationInfo(
            in ComponentName className, int flags);
    InstrumentationInfo getInstrumentationInfoAsUser(
            in ComponentName className, int flags, int userId);

    @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
    ParceledListSlice queryInstrumentation(
            String targetPackage, int flags);
    ParceledListSlice queryInstrumentationAsUser(
            String targetPackage, int flags, int userId);

    void finishPackageInstall(int token, boolean didLaunch);

+4 −7
Original line number Diff line number Diff line
@@ -14542,6 +14542,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        if (arguments != null && arguments.hasFileDescriptors()) {
            throw new IllegalArgumentException("File descriptors passed in Bundle");
        }
        final IPackageManager pm = AppGlobals.getPackageManager();
        synchronized(this) {
            InstrumentationInfo ii = null;
@@ -14550,11 +14551,8 @@ public class ActivityManagerService extends IActivityManager.Stub
            boolean noRestart = (flags & INSTR_FLAG_NO_RESTART) != 0;
            try {
                ii = mContext.getPackageManager().getInstrumentationInfo(
                        className, STOCK_PM_FLAGS);
                ai = AppGlobals.getPackageManager().getApplicationInfo(
                        ii.targetPackage, STOCK_PM_FLAGS, userId);
            } catch (PackageManager.NameNotFoundException e) {
                ii = pm.getInstrumentationInfoAsUser(className, STOCK_PM_FLAGS, userId);
                ai = pm.getApplicationInfo(ii.targetPackage, STOCK_PM_FLAGS, userId);
            } catch (RemoteException e) {
            }
            if (ii == null) {
@@ -14582,8 +14580,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            int match = SIGNATURE_NO_MATCH;
            try {
                match = AppGlobals.getPackageManager().checkSignatures(
                        ii.targetPackage, ii.packageName, userId);
                match = pm.checkSignatures(ii.targetPackage, ii.packageName, userId);
            } catch (RemoteException e) {
            }
            if (match < 0 && match != PackageManager.SIGNATURE_FIRST_NOT_SIGNED) {
Loading