When looking at the relevant Packagemanager code, inadvertently found under Android provides a PM command, usually placed under/system/bin/. This command is related to the package and is very useful. So the study.
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 would see.
The list Instrumentation command prints all instrumentations,
Or only those this 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 in 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 it 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
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
1 [internal]: Install on internal device storage
2 [external]: Install on external media
1. Specific Use method:
1.1: Look at the installed packages:
PM List Package
This displays all installed package names.
PM List package-f
Also displays the directory where the associated file is located (that is, the saved apk file)
1.2: Look at a known permission group:
PM List permission-groups
1.3: Look at all known permissions:
PM List Permissions
1.4: List all hardware-related information:
PM List Features
The results are usually similar:
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: The associated file (apk archive file) that lists the specified package name is located:
For example:
PM Path com. Tdijoy.fane
Package:/mnt/asec/com. tdijoy.fane-1/pkg.apk
1.6: Install APK:
PM install [-l] [-r] [-T] [-I installer_package_name] [-S] [-f] PATH
Path refers to the absolute path and file name of the APK file.
For example:
PM INSTALL/DATA/3DIJOY_FANE.APK
These several parameters are useful:
-r: Install an already installed APK to keep its data intact.
-I: Specifies the package name for the installation. (did not try to come out)
-S: Installed on the sdcard.
-F: Install to internal flash.
1.7: Uninstall APK:
PM Uninstall package name.
For example:
PM Uninstall COM. Tdijoy.fane
1.8: Get and set the default installation location:
The getinstalllocation command gets the current install location
0 [Auto]: let system decide
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
1 [internal]: Install on internal device storage
2 [external]: Install on external media
PM Getinstalllocation
Get the default installation location.
Set up:
PM Setinstalllocation <0|1|2>
0: Automatic.
1: Internal Flash.
2: Extended storage device.
Example: How to install the APK into a USB flash drive on Hisense 2.2 STB:
Sam first tries to use:
PM Setinstalllocation 2
After installation, it is useless.
Later try to do the following:
* Select the USB flash drive as the default storage device in the default storage device, such as storage device, other settings.
# PM Install-s xxxx.apk*
will be successful.
Android PM Command Detailed