diff options
author | David Brazdil <dbrazdil@google.com> | 2018-02-14 19:39:03 +0000 |
---|---|---|
committer | David Brazdil <dbrazdil@google.com> | 2018-02-14 19:45:11 +0000 |
commit | d5d4217ece5c1cedd5ac9ca3bbdc12d793e69313 (patch) | |
tree | 8cfcb6dd4a7bcfb7c1b2e057c84d08d6053ffce6 /cmds/am/src | |
parent | 427ef56c0f6f36fbf2f1e5902037a28f4cae09e0 (diff) |
Add flag to AMS.startInstrumentation() to disable hidden API checks
Some tests need to use hidden APIs to check the internal state of
the framework. For those special use cases, we add a new flag to
ActivityManagerService.startInstrumentation that enables to start
instrumented processes without hidden API enforcement. Individual
test harnesses can change their Am command to request the exemption.
Bug: 64382372
Test: adb shell am instrument --no-hidden-api-checks <component>
adb logcat | grep 'Accessing hidden'
Change-Id: I1d734a95423fae90dae63ff09d5f606495830905
Diffstat (limited to 'cmds/am/src')
-rw-r--r-- | cmds/am/src/com/android/commands/am/Am.java | 2 | ||||
-rw-r--r-- | cmds/am/src/com/android/commands/am/Instrument.java | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index 813335a688ab..c04e61b77274 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -172,6 +172,8 @@ public class Am extends BaseCommand { } else if (opt.equals("--no_window_animation") || opt.equals("--no-window-animation")) { instrument.noWindowAnimation = true; + } else if (opt.equals("--no-hidden-api-checks")) { + instrument.disableHiddenApiChecks = true; } else if (opt.equals("--user")) { instrument.userId = parseUserArg(nextArgRequired()); } else if (opt.equals("--abi")) { diff --git a/cmds/am/src/com/android/commands/am/Instrument.java b/cmds/am/src/com/android/commands/am/Instrument.java index d79b1a61eb5b..0dade0b2ba81 100644 --- a/cmds/am/src/com/android/commands/am/Instrument.java +++ b/cmds/am/src/com/android/commands/am/Instrument.java @@ -73,12 +73,17 @@ public class Instrument { boolean protoFile = false; // write proto to a file String logPath = null; public boolean noWindowAnimation = false; + public boolean disableHiddenApiChecks = false; public String abi = null; public int userId = UserHandle.USER_CURRENT; public Bundle args = new Bundle(); // Required 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. */ @@ -475,7 +480,8 @@ public class Instrument { } // 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)) { throw new AndroidException("INSTRUMENTATION_FAILED: " + cn.flattenToString()); } |