Android practical command summary-pm

1. Pm command

Command format:

pm <command>

Command list:

command Features Implementation
list packages List app package information PMS.getInstalledPackages
install [options<PATH> Install the app PMS.installPackageAsUser
uninstall [options]<package> Uninstall app IPackageInstaller.uninstall
enable <包名或组件名> enable PMS.setEnabledSetting
disable <包名或组件名> disable PMS.setEnabledSetting
hide <package> Hide app PMS.setApplicationHiddenSettingAsUser
unhide <package> Show apps PMS.setApplicationHiddenSettingAsUser
get-install-location Get installation location PMS.getInstallLocation
set-install-location Set the installation location PMS.setInstallLocation
path <package> View App Path PMS.getPackageInfo
clear <package> Clear App data AMS.clearApplicationUserData
get-max-users Maximum number of users UserManager.getMaxSupportedUsers
force-dex-opt <package> dex optimization PMS.forceDexOpt
dump <package> dump information AM.dumpPackageStateStatic
trim-caches <目标size> Tighten cache target size PMS.freeStorageAndNotify

The actual implementation of the pm command is in Pm.java, and most of the last is to call the PackageManagerServicecorresponding method to complete. After disbale, you should not see the app in the desktop and application list.

2. Detailed parameters

2.1 list packages

View all packages

list packages [options] <FILTER>

The [options] parameter:

  • -f: display the file associated with the package name;
  • -d: Only display the disabled package name;
  • -e: Only display the enabled package name;
  • -s: only display the system package name;
  • -3: Only the package name of the third-party application is displayed;
  • -i: the installer corresponding to the package name;
  • -u: contains the uninstalled package name.

Rule : disabled + enabled = total number of applications; system + third party = total number of applications.

For example: View the third-party application:

pm list packages -3

For another example, check the package name that has been disabled. (Domestic manufacturers generally disable Google's services)

pm list packages -d

<FILTER> Parameters:

When FILTER is not empty, only applications with FILTER field in the package name will be output; when FILTER is empty, all applications that meet the conditions will be displayed by default.

For example, check the package name with the google field

pm list packages google

2.2 pm install

Install the app

pm install [options] <PATH>

The [options] parameter:

  • -r: Overwrite and install Apk, and keep the original data;
  • -d: Run and install the lower version Apk;
  • -t: Run the installation test Apk
  • -i: Apk installer specified;
  • -s: install apk to shared fast storage, such as sdcard;
  • -f: install apk to internal system memory;
  • -l: installation process, holding forwarding lock
  • -g: allow all permissions in the Apk manifest;

<PATH> Parameters:

This parameter is required and refers to the path where the apk to be installed is located.

2.3 Other parameters

pm list users //查看当前手机用户
pm list libraries //查看当前设备所支持的库
pm list features //查看系统所有的features
pm list instrumentation //所有测试包的信息
pm list permission-groups //查看所有的权限组
pm list permissions [options] <group> 查看权限
    -g: 以组形式组织;
    -f: 打印所有信息;
    -s: 简要信息;
    -d: 只列举危险权限;
    -u: 只列举用户可见的权限。
发布了60 篇原创文章 · 获赞 44 · 访问量 34万+

Guess you like

Origin blog.csdn.net/beyond702/article/details/52858020