TShopping

 找回密碼
 註冊
搜索
查看: 1789|回復: 0
打印 上一主題 下一主題

[教學] Android pm 命令詳解

[複製鏈接]
跳轉到指定樓層
1#
發表於 2018-1-4 23:35:26 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
 
Push to Facebook
Sam在看相關PackageManager代碼時,無意中發現Android下提供一個pm命令,通常放在/ system / bin /下。這個命令與Package有關,且非常實用。
所以研究之


0. Usage:
  1. usage: pm [list|path|install|uninstall]
  2.        pm list packages [-f]
  3.        pm list permission-groups
  4.        pm list permissions [-g] [-f] [-d] [-u] [GROUP]
  5.        pm list instrumentation [-f] [TARGET-PACKAGE]
  6.        pm list features
  7.        pm path PACKAGE
  8.        pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] [-s] [-f] PATH
  9.        pm uninstall [-k] PACKAGE
  10.        pm enable PACKAGE_OR_COMPONENT
  11.        pm disable PACKAGE_OR_COMPONENT
  12.        pm setInstallLocation [0/auto] [1/internal] [2/external]

  13. The list packages command prints all packages.  Options:
  14.   -f: see their associated file.

  15. The list permission-groups command prints all known
  16. permission groups.

  17. The list permissions command prints all known
  18. permissions, optionally only those in GROUP.  Options:
  19.   -g: organize by group.
  20.   -f: print all information.
  21.   -s: short summary.
  22.   -d: only list dangerous permissions.
  23.   -u: list only the permissions users will see.

  24. The list instrumentation command prints all instrumentations,
  25. or only those that target a specified package.  Options:
  26.   -f: see their associated file.

  27. The list features command prints all features of the system.

  28. The path command prints the path to the .apk of a package.

  29. The install command installs a package to the system.  Options:
  30.   -l: install the package with FORWARD_LOCK.
  31.   -r: reinstall an exisiting app, keeping its data.
  32.   -t: allow test .apks to be installed.
  33.   -i: specify the installer package name.
  34.   -s: install package on sdcard.
  35.   -f: install package on internal flash.

  36. The uninstall command removes a package from the system. Options:
  37.   -k: keep the data and cache directories around.
  38. after the package removal.

  39. The enable and disable commands change the enabled state of
  40. a given package or component (written as "package/class").

  41. The getInstallLocation command gets the current install location
  42.   0 [auto]: Let system decide the best location
  43.   1 [internal]: Install on internal device storage
  44.   2 [external]: Install on external media

  45. The setInstallLocation command changes the default install location
  46.   0 [auto]: Let system decide the best location
  47.   1 [internal]: Install on internal device storage
  48.   2 [external]: Install on external media
複製代碼

1.具體使用方法:
1.1:察看已安裝的包:
pm list package
顯示所有已經安裝的包名。pm

pm list package -f
也顯示相關文件所在目錄(即保存的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:列出指定包名的  相關 文件 (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:安裝到內部。


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
之後安裝之,沒有用。

後來做如下嘗試:
   在其它設置- > 儲存設備- > 制定默認存儲設備中選擇ü 盤為默認存儲設備。

     #pm install   -s xxxx.apk

就可以成功。

文章出處

 

臉書網友討論
*滑块验证:
您需要登錄後才可以回帖 登錄 | 註冊 |

本版積分規則



Archiver|手機版|小黑屋|免責聲明|TShopping

GMT+8, 2024-4-26 20:07 , Processed in 0.056581 second(s), 22 queries .

本論壇言論純屬發表者個人意見,與 TShopping綜合論壇 立場無關 如有意見侵犯了您的權益 請寫信聯絡我們。

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表