1

ADB + Airplane Mode

To enable permission for toggle Airplane Mode only requires an ADB appops command be run only once. I have verified this using appops, that after device reboot, Tasker retains permission to toggle Airplane Mode without re-enabling ADB wifi.

Yet trying to toggle Airplane Mode in Tasker will fail due to ADB Wifi not being on. Tasker does not attempt to toggle Airplane Mode, even though it already has permission.

If Tasker can retain permissions, then enabling ADB Wifi after reboot appears unnecessary.

Thank you

2 replies

Hi. What appops permission can be set to allow Airplane mode exactly?

G

Sorry, I did have posted this originally, but didn't have the information on hand. I just looked it up.

    appops set net.dinglisch.android.taskerm CHANGE_WIFI_STATE allow

    appops set net.dinglisch.android.taskerm CHANGE_NETWORK_STATE allow

https://developer.android.com/reference/kotlin/android/Manifest.permission

Thanks. And what commands do you do after granting those permissions to toggle Airplane Mode exactly?

G

After granting Network permission, The commands I use are the standard Airplane On/Off in Tasker.

But there's the bug, because even though it has permission, Tasker won't act on the commands if ADB Wifi is not enabled.

G

I apologize for not explaining things clearly in the first message. Additionally, I would expect permissions from pm grant to carry over between reboots as well

But those permissions don't allow an app to toggle Airplane Mode at least as far as I'm aware. ADB Wifi is still needed. Or did you find otherwise? Do you have some documentation on that perhaps?

G

Sorry João, I wish I could give more information, but I don't do programming on Android. Everything explained here could be completely wrong, But we should be able to test it. Exactly what adb command does Tasker use to gain permission to toggle Airplane Mode?

We can use adb to see if that permission carries over between reboots

ADB doesn't use any special permission :) It simply executes a command that a normal app can't because the "shell" user in ADB is able to do stuff that normal apps can't, particularly broadcasting the 

"android.intent.action.AIRPLANE_MODE"

action which makes this work.

G

Very curious, because when I issue 'am broadcast -a android.intent.action.AIRPLANE_MODE' from within Tasker, I get an error

Permission Denial: not allowed to send broadcast

How is it possible that you say Tasker executes this command, but I try to run it directly and cannot?

Because Tasker uses ADB Wifi to execute it :) That's the only way it works.

G

Yes, that's what I meant. I ran 'am broadcast -a android.intent.action.AIRPLANE_MODE' using ADB Wifi in Tasker. But I get that error. Why might this be?

Running the Tasker action "Toggle Airplane Mode" works.

That's strange. It works on mine 😯 I don't know why it wouldn't work on yours if the Airplane Mode action works!

G

Wait what? You're saying running it as Wifi ADB command works for you? Please double check, is my syntax correct? I just ran it again and got the same error, but the Airplane Mode Action works just fine. I don't understand.

I don't understand either :/ It does work for me...