Skip to content

Instantly share code, notes, and snippets.

@androidneha
Last active November 7, 2025 06:00
Show Gist options
  • Select an option

  • Save androidneha/896ec6b08137ef75a95341550b9c60fc to your computer and use it in GitHub Desktop.

Select an option

Save androidneha/896ec6b08137ef75a95341550b9c60fc 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`
@jacko9000
Copy link

You have the + and - the wrong way round for battery optimization; it is + to turn off battery optimization.

@opus-x
Copy link

opus-x commented Dec 23, 2022

You have the + and - the wrong way round for battery optimization; it is + to turn off battery optimization.

Indeed

@androidneha
Copy link
Author

You have the + and - the wrong way round for battery optimization; it is + to turn off battery optimization.

Thanks

@aIecxs
Copy link

aIecxs commented Feb 20, 2023

still there are six more typos, but thx it was what I was looking for ;)

@binarynoise
Copy link

adb shell settings put secure enabled_accessibility_services packagname/servicename

this will disable all the other accessibility services, you need to concat them with : (like with $PATH)

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