Skip to content

ADB Reference

Anonymoussaurus edited this page Mar 24, 2024 · 3 revisions

Android SDK API Release Note

Some notes

  • pm disable-user is supported since Android 4.0 (SDK API 14) but root privileges is needed before Android 6.0.
  • I was surprised to see that the multi-user system was already a thing since Android 4.2 (SDK API 17). This means we can use pm disable-user [--user USER_ID] (but with root).
  • pm block/unblock [--user USER_ID] only exists on Android 4.4 (SDK API 19-20)
  • pm hide/unhide [--user USER_ID] has been introduced in Android 5.0 (SDK API 20/21) and is a replacement of pm block/unblock. Needs root since Android 6.0

pm block (Android 4.4 only) [SDK API 19-20]

Puts the package in a blocked state, which is almost like an uninstalled state making the package unavailable, but it doesn't remove the data or the actual package file.

The adb command calls the runSetBlockedSetting(boolean state) private method (ref) which then calls the setApplicationBlockedSettingAsUser(...) method of the package manager (ref)

pm hide (Android 5+) [SDK API 21]

Puts the package in a hidden state, which is almost like an uninstalled state, making the package unavailable, but it doesn't remove the data or the actual package file. Application can be unhidden by either resetting the hidden state or by installing it

The adb command calls the runSetHiddenSetting(boolean state) private method (ref) which then calls the setApplicationHiddenSettingAsUser(...) method of the package manager (ref)

pm disable-user (Android 4.0+) [SDK API 18]

The user has explicitly disabled the application, regardless of what it has specified in its manifest. Because this is due to the user's request, they may re-enable it if desired through the appropriate system UI. Source

The adb commands calls runSetEnabledSetting(PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER) (ref) which then calls the setComponentEnabledSetting(...) method of the package manager to enforce the new state. (ref)