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

Commit bff33b8c authored by Artur Satayev's avatar Artur Satayev Committed by satayev
Browse files

Do not propogate test api access flags to Zygote.

The flow has been replaced by @ChangeId ALLOW_TEST_API_ACCESS, making
old approach obsolete.

Bug: 147113465
Test: atest CameraEvictionTest#testBasicCamera2ActivityEviction
Merged-In: I0bf109fa78212d6d71ba85d25f80e27e8e7cd900
Merged-In: I0e58b6924744590afaadec6a6230aa9d552b2f6f
Change-Id: I9cf8f80abb0165d4aefbf943bade57f5e031904b
Exempt-From-Owner-Approval: cp
Bug: 178391911,147113465
(cherry picked from commit a27cd305)
parent 5c389e25
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ public final class Zygote {
     */
    public static final int PROFILE_FROM_SHELL = 1 << 15;

    /*
    /**
     * Enable using the ART app image startup cache
     */
    public static final int USE_APP_IMAGE_STARTUP_CACHE = 1 << 16;
@@ -116,13 +116,6 @@ public final class Zygote {
     */
    public static final int DEBUG_IGNORE_APP_SIGNAL_HANDLER = 1 << 17;

    /**
     * Disable runtime access to {@link android.annotation.TestApi} annotated members.
     *
     * <p>This only takes effect if Hidden API access restrictions are enabled as well.
     */
    public static final int DISABLE_TEST_API_ENFORCEMENT_POLICY = 1 << 18;

    public static final int MEMORY_TAG_LEVEL_MASK = (1 << 19) | (1 << 20);
    /**
     * Enable pointer tagging in this process.
+5 −15
Original line number Diff line number Diff line
@@ -8211,20 +8211,11 @@ public class ActivityManagerService extends IActivityManager.Stub
                false /* mountExtStorageFull */, abiOverride, zygotePolicyFlags);
    }
    // TODO: Move to ProcessList?
    @GuardedBy("this")
    final ProcessRecord addAppLocked(ApplicationInfo info, String customProcess, boolean isolated,
            boolean disableHiddenApiChecks, boolean mountExtStorageFull, String abiOverride,
            int zygotePolicyFlags) {
        return addAppLocked(info, customProcess, isolated, disableHiddenApiChecks,
                false /* disableTestApiChecks */, mountExtStorageFull, abiOverride,
                zygotePolicyFlags);
    }
    // TODO: Move to ProcessList?
    @GuardedBy("this")
    final ProcessRecord addAppLocked(ApplicationInfo info, String customProcess, boolean isolated,
            boolean disableHiddenApiChecks, boolean disableTestApiChecks,
            boolean mountExtStorageFull, String abiOverride, int zygotePolicyFlags) {
        ProcessRecord app;
        if (!isolated) {
            app = getProcessRecordLocked(customProcess != null ? customProcess : info.processName,
@@ -8259,8 +8250,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            mPersistentStartingProcesses.add(app);
            mProcessList.startProcessLocked(app, new HostingRecord("added application",
                    customProcess != null ? customProcess : app.processName),
                    zygotePolicyFlags, disableHiddenApiChecks, disableTestApiChecks,
                    mountExtStorageFull, abiOverride);
                    zygotePolicyFlags, disableHiddenApiChecks, mountExtStorageFull, abiOverride);
        }
        return app;
@@ -16943,11 +16933,12 @@ public class ActivityManagerService extends IActivityManager.Stub
                    || (flags & INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS) != 0;
            boolean disableTestApiChecks = disableHiddenApiChecks
                    || (flags & INSTR_FLAG_DISABLE_TEST_API_CHECKS) != 0;
            if (disableHiddenApiChecks || disableTestApiChecks) {
                enforceCallingPermission(android.Manifest.permission.DISABLE_HIDDEN_API_CHECKS,
                        "disable hidden API checks");
                enableTestApiAccess(ii.packageName);
                enableTestApiAccess(ai.packageName);
            }
            // TODO(b/158750470): remove
@@ -16965,8 +16956,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
            ProcessRecord app = addAppLocked(ai, defProcess, false, disableHiddenApiChecks,
                    disableTestApiChecks, mountExtStorageFull, abiOverride,
                    ZYGOTE_POLICY_FLAG_EMPTY);
                    mountExtStorageFull, abiOverride, ZYGOTE_POLICY_FLAG_EMPTY);
            app.setActiveInstrumentation(activeInstr);
            activeInstr.mFinished = false;
            activeInstr.mSourceUid = callingUid;
+3 −8
Original line number Diff line number Diff line
@@ -1769,8 +1769,8 @@ public final class ProcessList {
     */
    @GuardedBy("mService")
    boolean startProcessLocked(ProcessRecord app, HostingRecord hostingRecord,
            int zygotePolicyFlags, boolean disableHiddenApiChecks, boolean disableTestApiChecks,
            boolean mountExtStorageFull, String abiOverride) {
            int zygotePolicyFlags, boolean disableHiddenApiChecks, boolean mountExtStorageFull,
            String abiOverride) {
        if (app.pendingStart) {
            return true;
        }
@@ -1914,10 +1914,6 @@ public final class ProcessList {
                    throw new IllegalStateException("Invalid API policy: " + policy);
                }
                runtimeFlags |= policyBits;

                if (disableTestApiChecks) {
                    runtimeFlags |= Zygote.DISABLE_TEST_API_ENFORCEMENT_POLICY;
                }
            }

            String useAppImageCache = SystemProperties.get(
@@ -2360,8 +2356,7 @@ public final class ProcessList {
    final boolean startProcessLocked(ProcessRecord app, HostingRecord hostingRecord,
            int zygotePolicyFlags, String abiOverride) {
        return startProcessLocked(app, hostingRecord, zygotePolicyFlags,
                false /* disableHiddenApiChecks */, false /* disableTestApiChecks */,
                false /* mountExtStorageFull */, abiOverride);
                false /* disableHiddenApiChecks */, false /* mountExtStorageFull */, abiOverride);
    }

    @GuardedBy("mService")