The default user version does not have "developer Options", we can display the developer mode by clicking on the version number 7 times, and see how the code is handled today:
The first is the initialization of the Packages/apps/settings/src/com/android/settings/settings.java:
Boolean Showdev whether the developer options are displayed by default:
Final Boolean Showdev = Mdevelopmentpreferences.getboolean ( developmentsettings.pref_show, Android.os.Build.TYPE.equals ("eng"));
If you want the developer option to display by default, you do not need to click the 7 version number, you can directly set the Showdev to true:
If Showdev is false, the developer options are hidden in the following code:
if (id = = r.id.development_settings) { if (!showdev) { target.remove (i); }
Here's a look at the section showing developer options by clicking on the version number:
Code path: Packages/apps/settings/src/com/android/settings/deviceinfosettings.java
The first is to define the number of clicks:
static final int taps_to_be_a_developer = 7;
Click the version number of the processing logic, if the Mdevhitcountdown is less than 0, it means that "developer Options" has been shown, refer to the processing of the resume function:
if (Preference.getkey (). Equals (Key_build_number)) {//Don ' t enable developer options for secondary users. if (Userhandle.myuserid () = Userhandle.user_owner) return true; if (Mdevhitcountdown > 0) {if (Mdevhitcountdown = = 1) {if (super.ensurepinrestricte Dpreference (preference)) {return true; }} mdevhitcountdown--; if (Mdevhitcountdown = = 0) {getactivity (). Getsharedpreferences (Developmentsettings.pref_file, context.mode_private). Edit (). Putboolean (Developmentsettings.pref_sh OW, True). Apply (); if (mdevhittoast! = null) {Mdevhittoast.cancel (); } mdevhittoast = Toast.maketext (Getactivity (), r.string.show_dev_on, TOAST.L Ength_long); Mdevhittoast.show (); } else if (Mdevhitcountdown > 0 && mdevhitcountdown < (taps_to_be_a_developer-2)) { if (mdevhittoast! = null) {Mdevhittoast.cancel (); } mdevhittoast = Toast.maketext (Getactivity (), Getresources (). Getquantitystring ( R.plurals.show_dev_countdown, Mdevhitcountdown, Mdevhitcountdown), toast.length_short); Mdevhittoast.show (); }} else if (Mdevhitcountdown < 0) {if (mdevhittoast! = null) {Mdevhitto Ast.cancel (); } mdevhittoast = Toast.maketext (Getactivity (), R.string.show_dev_already, Toast.leng Th_long); Mdevhittoast.show (); } }
Resume function:
@Override public void Onresume () { super.onresume (); Preferencegroup parentpreference = Getpreferencescreen (); Mdevhitcountdown = Getactivity (). Getsharedpreferences (Developmentsettings.pref_file, Context.MODE_PRIVATE). Getboolean (Developmentsettings.pref_show, android.os.Build.TYPE.equals ("eng")) -1:taps_to_be_a_developer; Mdevhittoast = null; }
Reprint Please specify source: Zhou Mushi's csdn blog Http://blog.csdn.net/zhoumushui
My github: Zhou Mushi's GitHub Https://github.com/zhoumushui
Android setting logic to show developer options