Android shell command summary, androidshell
Pm
Package Manage
Pm list packages [FILTER] view installed application packages
-F: displays the associated apk file.
-S only searches for filters in System Applications
-3 search for filters only in third-party applications
-D only searches for Filter in the disabled package
-E only searches for Filter in enabled package
-I show installer
-U uninstalled package
-- User USERID
Pm list instrumentation [TARGET-PACKAGE] displays all test packages
-F: displays the associated apk file.
Pm list features
Pm list permission-groups
Pm list permissions [GROUP]
-G: organize by group
-F: Display All Information
-S display description
-D. Only dangerous permissions are displayed.
-U: only visible to users
Pm list users
Pm uninstall <package>
-K: retain data and Cache
Pm clear <package> clear data
-- User USERID
Pm path <package>: view the apk package path of an application
Pm dump <package> displays package-related system status information
Pm install PATH
-L FORWARD_LOCK
-R: reinstall and retain data
-T run the installation test apk
-I: Specifies the installation package name.
-S SDCard
-F internal memory
-D version downgrade allowed
Pm get-install-location returns the current default installation location
Return Value:
0 auto
1. Internal Storage
2 External Storage
Pm set-install-location 0 | 1 | 2 modify the default installation location,
Pm enable | disable-user | disable-until-used | block | unblock [-- user USERID] PACKAGE_OR_COMPONENT
Pm grant | increase or decrease permissions of the revoke package permission application (must be declared in the Application)
Pm create-user USER_NAME
Pm remove-user USER_ID
Pm get-max-users
Pm set-permission-enforced PERMISSION [true | false]
Pm trim-caches DESIRED_FREE_SPACE
Am
Activity Manage
General options
-- User <USER_ID> | current | all runs as a specific user
Am start [options] <INTENT> start Activity
Options:
-D debugging mode
-W: Wait Until startup ends.
-- Start-profilter <FILE> start the analyzer and output the result to the FILE.
-P <FILE> Start the analyzer, output the result to the FILE, and stop the analysis when the application is idle.
-R <COUNT> repeatedly starts Count times. Before each repetition, the upper-level Activity is ended.
-S: Force stop after startup
-- Opengl-trace starts OpenGL function records
-- User <USER_ID> | current specifies the user to run. The default value is the current user.
Am startservice <INTENT> start the service
Am stopservice <INTENT> stops the service
Am force-stop <PACKAGE> force stop all PACKAGE-related items
Am kill <PACKAGE> kill PACKAGE-related processes
Am kill-all: kill all background processes
Am broadcast <INTENT>
Am instrument [options] <COMPONENT>
Options:
-R outputs the test results in the original form. This option is usually used with-e perf true during performance testing.
-P <FILE> output the analysis data to the FILE
-W <TEST_PACKAGE/RUNNER_CLASS> will not be returned until the end of instrumentation
-- No-window-animation
-- User <USER_ID> | current
-E <testrunner_flag> <value> [, <value>…]
InstrumentationTestRunner available flag
|
Package |
<Full_java_package> |
Run the test in a java package. |
|
Class |
<Full_class_name>
<Full_class_name> # methos_name |
Execute a test class |
|
Func |
True |
Execute all InstrumentationTestCase |
|
Unit |
True |
Execute non-InstrumentationTestCase and non-PerformanceTestCase test classes |
|
Size |
Small | medium | large |
Run the @ SmallTest, @ MediumTest, @ LargeTest annotation test.
The android. test. annotation package defines @ LargeTest, @ MediumTest, @ SmallTest, @ Smoke, and @ Suppress. |
|
Perf |
True |
Execute PerformanceTestCase
Works with-r to output the original format. |
|
Debug |
True |
Test in debug mode |
|
Log |
True |
|
<INTENT> specifications include these flags and arguments:
[-A <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] android. intent. action. VIEW content: // contacts/people/1 image/png
[-C <CATEGORY> [-c <CATEGORY>]...] android. intent. category. APP_CONTACTS
[-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>...]
[-- Eu <EXTRA_KEY> <EXTRA_URI_VALUE>...]
[-- Ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]
[-- Eia <EXTRA_KEY> <EXTRA_INT_VALUE> [, <EXTRA_INT_VALUE...]
[-- Ela <EXTRA_KEY> <EXTRA_LONG_VALUE> [, <EXTRA_LONG_VALUE...]
[-- Efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE> [, <EXTRA_FLOAT_VALUE...]
[-N <COMPONENT>] [-f <FLAGS>]
[-- Grant-read-uri-permission] [-- grant-write-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]
[-- Cycler-registered-only] [-- Cycler-replace-pending]
[-- Selector]
[<URI >|< PACKAGE >|< COMPONENT>]
Dumpsys
Query System services to obtain system running status information
Principle: Call listServices of ServiceManager to query all registered services, and obtain the Binder remote proxy object of the service through the checkService interface, use the dump function of each service to print information about the service.
Source code: https://android.googlesource.com/platform/frameworks/native/+/master/cmds/dumpsys/dumpsys.cpp
When dumpsys does not contain any parameters, it lists all services and displays the status information of all services in turn.
Dumpsys | grep FILTER
Service list: displays the system service list
Dumpsys SERVICE [SERVICE_OPTIONS] displays the status of the specified SERVICE
Dumpsys SERVICE-h some services can view acceptable parameters
For example:
Dumpsys battery
Dumpsys wifi
Dumpsys cpuinfo
Dumpsys meminfo
Dumpsys meminfo com. xracoon. wifisetter
Dumpsys window w (indows) | grep mCurrentFocus
Dumpsys window d (disply) | grep Display
Debugging and Testing
Dumpstate
Dmesg
Monkey [options] count
Screenrecord [options] <file> android4.4 +
Screencap-p <file>
Input
Input [<source>] <command> [<arg>...]
Source:
Trackball, joystick, touchnavigation, mouse, keyboard, gamepad, touchpad, dpad, stylus, touchscreen
Command and/default source:
Text <string>/touchscreen
Keyevent [-- longpress] <key code number or name>.../keyboard
Tap <x> <y>/touchscreen
Swipe <x1> <y1> <x2> <y2> [duration_ms]/touchscreen
Press/trackball
Roll <dx> <dy>/trackball