[RK3288][Android6.0] 调试笔记 --- user版本默认显示开发者选项【转】

本文转载自:https://blog.csdn.net/kris_fei/article/details/70157137

Platform: ROCKCHIP
OS: Android 6.0
Kernel: 3.10.92

默认user版本不显示开发者选项这一栏,需要通过连续点击版本号7次来显示.
packages\apps\Settings\src\com\android\settings\DeviceInfoSettings.java

[cpp] view plain copy
 
  1. static final int TAPS_TO_BE_A_DEVELOPER = 7;  
  2.   
  3. public void onResume() {  
  4.     super.onResume();  
  5.     mDevHitCountdown = getActivity().getSharedPreferences(DevelopmentSettings.PREF_FILE,  
  6.             Context.MODE_PRIVATE).getBoolean(DevelopmentSettings.PREF_SHOW,  
  7.                     android.os.Build.TYPE.equals("eng")) ? -1 : TAPS_TO_BE_A_DEVELOPER;  
  8.     mDevHitToast = null;  
  9. }  
  10.   
  11.  public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {  
  12.  ......  
  13.      if (mDevHitCountdown > 0) {  
  14.         mDevHitCountdown--;  
  15.         if (mDevHitCountdown == 0) {  
  16.             getActivity().getSharedPreferences(DevelopmentSettings.PREF_FILE,  
  17.                     Context.MODE_PRIVATE).edit().putBoolean(  
  18.                             DevelopmentSettings.PREF_SHOW, true).apply();  
  19.             if (mDevHitToast != null) {  
  20.                 mDevHitToast.cancel();  
  21.             }  
  22.             mDevHitToast = Toast.makeText(getActivity(), R.string.show_dev_on,  
  23.                     Toast.LENGTH_LONG);  
  24.             mDevHitToast.show();  
  25.             // This is good time to index the Developer Options  
  26.             Index.getInstance(  
  27.                     getActivity().getApplicationContext()).updateFromClassNameResource(  
  28.                             DevelopmentSettings.class.getName(), true, true);  
  29.   
  30.         } else if (mDevHitCountdown > 0  
  31.                 && mDevHitCountdown < (TAPS_TO_BE_A_DEVELOPER-2)) {  
  32.             if (mDevHitToast != null) {  
  33.                 mDevHitToast.cancel();  
  34.             }  
  35.             mDevHitToast = Toast.makeText(getActivity(), getResources().getQuantityString(  
  36.                     R.plurals.show_dev_countdown, mDevHitCountdown, mDevHitCountdown),  
  37.                     Toast.LENGTH_SHORT);  
  38.             mDevHitToast.show();  
  39.         }  
  40.         } else if (mDevHitCountdown < 0) { //点击完7次之后显示  
  41.             if (mDevHitToast != null) {  
  42.                 mDevHitToast.cancel();  
  43.             }  
  44.             mDevHitToast = Toast.makeText(getActivity(), R.string.show_dev_already,  
  45.                     Toast.LENGTH_LONG);  
  46.             mDevHitToast.show();  
  47.         }  
  48.     }  
  49. ......  
  50. }  


而默认开机是否显示由变量showDev控制
packages\apps\Settings\src\com\android\settings\SettingsActivity.java

[cpp] view plain copy
 
  1. private void updateTilesList(List<DashboardCategory> target) {  
  2.     final boolean showDev = mDevelopmentPreferences.getBoolean(  
  3.             DevelopmentSettings.PREF_SHOW,  
  4.             android.os.Build.TYPE.equals("eng"));    //因此eng才返回true  
  5. ......  
  6.     } else if (id == R.id.development_settings) {  
  7.         if (!showDev || um.hasUserRestriction(  
  8.                 UserManager.DISALLOW_DEBUGGING_FEATURES)) {  
  9.             removeTile = true;    //showDev为false则不显示  
  10.         }  
  11.     }  
  12. }  


解决方法:
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 645add3..11a9c55 100755
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -1236,9 +1236,11 @@ public class SettingsActivity extends Activity
     }
 
     private void updateTilesList(List<DashboardCategory> target) {
-        final boolean showDev = mDevelopmentPreferences.getBoolean(
-                DevelopmentSettings.PREF_SHOW,
-                android.os.Build.TYPE.equals("eng"));
+       /*Kris, 170413, show development options anytime.*/
+      //  final boolean showDev = mDevelopmentPreferences.getBoolean(
+           //     DevelopmentSettings.PREF_SHOW,
+                //android.os.Build.TYPE.equals("eng"));
+         final boolean showDev = true;

posted @ 2018-06-05 17:46  请给我倒杯茶  阅读(598)  评论(0编辑  收藏  举报