android pm 命令总结

本文深入解析了Android Package Manager (PM) 命令及其参数的功能和用法,包括查看包信息、权限管理、安装与卸载应用等核心操作。对于Android开发人员而言,掌握这些命令能够更高效地进行应用管理和维护。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

文章出处:https://blog.youkuaiyun.com/shift_wwx/article/details/11257645

am命令一样,它的源码为位于frameworks/base/cmds/pm.

 

pm <command>

CommandDescription
list packages [options] <FILTER>Prints all packages, optionally only those whose package name contains the text in<FILTER>.

Options:

  • -f: See their associated file.
  • -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.
  • -u: Also include uninstalled packages.
  • --user <USER_ID>: The user space to query.

list permission-groupsPrints all known permission groups.
list permissions [options] <GROUP>Prints all known permissions, optionally only those in <GROUP>.

Options:

  • -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 instrumentationList all test packages.

Options:

  • -f: List the APK file for the test package.
  • <TARGET_PACKAGE>: List test packages for only this app.

list featuresPrints all features of the system.
list librariesPrints all the libraries supported by the current device.
list usersPrints all users on the system.
path <PACKAGE>Print the path to the APK of the given <PACKAGE>.
install [options] <PATH>Installs a package (specified by <PATH>) to the system.

Options:

  • -l: Install the package with forward lock.
  • -r: Reinstall an exisiting app, keeping its data.
  • -t: Allow test APKs to be installed.
  • -i <INSTALLER_PACKAGE_NAME>: Specify the installer package name.
  • -s: Install package on the shared mass storage (such as sdcard).
  • -f: Install package on the internal system memory.
  • -d: Allow version code downgrade.

uninstall [options] <PACKAGE>Removes a package from the system.

Options:

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

clear <PACKAGE>Deletes all data associated with a package.
enable <PACKAGE_OR_COMPONENT>Enable the given package or component (written as "package/class").
disable <PACKAGE_OR_COMPONENT>Disable the given package or component (written as "package/class").
disable-user [options] <PACKAGE_OR_COMPONENT>

Options:

  • --user <USER_ID>: The user to disable.

grant <PACKAGE_PERMISSION>Grant permissions to applications. Only optional permissions the application has declared can be granted.
revoke <PACKAGE_PERMISSION>Revoke permissions to applications. Only optional permissions the application has declared can be revoked.
set-install-location <LOCATION>Changes the default install location. Location values:
  • 0: Auto—Let system decide the best location.
  • 1: Internal—install on internal device storage.
  • 2: External—install on external media.

Note: This is only intended for debugging; using this can cause applications to break and other undesireable behavior.

get-install-locationReturns the current install location. Return values:
  • 0 [auto]: Lets system decide the best location
  • 1 [internal]: Installs on internal device storage
  • 2 [external]: Installs on external media
set-permission-enforced <PERMISSION> [true|false]Specifies whether the given permission should be enforced.
trim-caches <DESIRED_FREE_SPACE>Trim cache files to reach the given free space.
create-user <USER_NAME>Create a new user with the given <USER_NAME>, printing the new user identifier of the user.
ove-user <USER_ID>Remove the user with the given <USER_IDENTIFIER>, deleting all data associated with that user
get-max-usersPrints the maximum number of users supported by the device.
  






评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

私房菜

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值