android cmds

318 阅读33分钟

1.1. settings -h

Settings provider (settings) commands:

  help

      Print this help text.

  get [--user <USER_ID> | current] NAMESPACE KEY

      Retrieve the current value of KEY.

  put [--user <USER_ID> | current] NAMESPACE KEY VALUE [TAG] [default]

      Change the contents of KEY to VALUE.

      TAG to associate with the setting.

      {default} to set as the default, case-insensitive only for global/secure namespace

  delete [--user <USER_ID> | current] NAMESPACE KEY

      Delete the entry for KEY.

  reset [--user <USER_ID> | current] NAMESPACE {PACKAGE_NAME | RESET_MODE}

      Reset the global/secure table for a package with mode.

      RESET_MODE is one of {untrusted_defaults, untrusted_clear, trusted_defaults}, case-insensitive

  list [--user <USER_ID> | current] NAMESPACE

      Print all defined keys.

      NAMESPACE is one of {system, secure, global}, case-insensitive

查看某个命名空间下所有的字段值  

settings list global

settings list secure

settings list system

1.1.1. 低电量标记

settings get global low_power

settings put global low_power 1 // 要测试设备在低电量条件下的行为,请使用以下命令

1.1.2. 屏幕超时时间

settings put system screen_off_timeout 600000000  // 单位ms

settings get system screen_off_timeout

 

1.1.3. 屏幕亮度

settings get system screen_brightness_mode   // 输出0表示关闭自动调整亮度,1表示已开启

settings put system screen_brightness_mode 0   // 关闭自动亮度

settings get system screen_brightness   // 输出0-255,表示亮度值

settings put system screen_brightness 0

1.1.4. power参数

settings get global power_manager_constants

settings put global power_manager_constants no_cached_wake_locks=false //禁止wakelock移除,超出一定时长系统会自动移除wakelock

1.1.5. activity参数

settings get global activity_manager_constants

settings put global activity_manager_constants power_check_max_cpu_1=800,power_check_max_cpu_2=800,power_check_max_cpu_3=800,power_check_max_cpu_4=800

超出cpulimit参数会自动杀进程  

1.2. getprop --help and setprop

usage: getprop [-TZ] [NAME [DEFAULT]]

 

Gets an Android system property, or lists them all.

 

-T      Show property types instead of values

-Z      Show property contexts instead of values

 

usage: setprop NAME VALUE

 

Sets an Android system property.

1.2.1. 关机

setprop sys.powerctl shutdown

1.2.2. 打开网络adb

setprop persist.internet_adb_enable 1

1.3. wm -h

Window manager (window) commands:

  help

      Print this help text.

  size [reset|WxH|WdpxHdp] [-d DISPLAY_ID]

    Return or override display size.

    width and height in pixels unless suffixed with 'dp'.

  density [reset|DENSITY] [-d DISPLAY_ID]

    Return or override display density.

  folded-area [reset|LEFT,TOP,RIGHT,BOTTOM]

    Return or override folded area.

  scaling [off|auto] [-d DISPLAY_ID]

    Set display scaling mode.

  dismiss-keyguard

    Dismiss the keyguard, prompting user for auth if necessary.

  disable-blur [true|1|false|0]

  user-rotation [-d DISPLAY_ID] [free|lock] [rotation]

    Print or set user rotation mode and user rotation.

  dump-visible-window-views

    Dumps the encoded view hierarchies of visible windows

  fixed-to-user-rotation [-d DISPLAY_ID] [enabled|disabled|default]

    Print or set rotating display for app requested orientation.

  set-ignore-orientation-request [-d DISPLAY_ID] [true|1|false|0]

  get-ignore-orientation-request [-d DISPLAY_ID]

    If app requested orientation should be ignored.

  set-multi-window-config

    Sets options to determine if activity should be shown in multi window:

      --supportsNonResizable [configValue]

        Whether the device supports non-resizable activity in multi window.

        -1: The device doesn't support non-resizable in multi window.

         0: The device supports non-resizable in multi window only if

            this is a large screen device.

         1: The device always supports non-resizable in multi window.

      --respectsActivityMinWidthHeight [configValue]

        Whether the device checks the activity min width/height to determine

        if it can be shown in multi window.

        -1: The device ignores the activity min width/height when determining

            if it can be shown in multi window.

         0: If this is a small screen, the device compares the activity min

            width/height with the min multi window modes dimensions

            the device supports to determine if the activity can be shown in

            multi window.

         1: The device always compare the activity min width/height with the

            min multi window dimensions the device supports to determine if

            the activity can be shown in multi window.

  get-multi-window-config

    Prints values of the multi window config options.

  reset-multi-window-config

    Resets overrides to default values of the multi window config options.

  reset [-d DISPLAY_ID]

    Reset all override settings.

  tracing (start | stop)

    Start or stop window tracing.

  logging (start | stop | enable | disable | enable-text | disable-text)

    Logging settings.

Unisoc commands:

  unisoc-log {action} {fullClassName} {field}

  {action}: enable or disable

  {field}: fieldName or '--all'

  ex:

    unisoc-log enable com.android.server.wm.WindowManagerDebugConfig DEBUG_LAYOUT

    unisoc-log disable com.android.server.wm.WindowManagerDebugConfig DEBUG_LAYOUT

    unisoc-log enable WindowManagerDebugConfig DEBUG_LAYOUT

    unisoc-log enable WindowManagerDebugConfig --all

  unisoc-proto {action}

  {action}: see [ BaseProtoLogImpl#onShellCommand ]

  ex:

    unisoc-proto enable

    unisoc-proto disable

    unisoc-proto enable-text

    unisoc-proto disable-text

  and if you want to keep the proto state(valid after reboot), you need:

    unisoc-proto save

1.3.1. 查看整机分辨率

wm size

Physical size: 1080x2340

1.3.2. 查看整机dpi

wm density

Physical density: 480

1.3.3. 打开wm动态日志

wm logging enable-text WM_SHOW_TRANSACTIONS;wm logging enable-text WM_DEBUG_APP_TRANSITIONS_ANIM;wm logging enable-text WM_DEBUG_RECENTS_ANIMATIONS;wm logging enable-text WM_DEBUG_REMOTE_ANIMATIONS;wm logging enable-text WM_DEBUG_ORIENTATION

1.4. tar --help

Toybox 0.8.6-android multicall binary (see toybox --help)

 

usage: tar [-cxt] [-fvohmjkOS] [-XTCf NAME] [--selinux] [FILE...]

 

Create, extract, or list files in a .tar (or compressed t?z) file.

 

Options:

c  Create                x  Extract               t  Test (list)

f  tar FILE (default -)  C  Change to DIR first   v  Verbose display

o  Ignore owner          h  Follow symlinks       m  Ignore mtime

J  xz compression        j  bzip2 compression     z  gzip compression

O  Extract to stdout     X  exclude names in FILE T  include names in FILE

 

--exclude        FILENAME to exclude  --full-time         Show seconds with -tv

--mode MODE      Adjust permissions   --owner NAME[:UID]  Set file ownership

--mtime TIME     Override timestamps  --group NAME[:GID]  Set file group

--sparse         Record sparse files  --selinux           Save/restore labels

--restrict       All under one dir    --no-recursion      Skip dir contents

--numeric-owner  Use numeric uid/gid, not user/group names

--strip-components NUM  Ignore first NUM directory components when extracting

-I PROG          Filter through PROG to compress or PROG -d to decompress

1.4.1. 压缩

tar -czvf archive.tar.gz /path/to/directory1 /path/to/directory2

1.4.2. 解压

tar -xzvf archive.tar.gz

1.5. debuggerd -h

usage: debuggerd [-bj] PID

 

-b, --backtrace    just a backtrace rather than a full tombstone

-j                 collect java traces

debuggerd -j 10086 // 收集java trace

debuggerd -b 10086 // 收集native trace

 

1.6. am -h

Activity manager (activity) commands:

  help

      Print this help text.

  start-activity [-D] [-N] [-W] [-P <FILE>] [--start-profiler <FILE>]

          [--sampling INTERVAL] [--streaming] [-R COUNT] [-S]

          [--track-allocation] [--user <USER_ID> | current] <INTENT>

      Start an Activity.  Options are:

      -D: enable debugging

      -N: enable native debugging

      -W: wait for launch to complete

      --start-profiler <FILE>: start profiler and send results to <FILE>

      --sampling INTERVAL: use sample profiling with INTERVAL microseconds

          between samples (use with --start-profiler)

      --streaming: stream the profiling output to the specified file

          (use with --start-profiler)

      -P <FILE>: like above, but profiling stops when app goes idle

      --attach-agent <agent>: attach the given agent before binding

      --attach-agent-bind <agent>: attach the given agent during binding

      -R: repeat the activity launch <COUNT> times.  Prior to each repeat,

          the top activity will be finished.

      -S: force stop the target app before starting the activity

      --track-allocation: enable tracking of object allocations

      --user <USER_ID> | current: Specify which user to run as; if not

          specified then run as the current user.

      --windowingMode <WINDOWING_MODE>: The windowing mode to launch the activity into.

      --activityType <ACTIVITY_TYPE>: The activity type to launch the activity as.

      --display <DISPLAY_ID>: The display to launch the activity into.

      --splashscreen-icon: Show the splash screen icon on launch.

  start-service [--user <USER_ID> | current] <INTENT>

      Start a Service.  Options are:

      --user <USER_ID> | current: Specify which user to run as; if not

          specified then run as the current user.

  start-foreground-service [--user <USER_ID> | current] <INTENT>

      Start a foreground Service.  Options are:

      --user <USER_ID> | current: Specify which user to run as; if not

          specified then run as the current user.

  stop-service [--user <USER_ID> | current] <INTENT>

      Stop a Service.  Options are:

      --user <USER_ID> | current: Specify which user to run as; if not

          specified then run as the current user.

  broadcast [--user <USER_ID> | all | current]

          [--receiver-permission <PERMISSION>]

          [--allow-background-activity-starts]

          [--async] <INTENT>

      Send a broadcast Intent.  Options are:

      --user <USER_ID> | all | current: Specify which user to send to; if not

          specified then send to all users.

      --receiver-permission <PERMISSION>: Require receiver to hold permission.

      --allow-background-activity-starts: The receiver may start activities

          even if in the background.

      --async: Send without waiting for the completion of the receiver.

  compact <process_name> <Package UID> [some|full]

      Force process compaction.

      some: execute file compaction.

      full: execute anon + file compaction.

  instrument [-r] [-e <NAME> <VALUE>] [-p <FILE>] [-w]

          [--user <USER_ID> | current]

          [--no-hidden-api-checks [--no-test-api-access]]

          [--no-isolated-storage]

          [--no-window-animation] [--abi <ABI>] <COMPONENT>

      Start an Instrumentation.  Typically this target <COMPONENT> is in the

      form <TEST_PACKAGE>/<RUNNER_CLASS> or only <TEST_PACKAGE> if there

      is only one instrumentation.  Options are:

      -r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT).  Use with

          [-e perf true] to generate raw output for performance measurements.

      -e <NAME> <VALUE>: set argument <NAME> to <VALUE>.  For test runners a

          common form is [-e <testrunner_flag> <value>[,<value>...]].

      -p <FILE>: write profiling data to <FILE>

      -m: Write output as protobuf to stdout (machine readable)

      -f <Optional PATH/TO/FILE>: Write output as protobuf to a file (machine

          readable). If path is not specified, default directory and file name will

          be used: /sdcard/instrument-logs/log-yyyyMMdd-hhmmss-SSS.instrumentation_data_proto

      -w: wait for instrumentation to finish before returning.  Required for

          test runners.

      --user <USER_ID> | current: Specify user instrumentation runs in;

          current user if not specified.

      --no-hidden-api-checks: disable restrictions on use of hidden API.

      --no-test-api-access: do not allow access to test APIs, if hidden

          API checks are enabled.

      --no-isolated-storage: don't use isolated storage sandbox and

          mount full external storage

      --no-window-animation: turn off window animations while running.

      --abi <ABI>: Launch the instrumented process with the selected ABI.

          This assumes that the process supports the selected ABI.

  trace-ipc [start|stop] [--dump-file <FILE>]

      Trace IPC transactions.

      start: start tracing IPC transactions.

      stop: stop tracing IPC transactions and dump the results to file.

      --dump-file <FILE>: Specify the file the trace should be dumped to.

  profile start [--user <USER_ID> current]

          [--sampling INTERVAL | --streaming] <PROCESS> <FILE>

      Start profiler on a process.  The given <PROCESS> argument

        may be either a process name or pid.  Options are:

      --user <USER_ID> | current: When supplying a process name,

          specify user of process to profile; uses current user if not

          specified.

      --sampling INTERVAL: use sample profiling with INTERVAL microseconds

          between samples.

      --streaming: stream the profiling output to the specified file.

  profile stop [--user <USER_ID> current] <PROCESS>

      Stop profiler on a process.  The given <PROCESS> argument

        may be either a process name or pid.  Options are:

      --user <USER_ID> | current: When supplying a process name,

          specify user of process to profile; uses current user if not

          specified.

  dumpheap [--user <USER_ID> current] [-n] [-g] <PROCESS> <FILE>

      Dump the heap of a process.  The given <PROCESS> argument may

        be either a process name or pid.  Options are:

      -n: dump native heap instead of managed heap

      -g: force GC before dumping the heap

      --user <USER_ID> | current: When supplying a process name,

          specify user of process to dump; uses current user if not specified.

  set-debug-app [-w] [--persistent] <PACKAGE>

      Set application <PACKAGE> to debug.  Options are:

      -w: wait for debugger when application starts

      --persistent: retain this value

  clear-debug-app

      Clear the previously set-debug-app.

  set-watch-heap <PROCESS> <MEM-LIMIT>

      Start monitoring pss size of <PROCESS>, if it is at or

      above <HEAP-LIMIT> then a heap dump is collected for the user to report.

  clear-watch-heap

      Clear the previously set-watch-heap.

  clear-exit-info [--user <USER_ID> | all | current] [package]

      Clear the process exit-info for given package

  bug-report [--progress | --telephony]

      Request bug report generation; will launch a notification

        when done to select where it should be delivered. Options are:

     --progress: will launch a notification right away to show its progress.

     --telephony: will dump only telephony sections.

  fgs-notification-rate-limit {enable | disable}

     Enable/disable rate limit on FGS notification deferral policy.

  force-stop [--user <USER_ID> | all | current] <PACKAGE>

      Completely stop the given application package.

  stop-app [--user <USER_ID> | all | current] <PACKAGE>

      Stop an app and all of its services.  Unlike `force-stop` this does

      not cancel the app's scheduled alarms and jobs.

  crash [--user <USER_ID>] <PACKAGE|PID>

      Induce a VM crash in the specified package or process

  kill [--user <USER_ID> | all | current] <PACKAGE>

      Kill all background processes associated with the given application.

  kill-all

      Kill all processes that are safe to kill (cached, etc).

  make-uid-idle [--user <USER_ID> | all | current] <PACKAGE>

      If the given application's uid is in the background and waiting to

      become idle (not allowing background services), do that now.

  monitor [--gdb <port>]

      Start monitoring for crashes or ANRs.

      --gdb: start gdbserv on the given port at crash/ANR

  watch-uids [--oom <uid>]

      Start watching for and reporting uid state changes.

      --oom: specify a uid for which to report detailed change messages.

  hang [--allow-restart]

      Hang the system.

      --allow-restart: allow watchdog to perform normal system restart

  restart

      Restart the user-space system.

  idle-maintenance

      Perform idle maintenance now.

  screen-compat [on|off] <PACKAGE>

      Control screen compatibility mode of <PACKAGE>.

  package-importance <PACKAGE>

      Print current importance of <PACKAGE>.

  to-uri [INTENT]

      Print the given Intent specification as a URI.

  to-intent-uri [INTENT]

      Print the given Intent specification as an intent: URI.

  to-app-uri [INTENT]

      Print the given Intent specification as an android-app: URI.

  switch-user <USER_ID>

      Switch to put USER_ID in the foreground, starting

      execution of that user if it is currently stopped.

  get-current-user

      Returns id of the current foreground user.

  start-user [-w] <USER_ID>

      Start USER_ID in background if it is currently stopped;

      use switch-user if you want to start the user in foreground.

      -w: wait for start-user to complete and the user to be unlocked.

  unlock-user <USER_ID>

      Unlock the given user.  This will only work if the user doesn't

      have an LSKF (PIN/pattern/password).

  stop-user [-w] [-f] <USER_ID>

      Stop execution of USER_ID, not allowing it to run any

      code until a later explicit start or switch to it.

      -w: wait for stop-user to complete.

      -f: force stop even if there are related users that cannot be stopped.

  is-user-stopped <USER_ID>

      Returns whether <USER_ID> has been stopped or not.

  get-started-user-state <USER_ID>

      Gets the current state of the given started user.

  track-associations

      Enable association tracking.

  untrack-associations

      Disable and clear association tracking.

  get-uid-state <UID>

      Gets the process state of an app given its <UID>.

  attach-agent <PROCESS> <FILE>

    Attach an agent to the specified <PROCESS>, which may be either a process name or a PID.

  get-config [--days N] [--device] [--proto] [--display <DISPLAY_ID>]

      Retrieve the configuration and any recent configurations of the device.

      --days: also return last N days of configurations that have been seen.

      --device: also output global device configuration info.

      --proto: return result as a proto; does not include --days info.

      --display: Specify for which display to run the command; if not

          specified then run for the default display.

  supports-multiwindow

      Returns true if the device supports multiwindow.

  supports-split-screen-multi-window

      Returns true if the device supports split screen multiwindow.

  suppress-resize-config-changes <true|false>

      Suppresses configuration changes due to user resizing an activity/task.

  set-inactive [--user <USER_ID>] <PACKAGE> true|false

      Sets the inactive state of an app.

  get-inactive [--user <USER_ID>] <PACKAGE>

      Returns the inactive state of an app.

  set-standby-bucket [--user <USER_ID>] <PACKAGE> active|working_set|frequent|rare|restricted

      Puts an app in the standby bucket.

  get-standby-bucket [--user <USER_ID>] <PACKAGE>

      Returns the standby bucket of an app.

  send-trim-memory [--user <USER_ID>] <PROCESS>

          [HIDDEN|RUNNING_MODERATE|BACKGROUND|RUNNING_LOW|MODERATE|RUNNING_CRITICAL|COMPLETE]

      Send a memory trim event to a <PROCESS>.  May also supply a raw trim int level.

  display [COMMAND] [...]: sub-commands for operating on displays.

       move-stack <STACK_ID> <DISPLAY_ID>

           Move <STACK_ID> from its current display to <DISPLAY_ID>.

  stack [COMMAND] [...]: sub-commands for operating on activity stacks.

       move-task <TASK_ID> <STACK_ID> [true|false]

           Move <TASK_ID> from its current stack to the top (true) or

           bottom (false) of <STACK_ID>.

       list

           List all of the activity stacks and their sizes.

       info <WINDOWING_MODE> <ACTIVITY_TYPE>

           Display the information about activity stack in <WINDOWING_MODE> and <ACTIVITY_TYPE>.

       remove <STACK_ID>

           Remove stack <STACK_ID>.

  task [COMMAND] [...]: sub-commands for operating on activity tasks.

       lock <TASK_ID>

           Bring <TASK_ID> to the front and don't allow other tasks to run.

       lock stop

           End the current task lock.

       resizeable <TASK_ID> [0|1|2|3]

           Change resizeable mode of <TASK_ID> to one of the following:

           0: unresizeable

           1: crop_windows

           2: resizeable

           3: resizeable_and_pipable

       resize <TASK_ID> <LEFT,TOP,RIGHT,BOTTOM>

           Makes sure <TASK_ID> is in a stack with the specified bounds.

           Forces the task to be resizeable and creates a stack if no existing stack

           has the specified bounds.

  update-appinfo <USER_ID> <PACKAGE_NAME> [<PACKAGE_NAME>...]

      Update the ApplicationInfo objects of the listed packages for <USER_ID>

      without restarting any processes.

  write

      Write all pending state to storage.

  compat [COMMAND] [...]: sub-commands for toggling app-compat changes.

         enable|disable [--no-kill] <CHANGE_ID|CHANGE_NAME> <PACKAGE_NAME>

            Toggles a change either by id or by name for <PACKAGE_NAME>.

            It kills <PACKAGE_NAME> (to allow the toggle to take effect) unless --no-kill is provided.

         reset <CHANGE_ID|CHANGE_NAME> <PACKAGE_NAME>

            Toggles a change either by id or by name for <PACKAGE_NAME>.

            It kills <PACKAGE_NAME> (to allow the toggle to take effect).

         enable-all|disable-all <targetSdkVersion> <PACKAGE_NAME>

            Toggles all changes that are gated by <targetSdkVersion>.

         reset-all [--no-kill] <PACKAGE_NAME>

            Removes all existing overrides for all changes for

            <PACKAGE_NAME> (back to default behaviour).

            It kills <PACKAGE_NAME> (to allow the toggle to take effect) unless --no-kill is provided.

  memory-factor [command] [...]: sub-commands for overriding memory pressure factor

         set <NORMAL|MODERATE|LOW|CRITICAL>

            Overrides memory pressure factor. May also supply a raw int level

         show

            Shows the existing memory pressure factor

         reset

            Removes existing override for memory pressure factor

  service-restart-backoff <COMMAND> [...]: sub-commands to toggle service restart backoff policy.

         enable|disable <PACKAGE_NAME>

            Toggles the restart backoff policy on/off for <PACKAGE_NAME>.

         show <PACKAGE_NAME>

            Shows the restart backoff policy state for <PACKAGE_NAME>.

  get-isolated-pids <UID>

         Get the PIDs of isolated processes with packages in this <UID>

  set-stop-user-on-switch [true|false]

         Sets whether the current user (and its profiles) should be stopped when switching to a different user.

         Without arguments, it resets to the value defined by platform.

  set-bg-abusive-uids [uid=percentage][,uid=percentage...]

         Force setting the battery usage of the given UID.

Unisoc Activity manager (activity) commands:

  freeze <PID> [f|unf]

      Freeze or unFreeze the PID related process, the frozen process can not

      get the cpu cycles.

  get-isolated-pids <UID>

         Get the PIDs of isolated processes with packages in this <UID>

  set-ppa [--appName <PACKAGE_NAME>] [--minAdj <MINADJ>] [--maxAdj <MAXADJ>] [--protectLevel <PROTECT_LEVEL>]

        Set Process ProtectArea for package.

  reset-ppa [--appName <PACKAGE_NAME>]

        Reset Process ProtectArea for package.

  compact-system

        Compact all system process to make more available memory.

 

<INTENT> specifications include these flags and arguments:

    [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] [-i <IDENTIFIER>]

    [-c <CATEGORY> [-c <CATEGORY>] ...]

    [-n <COMPONENT_NAME>]

    [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]

    [--esn <EXTRA_KEY> ...]

    [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]

    [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]

    [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]

    [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]

    [--ed <EXTRA_KEY> <EXTRA_DOUBLE_VALUE> ...]

    [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]

    [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]

    [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]

        (multiple extras passed as Integer[])

    [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]

        (multiple extras passed as List<Integer>)

    [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]

        (multiple extras passed as Long[])

    [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]

        (multiple extras passed as List<Long>)

    [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]

        (multiple extras passed as Float[])

    [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]

        (multiple extras passed as List<Float>)

    [--eda <EXTRA_KEY> <EXTRA_DOUBLE_VALUE>[,<EXTRA_DOUBLE_VALUE...]]

        (multiple extras passed as Double[])

    [--edal <EXTRA_KEY> <EXTRA_DOUBLE_VALUE>[,<EXTRA_DOUBLE_VALUE...]]

        (multiple extras passed as List<Double>)

    [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]

        (multiple extras passed as String[]; to embed a comma into a string,

         escape it using "\,")

    [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]

        (multiple extras passed as List<String>; to embed a comma into a string,

         escape it using "\,")

    [-f <FLAG>]

    [--grant-read-uri-permission] [--grant-write-uri-permission]

    [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]

    [--debug-log-resolution] [--exclude-stopped-packages]

    [--include-stopped-packages]

    [--activity-brought-to-front] [--activity-clear-top]

    [--activity-clear-when-task-reset] [--activity-exclude-from-recents]

    [--activity-launched-from-history] [--activity-multiple-task]

    [--activity-no-animation] [--activity-no-history]

    [--activity-no-user-action] [--activity-previous-is-top]

    [--activity-reorder-to-front] [--activity-reset-task-if-needed]

    [--activity-single-top] [--activity-clear-task]

    [--activity-task-on-home] [--activity-match-external]

    [--receiver-registered-only] [--receiver-replace-pending]

    [--receiver-foreground] [--receiver-no-abort]

    [--receiver-include-background]

    [--selector]

    [<URI> | <PACKAGE> | <COMPONENT>]

 

1.7. pm -h

Package manager (package) commands:

  help

    Print this help text.

 

  path [--user USER_ID] PACKAGE

    Print the path to the .apk of the given PACKAGE.

 

  dump PACKAGE

    Print various system state associated with the given PACKAGE.

 

  has-feature FEATURE_NAME [version]

    Prints true and returns exit status 0 when system has a FEATURE_NAME,

    otherwise prints false and returns exit status 1

 

  list features

    Prints all features of the system.

 

  list instrumentation [-f] [TARGET-PACKAGE]

    Prints all test packages; optionally only those targeting TARGET-PACKAGE

    Options:

      -f: dump the name of the .apk file containing the test package

 

  list libraries

    Prints all system libraries.

 

  list packages [-f] [-d] [-e] [-s] [-3] [-i] [-l] [-u] [-U]

      [--show-versioncode] [--apex-only] [--uid UID] [--user USER_ID] [FILTER]

    Prints all packages; optionally only those whose name contains

    the text in FILTER.  Options are:

      -f: see their associated file

      -a: all known packages (but excluding APEXes)

      -d: filter to only show disabled packages

      -e: filter to only show enabled packages

      -s: filter to only show system packages

      -3: filter to only show third party packages

      -i: see the installer for the packages

      -l: ignored (used for compatibility with older releases)

      -U: also show the package UID

      -u: also include uninstalled packages

      --show-versioncode: also show the version code

      --apex-only: only show APEX packages

      --uid UID: filter to only show packages with the given UID

      --user USER_ID: only list packages belonging to the given user

 

  list permission-groups

    Prints all known permission groups.

 

  list permissions [-g] [-f] [-d] [-u] [GROUP]

    Prints all known permissions; optionally only those in GROUP.  Options are:

      -g: organize by group

      -f: print all information

      -s: short summary

      -d: only list dangerous permissions

      -u: list only the permissions users will see

 

  list staged-sessions [--only-ready] [--only-sessionid] [--only-parent]

    Prints all staged sessions.

      --only-ready: show only staged sessions that are ready

      --only-sessionid: show only sessionId of each session

      --only-parent: hide all children sessions

 

  list users

    Prints all users.

 

  resolve-activity [--brief] [--components] [--query-flags FLAGS]

       [--user USER_ID] INTENT

    Prints the activity that resolves to the given INTENT.

 

  query-activities [--brief] [--components] [--query-flags FLAGS]

       [--user USER_ID] INTENT

    Prints all activities that can handle the given INTENT.

 

  query-services [--brief] [--components] [--query-flags FLAGS]

       [--user USER_ID] INTENT

    Prints all services that can handle the given INTENT.

 

  query-receivers [--brief] [--components] [--query-flags FLAGS]

       [--user USER_ID] INTENT

    Prints all broadcast receivers that can handle the given INTENT.

 

  install [-rtfdg] [-i PACKAGE] [--user USER_ID|all|current]

       [-p INHERIT_PACKAGE] [--install-location 0/1/2]

       [--install-reason 0/1/2/3/4] [--originating-uri URI]

       [--referrer URI] [--abi ABI_NAME] [--force-sdk]

       [--preload] [--instant] [--full] [--dont-kill]

       [--enable-rollback]

       [--force-uuid internal|UUID] [--pkg PACKAGE] [-S BYTES]

       [--apex] [--staged-ready-timeout TIMEOUT]

       [PATH [SPLIT...]|-]

    Install an application.  Must provide the apk data to install, either as

    file path(s) or '-' to read from stdin.  Options are:

      -R: disallow replacement of existing application

      -t: allow test packages

      -i: specify package name of installer owning the app

      -f: install application on internal flash

      -d: allow version code downgrade (debuggable packages only)

      -p: partial application install (new split on top of existing pkg)

      -g: grant all runtime permissions

      -S: size in bytes of package, required for stdin

      --user: install under the given user.

      --dont-kill: installing a new feature split, don't kill running app

      --restrict-permissions: don't whitelist restricted permissions at install

      --originating-uri: set URI where app was downloaded from

      --referrer: set URI that instigated the install of the app

      --pkg: specify expected package name of app being installed

      --abi: override the default ABI of the platform

      --instant: cause the app to be installed as an ephemeral install app

      --full: cause the app to be installed as a non-ephemeral full app

      --install-location: force the install location:

          0=auto, 1=internal only, 2=prefer external

      --install-reason: indicates why the app is being installed:

          0=unknown, 1=admin policy, 2=device restore,

          3=device setup, 4=user request

      --force-uuid: force install on to disk volume with given UUID

      --apex: install an .apex file, not an .apk

      --staged-ready-timeout: By default, staged sessions wait 60000

          milliseconds for pre-reboot verification to complete when

          performing staged install. This flag is used to alter the waiting

          time. You can skip the waiting time by specifying a TIMEOUT of '0'

 

  install-existing [--user USER_ID|all|current]

       [--instant] [--full] [--wait] [--restrict-permissions] PACKAGE

    Installs an existing application for a new user.  Options are:

      --user: install for the given user.

      --instant: install as an instant app

      --full: install as a full app

      --wait: wait until the package is installed

      --restrict-permissions: don't whitelist restricted permissions

 

  install-create [-lrtsfdg] [-i PACKAGE] [--user USER_ID|all|current]

       [-p INHERIT_PACKAGE] [--install-location 0/1/2]

       [--install-reason 0/1/2/3/4] [--originating-uri URI]

       [--referrer URI] [--abi ABI_NAME] [--force-sdk]

       [--preload] [--instant] [--full] [--dont-kill]

       [--force-uuid internal|UUID] [--pkg PACKAGE] [--apex] [-S BYTES]

       [--multi-package] [--staged]

    Like "install", but starts an install session.  Use "install-write"

    to push data into the session, and "install-commit" to finish.

 

  install-write [-S BYTES] SESSION_ID SPLIT_NAME [PATH|-]

    Write an apk into the given install session.  If the path is '-', data

    will be read from stdin.  Options are:

      -S: size in bytes of package, required for stdin

 

  install-remove SESSION_ID SPLIT...

    Mark SPLIT(s) as removed in the given install session.

 

  install-add-session MULTI_PACKAGE_SESSION_ID CHILD_SESSION_IDs

    Add one or more session IDs to a multi-package session.

 

  install-commit SESSION_ID

    Commit the given active install session, installing the app.

 

  install-abandon SESSION_ID

    Delete the given active install session.

 

  set-install-location LOCATION

    Changes the default install location.  NOTE this is only intended for debugging;

    using this can cause applications to break and other undersireable behavior.

    LOCATION is one of:

    0 [auto]: Let system decide the best location

    1 [internal]: Install on internal device storage

    2 [external]: Install on external media

 

  get-install-location

    Returns the current install location: 0, 1 or 2 as per set-install-location.

 

  move-package PACKAGE [internal|UUID]

 

  move-primary-storage [internal|UUID]

 

  uninstall [-k] [--user USER_ID] [--versionCode VERSION_CODE]

       PACKAGE [SPLIT...]

    Remove the given package name from the system.  May remove an entire app

    if no SPLIT names specified, otherwise will remove only the splits of the

    given app.  Options are:

      -k: keep the data and cache directories around after package removal.

      --user: remove the app from the given user.

      --versionCode: only uninstall if the app has the given version code.

 

  clear [--user USER_ID] [--cache-only] PACKAGE

    Deletes data associated with a package. Options are:

    --user: specifies the user for which we need to clear data

    --cache-only: a flag which tells if we only need to clear cache data

 

  enable [--user USER_ID] PACKAGE_OR_COMPONENT

  disable [--user USER_ID] PACKAGE_OR_COMPONENT

  disable-user [--user USER_ID] PACKAGE_OR_COMPONENT

  disable-until-used [--user USER_ID] PACKAGE_OR_COMPONENT

  default-state [--user USER_ID] PACKAGE_OR_COMPONENT

    These commands change the enabled state of a given package or

    component (written as "package/class").

 

  hide [--user USER_ID] PACKAGE_OR_COMPONENT

  unhide [--user USER_ID] PACKAGE_OR_COMPONENT

 

  suspend [--user USER_ID] PACKAGE [PACKAGE...]

    Suspends the specified package(s) (as user).

 

  unsuspend [--user USER_ID] PACKAGE [PACKAGE...]

    Unsuspends the specified package(s) (as user).

 

  set-distracting-restriction [--user USER_ID] [--flag FLAG ...]

      PACKAGE [PACKAGE...]

    Sets the specified restriction flags to given package(s) (for user).

    Flags are:

      hide-notifications: Hides notifications from this package

      hide-from-suggestions: Hides this package from suggestions

        (by the launcher, etc.)

    Any existing flags are overwritten, which also means that if no flags are

    specified then all existing flags will be cleared.

 

  grant [--user USER_ID] PACKAGE PERMISSION

  revoke [--user USER_ID] PACKAGE PERMISSION

    These commands either grant or revoke permissions to apps.  The permissions

    must be declared as used in the app's manifest, be runtime permissions

    (protection level dangerous), and the app targeting SDK greater than Lollipop MR1.

 

  set-permission-flags [--user USER_ID] PACKAGE PERMISSION [FLAGS..]

  clear-permission-flags [--user USER_ID] PACKAGE PERMISSION [FLAGS..]

    These commands either set or clear permission flags on apps.  The permissions

    must be declared as used in the app's manifest, be runtime permissions

    (protection level dangerous), and the app targeting SDK greater than Lollipop MR1.

    The flags must be one or more of [review-required, revoked-compat, revoke-when-requested, user-fixed, user-set]

 

  reset-permissions

    Revert all runtime permissions to their default state.

 

  set-permission-enforced PERMISSION [true|false]

 

  get-privapp-permissions TARGET-PACKAGE

    Prints all privileged permissions for a package.

 

  get-privapp-deny-permissions TARGET-PACKAGE

    Prints all privileged permissions that are denied for a package.

 

  get-oem-permissions TARGET-PACKAGE

    Prints all OEM permissions for a package.

 

  trim-caches DESIRED_FREE_SPACE [internal|UUID]

    Trim cache files to reach the given free space.

 

  list users

    Lists the current users.

 

  create-user [--profileOf USER_ID] [--managed] [--restricted] [--ephemeral]

      [--guest] [--pre-create-only] [--user-type USER_TYPE] USER_NAME

    Create a new user with the given USER_NAME, printing the new user identifier

    of the user.

    USER_TYPE is the name of a user type, e.g. android.os.usertype.profile.MANAGED.

      If not specified, the default user type is android.os.usertype.full.SECONDARY.

      --managed is shorthand for '--user-type android.os.usertype.profile.MANAGED'.

      --restricted is shorthand for '--user-type android.os.usertype.full.RESTRICTED'.

      --guest is shorthand for '--user-type android.os.usertype.full.GUEST'.

 

  remove-user [--set-ephemeral-if-in-use | --wait] USER_ID

    Remove the user with the given USER_IDENTIFIER, deleting all data

    associated with that user.

      --set-ephemeral-if-in-use: If the user is currently running and

        therefore cannot be removed immediately, mark the user as ephemeral

        so that it will be automatically removed when possible (after user

        switch or reboot)

      --wait: Wait until user is removed. Ignored if set-ephemeral-if-in-use

 

  set-user-restriction [--user USER_ID] RESTRICTION VALUE

 

  get-max-users

 

  get-max-running-users

 

  compile [-m MODE | -r REASON] [-f] [-c] [--split SPLIT_NAME]

          [--reset] [--check-prof (true | false)] (-a | TARGET-PACKAGE)

    Trigger compilation of TARGET-PACKAGE or all packages if "-a".  Options are:

      -a: compile all packages

      -c: clear profile data before compiling

      -f: force compilation even if not needed

      -m: select compilation mode

          MODE is one of the dex2oat compiler filters:

            assume-verified

            extract

            verify

            quicken

            space-profile

            space

            speed-profile

            speed

            everything

      -r: select compilation reason

          REASON is one of:

            first-boot

            boot-after-ota

            post-boot

            install

            install-fast

            install-bulk

            install-bulk-secondary

            install-bulk-downgraded

            install-bulk-secondary-downgraded

            bg-dexopt

            ab-ota

            inactive

            cmdline

            shared

      --reset: restore package to its post-install state

      --check-prof (true | false): look at profiles when doing dexopt?

      --secondary-dex: compile app secondary dex files

      --split SPLIT: compile only the given split name

      --compile-layouts: compile layout resources for faster inflation

 

  force-dex-opt PACKAGE

    Force immediate execution of dex opt for the given PACKAGE.

 

  delete-dexopt PACKAGE

    Delete dex optimization results for the given PACKAGE.

 

  bg-dexopt-job

    Execute the background optimizations immediately.

    Note that the command only runs the background optimizer logic. It may

    overlap with the actual job but the job scheduler will not be able to

    cancel it. It will also run even if the device is not in the idle

    maintenance mode.

  cancel-bg-dexopt-job

    Cancels currently running background optimizations immediately.

    This cancels optimizations run from bg-dexopt-job or from JobScjeduler.

    Note that cancelling currently running bg-dexopt-job command requires

    running this command from separate adb shell.

 

  reconcile-secondary-dex-files TARGET-PACKAGE

    Reconciles the package secondary dex files with the generated oat files.

 

  dump-profiles [--dump-classes-and-methods] TARGET-PACKAGE

    Dumps method/class profile files to

    /data/misc/profman/TARGET-PACKAGE-primary.prof.txt.

      --dump-classes-and-methods: passed along to the profman binary to

        switch to the format used by 'profman --create-profile-from'.

 

  snapshot-profile TARGET-PACKAGE [--code-path path]

    Take a snapshot of the package profiles to

    /data/misc/profman/TARGET-PACKAGE[-code-path].prof

    If TARGET-PACKAGE=android it will take a snapshot of the boot image

 

  set-home-activity [--user USER_ID] TARGET-COMPONENT

    Set the default home activity (aka launcher).

    TARGET-COMPONENT can be a package name (com.package.my) or a full

    component (com.package.my/component.name). However, only the package name

    matters: the actual component used will be determined automatically from

    the package.

 

  set-installer PACKAGE INSTALLER

    Set installer package name

 

  get-instantapp-resolver

    Return the name of the component that is the current instant app installer.

 

  set-harmful-app-warning [--user <USER_ID>] <PACKAGE> [<WARNING>]

    Mark the app as harmful with the given warning message.

 

  get-harmful-app-warning [--user <USER_ID>] <PACKAGE>

    Return the harmful app warning message for the given app, if present

 

  uninstall-system-updates [<PACKAGE>]

    Removes updates to the given system application and falls back to its

    /system version. Does nothing if the given package is not a system app.

    If no package is specified, removes updates to all system applications.

 

  get-moduleinfo [--all | --installed] [module-name]

    Displays module info. If module-name is specified only that info is shown

    By default, without any argument only installed modules are shown.

      --all: show all module info

      --installed: show only installed modules

 

  log-visibility [--enable|--disable] <PACKAGE>

    Turns on debug logging when visibility is blocked for the given package.

      --enable: turn on debug logging (default)

      --disable: turn off debug logging

 

  set-silent-updates-policy [--allow-unlimited-silent-updates <INSTALLER>]

                            [--throttle-time <SECONDS>] [--reset]

    Sets the policies of the silent updates.

      --allow-unlimited-silent-updates: allows unlimited silent updated

        installation requests from the installer without the throttle time.

      --throttle-time: update the silent updates throttle time in seconds.

      --reset: restore the installer and throttle time to the default, and

        clear tracks of silent updates in the system.

 

  get-app-links [--user <USER_ID>] [<PACKAGE>]

    Prints the domain verification state for the given package, or for all

    packages if none is specified. State codes are defined as follows:

        - none: nothing has been recorded for this domain

        - verified: the domain has been successfully verified

        - approved: force approved, usually through shell

        - denied: force denied, usually through shell

        - migrated: preserved verification from a legacy response

        - restored: preserved verification from a user data restore

        - legacy_failure: rejected by a legacy verifier, unknown reason

        - system_configured: automatically approved by the device config

        - >= 1024: Custom error code which is specific to the device verifier

      --user <USER_ID>: include user selections (includes all domains, not

        just autoVerify ones)

  reset-app-links [--user <USER_ID>] [<PACKAGE>]

    Resets domain verification state for the given package, or for all

    packages if none is specified.

      --user <USER_ID>: clear user selection state instead; note this means

        domain verification state will NOT be cleared

      <PACKAGE>: the package to reset, or "all" to reset all packages

  verify-app-links [--re-verify] [<PACKAGE>]

    Broadcasts a verification request for the given package, or for all

    packages if none is specified. Only sends if the package has previously

    not recorded a response.

      --re-verify: send even if the package has recorded a response

  set-app-links [--package <PACKAGE>] <STATE> <DOMAINS>...

    Manually set the state of a domain for a package. The domain must be

    declared by the package as autoVerify for this to work. This command

    will not report a failure for domains that could not be applied.

      --package <PACKAGE>: the package to set, or "all" to set all packages

      <STATE>: the code to set the domains to, valid values are:

        STATE_NO_RESPONSE (0): reset as if no response was ever recorded.

        STATE_SUCCESS (1): treat domain as successfully verified by domain.

          verification agent. Note that the domain verification agent can

          override this.

        STATE_APPROVED (2): treat domain as always approved, preventing the

           domain verification agent from changing it.

        STATE_DENIED (3): treat domain as always denied, preveting the domain

          verification agent from changing it.

      <DOMAINS>: space separated list of domains to change, or "all" to

        change every domain.

  set-app-links-user-selection --user <USER_ID> [--package <PACKAGE>]

      <ENABLED> <DOMAINS>...

    Manually set the state of a host user selection for a package. The domain

    must be declared by the package for this to work. This command will not

    report a failure for domains that could not be applied.

      --user <USER_ID>: the user to change selections for

      --package <PACKAGE>: the package to set

      <ENABLED>: whether or not to approve the domain

      <DOMAINS>: space separated list of domains to change, or "all" to

        change every domain.

  set-app-links-allowed --user <USER_ID> [--package <PACKAGE>] <ALLOWED>

      <ENABLED> <DOMAINS>...

    Toggle the auto verified link handling setting for a package.

      --user <USER_ID>: the user to change selections for

      --package <PACKAGE>: the package to set, or "all" to set all packages

        packages will be reset if no one package is specified.

      <ALLOWED>: true to allow the package to open auto verified links, false

        to disable

  get-app-link-owners [--user <USER_ID>] [--package <PACKAGE>] [<DOMAINS>]

    Print the owners for a specific domain for a given user in low to high

    priority order.

      --user <USER_ID>: the user to query for

      --package <PACKAGE>: optionally also print for all web domains declared

        by a package, or "all" to print all packages

      --<DOMAINS>: space separated list of domains to query for

 

<INTENT> specifications include these flags and arguments:

    [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] [-i <IDENTIFIER>]

    [-c <CATEGORY> [-c <CATEGORY>] ...]

    [-n <COMPONENT_NAME>]

    [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]

    [--esn <EXTRA_KEY> ...]

    [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]

    [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]

    [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]

    [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]

    [--ed <EXTRA_KEY> <EXTRA_DOUBLE_VALUE> ...]

    [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]

    [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]

    [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]

        (multiple extras passed as Integer[])

    [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]

        (multiple extras passed as List<Integer>)

    [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]

        (multiple extras passed as Long[])

    [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]

        (multiple extras passed as List<Long>)

    [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]

        (multiple extras passed as Float[])

    [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]

        (multiple extras passed as List<Float>)

    [--eda <EXTRA_KEY> <EXTRA_DOUBLE_VALUE>[,<EXTRA_DOUBLE_VALUE...]]

        (multiple extras passed as Double[])

    [--edal <EXTRA_KEY> <EXTRA_DOUBLE_VALUE>[,<EXTRA_DOUBLE_VALUE...]]

        (multiple extras passed as List<Double>)

    [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]

        (multiple extras passed as String[]; to embed a comma into a string,

         escape it using "\,")

    [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]

        (multiple extras passed as List<String>; to embed a comma into a string,

         escape it using "\,")

    [-f <FLAG>]

    [--grant-read-uri-permission] [--grant-write-uri-permission]

    [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]

    [--debug-log-resolution] [--exclude-stopped-packages]

    [--include-stopped-packages]

    [--activity-brought-to-front] [--activity-clear-top]

    [--activity-clear-when-task-reset] [--activity-exclude-from-recents]

    [--activity-launched-from-history] [--activity-multiple-task]

    [--activity-no-animation] [--activity-no-history]

    [--activity-no-user-action] [--activity-previous-is-top]

    [--activity-reorder-to-front] [--activity-reset-task-if-needed]

    [--activity-single-top] [--activity-clear-task]

    [--activity-task-on-home] [--activity-match-external]

    [--receiver-registered-only] [--receiver-replace-pending]

    [--receiver-foreground] [--receiver-no-abort]

    [--receiver-include-background]

    [--selector]

    [<URI> | <PACKAGE> | <COMPONENT>]

1.7.1. 查看所有应用包

pm list packages ;格式如下:

package:com.android.providers.media.module

package:com.android.modulemetadata

package:com.android.connectivity.resources

1.7.2. 权限授权和撤销授权

pm grant com.starkylin.camera android.permission.CAMERA

pm revoke com.starkylin.camera android.permission.CAMERA

1.8. appops -h****

AppOps service (appops) commands:

  help

    Print this help text.

  start [--user <USER_ID>] [--attribution <ATTRIBUTION_TAG>] <PACKAGE | UID> <OP>

    Starts a given operation for a particular application.

  stop [--user <USER_ID>] [--attribution <ATTRIBUTION_TAG>] <PACKAGE | UID> <OP>

    Stops a given operation for a particular application.

  set [--user <USER_ID>] <[--uid] PACKAGE | UID> <OP> <MODE>

    Set the mode for a particular application and operation.

  get [--user <USER_ID>] [--attribution <ATTRIBUTION_TAG>] <PACKAGE | UID> [<OP>]

    Return the mode for a particular application and optional operation.

  query-op [--user <USER_ID>] <OP> [<MODE>]

    Print all packages that currently have the given op in the given mode.

  reset [--user <USER_ID>] [<PACKAGE>]

    Reset the given application or all applications to default modes.

  write-settings

    Immediately write pending changes to storage.

  read-settings

    Read the last written settings, replacing current state in RAM.

  options:

    <PACKAGE> an Android package name or its UID if prefixed by --uid

    <OP>      an AppOps operation.

    <MODE>    one of allow, ignore, deny, or default

    <USER_ID> the user id under which the package is installed. If --user is

              not specified, the current user is assumed.

 

1.8.1. 查询权限授权记录

appops get net.sourceforge.opencamera

Uid mode: COARSE_LOCATION: ignore

FINE_LOCATION: ignore

CAMERA: foreground

RECORD_AUDIO: foreground

READ_PHONE_STATE: ignore

BLUETOOTH_SCAN: ignore

LEGACY_STORAGE: ignore

BLUETOOTH_CONNECT: ignore

CAMERA: allow; time=+7m57s997ms ago; duration=+1s919ms

MANAGE_EXTERNAL_STORAGE: default; rejectTime=+7m59s338ms ago

NO_ISOLATED_STORAGE: deny; rejectTime=+7m59s332ms ago

 

1.9. atrace --help

usage: atrace [options] [categories...]

options include:

  -a appname      enable app-level tracing for a comma separated list of cmdlines; * is a wildcard matching any process

  -b N            use a trace buffer size of N KB

  -c              trace into a circular buffer

  -f filename     use the categories written in a file as space-separated

                    values in a line

  -k fname,...    trace the listed kernel functions

  -n              ignore signals

  -s N            sleep for N seconds before tracing [default 0]

  -t N            trace for N seconds [default 5]

  -z              compress the trace dump

  --async_start   start circular trace and return immediately

  --async_dump    dump the current contents of circular trace buffer

  --async_stop    stop tracing and dump the current contents of circular

                    trace buffer

  --stream        stream trace to stdout as it enters the trace buffer

                    Note: this can take significant CPU time, and is best

                    used for measuring things that are not affected by

                    CPU performance, like pagecache usage.

  --list_categories

                  list the available tracing categories

 -o filename      write the trace to the specified file instead

                    of stdout.

 

1.10. base64 --help

Toybox 0.8.6-android multicall binary (see toybox --help)

 

usage: base64 [-di] [-w COLUMNS] [FILE...]

 

Encode or decode in base64.

 

-d      Decode

-i      Ignore non-alphabetic characters

-w      Wrap output at COLUMNS (default 76 or 0 for no wrap)

1.11. dmesg --help

Toybox 0.8.6-android multicall binary (see toybox --help)

 

usage: dmesg [-Cc] [-r|-t|-T] [-n LEVEL] [-s SIZE] [-w]

 

Print or control the kernel ring buffer.

 

-C      Clear ring buffer without printing

-c      Clear ring buffer after printing

-n      Set kernel logging LEVEL (1-9)

-r      Raw output (with <level markers>)

-S      Use syslog(2) rather than /dev/kmsg

-s      Show the last SIZE many bytes

-T      Human readable timestamps

-t      Don't print timestamps

-w      Keep waiting for more output (aka --follow)

 

1.12. dumpstate -h

usage: dumpstate [-h] [-c] [-b soundfile] [-e soundfile] [-o directory] [-p] [-s] [-S] [-q] [-P] [-t] [-R] [-L] [-u][-V version]

  -h: display this help message

  -c: display cpu usage

  -b: play sound file instead of vibrate, at beginning of job

  -e: play sound file instead of vibrate, at end of job

  -o: write to custom directory (only in limited mode)

  -p: capture screenshot to filename.png

  -s: write zipped file to control socket (for init)

  -S: write file location to control socket (for init)

  -q: disable vibrate

  -P: send broadcast when started and do progress updates

  -t: dump process trace to /data/anr/dumptrace_xxx

  -R: take bugreport in remote mode (shouldn't be used with -P)

  -w: start binder service and make it wait for a call to startBugreport

  -L: output limited information that is safe for submission in feedback reports

  -u: delete /data/corefile/core-XXXX

  -v: prints the dumpstate header and exit

 

1.13. getenforce and setenforce

getenforce  // 获取selinux状态

Permissive

setenforce 0  // 关闭selinux检查

 

1.14. getevent -h

Usage: getevent [-t] [-n] [-s switchmask] [-S] [-v [mask]] [-d] [-p] [-i] [-l] [-q] [-c count] [-r] [device]

    -t: show time stamps

    -n: don't print newlines

    -s: print switch states for given bits

    -S: print all switch states

    -v: verbosity mask (errs=1, dev=2, name=4, info=8, vers=16, pos. events=32, props=64)

    -d: show HID descriptor, if available

    -p: show possible events (errs, dev, name, pos. events)

    -i: show all device info and possible events

    -l: label event types and names in plain text

    -q: quiet (clear verbosity mask)

    -c: print given number of events then exit

    -r: print rate events are received

 

1.14.1.  getevent -i

找到name:     "goodix_ts",表示触摸屏的事件/dev/input/event4

1.14.2.  getevent -lt /dev/input/event4

查看触摸屏驱动发送过来的touch事件

1.15. input --help

Usage: input [<source>] [-d DISPLAY_ID] <command> [<arg>...]

 

The sources are:

      touchnavigation

      touchscreen

      joystick

      stylus

      touchpad

      gamepad

      dpad

      mouse

      keyboard

      trackball

 

-d: specify the display ID.

      (Default: -1 for key event, 0 for motion event if not specified.)

The commands and default sources are:

      text <string> (Default: touchscreen)

      keyevent [--longpress|--doubletap] <key code number or name> ... (Default: keyboard)

      tap <x> <y> (Default: touchscreen)

      swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)

      draganddrop <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)

      press (Default: trackball)

      roll <dx> <dy> (Default: trackball)

      motionevent <DOWN|UP|MOVE|CANCEL> <x> <y> (Default: touchscreen)

      keycombination [-t duration(ms)] <key code 1> <key code 2> ... (Default: keyboard, the key order is important here.)

 

1.16. iptables --help

iptables v1.8.7

 

Usage: iptables -[ACD] chain rule-specification [options]

       iptables -I chain [rulenum] rule-specification [options]

       iptables -R chain rulenum rule-specification [options]

       iptables -D chain rulenum [options]

       iptables -[LS] [chain [rulenum]] [options]

       iptables -[FZ] [chain] [options]

       iptables -[NX] chain

       iptables -E old-chain-name new-chain-name

       iptables -P chain target [options]

       iptables -h (print this help information)

 

Commands:

Either long or short options are allowed.

  --append  -A chain            Append to chain

  --check   -C chain            Check for the existence of a rule

  --delete  -D chain            Delete matching rule from chain

  --delete  -D chain rulenum

                                Delete rule rulenum (1 = first) from chain

  --insert  -I chain [rulenum]

                                Insert in chain as rulenum (default 1=first)

  --replace -R chain rulenum

                                Replace rule rulenum (1 = first) in chain

  --list    -L [chain [rulenum]]

                                List the rules in a chain or all chains

  --list-rules -S [chain [rulenum]]

                                Print the rules in a chain or all chains

  --flush   -F [chain]          Delete all rules in  chain or all chains

  --zero    -Z [chain [rulenum]]

                                Zero counters in chain or all chains

  --new     -N chain            Create a new user-defined chain

  --delete-chain

            -X [chain]          Delete a user-defined chain

  --policy  -P chain target

                                Change policy on chain to target

  --rename-chain

            -E old-chain new-chain

                                Change chain name, (moving any references)

Options:

    --ipv4      -4              Nothing (line is ignored by ip6tables-restore)

    --ipv6      -6              Error (line is ignored by iptables-restore)

[!] --protocol  -p proto        protocol: by number or name, eg. `tcp'

[!] --source    -s address[/mask][...]

                                source specification

[!] --destination -d address[/mask][...]

                                destination specification

[!] --in-interface -i input name[+]

                                network interface name ([+] for wildcard)

 --jump -j target

                                target for rule (may load target extension)

  --goto      -g chain

                              jump to chain with no return

  --match       -m match

                                extended match (may load extension)

  --numeric     -n              numeric output of addresses and ports

[!] --out-interface -o output name[+]

                                network interface name ([+] for wildcard)

  --table       -t table        table to manipulate (default: `filter')

  --verbose     -v              verbose mode

  --wait        -w [seconds]    maximum wait to acquire xtables lock before give up

  --wait-interval -W [usecs]    wait time to try to acquire xtables lock

                                default is 1 second

  --line-numbers                print line numbers when listing

  --exact       -x              expand numbers (display exact values)

[!] --fragment  -f              match second or further fragments only

  --modprobe=<command>          try to insert modules using this command

  --set-counters PKTS BYTES     set the counter during insert/append

[!] --version   -V              print package version.

 

1.17.  kill

usage:  kill [-s signame | -signum | -signame] { job | pid | pgrp } ...

        kill -l [exit_status ...]

 

 

1.18.  log -h

Toybox 0.8.6-android multicall binary (see toybox --help)

 

usage: log [-p PRI] [-t TAG] [MESSAGE...]

 

Logs message (or stdin) to logcat.

 

-p      Use the given priority instead of INFO:

        d: DEBUG  e: ERROR  f: FATAL  i: INFO  v: VERBOSE  w: WARN  s: SILENT

-t      Use the given tag instead of "log"

 

1.19.  logcat --help

Usage: logcat [options] [filterspecs]

 

General options:

  -b, --buffer=<buffer>       Request alternate ring buffer(s):

                                main system radio events crash default all

                              Additionally, 'kernel' for userdebug and eng builds, and

                              'security' for Device Owner installations.

                              Multiple -b parameters or comma separated list of buffers are

                              allowed. Buffers are interleaved.

                              Default -b main,system,crash,kernel.

  -L, --last                  Dump logs from prior to last reboot from pstore.

  -c, --clear                 Clear (flush) the entire log and exit.

                              if -f is specified, clear the specified file and its related rotated

                              log files instead.

                              if -L is specified, clear pstore log instead.

  -d                          Dump the log and then exit (don't block).

  --pid=<pid>                 Only print logs from the given pid.

  --wrap                      Sleep for 2 hours or when buffer about to wrap whichever

                              comes first. Improves efficiency of polling by providing

                              an about-to-wrap wakeup.

 

Formatting:

  -v, --format=<format>       Sets log print format verb and adverbs, where <format> is one of:

                                brief help long process raw tag thread threadtime time

                              Modifying adverbs can be added:

                                color descriptive epoch monotonic printable uid usec UTC year zone

                              Multiple -v parameters or comma separated list of format and format

                              modifiers are allowed.

  -D, --dividers              Print dividers between each log buffer.

  -B, --binary                Output the log in binary.

 

Outfile files:

  -f, --file=<file>           Log to file instead of stdout.

  -r, --rotate-kbytes=<n>     Rotate log every <n> kbytes. Requires -f option.

  -n, --rotate-count=<count>  Sets max number of rotated logs to <count>, default 4.

  --id=<id>                   If the signature <id> for logging to file changes, then clear the

                              associated files and continue.

 

Logd control:

 These options send a control message to the logd daemon on device, print its return message if

 applicable, then exit. They are incompatible with -L, as these attributes do not apply to pstore.

  -g, --buffer-size           Get the size of the ring buffers within logd.

  -G, --buffer-size=<size>    Set size of a ring buffer in logd. May suffix with K or M.

                              This can individually control each buffer's size with -b.

  -S, --statistics            Output statistics.

                              --pid can be used to provide pid specific stats.

  -p, --prune                 Print prune rules. Each rule is specified as UID, UID/PID or /PID. A

                              '~' prefix indicates that elements matching the rule should be pruned

                              with higher priority otherwise they're pruned with lower priority. All

                              other pruning activity is oldest first. Special case ~! represents an

                              automatic pruning for the noisiest UID as determined by the current

                              statistics.  Special case ~1000/! represents pruning of the worst PID

                              within AID_SYSTEM when AID_SYSTEM is the noisiest UID.

  -P, --prune='<list> ...'    Set prune rules, using same format as listed above. Must be quoted.

 

Filtering:

  -s                          Set default filter to silent. Equivalent to filterspec '*:S'

  -e, --regex=<expr>          Only print lines where the log message matches <expr> where <expr> is

                              an ECMAScript regular expression.

  -m, --max-count=<count>     Quit after printing <count> lines. This is meant to be paired with

                              --regex, but will work on its own.

  --print                     This option is only applicable when --regex is set and only useful if

                              --max-count is also provided.

                              With --print, logcat will print all messages even if they do not

                              match the regex. Logcat will quit after printing the max-count number

                              of lines that match the regex.

  -t <count>                  Print only the most recent <count> lines (implies -d).

  -t '<time>'                 Print the lines since specified time (implies -d).

  -T <count>                  Print only the most recent <count> lines (does not imply -d).

  -T '<time>'                 Print the lines since specified time (not imply -d).

                              count is pure numerical, time is 'MM-DD hh:mm:ss.mmm...'

                              'YYYY-MM-DD hh:mm:ss.mmm...' or 'sssss.mmm...' format.

  --uid=<uids>                Only display log messages from UIDs present in the comma separate list

                              <uids>. No name look-up is performed, so UIDs must be provided as

                              numeric values. This option is only useful for the 'root', 'log', and

                              'system' users since only those users can view logs from other users.

 

filterspecs are a series of

  <tag>[:priority]

 

where <tag> is a log component tag (or * for all) and priority is:

  V    Verbose (default for <tag>)

  D    Debug (default for '*')

  I    Info

  W    Warn

  E    Error

  F    Fatal

  S    Silent (suppress all output)

 

'*' by itself means '*:D' and <tag> by itself means <tag>:V.

If no '*' filterspec or -s on command line, all filter defaults to '*:V'.

eg: '*:S <tag>' prints only <tag>, '<tag>:S' suppresses all <tag> log messages.

 

If not specified on the command line, filterspec is set from ANDROID_LOG_TAGS.

 

If not specified with -v on command line, format is set from ANDROID_PRINTF_LOG

or defaults to "threadtime"

 

1.20.  lsmod --help

Toybox 0.8.6-android multicall binary (see toybox --help)

 

usage: lsmod

 

Display the currently loaded modules, their sizes and their dependencies.

 

 

1.21.  lsusb --help

Toybox 0.8.6-android multicall binary (see toybox --help)

 

usage: ls [-ACFHLRSZacdfhiklmnpqrstuwx1] [--color[=auto]] [FILE...]

 

List files.

 

what to show:

-a  all files including .hidden    -b  escape nongraphic chars

-c  use ctime for timestamps       -d  directory, not contents

-i  inode number                   -p  put a '/' after dir names

-q  unprintable chars as '?'       -s  storage used (1024 byte units)

-u  use access time for timestamps -A  list all files but . and ..

-H  follow command line symlinks   -L  follow symlinks

-R  recursively list in subdirs    -F  append /dir *exe @sym |FIFO

-Z  security context

 

output formats:

-1  list one file per line         -C  columns (sorted vertically)

-g  like -l but no owner           -h  human readable sizes

-l  long (show full details)       -m  comma separated

-n  like -l but numeric uid/gid    -o  like -l but no group

-w  set column width               -x  columns (horizontal sort)

-ll long with nanoseconds (--full-time)

--color  device=yellow  symlink=turquoise/red  dir=blue  socket=purple

         files: exe=green  suid=red  suidfile=redback  stickydir=greenback

         =auto means detect if output is a tty.

 

sorting (default is alphabetical):

-f  unsorted    -r  reverse    -t  timestamp    -S  size

 

1.22. lshal -h

lshal: List and debug HIDL HALs.

   (for AIDL HALs, see `dumpsys`)

 

commands:

    list         List HIDL HALs.

    debug        Debug a specified HIDL HAL.

    help         Print help message.

    wait         Wait for HIDL HAL to start if it is not already started.

If no command is specified, `list` is the default.

 

list:

    lshal

    lshal list

        List all hals with default ordering and columns (`lshal list -Vliepc`)

    lshal list [-h|--help]

        -h, --help: Print help message for list (`lshal help list`)

    lshal [list] [OPTIONS...]

        -i, --interface: print the instance name column

        -l, --released: print the 'is released?' column

            (Y=released, N=unreleased, ?=unknown)

        -t, --transport: print the transport mode column

        -r, --arch: print the bitness column

        -s, --hash: print hash of the interface

        -p, --pid: print the server PID, or server cmdline if -m is set

        -a, --address: print the server object address column

        -c, --clients: print the client PIDs, or client cmdlines if -m is set

        -e, --threads: print currently used/available threads

            (note, available threads created lazily)

        -m, --cmdline: print cmdline instead of PIDs

        -d[=<arg>], --debug[=<arg>]: Emit debug info from

            IBase::debug with empty options. Cannot be used with --neat.

            Writes to specified file if 'arg' is provided, otherwise stdout.

        -V, --vintf: print VINTF info. This column contains a comma-separated list of:

                - DM: if the HIDL HAL is in the device manifest

                - DC: if the HIDL HAL is in the device compatibility matrix

                - FM: if the HIDL HAL is in the framework manifest

                - FC: if the HIDL HAL is in the framework compatibility matrix

                - X: if the HIDL HAL is in none of the above lists

        -S, --service-status: print service status column. Possible values are:

                - alive: alive and running hwbinder service;

                - registered;dead: registered to hwservicemanager but is not responsive;

                - declared: only declared in VINTF manifest but is not registered to hwservicemanager;

                - N/A: no information for passthrough HALs.

        -A, --all: print all columns

        --init-vintf: form a skeleton HAL manifest to specified file,

            or stdout if no file specified.

        --init-vintf-partition=<arg>: Specify the partition of the HAL manifest

            generated by --init-vintf.

            Valid values are 'system', 'vendor', and 'odm'. Default is 'vendor'.

        --sort=<arg>: sort by a column. 'arg' can be (i|interface) or (p|pid).

        --neat: output is machine parsable (no explanatory text).

            Cannot be used with --debug.

        --types=<arg>: comma-separated list of one or more sections.

            The output is restricted to the selected section(s). Valid options

            are: (b|binderized), (c|passthrough_clients), (l|passthrough_libs), (v|vintf), (z|lazy), and (a|all).

            Default is `b,c,l`.

 

debug:

    lshal debug [-E] <interface> [options [options [...]]]

        Print debug information of a specified interface.

        -E: excludes debug output if HIDL HAL is actually a subclass.

        <interface>: Format is `android.hardware.foo@1.0::IFoo/default`.

            If instance name is missing `default` is used.

        options: space separated options to IBase::debug.

 

help:

    lshal -h

    lshal --help

    lshal help

        Print this help message

    lshal help list

        Print help message for list

    lshal help debug

        Print help message for debug

    lshal help help

        Print help message for help

    lshal help wait

        Print help message for wait

 

wait:

    lshal wait <interface/instance>

        For a HAL that is on the device, wait for the HAL to start.

        This will not start a HAL unless it is configured as a lazy HAL.

        <interface>: Format is `android.hardware.foo@1.0::IFoo/default`.

            If instance name is missing `default` is used.

 

1.23. mkdir --help

Toybox 0.8.6-android multicall binary (see toybox --help)

 

usage: mkdir [-vp] [-m MODE] [DIR...]

 

Create one or more directories.

 

-m      Set permissions of directory to mode

-p      Make parent directories as needed

-v      Verbose

 

1.24.  pkill --help

Toybox 0.8.6-android multicall binary (see toybox --help)

 

usage: pkill [-fnovx] [-SIGNAL|-l SIGNAL] [PATTERN] [-G GID,] [-g PGRP,] [-P PPID,] [-s SID,] [-t TERM,] [-U UID,] [-u EUID,]

 

-l      Send SIGNAL (default SIGTERM)

-V      Verbose

-f      Check full command line for PATTERN

-G      Match real Group ID(s)

-g      Match Process Group(s) (0 is current user)

-n      Newest match only

-o      Oldest match only

-P      Match Parent Process ID(s)

-s      Match Session ID(s) (0 for current)

-t      Match Terminal(s)

-U      Match real User ID(s)

-u      Match effective User ID(s)

-v      Negate the match

-x      Match whole command (not substring)

 

1.25. screencap -hp

usage: screencap [-hp] [-d display-id] [FILENAME]

   -h: this message

   -p: save the file as a png.

   -d: specify the display ID to capture (default: 0)

       see "dumpsys SurfaceFlinger --display-id" for valid display IDs.

If FILENAME ends with .png it will be saved as a png.

If FILENAME is not given, the results will be printed to stdout.

 

1.26. sendevent --help

Toybox 0.8.6-android multicall binary (see toybox --help)

 

usage: sendevent DEVICE TYPE CODE VALUE

 

Sends a Linux input event.

1.27. monkey -h

usage: monkey [-p ALLOWED_PACKAGE [-p ALLOWED_PACKAGE] ...]
              [-c MAIN_CATEGORY [-c MAIN_CATEGORY] ...]
              [--ignore-crashes] [--ignore-timeouts]
              [--ignore-security-exceptions]
              [--monitor-native-crashes] [--ignore-native-crashes]
              [--kill-process-after-error] [--hprof]
              [--match-description TEXT]
              [--pct-touch PERCENT] [--pct-motion PERCENT]
              [--pct-trackball PERCENT] [--pct-syskeys PERCENT]
              [--pct-nav PERCENT] [--pct-majornav PERCENT]
              [--pct-appswitch PERCENT] [--pct-flip PERCENT]
              [--pct-anyevent PERCENT] [--pct-pinchzoom PERCENT]
              [--pct-permission PERCENT]
              [--pkg-blacklist-file PACKAGE_BLACKLIST_FILE]
              [--pkg-whitelist-file PACKAGE_WHITELIST_FILE]
              [--wait-dbg] [--dbg-no-events]
              [--setup scriptfile] [-f scriptfile [-f scriptfile] ...]
              [--port port]
              [-s SEED] [-v [-v] ...]
              [--throttle MILLISEC] [--randomize-throttle]
              [--profile-wait MILLISEC]
              [--device-sleep-time MILLISEC]
              [--randomize-script]
              [--script-log]
              [--bugreport]
              [--periodic-bugreport]
              [--permission-target-system]
              COUNT

monkey --pct-anyevent 0 --ignore-crashes --ignore-timeouts --ignore-security-exceptions --ignore-native-crashes --monitor-native-crashes -v --throttle 800 999999999 monkey --pkg-blacklist-file /data/local/black.txt --pct-anyevent 0 --ignore-crashes --ignore-timeouts --ignore-security-exceptions --ignore-native-crashes --monitor-native-crashes -v --throttle 800 999999999

1.28. systrace

python E:\002-Android\Sdk\platform-tools\systrace\systrace.py sched freq idle am wm gfx view sync binder_driver irq workq input webview audio video camera hal res sm dalvik rs power pm ss aidl disk load memory -b 96000 -t 10

1.29. addr2line

addr2line -f -e out/target/product/rk3568_s/symbols/system/lib64/libkdjni.so 0000000000002600

中间参数是路劲,最后的参数是pc值

1.30. ndk-stack

cd E:\002-Android\Sdk\ndk\27.0.11902837

.\ndk-stack.cmd -sym Y:\st7885-0802\out\target\product\uis7885_smc50cube\symbols\system\lib64\ -dump .\ne-log\data_app_native_crash@1725768417119.txt