Android系統移植與除錯之-------)如何修改Android系統預設顯示
1、首先解決【設定】介面預設顯示【開發者選項】的問題
檢視原始碼:packages/apps/Settings/src/com/android/settings/SettingsActivity.java
在updateTilesList(List target)方法中,可以找到【開發者選項】相關的程式碼:
?1 2 3 4 5 6 7 |
else if
(id == R.id.development_settings) {
Log.d(LOG_TAG,
=================oyp K=+showDev); if (!showDev
|| um.hasUserRestriction(
UserManager.DISALLOW_DEBUGGING_FEATURES))
{
removeTile
= true ;
}
}
|
其中showDev變數定義在該方法最開始處
1 2 3 |
final boolean
showDev = mDevelopmentPreferences.getBoolean(
DevelopmentSettings.PREF_SHOW, android.os.Build.TYPE.equals(eng));
|
因此要想特定客戶直接顯示【開發者選項】,則將showDev的值改變即可,程式碼如下:
1 2 3 4 5 6 7 8 9 10 11 |
//added
by ouyang 2015-11-10 set DevelopmentSettings.PREF_SHOW=true if model is J5
if (android.os.SystemProperties.isJ5Version())
{ SharedPreferences.Editor
editor=mDevelopmentPreferences.edit();
editor.putBoolean(DevelopmentSettings.PREF_SHOW, true );
editor.commit();
Log.d(LOG_TAG,
=================oyp set DevelopmentSettings.PREF_SHOW= true if
model is J5 );
}
//added
by ouyang 2015-11-10 end
final boolean
showDev = mDevelopmentPreferences.getBoolean(
DevelopmentSettings.PREF_SHOW,
android.os.Build.TYPE.equals(eng));
|
即在初始化showDev變數之前,將DevelopmentSettings.PREF_SHOW的值設定為true,那麼showDev也會是true。這樣【開發者選項】就會預設開啟。那個判斷是J5客戶的方法在/frameworks/base/core/java/android/os/SystemProperties.java中定義