Skip to content

Instantly share code, notes, and snippets.

@xgouchet
Created March 11, 2016 14:28
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save xgouchet/e46b634732eeb28ad1da to your computer and use it in GitHub Desktop.
Save xgouchet/e46b634732eeb28ad1da to your computer and use it in GitHub Desktop.
Shell script to toggle airplane mode on connected device
function adb_toggle_airplane_mode {
# Open airplane mode settings
adb shell am start -a android.settings.AIRPLANE_MODE_SETTINGS
# Key UP to focus on the first switch = toggle airplane mode, then sleep 100ms
adb shell input keyevent 19 ; sleep 0.1
# Key CENTER to toggle the first switch, then sleep 100ms
adb shell input keyevent 23 ; sleep 0.1
# Key BACK to close the settings
adb shell input keyevent 4
}
@xgouchet
Copy link
Author

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