Merge "Set Zygote.DISABLE_HIDDEN_API_CHECKS for system apps"

This commit is contained in:
Treehugger Robot
2018-01-24 23:09:28 +00:00
committed by Gerrit Code Review
2 changed files with 11 additions and 0 deletions

View File

@@ -55,6 +55,8 @@ public final class Zygote {
public static final int DISABLE_VERIFIER = 1 << 9;
/** Only use oat files located in /system. Otherwise use dex/jar/apk . */
public static final int ONLY_USE_SYSTEM_OAT_FILES = 1 << 10;
/** Do not enfore hidden API access restrictions. */
public static final int DISABLE_HIDDEN_API_CHECKS = 1 << 11;
/** No external storage should be mounted. */
public static final int MOUNT_EXTERNAL_NONE = 0;
@@ -158,6 +160,9 @@ public final class Zygote {
*/
public static int forkSystemServer(int uid, int gid, int[] gids, int runtimeFlags,
int[][] rlimits, long permittedCapabilities, long effectiveCapabilities) {
// SystemServer is always allowed to use hidden APIs.
runtimeFlags |= DISABLE_HIDDEN_API_CHECKS;
VM_HOOKS.preFork();
// Resets nice priority for zygote process.
resetNicePriority();

View File

@@ -3877,6 +3877,12 @@ public class ActivityManagerService extends IActivityManager.Stub
runtimeFlags |= Zygote.ONLY_USE_SYSTEM_OAT_FILES;
}
if (app.info.isAllowedToUseHiddenApi()) {
// This app is allowed to use undocumented and private APIs. Set
// up its runtime with the appropriate flag.
runtimeFlags |= Zygote.DISABLE_HIDDEN_API_CHECKS;
}
String invokeWith = null;
if ((app.info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
// Debuggable apps may include a wrapper script with their library directory.