Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adb command to open settings and change them

I'm looking for adb command to open settings and change them. For example: this command open display settings

adb shell am start -n com.android.settings/.DisplaySettings 

I want to go further in menu to Display output mode then choose 720P 60HZ

As my menu is like this on android tv box:

Settings > Display > Display output Mode > HDMI 720P60HZ etc

Is there a adb command to do this go through settings then choose 720P60Hz directly with shell ?

like image 410
Valmik Ahire Avatar asked Jan 21 '13 04:01

Valmik Ahire


3 Answers

Use this command to see a help on how you can use the settings adb shell command:

adb shell settings

Use get and put commands (after settings) to change the settings.

You will have to figure out the KEYs (use list) and acceptable VALUEs yourself (read documentation like https://developer.android.com/reference/android/provider/Settings.Global for the global NAMESPACE).

like image 101
pd12 Avatar answered Sep 21 '22 18:09

pd12


As far as I know ther is no such functionality. However, you can use the

adb shell input tap <x> <y>

command to trigger a touch event. Unfortunately, such code will not work device-indepently as the position of your settings on the screen depends on the device you are using.

Alternatively you can try the

adb shell input keyevent <19|20|21|22>

command to emulate curser events to select the setting you want to alter.

Finally, you can use

adb shell input keyevent 66

to trigger the enter key. This should work on all devices having the same options in the settings submenu.

like image 31
Claas Wilke Avatar answered Sep 19 '22 18:09

Claas Wilke


I'm not sure how to change the value directly, but to expand on another answer (and also because it sounds like this is what you're asking for), you can use adb to navigate through settings windows and pick different things in the UI. I've done that with some settings I can't seem to set a value from a single adb command. I just use the virtual Tab key to navigate through the menu items then press Enter to select a submenu or toggle an option.

I don't have an android tv box so I don't have the setting you do, but the commands would look something like this:

adb shell am start -a android.settings.DISPLAY_SETTINGS
adb shell input keyevent TAB
adb shell input keyevent TAB
adb shell input keyevent ENTER
adb shell input keyevent TAB
adb shell input keyevent TAB
adb shell input keyevent TAB
adb shell input keyevent TAB
adb shell input keyevent ENTER
adb shell am force-stop com.android.settings

You can try sending one tab command at a time to see how many you need to send before getting to the item you want.


Tips:

You can also use the Back button to go back a page:

adb shell input keyevent BACK

And you can use the arrow keys to navigate through confirmation popups (or move brightness/volume sliders):

adb shell input keyevent DPAD_RIGHT
adb shell input keyevent DPAD_LEFT
adb shell input keyevent DPAD_UP
adb shell input keyevent DPAD_DOWN

Here's a list of more key commands you can use (just look for the ones preceded by KEYCODE_, and remove that part. e.g. KEYCODE_BACK would be BACK as illustrated above):

https://developer.android.com/reference/android/view/KeyEvent

And here's a list of more direct settings windows you can launch:

https://stackoverflow.com/a/39873312

Copied here: (just precede them with adb shell am start -a to launch)

com.android.settings
com.android.settings.APPLICATION_DEVELOPMENT_SETTINGS
com.android.settings.DISPLAY_SETTINGS
com.android.settings.DOCK_SETTINGS
com.android.settings.QUICK_LAUNCH_SETTINGS
com.android.settings.SOUND_SETTINGS
com.android.settings.TTS_SETTINGS
com.android.settings.VOICE_INPUT_OUTPUT_SETTINGS
android.settings.ACCESSIBILITY_SETTINGS
android.settings.ACCOUNT_SYNC_SETTINGS
android.settings.ACCOUNT_SYNC_SETTINGS_ADD_ACCOUNT
android.settings.ADD_ACCOUNT_SETTINGS
android.settings.AIRPLANE_MODE_SETTINGS
android.settings.APN_SETTINGS
android.settings.APPLICATION_SETTINGS
android.settings.BLUETOOTH_SETTINGS
android.settings.DATA_ROAMING_SETTINGS
android.settings.DATE_SETTINGS
android.settings.DEVICE_INFO_SETTINGS
android.settings.DISPLAY_SETTINGS
android.settings.INPUT_METHOD_SETTINGS
android.settings.INTERNAL_STORAGE_SETTINGS
android.settings.LOCALE_SETTINGS
android.settings.LOCATION_SOURCE_SETTINGS
android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS
android.settings.MANAGE_APPLICATIONS_SETTINGS
android.settings.MEMORY_CARD_SETTINGS
android.settings.PRIVACY_SETTINGS
android.settings.SECURITY_SETTINGS
android.settings.SETTINGS
android.settings.SOUND_SETTINGS
android.settings.SYNC_SETTINGS
android.settings.SYSTEM_UPDATE_SETTINGS
android.settings.USER_DICTIONARY_SETTINGS
android.settings.WIFI_IP_SETTINGS
android.settings.WIFI_SETTINGS
android.settings.WIRELESS_SETTINGS
ACCESSIBILITY_FEEDBACK_SETTINGS
android.net.vpn.SETTINGS
android.search.action.SEARCH_SETTINGS
android.search.action.WEB_SEARCH_SETTINGS
like image 34
gamingexpert13 Avatar answered Sep 23 '22 18:09

gamingexpert13