Merge "Revert "Do not propogate test api access flags to Zygote."" am: 6faddabeb7 am: 1856a9efdd

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1598954

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I35de41959fed409a49d101ea9ef3da5c4ced84b6
This commit is contained in:
Treehugger Robot
2021-02-24 04:07:23 +00:00
committed by Automerger Merge Worker
3 changed files with 31 additions and 9 deletions

View File

@@ -103,7 +103,7 @@ public final class Zygote {
*/ */
public static final int PROFILE_FROM_SHELL = 1 << 15; public static final int PROFILE_FROM_SHELL = 1 << 15;
/** /*
* Enable using the ART app image startup cache * Enable using the ART app image startup cache
*/ */
public static final int USE_APP_IMAGE_STARTUP_CACHE = 1 << 16; public static final int USE_APP_IMAGE_STARTUP_CACHE = 1 << 16;
@@ -116,6 +116,13 @@ public final class Zygote {
*/ */
public static final int DEBUG_IGNORE_APP_SIGNAL_HANDLER = 1 << 17; 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); public static final int MEMORY_TAG_LEVEL_MASK = (1 << 19) | (1 << 20);
/** /**
* Enable pointer tagging in this process. * Enable pointer tagging in this process.

View File

@@ -8211,11 +8211,20 @@ public class ActivityManagerService extends IActivityManager.Stub
false /* mountExtStorageFull */, abiOverride, zygotePolicyFlags); false /* mountExtStorageFull */, abiOverride, zygotePolicyFlags);
} }
// TODO: Move to ProcessList?
@GuardedBy("this") @GuardedBy("this")
final ProcessRecord addAppLocked(ApplicationInfo info, String customProcess, boolean isolated, final ProcessRecord addAppLocked(ApplicationInfo info, String customProcess, boolean isolated,
boolean disableHiddenApiChecks, boolean mountExtStorageFull, String abiOverride, boolean disableHiddenApiChecks, boolean mountExtStorageFull, String abiOverride,
int zygotePolicyFlags) { 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; ProcessRecord app;
if (!isolated) { if (!isolated) {
app = getProcessRecordLocked(customProcess != null ? customProcess : info.processName, app = getProcessRecordLocked(customProcess != null ? customProcess : info.processName,
@@ -8250,7 +8259,8 @@ public class ActivityManagerService extends IActivityManager.Stub
mPersistentStartingProcesses.add(app); mPersistentStartingProcesses.add(app);
mProcessList.startProcessLocked(app, new HostingRecord("added application", mProcessList.startProcessLocked(app, new HostingRecord("added application",
customProcess != null ? customProcess : app.processName), customProcess != null ? customProcess : app.processName),
zygotePolicyFlags, disableHiddenApiChecks, mountExtStorageFull, abiOverride); zygotePolicyFlags, disableHiddenApiChecks, disableTestApiChecks,
mountExtStorageFull, abiOverride);
} }
return app; return app;
@@ -17056,12 +17066,11 @@ public class ActivityManagerService extends IActivityManager.Stub
|| (flags & INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS) != 0; || (flags & INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS) != 0;
boolean disableTestApiChecks = disableHiddenApiChecks boolean disableTestApiChecks = disableHiddenApiChecks
|| (flags & INSTR_FLAG_DISABLE_TEST_API_CHECKS) != 0; || (flags & INSTR_FLAG_DISABLE_TEST_API_CHECKS) != 0;
if (disableHiddenApiChecks || disableTestApiChecks) { if (disableHiddenApiChecks || disableTestApiChecks) {
enforceCallingPermission(android.Manifest.permission.DISABLE_HIDDEN_API_CHECKS, enforceCallingPermission(android.Manifest.permission.DISABLE_HIDDEN_API_CHECKS,
"disable hidden API checks"); "disable hidden API checks");
enableTestApiAccess(ai.packageName); enableTestApiAccess(ii.packageName);
} }
// TODO(b/158750470): remove // TODO(b/158750470): remove
@@ -17079,7 +17088,8 @@ public class ActivityManagerService extends IActivityManager.Stub
} }
ProcessRecord app = addAppLocked(ai, defProcess, false, disableHiddenApiChecks, ProcessRecord app = addAppLocked(ai, defProcess, false, disableHiddenApiChecks,
mountExtStorageFull, abiOverride, ZYGOTE_POLICY_FLAG_EMPTY); disableTestApiChecks, mountExtStorageFull, abiOverride,
ZYGOTE_POLICY_FLAG_EMPTY);
app.setActiveInstrumentation(activeInstr); app.setActiveInstrumentation(activeInstr);
activeInstr.mFinished = false; activeInstr.mFinished = false;
activeInstr.mSourceUid = callingUid; activeInstr.mSourceUid = callingUid;

View File

@@ -1769,8 +1769,8 @@ public final class ProcessList {
*/ */
@GuardedBy("mService") @GuardedBy("mService")
boolean startProcessLocked(ProcessRecord app, HostingRecord hostingRecord, boolean startProcessLocked(ProcessRecord app, HostingRecord hostingRecord,
int zygotePolicyFlags, boolean disableHiddenApiChecks, boolean mountExtStorageFull, int zygotePolicyFlags, boolean disableHiddenApiChecks, boolean disableTestApiChecks,
String abiOverride) { boolean mountExtStorageFull, String abiOverride) {
if (app.pendingStart) { if (app.pendingStart) {
return true; return true;
} }
@@ -1914,6 +1914,10 @@ public final class ProcessList {
throw new IllegalStateException("Invalid API policy: " + policy); throw new IllegalStateException("Invalid API policy: " + policy);
} }
runtimeFlags |= policyBits; runtimeFlags |= policyBits;
if (disableTestApiChecks) {
runtimeFlags |= Zygote.DISABLE_TEST_API_ENFORCEMENT_POLICY;
}
} }
String useAppImageCache = SystemProperties.get( String useAppImageCache = SystemProperties.get(
@@ -2356,7 +2360,8 @@ public final class ProcessList {
final boolean startProcessLocked(ProcessRecord app, HostingRecord hostingRecord, final boolean startProcessLocked(ProcessRecord app, HostingRecord hostingRecord,
int zygotePolicyFlags, String abiOverride) { int zygotePolicyFlags, String abiOverride) {
return startProcessLocked(app, hostingRecord, zygotePolicyFlags, return startProcessLocked(app, hostingRecord, zygotePolicyFlags,
false /* disableHiddenApiChecks */, false /* mountExtStorageFull */, abiOverride); false /* disableHiddenApiChecks */, false /* disableTestApiChecks */,
false /* mountExtStorageFull */, abiOverride);
} }
@GuardedBy("mService") @GuardedBy("mService")