Loading cmds/am/src/com/android/commands/am/Am.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -172,6 +172,8 @@ public class Am extends BaseCommand { } else if (opt.equals("--no_window_animation") } else if (opt.equals("--no_window_animation") || opt.equals("--no-window-animation")) { || opt.equals("--no-window-animation")) { instrument.noWindowAnimation = true; instrument.noWindowAnimation = true; } else if (opt.equals("--no-hidden-api-checks")) { instrument.disableHiddenApiChecks = true; } else if (opt.equals("--user")) { } else if (opt.equals("--user")) { instrument.userId = parseUserArg(nextArgRequired()); instrument.userId = parseUserArg(nextArgRequired()); } else if (opt.equals("--abi")) { } else if (opt.equals("--abi")) { Loading cmds/am/src/com/android/commands/am/Instrument.java +7 −1 Original line number Original line Diff line number Diff line Loading @@ -73,12 +73,17 @@ public class Instrument { boolean protoFile = false; // write proto to a file boolean protoFile = false; // write proto to a file String logPath = null; String logPath = null; public boolean noWindowAnimation = false; public boolean noWindowAnimation = false; public boolean disableHiddenApiChecks = false; public String abi = null; public String abi = null; public int userId = UserHandle.USER_CURRENT; public int userId = UserHandle.USER_CURRENT; public Bundle args = new Bundle(); public Bundle args = new Bundle(); // Required // Required public String componentNameArg; public String componentNameArg; // Disable hidden API checks for the newly started instrumentation. // Must be kept in sync with ActivityManagerService. private static final int INSTRUMENTATION_FLAG_DISABLE_HIDDEN_API_CHECKS = 1 << 0; /** /** * Construct the instrument command runner. * Construct the instrument command runner. */ */ Loading Loading @@ -475,7 +480,8 @@ public class Instrument { } } // Start the instrumentation // Start the instrumentation if (!mAm.startInstrumentation(cn, profileFile, 0, args, watcher, connection, userId, int flags = disableHiddenApiChecks ? INSTRUMENTATION_FLAG_DISABLE_HIDDEN_API_CHECKS : 0; if (!mAm.startInstrumentation(cn, profileFile, flags, args, watcher, connection, userId, abi)) { abi)) { throw new AndroidException("INSTRUMENTATION_FAILED: " + cn.flattenToString()); throw new AndroidException("INSTRUMENTATION_FAILED: " + cn.flattenToString()); } } Loading services/core/java/com/android/server/am/ActivityManagerService.java +27 −4 Original line number Original line Diff line number Diff line Loading @@ -580,6 +580,10 @@ public class ActivityManagerService extends IActivityManager.Stub // How long we wait until we timeout on key dispatching during instrumentation. // How long we wait until we timeout on key dispatching during instrumentation. static final int INSTRUMENTATION_KEY_DISPATCHING_TIMEOUT = 60*1000; static final int INSTRUMENTATION_KEY_DISPATCHING_TIMEOUT = 60*1000; // Disable hidden API checks for the newly started instrumentation. // Must be kept in sync with Am. private static final int INSTRUMENTATION_FLAG_DISABLE_HIDDEN_API_CHECKS = 1 << 0; // How long to wait in getAssistContextExtras for the activity and foreground services // How long to wait in getAssistContextExtras for the activity and foreground services // to respond with the result. // to respond with the result. static final int PENDING_ASSIST_EXTRAS_TIMEOUT = 500; static final int PENDING_ASSIST_EXTRAS_TIMEOUT = 500; Loading Loading @@ -4003,12 +4007,19 @@ public class ActivityManagerService extends IActivityManager.Stub startProcessLocked(app, hostingType, hostingNameStr, null /* abiOverride */); startProcessLocked(app, hostingType, hostingNameStr, null /* abiOverride */); } } @GuardedBy("this") private final boolean startProcessLocked(ProcessRecord app, String hostingType, String hostingNameStr, String abiOverride) { return startProcessLocked(app, hostingType, hostingNameStr, false /* disableHiddenApiChecks */, abiOverride); } /** /** * @return {@code true} if process start is successful, false otherwise. * @return {@code true} if process start is successful, false otherwise. */ */ @GuardedBy("this") @GuardedBy("this") private final boolean startProcessLocked(ProcessRecord app, String hostingType, private final boolean startProcessLocked(ProcessRecord app, String hostingType, String hostingNameStr, String abiOverride) { String hostingNameStr, boolean disableHiddenApiChecks, String abiOverride) { if (app.pendingStart) { if (app.pendingStart) { return true; return true; } } Loading Loading @@ -4131,7 +4142,9 @@ public class ActivityManagerService extends IActivityManager.Stub runtimeFlags |= Zygote.ONLY_USE_SYSTEM_OAT_FILES; runtimeFlags |= Zygote.ONLY_USE_SYSTEM_OAT_FILES; } } if (!app.info.isAllowedToUseHiddenApi() && !mHiddenApiBlacklist.isDisabled()) { if (!app.info.isAllowedToUseHiddenApi() && !disableHiddenApiChecks && !mHiddenApiBlacklist.isDisabled()) { // This app is not allowed to use undocumented and private APIs, or blacklisting is // This app is not allowed to use undocumented and private APIs, or blacklisting is // enabled. Set up its runtime with the appropriate flag. // enabled. Set up its runtime with the appropriate flag. runtimeFlags |= Zygote.ENABLE_HIDDEN_API_CHECKS; runtimeFlags |= Zygote.ENABLE_HIDDEN_API_CHECKS; Loading Loading @@ -12852,6 +12865,12 @@ public class ActivityManagerService extends IActivityManager.Stub @GuardedBy("this") @GuardedBy("this") final ProcessRecord addAppLocked(ApplicationInfo info, String customProcess, boolean isolated, final ProcessRecord addAppLocked(ApplicationInfo info, String customProcess, boolean isolated, String abiOverride) { String abiOverride) { return addAppLocked(info, customProcess, isolated, false /* disableHiddenApiChecks */, abiOverride); } final ProcessRecord addAppLocked(ApplicationInfo info, String customProcess, boolean isolated, boolean disableHiddenApiChecks, String abiOverride) { ProcessRecord app; ProcessRecord app; if (!isolated) { if (!isolated) { app = getProcessRecordLocked(customProcess != null ? customProcess : info.processName, app = getProcessRecordLocked(customProcess != null ? customProcess : info.processName, Loading Loading @@ -12883,7 +12902,8 @@ public class ActivityManagerService extends IActivityManager.Stub if (app.thread == null && mPersistentStartingProcesses.indexOf(app) < 0) { if (app.thread == null && mPersistentStartingProcesses.indexOf(app) < 0) { mPersistentStartingProcesses.add(app); mPersistentStartingProcesses.add(app); startProcessLocked(app, "added application", startProcessLocked(app, "added application", customProcess != null ? customProcess : app.processName, abiOverride); customProcess != null ? customProcess : app.processName, disableHiddenApiChecks, abiOverride); } } return app; return app; Loading Loading @@ -21694,7 +21714,10 @@ public class ActivityManagerService extends IActivityManager.Stub mUsageStatsService.reportEvent(ii.targetPackage, userId, mUsageStatsService.reportEvent(ii.targetPackage, userId, UsageEvents.Event.SYSTEM_INTERACTION); UsageEvents.Event.SYSTEM_INTERACTION); } } ProcessRecord app = addAppLocked(ai, defProcess, false, abiOverride); boolean disableHiddenApiChecks = (flags & INSTRUMENTATION_FLAG_DISABLE_HIDDEN_API_CHECKS) != 0; ProcessRecord app = addAppLocked(ai, defProcess, false, disableHiddenApiChecks, abiOverride); app.instr = activeInstr; app.instr = activeInstr; activeInstr.mFinished = false; activeInstr.mFinished = false; activeInstr.mRunningProcesses.add(app); activeInstr.mRunningProcesses.add(app); services/core/java/com/android/server/am/ActivityManagerShellCommand.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -2608,7 +2608,7 @@ final class ActivityManagerShellCommand extends ShellCommand { pw.println(" specified then send to all users."); pw.println(" specified then send to all users."); pw.println(" --receiver-permission <PERMISSION>: Require receiver to hold permission."); pw.println(" --receiver-permission <PERMISSION>: Require receiver to hold permission."); pw.println(" instrument [-r] [-e <NAME> <VALUE>] [-p <FILE>] [-w]"); pw.println(" instrument [-r] [-e <NAME> <VALUE>] [-p <FILE>] [-w]"); pw.println(" [--user <USER_ID> | current]"); pw.println(" [--user <USER_ID> | current] [--no-hidden-api-checks]"); pw.println(" [--no-window-animation] [--abi <ABI>] <COMPONENT>"); pw.println(" [--no-window-animation] [--abi <ABI>] <COMPONENT>"); pw.println(" Start an Instrumentation. Typically this target <COMPONENT> is in the"); pw.println(" Start an Instrumentation. Typically this target <COMPONENT> is in the"); pw.println(" form <TEST_PACKAGE>/<RUNNER_CLASS> or only <TEST_PACKAGE> if there"); pw.println(" form <TEST_PACKAGE>/<RUNNER_CLASS> or only <TEST_PACKAGE> if there"); Loading @@ -2626,6 +2626,7 @@ final class ActivityManagerShellCommand extends ShellCommand { pw.println(" test runners."); pw.println(" test runners."); pw.println(" --user <USER_ID> | current: Specify user instrumentation runs in;"); pw.println(" --user <USER_ID> | current: Specify user instrumentation runs in;"); pw.println(" current user if not specified."); pw.println(" current user if not specified."); pw.println(" --no-hidden-api-checks: disable restrictions on use of hidden API."); pw.println(" --no-window-animation: turn off window animations while running."); pw.println(" --no-window-animation: turn off window animations while running."); pw.println(" --abi <ABI>: Launch the instrumented process with the selected ABI."); pw.println(" --abi <ABI>: Launch the instrumented process with the selected ABI."); pw.println(" This assumes that the process supports the selected ABI."); pw.println(" This assumes that the process supports the selected ABI."); Loading Loading
cmds/am/src/com/android/commands/am/Am.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -172,6 +172,8 @@ public class Am extends BaseCommand { } else if (opt.equals("--no_window_animation") } else if (opt.equals("--no_window_animation") || opt.equals("--no-window-animation")) { || opt.equals("--no-window-animation")) { instrument.noWindowAnimation = true; instrument.noWindowAnimation = true; } else if (opt.equals("--no-hidden-api-checks")) { instrument.disableHiddenApiChecks = true; } else if (opt.equals("--user")) { } else if (opt.equals("--user")) { instrument.userId = parseUserArg(nextArgRequired()); instrument.userId = parseUserArg(nextArgRequired()); } else if (opt.equals("--abi")) { } else if (opt.equals("--abi")) { Loading
cmds/am/src/com/android/commands/am/Instrument.java +7 −1 Original line number Original line Diff line number Diff line Loading @@ -73,12 +73,17 @@ public class Instrument { boolean protoFile = false; // write proto to a file boolean protoFile = false; // write proto to a file String logPath = null; String logPath = null; public boolean noWindowAnimation = false; public boolean noWindowAnimation = false; public boolean disableHiddenApiChecks = false; public String abi = null; public String abi = null; public int userId = UserHandle.USER_CURRENT; public int userId = UserHandle.USER_CURRENT; public Bundle args = new Bundle(); public Bundle args = new Bundle(); // Required // Required public String componentNameArg; public String componentNameArg; // Disable hidden API checks for the newly started instrumentation. // Must be kept in sync with ActivityManagerService. private static final int INSTRUMENTATION_FLAG_DISABLE_HIDDEN_API_CHECKS = 1 << 0; /** /** * Construct the instrument command runner. * Construct the instrument command runner. */ */ Loading Loading @@ -475,7 +480,8 @@ public class Instrument { } } // Start the instrumentation // Start the instrumentation if (!mAm.startInstrumentation(cn, profileFile, 0, args, watcher, connection, userId, int flags = disableHiddenApiChecks ? INSTRUMENTATION_FLAG_DISABLE_HIDDEN_API_CHECKS : 0; if (!mAm.startInstrumentation(cn, profileFile, flags, args, watcher, connection, userId, abi)) { abi)) { throw new AndroidException("INSTRUMENTATION_FAILED: " + cn.flattenToString()); throw new AndroidException("INSTRUMENTATION_FAILED: " + cn.flattenToString()); } } Loading
services/core/java/com/android/server/am/ActivityManagerService.java +27 −4 Original line number Original line Diff line number Diff line Loading @@ -580,6 +580,10 @@ public class ActivityManagerService extends IActivityManager.Stub // How long we wait until we timeout on key dispatching during instrumentation. // How long we wait until we timeout on key dispatching during instrumentation. static final int INSTRUMENTATION_KEY_DISPATCHING_TIMEOUT = 60*1000; static final int INSTRUMENTATION_KEY_DISPATCHING_TIMEOUT = 60*1000; // Disable hidden API checks for the newly started instrumentation. // Must be kept in sync with Am. private static final int INSTRUMENTATION_FLAG_DISABLE_HIDDEN_API_CHECKS = 1 << 0; // How long to wait in getAssistContextExtras for the activity and foreground services // How long to wait in getAssistContextExtras for the activity and foreground services // to respond with the result. // to respond with the result. static final int PENDING_ASSIST_EXTRAS_TIMEOUT = 500; static final int PENDING_ASSIST_EXTRAS_TIMEOUT = 500; Loading Loading @@ -4003,12 +4007,19 @@ public class ActivityManagerService extends IActivityManager.Stub startProcessLocked(app, hostingType, hostingNameStr, null /* abiOverride */); startProcessLocked(app, hostingType, hostingNameStr, null /* abiOverride */); } } @GuardedBy("this") private final boolean startProcessLocked(ProcessRecord app, String hostingType, String hostingNameStr, String abiOverride) { return startProcessLocked(app, hostingType, hostingNameStr, false /* disableHiddenApiChecks */, abiOverride); } /** /** * @return {@code true} if process start is successful, false otherwise. * @return {@code true} if process start is successful, false otherwise. */ */ @GuardedBy("this") @GuardedBy("this") private final boolean startProcessLocked(ProcessRecord app, String hostingType, private final boolean startProcessLocked(ProcessRecord app, String hostingType, String hostingNameStr, String abiOverride) { String hostingNameStr, boolean disableHiddenApiChecks, String abiOverride) { if (app.pendingStart) { if (app.pendingStart) { return true; return true; } } Loading Loading @@ -4131,7 +4142,9 @@ public class ActivityManagerService extends IActivityManager.Stub runtimeFlags |= Zygote.ONLY_USE_SYSTEM_OAT_FILES; runtimeFlags |= Zygote.ONLY_USE_SYSTEM_OAT_FILES; } } if (!app.info.isAllowedToUseHiddenApi() && !mHiddenApiBlacklist.isDisabled()) { if (!app.info.isAllowedToUseHiddenApi() && !disableHiddenApiChecks && !mHiddenApiBlacklist.isDisabled()) { // This app is not allowed to use undocumented and private APIs, or blacklisting is // This app is not allowed to use undocumented and private APIs, or blacklisting is // enabled. Set up its runtime with the appropriate flag. // enabled. Set up its runtime with the appropriate flag. runtimeFlags |= Zygote.ENABLE_HIDDEN_API_CHECKS; runtimeFlags |= Zygote.ENABLE_HIDDEN_API_CHECKS; Loading Loading @@ -12852,6 +12865,12 @@ public class ActivityManagerService extends IActivityManager.Stub @GuardedBy("this") @GuardedBy("this") final ProcessRecord addAppLocked(ApplicationInfo info, String customProcess, boolean isolated, final ProcessRecord addAppLocked(ApplicationInfo info, String customProcess, boolean isolated, String abiOverride) { String abiOverride) { return addAppLocked(info, customProcess, isolated, false /* disableHiddenApiChecks */, abiOverride); } final ProcessRecord addAppLocked(ApplicationInfo info, String customProcess, boolean isolated, boolean disableHiddenApiChecks, String abiOverride) { ProcessRecord app; ProcessRecord app; if (!isolated) { if (!isolated) { app = getProcessRecordLocked(customProcess != null ? customProcess : info.processName, app = getProcessRecordLocked(customProcess != null ? customProcess : info.processName, Loading Loading @@ -12883,7 +12902,8 @@ public class ActivityManagerService extends IActivityManager.Stub if (app.thread == null && mPersistentStartingProcesses.indexOf(app) < 0) { if (app.thread == null && mPersistentStartingProcesses.indexOf(app) < 0) { mPersistentStartingProcesses.add(app); mPersistentStartingProcesses.add(app); startProcessLocked(app, "added application", startProcessLocked(app, "added application", customProcess != null ? customProcess : app.processName, abiOverride); customProcess != null ? customProcess : app.processName, disableHiddenApiChecks, abiOverride); } } return app; return app; Loading Loading @@ -21694,7 +21714,10 @@ public class ActivityManagerService extends IActivityManager.Stub mUsageStatsService.reportEvent(ii.targetPackage, userId, mUsageStatsService.reportEvent(ii.targetPackage, userId, UsageEvents.Event.SYSTEM_INTERACTION); UsageEvents.Event.SYSTEM_INTERACTION); } } ProcessRecord app = addAppLocked(ai, defProcess, false, abiOverride); boolean disableHiddenApiChecks = (flags & INSTRUMENTATION_FLAG_DISABLE_HIDDEN_API_CHECKS) != 0; ProcessRecord app = addAppLocked(ai, defProcess, false, disableHiddenApiChecks, abiOverride); app.instr = activeInstr; app.instr = activeInstr; activeInstr.mFinished = false; activeInstr.mFinished = false; activeInstr.mRunningProcesses.add(app); activeInstr.mRunningProcesses.add(app);
services/core/java/com/android/server/am/ActivityManagerShellCommand.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -2608,7 +2608,7 @@ final class ActivityManagerShellCommand extends ShellCommand { pw.println(" specified then send to all users."); pw.println(" specified then send to all users."); pw.println(" --receiver-permission <PERMISSION>: Require receiver to hold permission."); pw.println(" --receiver-permission <PERMISSION>: Require receiver to hold permission."); pw.println(" instrument [-r] [-e <NAME> <VALUE>] [-p <FILE>] [-w]"); pw.println(" instrument [-r] [-e <NAME> <VALUE>] [-p <FILE>] [-w]"); pw.println(" [--user <USER_ID> | current]"); pw.println(" [--user <USER_ID> | current] [--no-hidden-api-checks]"); pw.println(" [--no-window-animation] [--abi <ABI>] <COMPONENT>"); pw.println(" [--no-window-animation] [--abi <ABI>] <COMPONENT>"); pw.println(" Start an Instrumentation. Typically this target <COMPONENT> is in the"); pw.println(" Start an Instrumentation. Typically this target <COMPONENT> is in the"); pw.println(" form <TEST_PACKAGE>/<RUNNER_CLASS> or only <TEST_PACKAGE> if there"); pw.println(" form <TEST_PACKAGE>/<RUNNER_CLASS> or only <TEST_PACKAGE> if there"); Loading @@ -2626,6 +2626,7 @@ final class ActivityManagerShellCommand extends ShellCommand { pw.println(" test runners."); pw.println(" test runners."); pw.println(" --user <USER_ID> | current: Specify user instrumentation runs in;"); pw.println(" --user <USER_ID> | current: Specify user instrumentation runs in;"); pw.println(" current user if not specified."); pw.println(" current user if not specified."); pw.println(" --no-hidden-api-checks: disable restrictions on use of hidden API."); pw.println(" --no-window-animation: turn off window animations while running."); pw.println(" --no-window-animation: turn off window animations while running."); pw.println(" --abi <ABI>: Launch the instrumented process with the selected ABI."); pw.println(" --abi <ABI>: Launch the instrumented process with the selected ABI."); pw.println(" This assumes that the process supports the selected ABI."); pw.println(" This assumes that the process supports the selected ABI."); Loading