Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save beebird/41298f449e7d781bf442f86c8b37174c to your computer and use it in GitHub Desktop.
Save beebird/41298f449e7d781bf442f86c8b37174c 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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment