Android下pm命令詳解

2021-09-06 19:05:36 字數 4374 閱讀 8807

在看相關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 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

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盤中:

首先嘗試使用:

pm setinstalllocation 2

之後安裝之,沒有用。

後來做如下嘗試:

在其它設定->儲存裝置->制定預設儲存裝置中選擇u盤為預設儲存裝置。

# pm install -s ***x.apk

就可以成功。

Android下pm 命令詳解

sam在看相關packagemanager 時,無意中發現android 下提供乙個pm命令,通常放在 system bin 下。這個命令與package有關,且非常實用。所以研究之。0.usage usage pm list path install uninstall pm list packa...

Android下PM命令常見使用方法

1.1 察看已安裝的包 pm list package 此時則顯示所有已經安裝的包名。pm list package f 也顯示associated檔案所在目錄 即儲存的apk檔案 1.2 察看已知的許可權組 pm list permission groups 1.3 察看所有已知的許可權 pm l...

Android下logcat用法詳解

android日誌系統提供了記錄和檢視系統除錯資訊的功能。日誌都是從各種軟體和一些系統的緩衝區中記錄下來的,緩衝區可以通過 logcat 命令來檢視和使用.一 使用logcat命令的目的 1 你可以用 logcat 命令來檢視系統日誌緩衝區的內容 adb logcat 詳細內容,請檢視listing...