Loading cmds/am/src/com/android/commands/am/Am.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -174,6 +174,8 @@ public class Am extends BaseCommand { instrument.noWindowAnimation = true; instrument.noWindowAnimation = true; } else if (opt.equals("--no-hidden-api-checks")) { } else if (opt.equals("--no-hidden-api-checks")) { instrument.disableHiddenApiChecks = true; instrument.disableHiddenApiChecks = true; } else if (opt.equals("--no-test-api-checks")) { instrument.disableTestApiChecks = true; } else if (opt.equals("--no-isolated-storage")) { } else if (opt.equals("--no-isolated-storage")) { instrument.disableIsolatedStorage = true; instrument.disableIsolatedStorage = true; } else if (opt.equals("--user")) { } else if (opt.equals("--user")) { Loading cmds/am/src/com/android/commands/am/Instrument.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.commands.am; package com.android.commands.am; import static android.app.ActivityManager.INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS; import static android.app.ActivityManager.INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS; import static android.app.ActivityManager.INSTR_FLAG_DISABLE_TEST_API_CHECKS; import static android.app.ActivityManager.INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL; import static android.app.ActivityManager.INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL; import android.app.IActivityManager; import android.app.IActivityManager; Loading Loading @@ -85,6 +86,7 @@ public class Instrument { String logPath = null; String logPath = null; public boolean noWindowAnimation = false; public boolean noWindowAnimation = false; public boolean disableHiddenApiChecks = false; public boolean disableHiddenApiChecks = false; public boolean disableTestApiChecks = false; public boolean disableIsolatedStorage = false; public boolean disableIsolatedStorage = false; public String abi = null; public String abi = null; public int userId = UserHandle.USER_CURRENT; public int userId = UserHandle.USER_CURRENT; Loading Loading @@ -506,6 +508,9 @@ public class Instrument { if (disableHiddenApiChecks) { if (disableHiddenApiChecks) { flags |= INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS; flags |= INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS; } } if (disableTestApiChecks) { flags |= INSTR_FLAG_DISABLE_TEST_API_CHECKS; } if (disableIsolatedStorage) { if (disableIsolatedStorage) { flags |= INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL; flags |= INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL; } } Loading core/java/android/app/ActivityManager.java +6 −0 Original line number Original line Diff line number Diff line Loading @@ -153,6 +153,12 @@ public class ActivityManager { */ */ public static final int INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL = 1 << 1; public static final int INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL = 1 << 1; /** * Disable test API access for the newly started instrumentation. * @hide */ public static final int INSTR_FLAG_DISABLE_TEST_API_CHECKS = 1 << 2; static final class UidObserver extends IUidObserver.Stub { static final class UidObserver extends IUidObserver.Stub { final OnUidImportanceListener mListener; final OnUidImportanceListener mListener; final Context mContext; final Context mContext; Loading services/core/java/com/android/server/am/ActivityManagerService.java +4 −4 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL; import static android.Manifest.permission.REMOVE_TASKS; import static android.Manifest.permission.REMOVE_TASKS; import static android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND; import static android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND; import static android.app.ActivityManager.INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS; import static android.app.ActivityManager.INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS; import static android.app.ActivityManager.INSTR_FLAG_DISABLE_TEST_API_CHECKS; import static android.app.ActivityManager.INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL; import static android.app.ActivityManager.INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL; import static android.app.ActivityManager.PROCESS_STATE_LAST_ACTIVITY; import static android.app.ActivityManager.PROCESS_STATE_LAST_ACTIVITY; import static android.app.ActivityManager.PROCESS_STATE_NONEXISTENT; import static android.app.ActivityManager.PROCESS_STATE_NONEXISTENT; Loading Loading @@ -15796,13 +15797,12 @@ public class ActivityManagerService extends IActivityManager.Stub boolean disableHiddenApiChecks = ai.usesNonSdkApi() boolean disableHiddenApiChecks = ai.usesNonSdkApi() || (flags & INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS) != 0; || (flags & INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS) != 0; if (disableHiddenApiChecks) { boolean disableTestApiChecks = disableHiddenApiChecks || (flags & INSTR_FLAG_DISABLE_TEST_API_CHECKS) != 0; 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"); } } // Allow instrumented processes access to test APIs. // TODO(satayev): make this configurable via testing framework. boolean disableTestApiChecks = true; final boolean mountExtStorageFull = isCallerShell() final boolean mountExtStorageFull = isCallerShell() && (flags & INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL) != 0; && (flags & INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL) != 0; services/core/java/com/android/server/am/ActivityManagerShellCommand.java +4 −1 Original line number Original line Diff line number Diff line Loading @@ -3032,7 +3032,8 @@ 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] [--no-hidden-api-checks]"); pw.println(" [--user <USER_ID> | current]"); pw.println(" [--no-hidden-api-checks [--no-test-api-checks]]"); pw.println(" [--no-isolated-storage]"); pw.println(" [--no-isolated-storage]"); 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"); Loading @@ -3052,6 +3053,8 @@ final class ActivityManagerShellCommand extends ShellCommand { 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-hidden-api-checks: disable restrictions on use of hidden API."); pw.println(" --no-test-api-checks: disable restrictions to test APIs, if hidden"); pw.println(" API checks are enabled."); pw.println(" --no-isolated-storage: don't use isolated storage sandbox and "); pw.println(" --no-isolated-storage: don't use isolated storage sandbox and "); pw.println(" mount full external storage"); pw.println(" mount full external storage"); pw.println(" --no-window-animation: turn off window animations while running."); pw.println(" --no-window-animation: turn off window animations while running."); Loading Loading
cmds/am/src/com/android/commands/am/Am.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -174,6 +174,8 @@ public class Am extends BaseCommand { instrument.noWindowAnimation = true; instrument.noWindowAnimation = true; } else if (opt.equals("--no-hidden-api-checks")) { } else if (opt.equals("--no-hidden-api-checks")) { instrument.disableHiddenApiChecks = true; instrument.disableHiddenApiChecks = true; } else if (opt.equals("--no-test-api-checks")) { instrument.disableTestApiChecks = true; } else if (opt.equals("--no-isolated-storage")) { } else if (opt.equals("--no-isolated-storage")) { instrument.disableIsolatedStorage = true; instrument.disableIsolatedStorage = true; } else if (opt.equals("--user")) { } else if (opt.equals("--user")) { Loading
cmds/am/src/com/android/commands/am/Instrument.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.commands.am; package com.android.commands.am; import static android.app.ActivityManager.INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS; import static android.app.ActivityManager.INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS; import static android.app.ActivityManager.INSTR_FLAG_DISABLE_TEST_API_CHECKS; import static android.app.ActivityManager.INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL; import static android.app.ActivityManager.INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL; import android.app.IActivityManager; import android.app.IActivityManager; Loading Loading @@ -85,6 +86,7 @@ public class Instrument { String logPath = null; String logPath = null; public boolean noWindowAnimation = false; public boolean noWindowAnimation = false; public boolean disableHiddenApiChecks = false; public boolean disableHiddenApiChecks = false; public boolean disableTestApiChecks = false; public boolean disableIsolatedStorage = false; public boolean disableIsolatedStorage = false; public String abi = null; public String abi = null; public int userId = UserHandle.USER_CURRENT; public int userId = UserHandle.USER_CURRENT; Loading Loading @@ -506,6 +508,9 @@ public class Instrument { if (disableHiddenApiChecks) { if (disableHiddenApiChecks) { flags |= INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS; flags |= INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS; } } if (disableTestApiChecks) { flags |= INSTR_FLAG_DISABLE_TEST_API_CHECKS; } if (disableIsolatedStorage) { if (disableIsolatedStorage) { flags |= INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL; flags |= INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL; } } Loading
core/java/android/app/ActivityManager.java +6 −0 Original line number Original line Diff line number Diff line Loading @@ -153,6 +153,12 @@ public class ActivityManager { */ */ public static final int INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL = 1 << 1; public static final int INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL = 1 << 1; /** * Disable test API access for the newly started instrumentation. * @hide */ public static final int INSTR_FLAG_DISABLE_TEST_API_CHECKS = 1 << 2; static final class UidObserver extends IUidObserver.Stub { static final class UidObserver extends IUidObserver.Stub { final OnUidImportanceListener mListener; final OnUidImportanceListener mListener; final Context mContext; final Context mContext; Loading
services/core/java/com/android/server/am/ActivityManagerService.java +4 −4 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL; import static android.Manifest.permission.REMOVE_TASKS; import static android.Manifest.permission.REMOVE_TASKS; import static android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND; import static android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND; import static android.app.ActivityManager.INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS; import static android.app.ActivityManager.INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS; import static android.app.ActivityManager.INSTR_FLAG_DISABLE_TEST_API_CHECKS; import static android.app.ActivityManager.INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL; import static android.app.ActivityManager.INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL; import static android.app.ActivityManager.PROCESS_STATE_LAST_ACTIVITY; import static android.app.ActivityManager.PROCESS_STATE_LAST_ACTIVITY; import static android.app.ActivityManager.PROCESS_STATE_NONEXISTENT; import static android.app.ActivityManager.PROCESS_STATE_NONEXISTENT; Loading Loading @@ -15796,13 +15797,12 @@ public class ActivityManagerService extends IActivityManager.Stub boolean disableHiddenApiChecks = ai.usesNonSdkApi() boolean disableHiddenApiChecks = ai.usesNonSdkApi() || (flags & INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS) != 0; || (flags & INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS) != 0; if (disableHiddenApiChecks) { boolean disableTestApiChecks = disableHiddenApiChecks || (flags & INSTR_FLAG_DISABLE_TEST_API_CHECKS) != 0; 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"); } } // Allow instrumented processes access to test APIs. // TODO(satayev): make this configurable via testing framework. boolean disableTestApiChecks = true; final boolean mountExtStorageFull = isCallerShell() final boolean mountExtStorageFull = isCallerShell() && (flags & INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL) != 0; && (flags & INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL) != 0;
services/core/java/com/android/server/am/ActivityManagerShellCommand.java +4 −1 Original line number Original line Diff line number Diff line Loading @@ -3032,7 +3032,8 @@ 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] [--no-hidden-api-checks]"); pw.println(" [--user <USER_ID> | current]"); pw.println(" [--no-hidden-api-checks [--no-test-api-checks]]"); pw.println(" [--no-isolated-storage]"); pw.println(" [--no-isolated-storage]"); 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"); Loading @@ -3052,6 +3053,8 @@ final class ActivityManagerShellCommand extends ShellCommand { 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-hidden-api-checks: disable restrictions on use of hidden API."); pw.println(" --no-test-api-checks: disable restrictions to test APIs, if hidden"); pw.println(" API checks are enabled."); pw.println(" --no-isolated-storage: don't use isolated storage sandbox and "); pw.println(" --no-isolated-storage: don't use isolated storage sandbox and "); pw.println(" mount full external storage"); pw.println(" mount full external storage"); pw.println(" --no-window-animation: turn off window animations while running."); pw.println(" --no-window-animation: turn off window animations while running."); Loading