Skip to content

Instantly share code, notes, and snippets.

@p1r473
Forked from androidneha/adb_commands.MD
Created December 4, 2023 17:05
Show Gist options
  • Save p1r473/bf6635a44b78f547d216749a5ad1f166 to your computer and use it in GitHub Desktop.
Save p1r473/bf6635a44b78f547d216749a5ad1f166 to your computer and use it in GitHub Desktop.
Some adb commands to change setting for battery optimisation, start service, stop service, grant permission, revoke permission and etc.

To list-up installed app

pm list packages

Search for a particualr app with pacakagename

pm list pacakges | grep com.abc

Turn on Battery Optimization for a particular app

adb shell dumpsys deviceidle whitelist -<package_name>

Turn off Battery Optimization for a particular app

adb shell dumpsys deviceidle whitelist +<package_name>

To start a service

adb shell am startservice com.some.package.name/.YourServiceSubClassName

To start a service

adb shell am stopservice com.some.package.name/.YourServiceSubClassName

Grant Permission for ex WRITE_SECURE_STTINGS

adb shell pm grant com.abc.yourpackagename android.permission.WRITE_SECURE_SETTINGS

Revoke Permission for ex WRITE_SECURE_STTINGS

adb shell pm revoke com.abc.yourpackagename android.permission.WRITE_SECURE_SETTINGS

Enable accessibility

adb shell settings put secure enabled_accessibility_services packagname/servicename

Turn on Device admin

adb shell dpm set-active-admin --user current packagename/.receivers.DeviceAdministrationReceiver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment