[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
- static final int TAPS_TO_BE_A_DEVELOPER = 7;
- public void onResume() {
- super.onResume();
- 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;
- }
- public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
- ......
- if (mDevHitCountdown > 0) {
- mDevHitCountdown--;
- if (mDevHitCountdown == 0) {
- getActivity().getSharedPreferences(DevelopmentSettings.PREF_FILE,
- Context.MODE_PRIVATE).edit().putBoolean(
- DevelopmentSettings.PREF_SHOW, true).apply();
- if (mDevHitToast != null) {
- mDevHitToast.cancel();
- }
- mDevHitToast = Toast.makeText(getActivity(), R.string.show_dev_on,
- Toast.LENGTH_LONG);
- mDevHitToast.show();
- // This is good time to index the Developer Options
- Index.getInstance(
- getActivity().getApplicationContext()).updateFromClassNameResource(
- DevelopmentSettings.class.getName(), true, true);
- } 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) { //点击完7次之后显示
- if (mDevHitToast != null) {
- mDevHitToast.cancel();
- }
- mDevHitToast = Toast.makeText(getActivity(), R.string.show_dev_already,
- Toast.LENGTH_LONG);
- mDevHitToast.show();
- }
- }
- ......
- }
而默认开机是否显示由变量showDev控制
packages\apps\Settings\src\com\android\settings\SettingsActivity.java
- private void updateTilesList(List<DashboardCategory> target) {
- final boolean showDev = mDevelopmentPreferences.getBoolean(
- DevelopmentSettings.PREF_SHOW,
- android.os.Build.TYPE.equals("eng")); //因此eng才返回true
- ......
- } else if (id == R.id.development_settings) {
- if (!showDev || um.hasUserRestriction(
- UserManager.DISALLOW_DEBUGGING_FEATURES)) {
- removeTile = true; //showDev为false则不显示
- }
- }
- }
解决方法:
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;