zoukankan      html  css  js  c++  java
  • [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次来显示.
    packagesappsSettingssrccomandroidsettingsDeviceInfoSettings.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控制
    packagesappsSettingssrccomandroidsettingsSettingsActivity.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;

  • 相关阅读:
    [WCF权限控制]模拟(Impersonation)与委托(Delegation)[上篇]
    深入剖析授权在WCF中的实现[共14篇]
    模拟在WCF中的应用
    WCF服务端运行时架构体系详解[下篇]
    WCF运行时框架的构建与扩展[共10篇]
    如何在EHAB(EntLib)中定义”细粒度”异常策略?
    WCF服务端运行时架构体系详解[续篇]
    《WCF服务编程》关于“队列服务”一个值得商榷的地方
    vs2005入门 之 结构化数据类型[一](数组)[视频]
    Atlas入门UpdateProgress(利用GridView翻页)[视频]
  • 原文地址:https://www.cnblogs.com/zzb-Dream-90Time/p/9141000.html
Copyright © 2011-2022 走看看