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

Commit eb6be3bd authored by satayev's avatar satayev Committed by Gerrit Code Review
Browse files

Merge "Plumb @TestApi enforcement policy to runtime."

parents 97757aa6 19305b4f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -114,6 +114,13 @@ 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;

    /** No external storage should be mounted. */
    public static final int MOUNT_EXTERNAL_NONE = IVold.REMOUNT_MODE_NONE;
    /** Default external storage should be mounted. */
+15 −3
Original line number Diff line number Diff line
@@ -7786,10 +7786,18 @@ public class ActivityManagerService extends IActivityManager.Stub
                false /* mountExtStorageFull */, abiOverride);
    }
    // TODO: Move to ProcessList?
    @GuardedBy("this")
    final ProcessRecord addAppLocked(ApplicationInfo info, String customProcess, boolean isolated,
            boolean disableHiddenApiChecks, boolean mountExtStorageFull, String abiOverride) {
        return addAppLocked(info, customProcess, isolated, disableHiddenApiChecks,
                false /* disableTestApiChecks */, mountExtStorageFull, abiOverride);
    }
    // TODO: Move to ProcessList?
    @GuardedBy("this")
    final ProcessRecord addAppLocked(ApplicationInfo info, String customProcess, boolean isolated,
            boolean disableHiddenApiChecks, boolean disableTestApiChecks,
            boolean mountExtStorageFull, String abiOverride) {
        ProcessRecord app;
        if (!isolated) {
            app = getProcessRecordLocked(customProcess != null ? customProcess : info.processName,
@@ -7824,7 +7832,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            mPersistentStartingProcesses.add(app);
            mProcessList.startProcessLocked(app, new HostingRecord("added application",
                    customProcess != null ? customProcess : app.processName),
                    disableHiddenApiChecks, mountExtStorageFull, abiOverride);
                    disableHiddenApiChecks, disableTestApiChecks, mountExtStorageFull, abiOverride);
        }
        return app;
@@ -15765,6 +15773,10 @@ public class ActivityManagerService extends IActivityManager.Stub
                enforceCallingPermission(android.Manifest.permission.DISABLE_HIDDEN_API_CHECKS,
                        "disable hidden API checks");
            }
            // Allow instrumented processes access to test APIs.
            // TODO(satayev): make this configurable via testing framework.
            boolean disableTestApiChecks = true;
            final boolean mountExtStorageFull = isCallerShell()
                    && (flags & INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL) != 0;
@@ -15779,7 +15791,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
            ProcessRecord app = addAppLocked(ai, defProcess, false, disableHiddenApiChecks,
                    mountExtStorageFull, abiOverride);
                    disableTestApiChecks, mountExtStorageFull, abiOverride);
            app.setActiveInstrumentation(activeInstr);
            activeInstr.mFinished = false;
            activeInstr.mRunningProcesses.add(app);
+8 −7
Original line number Diff line number Diff line
@@ -1419,15 +1419,11 @@ public final class ProcessList {

    /**
     * @return {@code true} if process start is successful, false otherwise.
     * @param app
     * @param hostingRecord
     * @param disableHiddenApiChecks
     * @param abiOverride
     */
    @GuardedBy("mService")
    boolean startProcessLocked(ProcessRecord app, HostingRecord hostingRecord,
            boolean disableHiddenApiChecks, boolean mountExtStorageFull,
            String abiOverride) {
            boolean disableHiddenApiChecks, boolean disableTestApiChecks,
            boolean mountExtStorageFull, String abiOverride) {
        if (app.pendingStart) {
            return true;
        }
@@ -1572,6 +1568,10 @@ 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(
@@ -1845,7 +1845,8 @@ public final class ProcessList {
    final boolean startProcessLocked(ProcessRecord app, HostingRecord hostingRecord,
            String abiOverride) {
        return startProcessLocked(app, hostingRecord,
                false /* disableHiddenApiChecks */, false /* mountExtStorageFull */, abiOverride);
                false /* disableHiddenApiChecks */, false /* disableTestApiChecks */,
                false /* mountExtStorageFull */, abiOverride);
    }

    @GuardedBy("mService")