Commands pm with the package name information query

1.pm Commands

pm for the package management tool (package manager) for short

You can use the tool to perform the installation pm and query application treasure of information applications, system privileges, control applications

pm Android development and testing tools are essential to the process tool, shell command format is as follows:

pm <command>

2. The package name information query

Shell mode:

pm list packages [options] [FILTER]

Print all of the package name of the application has been installed, if you set the value of the content filtering file containing the filter text display

parameter

description

-f The display position of each package file
-d Use filters to show only the name of the application package disabled
-e Use a filter to display only the name of the application package available
-s Use a filter to display only the application package name system
-3 Use filters to show only third-party application package name
-i View installer application

 

Second, the authority information inquiry

1. basic rights

Consisting of rights: the name of the rights, powers belong to the group, the level of protection

E.g:

<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

Explanation

normal Means permission to be low risk, will not cause harm to the system, users or other applications
dangerous Means permission is a high risk, the system will probably be balls user input relevant information, will grant this permission
signature At the same time said that only when the application you are using a digital signature and authority to declare a reference application with the signature phase, in order to be granted permission to it
signatureOrSystem Need to be signed or system-level application (placed in the / system under / app directory) to give permission
system System-level applications (placed in the / system / app directory) to give permission
Custom Permissions Application Permissions define yourself

 

2. The rights inquiry

Shell mode:

pm list permission-groups

# Prints all known permission groups

pm list permissions [options] [GROUP]

# Print permissions

Parameters may be used in combination, for example: pm list permissions -g -d

parameter

Explanation

-g Permissions were listed by group
-f Print all information
-s Short summary
-d Only dangerous permissions list
-u Only user rights will see a list of 
user-defined rights

 

3. Authorization and Cancellation

Note: apk target of minSdkVersion, targetSdkVersion must also be 23 and above

Subcommand

Explanation

grant <package_name> <permission> Licenses granted the application. Required android6.0 (API level 23) than devices
revoke <package_name> <permission> Revoke permission application. Required android6.0 (API level 23) than devices

E.g:

Note that the so-called authorization refers to existing permission apk inside your authorization, equivalent to the concept enabled

adb shell pm grant <packageName> android.permission.READ_CONTACTS
# Authorization (permission to cancel empathy)

 

Third, other information inquiry

1. Test package and apk path query

pm

Subcommand

parameter

Explanation

list instrymentation No arguments List all the instrumentation test kits
-f Apk file locations listed
<target_package> A list of test kits app
path <package> <package> Print specify the package name apk path

E.g:

adb shell pm list instrumentation

adb shell pm list instrumentation TARGET_PACKAGE

adb shell pm path PACKAGE_NAME

2. System features and support database queries

pm

Subcommand

Explanation

list feature All functions of the printing system 
lists all hardware-related information
list libraries Print all devices supported by current library

E.g:

adb shell pm list feature

3. The print system status information packet

pm dump PACKAGE

Printing given packet system status

Print Content

Explanation

DUMP OF SERVICE package Print service information
DUMP OF SERVICE activity Print activity information
DUMP OF SERVICE meminfo Print memory usage information
DUMP OF SERVICE procstats The printing system memory usage and the memory for some time summary
DUMP OF SERVICE usagestats Print server status information
DUMP OF SERVICE batterystats Printing battery status information

E.g:

adb shell pm dump PACKAGE_NAME

 

Fourth, the installation and uninstallation

1. Install

pm install [-lrtsfd] [-i PACKAGE] [PATH]

Apk installation by specifying a path to your phone (with adb install the difference is adb install .apk is installed on your computer, and install the apk pm install is stored in your phone)

parameter

Explanation

-l Lock Application
-r Reinstall the application and application data retention
-t Allow the test to be mounted apk
-i <INSTALLER_PACKAGE_NAME> Specifies the package name of the installation package
-s Installation to sd card
-f Installed into the built-in storage system (the default installation location)
-d Allow downgrade installations (the same advanced application of low-level change)
-g Grant application manifest lists all the permissions (only 6.0 system is available)

首先将test.apk文件push到手机目录中比如/data/local/tmp

adb shell pm install /data/local/tmp/test.apk           #安装

adb shell pm install –r /data/local/tmp/test.apk       #重新安装

2.卸载

pm uninstall [options] <PACKAGE>

#卸载应用

参数

说明

-k 卸载应用且保留数据与缓存(如果不加-k则全部删除)

 

五、控制命令

1.清除应用数据

pm clear <PACKAGE_NAME>

 

2.禁用和启用应用

pm

只有系统应用才可以用,第三方应用不行

子命令

说明

enable <PACKAGE_OR_COMPONENT> 使package或component可用
disenable <PACKAGE_OR_COMPONENT> 使package或component不可用(直接就找不到应用了)
disenable-user [options] <PACKAGE_OR_COMPONENT> 使package或component不可用(会显示已停用)

 

3.隐藏与恢复应用

pm

被隐藏应用在应用管理中变得不可见,桌面图标也会消失

子命令

说明

hide PACKAGE_OR_COMPONENT 隐藏package或component
unhide PACKAGE_OR_CONPONENT 恢复可见package或component

 

4.控制应用的默认安装位置

pm

需要root权限

子命令

说明

set-install-location <LOCATION> 更改默认的安装位置: 
0:自动-让系统决定最好的位置 
1:内部存储-安装在内部设备上的存储 
2:外部存储-安装在外部媒体 
注:只用于调试,不要瞎搞
get-install-localtion 返回当前的安装位置 



对应上面的数字说明
发布了36 篇原创文章 · 获赞 162 · 访问量 62万+

Guess you like

Origin blog.csdn.net/qq_19004627/article/details/103911681