Turning airplane mode on via ADB

后端 未结 15 1660
暖寄归人
暖寄归人 2020-12-01 06:43

I\'ve looked all over and I haven\'t found a concrete answer to this question. I\'m hoping to find a way to toggle airplane mode from ADB that doesn\'t involve the GUI in an

15条回答
  •  星月不相逢
    2020-12-01 07:11

    If you have root access, and the method in the answer from David Ferenczy Rogožan left you with a security exception:

    Permission Denial: not allowed to send broadcast android.intent.action.AIRPLANE_MODE
    

    you can try to run the commands as superuser as follows.

    Enable Airplane Mode

    adb shell "su -c 'settings put global airplane_mode_on 1'"
    adb shell "su -c 'am broadcast -a android.intent.action.AIRPLANE_MODE'"
    

    Disable Airplane Mode

    adb shell "su -c 'settings put global airplane_mode_on 0'"
    adb shell "su -c 'am broadcast -a android.intent.action.AIRPLANE_MODE'"
    

    In my experience with Android 9 the explicit invoke of su was only necessary for the broadcasting command while for the former I could keep:

    adb shell settings put global airplane_mode_on [0|1]
    

    Credits to Arya who left this trick into the comment section of the answer mentioned above.

提交回复
热议问题