Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5c8ed7f6 authored by satayev's avatar satayev Committed by android-build-merger
Browse files

Merge "Add --no-test-api-acces to am instrument."

am: 188abff5

Change-Id: I4b345fd330ba92caa96781f64f703a057adad2b0
parents d9b11a28 188abff5
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -174,6 +174,8 @@ public class Am extends BaseCommand {
                instrument.noWindowAnimation = true;
            } else if (opt.equals("--no-hidden-api-checks")) {
                instrument.disableHiddenApiChecks = true;
            } else if (opt.equals("--no-test-api-checks")) {
                instrument.disableTestApiChecks = true;
            } else if (opt.equals("--no-isolated-storage")) {
                instrument.disableIsolatedStorage = true;
            } else if (opt.equals("--user")) {
+5 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.commands.am;

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 android.app.IActivityManager;
@@ -85,6 +86,7 @@ public class Instrument {
    String logPath = null;
    public boolean noWindowAnimation = false;
    public boolean disableHiddenApiChecks = false;
    public boolean disableTestApiChecks = false;
    public boolean disableIsolatedStorage = false;
    public String abi = null;
    public int userId = UserHandle.USER_CURRENT;
@@ -506,6 +508,9 @@ public class Instrument {
            if (disableHiddenApiChecks) {
                flags |= INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS;
            }
            if (disableTestApiChecks) {
                flags |= INSTR_FLAG_DISABLE_TEST_API_CHECKS;
            }
            if (disableIsolatedStorage) {
                flags |= INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL;
            }
+6 −0
Original line number Diff line number Diff line
@@ -153,6 +153,12 @@ public class ActivityManager {
     */
    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 {
        final OnUidImportanceListener mListener;
        final Context mContext;
+4 −4
Original line number Diff line number Diff line
@@ -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.START_ACTIVITIES_FROM_BACKGROUND;
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.PROCESS_STATE_LAST_ACTIVITY;
import static android.app.ActivityManager.PROCESS_STATE_NONEXISTENT;
@@ -15796,13 +15797,12 @@ public class ActivityManagerService extends IActivityManager.Stub
            boolean disableHiddenApiChecks = ai.usesNonSdkApi()
                    || (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,
                        "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()
                    && (flags & INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL) != 0;
+4 −1
Original line number Diff line number Diff line
@@ -3032,7 +3032,8 @@ final class ActivityManagerShellCommand extends ShellCommand {
            pw.println("          specified then send to all users.");
            pw.println("      --receiver-permission <PERMISSION>: Require receiver to hold permission.");
            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-window-animation] [--abi <ABI>] <COMPONENT>");
            pw.println("      Start an Instrumentation.  Typically this target <COMPONENT> is in the");
@@ -3052,6 +3053,8 @@ final class ActivityManagerShellCommand extends ShellCommand {
            pw.println("      --user <USER_ID> | current: Specify user instrumentation runs in;");
            pw.println("          current user if not specified.");
            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("          mount full external storage");
            pw.println("      --no-window-animation: turn off window animations while running.");