Is there any adb command to enable developer options?
Asked Answered
A

3

16

Developer Options can be enabled by tapping 7 times on build number. I am using

adb shell input tap x y command to tap on build number. is there any adb command to tap on build number 7 times?

Aron answered 27/11, 2017 at 11:45 Comment(2)
Please check this Question : #18270269Elisha
Hi @kuldeepraj with "adb shell am start -n com.android.settings/.DevelopmentSettings" you can open the developer options but the user want have the developer optiones enabled (I think)Noisome
D
24

much easier way:

adb shell settings put global development_settings_enabled 1
Deracinate answered 27/11, 2017 at 15:23 Comment(6)
And for disable? I tried adb shell settings put global development_settings_enabled 0 but it doesn't workPuma
I think this has changed, starting with Android 4.2. Anyway, this answer doesn't work for me on Android 7.1, but @Olaia's does.Euphonious
the chicken and egg problem ... if development_settings aren't enabled, adb can't connect ;)Sherborn
This answer still works on Android 11 and Android 12 Beta. But note that as @ childno͡.de mentioned Developer options have to be enabled at least once for device to be recognised by the computer and the above command can then be executed for disabling/enabling the options.Clipboard
@childno͡.de «chicken and egg problem» shouldn't this also work in a terminal app? Without the adb shell prefix.Deist
sorry @Deist I don't get it? you need a connection to the device, that's what adb does. There is no other "API" by design, else someone could catch up your private device, enable dev mode and hack your data without any interaction. That's why I don't see that this is working for enabling as Siju mentioned. But yes, if it is enabled you might disable it programatically. Anything other is a big security flawSherborn
V
4

That info is stored in a shared preference of the settings app. Which is located at: /data/user_de/0/com.android.settings/shared_prefs/development.xml it has a boolean named show stored, if set to true, developer options is shown, gone otherwise.

If device IS ROOTED, you could do:

  1. adb root
  2. adb shell sed -i -e 's/false/true/g' data/user_de/0/com.android.settings/shared_prefs/development.xml
  3. adb shell chown system:system data/user_de/0/com.android.settings/shared_prefs/development.xml
  4. adb shell cat data/user_de/0/com.android.settings/shared_prefs/development.xml
  5. adb shell am force-stop com.android.settings

This is the explanation for each command:

  1. Make sure we are root
  2. We intend to change the value from false to true. There is only this value stored in that XML, in that sense it's save for now.
  3. Change the owner and group to system, because after we modified it, it was set to root:root.
  4. Verify the value is correctly set. (could be done before step 3, it doesn't matter)
  5. Kill settings app so we force it to read the value again.

If device is NOT rooted, I can not think of a way to accomplish this.

Even if we have a rooted device, this method is way longer than doing 7 keyevents through adb (after a swipe to the end). So I think you're better off with your current method. (Sorry to say)

Vocational answered 27/11, 2017 at 14:24 Comment(0)
A
0

FYI cannot enable developer option since device will not be connected with the pc.hence, adb command wont work if developer options is off. Although you can disable it using

" adb shell settings put global development_settings_enabled 0 "

Animato answered 14/3 at 9:42 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Mcgill

© 2022 - 2024 — McMap. All rights reserved.