How can I emulate pressing another application's Quick Settings tile? I'd like to programatically press another application's Quick Settings Tile, e.g. from the shell or Tasker.



In this particular case, I'd like to press ProtonVPN's tile in order to automate connecting and disconnecting.

After tearing apart the app, I found that I could reliably disconnect the VPN with:

su root -c am start-foreground-service -n com.protonvpn.android/org.strongswan.android.logic.CharonVpnService -a android.net.VpnService.DISCONNECT


I can sometimes connect with:

su root -c am start-foreground-service -n com.protonvpn.android/org.strongswan.android.logic.CharonVpnService -a android.net.VpnService


However, this is not very reliable as it's an internal mechanism that bypasses much of what the app does in the process of properly establishing a Quick Connect connection.

If there's an intent that will simulate what occurs when an app's tile is pressed, it should provide a much cleaner solution.

In this instance, the app has the service com.protonvpn.android.components.QuickTileService and an intent action filter of android.service.quicksettings.action.QS_TILE however I'm at a loss for where to go from there.
I'm stepping out of my comfort zone with this one, but seeing as no one else has had any input, I thought I may as well mention it for you to test:

1) Go to G Play Market and install Nova Launcher.
2) Skip all the setup and go straight to Home screen with Nova as default launcher (since you're just testing functionality at this point)
3) Long press your background and select Widgets, then scroll down to Nova Launcher and find the "Activity" widget (for me it's the second widget); long-press then drag to an empty space on Home Screen
4) Once you let go to set the widget, an overlay prompt will come into focus and start loading.  Depending on your device and number of apps installed, this may take a minute or two, so don't be alarmed.  Once it finishes loading, scroll down to your app and locate the activity thread you're looking for and select it (you can long-press them one by one to test the function as well, it will return you back to the previous overlay prompt if the thread didn't cause a crash...if it does, you'll have to restart from step 3.  

I always thought it was a neat function but never got around to testing what it was capable of doing.  Hope this works out for you!

NOTE: I am enrolled in the Beta, and have the Prime (paid) version, so I'm not sure if that might affect this specific function or not.  You can likely purchase for testing and request refund if necessary.