大家都熟悉android 的安装命令,pm 

pm
usage: pm list packages [-f] [-d] [-e] [-s] [-3] [-i] [-u] [--user USER_ID] [FILTER]
       pm list permission-groups
       pm list permissions [-g] [-f] [-d] [-u] [GROUP]
       pm list instrumentation [-f] [TARGET-PACKAGE]
       pm list features
       pm list libraries
       pm list users
       pm path PACKAGE
       pm dump PACKAGE
       pm install [-lrtsfd] [-i PACKAGE] [PATH]
       pm install-create [-lrtsfdp] [-i PACKAGE] [-S BYTES]
       pm install-write [-S BYTES] SESSION_ID SPLIT_NAME [PATH]
       pm install-commit SESSION_ID
       pm install-abandon SESSION_ID
       pm uninstall [-k] [--user USER_ID] PACKAGE
       pm set-installer PACKAGE INSTALLER
       pm clear [--user USER_ID] PACKAGE
       pm enable [--user USER_ID] PACKAGE_OR_COMPONENT
       pm disable [--user USER_ID] PACKAGE_OR_COMPONENT
       pm disable-user [--user USER_ID] PACKAGE_OR_COMPONENT
       pm disable-until-used [--user USER_ID] PACKAGE_OR_COMPONENT
       pm hide [--user USER_ID] PACKAGE_OR_COMPONENT
       pm unhide [--user USER_ID] PACKAGE_OR_COMPONENT
       pm grant PACKAGE PERMISSION
       pm revoke PACKAGE PERMISSION
       pm set-install-location [0/auto] [1/internal] [2/external]
       pm get-install-location
       pm set-permission-enforced PERMISSION [true|false]
       pm trim-caches DESIRED_FREE_SPACE
       pm create-user [--profileOf USER_ID] [--managed] USER_NAME
       pm remove-user USER_ID
       pm get-max-users

pm list packages: 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 disbled 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.

pm list permission-groups: prints all known permission groups.

pm list permissions: 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.

pm list instrumentation: use to list all test packages; optionally
  supply to list the test packages for a particular
  application.  Options:
    -f: list the .apk file for the test package.

pm list features: prints all features of the system.

pm list users: prints all users on the system.

pm path: print the path to the .apk of the given PACKAGE.

pm dump: print system state associated with the given PACKAGE.

pm install: install a single legacy package
pm install-create: create an install session
    -l: forward lock application
    -r: replace existing application
    -t: allow test packages
    -i: specify the installer package name
    -s: install application on sdcard
    -f: install application on internal flash
    -d: allow version code downgrade
    -p: partial application install
    -S: size in bytes of entire session

pm install-write: write a package into existing session; path may
  be '-' to read from stdin
    -S: size in bytes of package, required for stdin

pm install-commit: perform install of fully staged session
pm install-abandon: abandon session

pm set-installer: set installer package name

pm uninstall: removes a package from the system. Options:
    -k: keep the data and cache directories around after package removal.

pm clear: deletes all data associated with a package.

pm enable, disable, disable-user, disable-until-used: these commands
  change the enabled state of a given package or component (written
  as "package/class").

pm grant, revoke: these commands either grant or revoke permissions
  to applications.  Only optional permissions the application has
  declared can be granted or revoked.

pm get-install-location: returns 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

pm set-install-location: changes the default install location.
  NOTE: this is only intended for debugging; using this can cause
  applications to break and other undersireable behavior.
    0 [auto]: Let system decide the best location
    1 [internal]: Install on internal device storage
    2 [external]: Install on external media

pm trim-caches: trim cache files to reach the given free space.

pm create-user: create a new user with the given USER_NAME,
  printing the new user identifier of the user.

pm remove-user: remove the user with the given USER_IDENTIFIER,
  deleting all data associated with that user

pm 在android 代码中的外置:

frameworks\base\cmds\pm

Android.mk 的解析:

3LOCAL_PATH:= $(call my-dir)4include $(CLEAR_VARS)56LOCAL_SRC_FILES := $(call all-subdir-java-files)7LOCAL_MODULE := pm8include $(BUILD_JAVA_LIBRARY) //pm.jar编译出91011include $(CLEAR_VARS)12ALL_PREBUILT += $(TARGET_OUT)/bin/pm13$(TARGET_OUT)/bin/pm : $(LOCAL_PATH)/pm | $(ACP) //拷贝pm 命令为/system/bin/pm14$(transform-prebuilt-to-target)15

pm 命令代码为

1# Script to start "pm" on the device, which has a very rudimentary2# shell.3#4base=/system5export CLASSPATH=$base/framework/pm.jar6exec app_process $base/bin com.android.commands.pm.Pm "$@"7

上面代码中调用pm.jar 中的Pm 静态方法,传入$@ 参数,执行apk 的安装流程。

更多相关文章

  1. android adb常用命令整理
  2. Android 解屏代码
  3. android 实现代码关机
  4. Android 文件管理器 Android文件管理器源代码
  5. googleMap----放大,缩小,东南西北,四种视图切换代码
  6. 转:善用Android预定义样式来为我们的布局设置效果,大大节约代码量
  7. 在EeePC上运行Android!(转)(也是代码下载配置编译的流程!)
  8. Android官方命令深入分析之AVD Manager
  9. -Android各版本系统源代码下载

随机推荐

  1. Ping32分析员工电脑行为,防范内部泄露威胁
  2. 马铁大神的 Apache Spark 十年回顾
  3. 阿里面试:说说一致性读实现原理?
  4. 国内最好的数据丢失防护服务-Ping32
  5. Apache Spark 3.0.0 正式版终于发布了,重
  6. FastAPI基础之 模型的额外信息-示例
  7. 解密算法思维
  8. 敖丙跟你聊聊MySQL安全的那些事
  9. Apache Arrow:跨平台的内存数据交换格式
  10. 前任都能看懂的分库分表方案