In brief
Automating an already visible Quick Settings tile
# Click on a TileService of the specified component
cmd statusbar click-tile com.package.name/.service.QuickSettingsTileComponent
You may need to expand the status bar to show the quick settings
before it'll apply. Not sure why.
cmd statusbar expand-settings
sleep 0.25 # 250 ms or shorter may be enough
cmd statusbar collapse
Adding a Quick Settings tile and removing it after clicking
# Expand, add tile, wait for it to initialize
cmd statusbar expand-settings
cmd statusbar add-tile com.package.name/.service.QuickSettingsTileComponent
sleep 0.20
Click tile, wait for it to react
cmd statusbar click-tile com.package.name/.service.QuickSettingsTileComponent
sleep 0.35
Remove tile, collapse
cmd statusbar remove-tile com.package.name/.service.QuickSettingsTileComponent
cmd statusbar collapse
Guided walkthrough
Finding package name and component
Skip this if you already know how to find the QuickSettings Tile service.
Install an application like apps_Packages Info [F-Droid] to browse through the list of installed apps and all services.
Find the application whose tile you want to toggle and open the application details by tapping on it
- Example:
Digital Wellbeing
is com.google.android.apps.wellbeing
Expand the Services
dropdown in the application detail page
Find the tile service, which will have the permission android.permission.BIND_QUICK_SETTINGS_TILE
, then note down the component name
- Example:
Bedtime mode
(formerly Grayscale
) QS tile is .screen.ui.GrayscaleTileService
Make note of the full package name and component name, and fill out the command below:
cmd statusbar click-tile com.package.name/.service.QuickSettingsTileComponent
Example 1: to toggle Digital Wellbeing
's Bedtime mode
(formerly Grayscale
) QS tile…
cmd statusbar click-tile com.google.android.apps.wellbeing/.screen.ui.GrayscaleTileService
Example 2: to toggle Digital Wellbeing
's Focus Mode
QS tile…
cmd statusbar click-tile com.google.android.apps.wellbeing/.focusmode.quicksettings.FocusModeTileService
Automating the Quick Settings tile
On some versions of Android, toggling the Quick Settings tile via click-tile
won't apply until the Quick Settings section is expanded. As soon as the Quick Settings section is revealed, it'll work, even if the tile itself is placed on a secondary page of quick settings tiles (e.g. page 2).
This works even when the screen is locked if the QS tile doesn't require unlocking to toggle. However, the display must be on.
Try without expanding the Quick Settings section first, and if that doesn't work, try the expanding method instead.
General steps
If the Quick Settings tile is already added…
- Turn on screen if it's off
- Expand Quick Settings via
cmd statusbar expand-settings
- This might not be needed for you - try without first
- Run
cmd statusbar click-tile [component]
command discovered above
- Wait a short delay, e.g.
250 ms
- Optionally, close status bar via
cmd statusbar collapse
- Optionally, turn screen off if it wasn't already on
If you don't want to keep the Quick Settings tile around…
- Turn on screen if it's off
- Expand Quick Settings via
cmd statusbar expand-settings
- As before, this might not be needed - try without first
- Add the Quick Settings tile via
cmd statusbar add-tile [component]
- Wait a short delay, e.g.
200 ms
- Run
cmd statusbar click-tile [component]
command discovered above
- Wait a short delay, e.g.
350 ms
- Run
cmd statusbar remove-tile [component]
- Optionally, close status bar via
cmd statusbar collapse
- Optionally, turn screen off if it wasn't already on
Example shell script (with Tasker counterpart)
If the Quick Settings tile is already added…
# Wake up device
input keyevent KEYCODE_WAKEUP
#
# Tasker: Add Action -> Display -> Turn On
Expand the Quick Settings section of the status bar
cmd statusbar expand-settings
Tasker: Add Action -> Code -> Run Shell, copy above
Click on a TileService of the specified component
cmd statusbar click-tile com.package.name/.service.QuickSettingsTileComponent
Tasker: Add Action -> Code -> Run Shell, copy above, check "Use Root"
Wait for click to register, 350 ms or shorter may be enough
sleep 0.35
Tasker: Add Action -> Task -> Wait, then set delay to 350 ms
Optional: collapse status bar
This won't work when on the lockscreen, but turning the screen off
also collapses the status bar for you.
cmd statusbar collapse
Tasker: Add Action -> Code -> Run Shell, copy above
Optional: put device to sleep
(Up to you: only turn off if the screen wasn't already on.)
input keyevent KEYCODE_POWER
Tasker: Add Action -> Display -> Turn Off, enabling "Lock"
If you don't want to keep the Quick Settings tile around…
# Wake up device
input keyevent KEYCODE_WAKEUP
#
# Tasker: Add Action -> Display -> Turn On
Expand the Quick Settings section of the status bar
cmd statusbar expand-settings
Tasker: Add Action -> Code -> Run Shell, copy above
Add the TileService of the specified component, click on it, then
remove it
'sleep' gives time for the tile to initialize and the click to
register, 200 ms or shorter may be enough
cmd statusbar add-tile com.package.name/.service.QuickSettingsTileComponent
sleep 0.20
cmd statusbar click-tile com.package.name/.service.QuickSettingsTileComponent
sleep 0.35
cmd statusbar remove-tile com.package.name/.service.QuickSettingsTileComponent
Tasker: Add Action -> Code -> Run Shell, copy above, check "Use Root"
No need to wait for click to register, waiting was done above
Optional: collapse status bar
This won't work when on the lockscreen, but turning the screen off
also collapses the status bar for you.
cmd statusbar collapse
Tasker: Add Action -> Code -> Run Shell, copy above
Optional: put device to sleep
(Up to you: only turn off if the screen wasn't already on.)
input keyevent KEYCODE_POWER
Tasker: Add Action -> Display -> Turn Off, enabling "Lock"
NOTE: root or ADB is required!
If you are using an automation app rather than adb shell
, cmd statusbar add-tile/click-tile/remove-tile
must be run with root or via e.g. ADB WiFi actions.
The other cmd statusbar
commands may be run without root.
Tasker/etc have non-root options for waking the screen and putting it to sleep.
Other details
cmd statusbar click-tile
appears to have been added with Android 7.0, so this should work ever since custom quick setting tiles were officially added to Android.
I've not found any way to read the Quick Settings tile state, e.g. active/on or inactive/off. To work around this, I've checked logcat
and app notifications via dumpsys notification
to see what's running or paused.
I've also not found out how to toggle the built-in Android System Quick Settings tiles; fortunately, most of them appear to be achievable via other means (secure settings, service calls, etc).