Android下pm 命令详解
2016-03-31 12:45
645 查看
Sam在看相关PackageManager代码时,无意中发现Android 下提供一个pm命令,通常放在/system/bin/下。这个命令与Package有关,且非常实用。所以研究之。
0. Usage:
usage: pm [list|path|install|uninstall]
pm list packages [-f]
pm list permission-groups
pm list permissions [-g] [-f] [-d] [-u] [GROUP]
pm list instrumentation [-f] [TARGET-PACKAGE]
pm list features
pm path PACKAGE
pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] [-s] [-f] PATH
pm uninstall [-k] PACKAGE
pm enable PACKAGE_OR_COMPONENT
pm disable PACKAGE_OR_COMPONENT
pm setInstallLocation [0/auto] [1/internal] [2/external]
The list packages command prints all packages. Options:
-f: see their associated file.
The list permission-groups command prints all known
permission groups.
The list permissions command 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.
The list instrumentation command prints all instrumentations,
or only those that target a specified package. Options:
-f: see their associated file.
The list features command prints all features of the system.
The path command prints the path to the .apk of a package.
The install command installs a package 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: specify the installer package name.
-s: install package on sdcard.
-f: install package on internal flash.
The uninstall command removes a package from the system. Options:
-k: keep the data and cache directories around.
after the package removal.
The enable and disable commands change the enabled state of
a given package or component (written as "package/class").
The getInstallLocation command gets the current install location
0 [auto]: Let system decide the best location
1 [internal]: Install on internal device storage
2 [external]: Install on external media
The setInstallLocation command changes the default install location
0 [auto]: Let system decide the best location
1 [internal]: Install on internal device storage
2 [external]: Install on external media
1. 具体使用方法:
1.1:察看已安装的包:
pm list package
此时则显示所有已经安装的包名。
pm list package -f
也显示associated文件所在目录(即保存的APK文件)
1.2:察看已知的权限组:
pm list permission-groups
1.3:察看所有已知的权限:
pm list permissions
1.4:列出所有硬件相关信息:
pm list features
结果通常类似:
feature:reqGlEsVersion=0x20000
feature:android.hardware.bluetooth
feature:android.hardware.camera
feature:android.hardware.location
feature:android.hardware.location.network
feature:android.hardware.microphone
feature:android.hardware.sensor.accelerometer
feature:android.hardware.sensor.compass
feature:android.hardware.touchscreen
feature:android.hardware.wifi
1.5:列出指定包名的 associated 文件 (APK存档文件) 所在:
例如:
pm path com.TDiJoy.fane
package:/mnt/asec/com.TDiJoy.fane-1/pkg.apk
1.6: 安装APK:
pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] [-s] [-f] PATH
PATH 指 APK文件绝对路径和文件名。
例如:
pm install /data/3dijoy_fane.apk
这几个参数很有用:
-r: 安装一个已经安装的APK,保持其数据不变。
-i:指定安装的包名。(没试出来)
-s: 安装到SDCard上。
-f: 安装到内部Flash上。
1.6:卸载APK:
pm uninstall 包名。
例如:
pm uninstall com.TDiJoy.fane
1.7: 得到和设置缺省安装位置:
The getInstallLocation command gets the current install location
0 [auto]: Let system decide the best location
1 [internal]: Install on internal device storage
2 [external]: Install on external media
The setInstallLocation command changes the default install location
0 [auto]: Let system decide the best location
1 [internal]: Install on internal device storage
2 [external]: Install on external media
pm getInstallLocation
得到缺省的安装位置。
设置:
pm setInstallLocation <0|1|2>
0: 自动。
1:内部Flash。
2:扩展存储设备。
实例:如何在海信2.2 STB上将APK安装到U盘中:
Sam首先尝试使用:
pm setInstallLocation 2
之后安装之,没有用。
后来做如下尝试:
在其它设置->存储设备->制定默认存储设备中选择U盘为默认存储设备。
# pm install -s xxxx.apk
就可以成功。
0. Usage:
usage: pm [list|path|install|uninstall]
pm list packages [-f]
pm list permission-groups
pm list permissions [-g] [-f] [-d] [-u] [GROUP]
pm list instrumentation [-f] [TARGET-PACKAGE]
pm list features
pm path PACKAGE
pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] [-s] [-f] PATH
pm uninstall [-k] PACKAGE
pm enable PACKAGE_OR_COMPONENT
pm disable PACKAGE_OR_COMPONENT
pm setInstallLocation [0/auto] [1/internal] [2/external]
The list packages command prints all packages. Options:
-f: see their associated file.
The list permission-groups command prints all known
permission groups.
The list permissions command 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.
The list instrumentation command prints all instrumentations,
or only those that target a specified package. Options:
-f: see their associated file.
The list features command prints all features of the system.
The path command prints the path to the .apk of a package.
The install command installs a package 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: specify the installer package name.
-s: install package on sdcard.
-f: install package on internal flash.
The uninstall command removes a package from the system. Options:
-k: keep the data and cache directories around.
after the package removal.
The enable and disable commands change the enabled state of
a given package or component (written as "package/class").
The getInstallLocation command gets the current install location
0 [auto]: Let system decide the best location
1 [internal]: Install on internal device storage
2 [external]: Install on external media
The setInstallLocation command changes the default install location
0 [auto]: Let system decide the best location
1 [internal]: Install on internal device storage
2 [external]: Install on external media
1. 具体使用方法:
1.1:察看已安装的包:
pm list package
此时则显示所有已经安装的包名。
pm list package -f
也显示associated文件所在目录(即保存的APK文件)
1.2:察看已知的权限组:
pm list permission-groups
1.3:察看所有已知的权限:
pm list permissions
1.4:列出所有硬件相关信息:
pm list features
结果通常类似:
feature:reqGlEsVersion=0x20000
feature:android.hardware.bluetooth
feature:android.hardware.camera
feature:android.hardware.location
feature:android.hardware.location.network
feature:android.hardware.microphone
feature:android.hardware.sensor.accelerometer
feature:android.hardware.sensor.compass
feature:android.hardware.touchscreen
feature:android.hardware.wifi
1.5:列出指定包名的 associated 文件 (APK存档文件) 所在:
例如:
pm path com.TDiJoy.fane
package:/mnt/asec/com.TDiJoy.fane-1/pkg.apk
1.6: 安装APK:
pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] [-s] [-f] PATH
PATH 指 APK文件绝对路径和文件名。
例如:
pm install /data/3dijoy_fane.apk
这几个参数很有用:
-r: 安装一个已经安装的APK,保持其数据不变。
-i:指定安装的包名。(没试出来)
-s: 安装到SDCard上。
-f: 安装到内部Flash上。
1.6:卸载APK:
pm uninstall 包名。
例如:
pm uninstall com.TDiJoy.fane
1.7: 得到和设置缺省安装位置:
The getInstallLocation command gets the current install location
0 [auto]: Let system decide the best location
1 [internal]: Install on internal device storage
2 [external]: Install on external media
The setInstallLocation command changes the default install location
0 [auto]: Let system decide the best location
1 [internal]: Install on internal device storage
2 [external]: Install on external media
pm getInstallLocation
得到缺省的安装位置。
设置:
pm setInstallLocation <0|1|2>
0: 自动。
1:内部Flash。
2:扩展存储设备。
实例:如何在海信2.2 STB上将APK安装到U盘中:
Sam首先尝试使用:
pm setInstallLocation 2
之后安装之,没有用。
后来做如下尝试:
在其它设置->存储设备->制定默认存储设备中选择U盘为默认存储设备。
# pm install -s xxxx.apk
就可以成功。
相关文章推荐
- android 代理模式创建Activity
- Android实现下拉刷新上拉加载(PullToRefreshLayout)
- android 数据库创建在本地, 监听数据库变化
- Chronometer android自带的倒计时控件
- Android控件拖动的实现
- 怎样解决Android studio中文乱码问题
- Android-include获取其子标签并且设置事件
- $《第一行代码:Android》读书笔记——第2章 Activity
- Android获取软键盘状态
- Android classes.dex 反编译
- Android-动态加载和静态加载Fragment
- activity的几种启动模式
- Android TextView轮播
- (4.5.3.5)Failed to resolve : junit:junit:4.12 in android studio 1.4
- Android源码(好几百个实用的源码分享)
- android 打包报错 conversion to dalvik format failed with error 1
- Android Meterial Design Support Library
- Android进阶之ListView实现多条数据同时倒计时功能
- Android中Path类的lineTo方法和quadTo方法画线的区别
- android对list对象中的string字符串进行排序