First, PM command introduction and package name information Query 1.pm command Introduction
PM Tools for the short name of package Manager
You can use the PM tool to perform app installation and query app Bao information, system permissions, control applications
The PM tool is an essential tool in the Android development and testing process, and the shell command format is as follows:
PM <command>
2. Package Name information Query
Shell mode:
PM list packages [options] [FILTER]
Print the package name of all installed apps, and if file filtering is set, the value displays the content that contains the filtered text
Parameters |
Describe |
-F |
Show file location for each package |
-D |
Use filters to show only the package names of disabled apps |
-E |
Use filters to show only the package names of available apps |
-S |
Use filters to show only the package name of the system app |
-3 |
Use filters to show only the package names of third-party apps |
-I. |
View the installers for your app |
Second, access information Query 1. Authority basis
The composition of permissions: The name of the permission, the permission group that belongs to, the protection level
For example:
<permission android:description="string Resource"Android:icon="drable Resource"Android:label="string Resource"Android:name="string"Android:permissiongroup="string"Android:protectionlevel=["Normal"|"Dangerous"|"Signature"|"Signatureorsystem"]/>
ProtectionLevel |
Description |
Normal |
Indicates that permissions are low-risk and will not compromise the system, users, or other applications |
Dangerous |
Indicates that permissions are risky, and the system will probably want the ball user to enter relevant information before granting this permission |
Signature |
Indicates that a permission can be granted to an application only if it uses the same signature as the application that declares the reference permission. |
Signatureorsystem |
Requires a signature or system-level application (placed in the/system/app directory) to give permission |
System |
System-level applications (placed in the/system/app directory) to give permissions |
Custom Permissions |
Apply self-defined permissions |
2. Permission Query
Shell mode:
PM List permission-groups
#打印所有已知的权限组
PM list permissions [options] [GROUP]
#打印权限
Parameters can be combined using for example: PM List permissions–g-d
Parameters |
Description |
-G |
List permissions by group |
-F |
Print all information |
-S |
A brief summary |
-D |
Only a dangerous list of permissions |
-U |
Only users with permissions will see the list User definable permissions |
3. Authorization and cancellation
Note: The target apk minsdkversion, targetsdkversion must also be 23 and above
Sub-command |
Description |
Grant <package_name> <permission> |
Grant permission to apply permissions. devices with required android6.0 (API level 23) |
Revoke <package_name> <permission> |
Revoke app permissions. devices with required android6.0 (API level 23) |
For example:
It is important to note that the so-called authorization refers to the license that is already in your apk, which is equivalent to the concept of enabling
ADB shell PM Grant <packageName> Android.permission.READ_CONTACTS# Authorization (same as canceling permissions)
Third, other information inquiries 1. Test package and APK path query
Pm
Sub-command |
Parameters |
Description |
List Instrymentation |
No parameters |
List all the instrumentation test packages |
-F |
List APK file Locations |
<target_package> |
List test packages for an app |
Path <package> |
<package> |
Print the APK path for the specified package name |
For example:
ADB shell PM List Instrumentation
ADB shell pm List Instrumentation Target_package
ADB shell PM Path package_name
2. system function and Support library query
Pm
Sub-command |
Description |
List feature |
All functions of the printing system List all hardware-related information |
List libraries |
Print all libraries supported by the current device |
For example:
ADB shell PM List feature
3. Print the System status information for the package
PM Dump Package
Prints the system state of a given package
Print content |
Description |
DUMP of SERVICE Package |
Print Service Information |
DUMP of SERVICE activity |
Print activity Information |
DUMP of SERVICE Meminfo |
Print Current Memory usage information |
DUMP of SERVICE Procstats |
Print system memory usage with a period of time memory rollup |
DUMP of SERVICE Usagestats |
Print Server usage status information |
DUMP of SERVICE Batterystats |
Print Battery status information |
For example:
adb shell PM Dump package_name
Iv. installation and uninstallation 1. Installation
PM Install [-LRTSFD] [-I package] [PATH]
Install apk into your phone by specifying a path (unlike adb install, the. APK is installed on your PC, and the APK installed by PM install is stored on your phone)
Parameters |
Description |
-L |
Lock the application |
-R |
Reinstall the app and keep the app data |
-T |
Allow test apk to be installed |
-I <INSTALLER_PACKAGE_NAME> |
Specify the package name for the installation package |
-S |
Install to SD card |
-F |
Install to system built-in storage (default installation location) |
-D |
Allow downgrade installation (same app low-level advanced) |
-G |
Grant all permissions listed in the application manifest (only 6.0 systems are available) |
First push the test.apk file to the phone directory, such as/data/local/tmp
adb shell pm install/data/local/tmp/test.apk #安装
adb shell pm install–r/data/local/tmp/test.apk #重新安装
2. Uninstall
PM Uninstall [Options] <PACKAGE>
#卸载应用
Parameters |
Description |
-K |
Uninstall the app and keep the data and cache (delete all if not plus-K) |
V. Control commands 1. Clear Application Data
PM Clear <PACKAGE_NAME>
2. Disabling and enabling apps
Pm
Only system application can be used, third-party application not
Sub-command |
Description |
Enable <PACKAGE_OR_COMPONENT> |
Make a package or component available |
Disenable <PACKAGE_OR_COMPONENT> |
Make the package or component unavailable (you can't find the app directly) |
Disenable-user [Options] <PACKAGE_OR_COMPONENT> |
Make package or component unavailable (will show disabled) |
3. Hide and Restore apps
Pm
Hidden apps become invisible in app management and desktop icons disappear
Sub-command |
Description |
Hide Package_or_component |
Hide Package or component |
Unhide Package_or_conponent |
Recover visible Package or component |
4. Control the default installation location for your app
Pm
Requires root privileges
Sub-command |
Description |
Set-install-location <LOCATION> |
To change the default installation location: 0: Auto-let the system decide the best location 1: Internal Storage-storage installed on internal devices 2: External storage-installed on external media Note: Only for debugging, do not engage in blind |
Get-install-localtion |
Returns the current installation location 0 1 2 Corresponding to the above numerical description |
Android PM Command Detailed