默认第一次开机屏幕亮度/日期格式/picture makeer model
最后更新于:2022-04-01 14:48:35
今天给大家分享下关于修改MTK平台下系统首次开机的默认屏幕背光亮度,系统语言默认英语情况下修改日期格式,修改拍照属性,具体修改的地方不清楚或者没人告知的
话,请参照之前几篇博客的方法分享,现在直接进入主题
首先我们来修改第一次开机的屏幕亮度
①修改首次开机的系统默认屏幕背光亮度,我是在该java下修改的------(把注释的地方都去掉,因为注释的地方都是修改了的)
packages\apps\Settings\src\com.mediatek.settings\RestoreRotationReceiver.java
~~~
// private SharedPreferences mSharedPreferences;
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.v("RestoreRotationReceiver_IPO", action);
// mSharedPreferences = context.getSharedPreferences("walpad_first_run",Context.MODE_PRIVATE);
if (action.equals(Intent.ACTION_BOOT_COMPLETED)
|| action.equals("android.intent.action.ACTION_BOOT_IPO")) {
sRestoreRetore = Settings.System.getInt(context
.getContentResolver(),
Settings.System.ACCELEROMETER_ROTATION_RESTORE, 0) != 0;
// Engineer-Jsp add Unknown sources and Usb debugging default true
if (android.os.SystemProperties.isWalPadVersion() && !isFirstRunSettings(context)) {
// reboot first default unkonwn sources check
Settings.Global.putInt(context.getContentResolver(), Settings.Global.INSTALL_NON_MARKET_APPS,1);
// reboot first default usb debugging check
Settings.Global.putInt(context.getContentResolver(),Settings.Global.ADB_ENABLED, 1);
// save first reboot falgs boolean
// mSharedPreferences.edit().putString("isfirstrun", String.valueOf(true)).commit();
// firstrun defaulr birghtness value for 100%
// setWalpadCFirstRunDefaultBrightness(context);
}
if (sRestoreRetore) {
Settings.System.putInt(context.getContentResolver(),
Settings.System.ACCELEROMETER_ROTATION, 1);
Settings.System.putInt(context.getContentResolver(),
Settings.System.ACCELEROMETER_ROTATION_RESTORE, 0);
}
}
}
/**
* ***- MTK-6582-8382© -***
* isFirstRunSettings(Context context)
* walpad c firstrun need default false
* Engineer-Jsp add
* */
public boolean isFirstRunSettings(Context context){
if (TextUtils.isEmpty(mSharedPreferences.getString("isfirstrun", ""))) {
mSharedPreferences.edit()
.putString("isfirstrun", String.valueOf(false))
.commit();
}
return Boolean.valueOf(mSharedPreferences.getString("isfirstrun", ""));
}
/**
* ***- MTK-6582-8382© -***
* setWalpadCFirstRunDefaultBrightness(Context context)
* walpad c firstrun need default settings brightness value for 100%
* Engineer-Jsp add
* */
public void setWalpadCFirstRunDefaultBrightness(Context context){
try{
Uri uri = Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS);
Settings.System.putInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, 255);
context.getContentResolver().notifyChange(uri, null);
} catch (Exception localException){
localException.printStackTrace();
}
}
~~~
背光值最大 255 ,所以我们设置到最大就OK,意思是100%屏幕亮度,执行条件是我自己写的,分别是 android.os.SystemProperties.isWalPadVersion(),这个函数也是
我在系统代码里自己添加的,前面几篇博客也有提到,这里就不细说了,首次开机的记录,因为我们只需要第一次开机设置100%的屏幕亮度
②日期格式修改
packages\apps\Settings\src\com\android\settings\DateTimeSettings.java
~~~
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.date_time_prefs);
initUI();
/// M: get plug in and move roaming time setting into date and time settings @{
mExt = UtilsExt.getDateTimeSettingsPlugin(getActivity());
mExt.customizePreferenceScreen(getActivity(), getPreferenceScreen());
/// @}
}
~~~
修改initUI之前的原始系统代码:
~~~
private void initUI() {
boolean autoTimeEnabled = getAutoState(Settings.Global.AUTO_TIME);
boolean autoTimeZoneEnabled = getAutoState(Settings.Global.AUTO_TIME_ZONE);
///M: MTK use ListPreference instead of google CheckboxPerference
......
String [] dateFormats = getResources().getStringArray(R.array.date_format_values);
String [] formattedDates = new String[dateFormats.length];
String currentFormat = getDateFormat();
// Initialize if DATE_FORMAT is not set in the system settings
// This can happen after a factory reset (or data wipe)
if (currentFormat == null) {
currentFormat = "";
}
// Prevents duplicated values on date format selector.
mDummyDate.set(mDummyDate.get(Calendar.YEAR), mDummyDate.DECEMBER, 31, 13, 0, 0);
for (int i = 0; i < formattedDates.length; i++) {
String formatted =
DateFormat.getDateFormatForSetting(getActivity(), dateFormats[i])
.format(mDummyDate.getTime());
if (dateFormats[i].length() == 0) {
formattedDates[i] = getResources().
getString(R.string.normal_date_format, formatted);
} else {
formattedDates[i] = formatted;
}
}
mDateFormat.setEntries(formattedDates);
mDateFormat.setEntryValues(R.array.date_format_values);
mDateFormat.setValue(currentFormat);
......
}
~~~
原始getDateFormat():
~~~
private String getDateFormat() {
return Settings.System.getString(getContentResolver(),
Settings.System.DATE_FORMAT);
}
~~~
修改如下(修改为日期格式默认日月年):
initUI:
~~~
private void initUI() {
boolean autoTimeEnabled = getAutoState(Settings.Global.AUTO_TIME);
boolean autoTimeZoneEnabled = getAutoState(Settings.Global.AUTO_TIME_ZONE);
///M: MTK use ListPreference instead of google CheckboxPerference
......
String [] dateFormats = getResources().getStringArray(R.array.date_format_values);
String [] formattedDates = new String[dateFormats.length];
String currentFormat = getDateFormat(dateFormats[2]);
// Initialize if DATE_FORMAT is not set in the system settings
// This can happen after a factory reset (or data wipe)
if (currentFormat == null) {
currentFormat = "";
}
// Prevents duplicated values on date format selector.
mDummyDate.set(mDummyDate.get(Calendar.YEAR), mDummyDate.DECEMBER, 31, 13, 0, 0);
for (int i = 0; i < formattedDates.length; i++) {
String formatted =
DateFormat.getDateFormatForSetting(getActivity(), dateFormats[i])
.format(mDummyDate.getTime());
if (dateFormats[i].length() == 0) {
formattedDates[i] = getResources().
getString(R.string.normal_date_format, formatted);
} else {
formattedDates[i] = formatted;
}
}
mDateFormat.setEntries(formattedDates);
mDateFormat.setEntryValues(R.array.date_format_values);
mDateFormat.setValue(currentFormat);
......
}
~~~
修改DateFormat():
~~~
private String getDateFormat(String format) {
// Engineer-Jsp add walpad c default date format
if(android.os.SystemProperties.isWalPadVersion()){
Settings.System.putString(getContentResolver(),
Settings.System.DATE_FORMAT, format);
}
return Settings.System.getString(getContentResolver(),
Settings.System.DATE_FORMAT);
}
~~~
R.array.date_format_values:
~~~
<string-array name="date_format_values" translatable="false">
<!-- The blank item means to use whatever the locale calls for. -->
<item></item>
<item>MM-dd-yyyy</item>
<item>dd-MM-yyyy</item>
<item>yyyy-MM-dd</item>
<item>EE-MMM-d-yyyy</item>
<item>EE-d-MMM-yyyy</item>
<item>yyyy-MMM-d-EE</item>
</string-array>
~~~
dateFormats[2] == <item>dd-MM-yyyy</item>
③picture makeer model ,修改 buildinfo.sh 文件,model\product 属性
修改之前:
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a42fece.jpg)
修改之后:
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a4514dc.jpg)
第③是编译之后的效果图,前面两个的效果图就没有贴出来了
Default Voice Control/输入法校准、自动校准、首字母大写、按键声音
最后更新于:2022-04-01 14:48:33
今天给大家分享MTK平台系统编程与修改的另一个部分,分别是输入法校准、自动校准默认关、首字母大写默认开、按键声音默认关、Voice Control 移除系统中文,默认
英文,下面一个一个的介绍给大家
①Language & input> Android Keyboard>Auto Correction > Uncheck as Default(Off) 语言输入-安卓键盘-自动校准默认关
根据红色框关键词用命令行在settings下执行热词检索:
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a3a55be.jpg)
~~~
.../mnt/disk3/jsp/xxx8382$ find packages/apps/Settings/ -name "*.xml" | xargs grep "Very aggressive" -l
~~~
搜索无果,于是扩大搜索范围,键入如下命令行
~~~
.../mnt/disk3/jsp/xxx8382$ find packages/ -name "*.xml" | xargs grep "Very aggressive" -l
packages/inputmethods/LatinIME/java/res/values/strings.xml
packages/inputmethods/LatinIME/java/res/values-en-rIN/strings.xml
packages/inputmethods/LatinIME/java/res/values-en-rGB/strings.xml
~~~
得到3条结果,进入查看得到热词 auto_correction_threshold_mode_very_aggressive 搜索热词
~~~
android5@ubuntu2015:/mnt/disk3/jsp/xxx8382$ find packages/ -name "*.xml" | xargs grep "auto_correction_threshold_mode_very_aggressive" -l
packages/inputmethods/LatinIME/java/res/values-es/strings.xml
packages/inputmethods/LatinIME/java/res/values-ms-rMY/strings.xml
packages/inputmethods/LatinIME/java/res/values-my/strings.xml
packages/inputmethods/LatinIME/java/res/values-ky-rKG/strings.xml
packages/inputmethods/LatinIME/java/res/values-hu/strings.xml
packages/inputmethods/LatinIME/java/res/values-ne-rNP/strings.xml
packages/inputmethods/LatinIME/java/res/values-pl/strings.xml
packages/inputmethods/LatinIME/java/res/values-lo-rLA/strings.xml
packages/inputmethods/LatinIME/java/res/values/strings.xml
packages/inputmethods/LatinIME/java/res/values/config-auto-correction-thresholds.xml
~~~
查看 config-auto-correction-thresholds.xml 文件 ,查找如下代码
~~~
<!-- The index of the auto correction threshold values array. -->
<string name="auto_correction_threshold_mode_index_off" translatable="false">0</string>
<string name="auto_correction_threshold_mode_index_modest" translatable="false">1</string>
<string name="auto_correction_threshold_mode_index_aggressive" translatable="false">2</string>
<string name="auto_correction_threshold_mode_index_very_aggressive" translatable="false">3</string>
<!-- The array of the auto correction threshold settings values. -->
<string-array name="auto_correction_threshold_mode_indexes" translatable="false">
<item>@string/auto_correction_threshold_mode_index_off</item>
<item>@string/auto_correction_threshold_mode_index_modest</item>
<item>@string/auto_correction_threshold_mode_index_aggressive</item>
<item>@string/auto_correction_threshold_mode_index_very_aggressive</item>
</string-array>
<!-- The array of the human readable auto correction threshold settings entries. -->
<string-array name="auto_correction_threshold_modes" translatable="false">
<item>@string/auto_correction_threshold_mode_off</item>
<item>@string/auto_correction_threshold_mode_modest</item>
<item>@string/auto_correction_threshold_mode_aggressive</item>
<item>@string/auto_correction_threshold_mode_very_aggressive</item>
</string-array>
~~~
继续热词搜索追踪
~~~
jsp@ubuntu2015:/mnt/disk3/jsp/RMT8382$ find packages/ -name "*.xml" | xargs grep "auto_correction_threshold_modes" -l
packages/inputmethods/LatinIME/java/res/values/config-auto-correction-thresholds.xml
packages/inputmethods/LatinIME/java/res/xml/prefs_screen_correction.xml
~~~
查看 prefs_screen_correction.xml 文件 修改如下,运用 Beyond Compare 工具直接copy
~~~
<ListPreference
android:key="auto_correction_threshold"
android:title="@string/auto_correction"
android:summary="@string/auto_correction_summary"
android:entryValues="@array/auto_correction_threshold_mode_indexes"
android:entries="@array/auto_correction_threshold_modes"
android:defaultValue="@string/auto_correction_threshold_mode_index_off"
android:persistent="true" />
~~~
就可以重新修改默认值,重新编译工程,刷机即可看到效果
重新刷机第一次开机之后的效果图:
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a3b86a6.jpg)
②系统输入法自动大写默认开/输入法按键音效默认关/输入法拼写校准默认开-修改
热词检索命令
~~~
android5@ubuntu2015:/mnt/disk3/jsp/RMT8382$ find packages/ -name "*.xml" | xargs grep "按键音效" -l
packages/inputmethods/LatinIME/java/res/values-zh-rCN/strings.xml
android5@ubuntu2015:/mnt/disk3/jsp/RMT8382$ find packages/ -name "*.xml" | xargs grep "sound_on_keypress" -l
packages/inputmethods/LatinIME/java/res/values-es/strings.xml
packages/inputmethods/LatinIME/java/res/values-ms-rMY/strings.xml
packages/inputmethods/LatinIME/java/res/values-my/strings.xml
packages/inputmethods/LatinIME/java/res/values-ky-rKG/strings.xml
packages/inputmethods/LatinIME/java/res/values-hu/strings.xml
packages/inputmethods/LatinIME/java/res/values-ne-rNP/strings.xml
packages/inputmethods/LatinIME/java/res/values-pl/strings.xml
packages/inputmethods/LatinIME/java/res/values-lo-rLA/strings.xml
packages/inputmethods/LatinIME/java/res/values/strings.xml
packages/inputmethods/LatinIME/java/res/values-es-rUS/strings.xml
packages/inputmethods/LatinIME/java/res/values-bn/strings.xml
packages/inputmethods/LatinIME/java/res/values-tl/strings.xml
packages/inputmethods/LatinIME/java/res/xml/prefs_screen_preferences.xml
~~~
查看 prefs_screen_preferences.xml 文件,检索热词
~~~
jsp@ubuntu2015:/mnt/disk3/jsp/xxx8382$ find packages/ -name "*.xml" | xargs grep "config_default_sound_enabled" -l
packages/inputmethods/LatinIME/java/res/values/config-per-form-factor.xml
~~~
其实在prefs_screen_preferences.xml 可以直接修改,根据需求修改如下:
~~~
#首字母大写开
<CheckBoxPreference
android:key="auto_cap"
android:title="@string/auto_cap"
android:summary="@string/auto_cap_summary"
android:defaultValue="true"
android:persistent="true" />
#输入法按键音效关
<CheckBoxPreference
android:key="sound_on"
android:title="@string/sound_on_keypress"
android:defaultValue="false"
android:persistent="true" />
#输入法拼写校准默认开
<CheckBoxPreference
android:key="vibrate_on"
android:title="@string/vibrate_on_keypress"
android:defaultValue="@bool/config_default_vibration_enabled"
android:persistent="true" />
~~~
刷机第一次启动的效果:
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a3cf9e7.jpg)
③setting - voice control - language for voice control -Keep only english 设置-声音控制-语言只留英语去掉中文
最初效果图,默认简体中文:![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a3e308f.jpg)
定位到settings下检索关键字
~~~
jsp@ubuntu2015:/mnt/disk3/jsp/xxx8382$ find packages/apps/Settings/ -type f|xargs grep "繁體中文" -l
~~~
搜索无果,扩大检索范围
~~~
jsp@ubuntu2015:/mnt/disk3/jsp/xxx8382$ find ./ -type f|xargs grep "繁體中文" -l
~~~
发现结果根本不是想要的,而且由于源码较大,所以这个果断放弃,采用另一个方案,使用Eclipse工具来检索,这是笔者介绍给大家的一个非常实用的方法,以后绝对会用
得着不管是检索资料还是反编译apk等,都很实用
连接USB打开debugging,打开Eclipse → 打开 DDMS 点击设备 如下界面操作:
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a401f74.jpg)
检索包名 com.mediatek.voicecommand
~~~
android5@ubuntu2015:/mnt/disk3/jsp/RMT8382$ find -name "*.xml"|xargs grep "com.mediatek.voicecommand" -l
./vendor/mediatek/proprietary/packages/apps/VoiceCommand/tests/AndroidManifest.xml
./vendor/mediatek/proprietary/packages/apps/VoiceCommand/res/xml/voice_ui_available_preference.xml
./vendor/mediatek/proprietary/packages/apps/VoiceCommand/res/xml/voiceprocessinfo.xml
./vendor/mediatek/proprietary/packages/apps/VoiceCommand/AndroidManifest.xml
~~~
得到如上结果,大大缩小我们要查找的范围,继续之前的检索
~~~
android5@ubuntu2015:/mnt/disk3/jsp/RMT8382$ find vendor/mediatek/proprietary/packages/apps/VoiceCommand -type f|xargs grep "繁體中文" -l
vendor/mediatek/proprietary/packages/apps/VoiceCommand/res/xml/voicelanguage.xml
~~~
得到 voicelanguage.xml 资源文件,继续下一步检索
~~~
android5@ubuntu2015:/mnt/disk3/jsp/RMT8382$ find -name "*.java"|xargs grep "voicelanguage" -l
./out/target/common/R/com/mediatek/voicecommand/R.java
./out/target/common/obj/APPS/VoiceCommand_intermediates/src/com/mediatek/voicecommand/R.java
~~~
搜到的都不是想要的,继续检索,在当前目录下,看某个java文件调用了刚刚DDMS解析的 list 资源 id
~~~
android5@ubuntu2015:/mnt/disk3/jsp/RMT8382$ find vendor/mediatek/proprietary/packages/apps/VoiceCommand -name "*.java"|xargs grep "list" -l
vendor/mediatek/proprietary/packages/apps/VoiceCommand/tests/src/com/mediatek/voicecommand/tests/VoiceCommandTest.java
vendor/mediatek/proprietary/packages/apps/VoiceCommand/src/com/mediatek/voicecommand/ui/settings/VoiceUiSettings.java
vendor/mediatek/proprietary/packages/apps/VoiceCommand/src/com/mediatek/voicecommand/mgr/ConfigurationManager.java
vendor/mediatek/proprietary/packages/apps/VoiceCommand/src/com/mediatek/voicecommand/mgr/AppDataManager.java
vendor/mediatek/proprietary/packages/apps/VoiceCommand/src/com/mediatek/voicecommand/business/VoiceContacts.java
vendor/mediatek/proprietary/packages/apps/VoiceCommand/src/com/mediatek/voicecommand/business/VoiceWakeupMode.java
vendor/mediatek/proprietary/packages/apps/VoiceCommand/src/com/mediatek/voicecommand/service/VoiceCommandManagerStub.java
vendor/mediatek/proprietary/packages/apps/VoiceCommand/src/com/mediatek/voicecommand/cfg/ConfigurationXML.java
~~~
打开 VoiceUiSettings.java 查看系统代码,检索到相关资源
~~~
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
Preference preference) {
if (KEY_VOICE_UI_LANGUAGE.equals(preference.getKey())) {// 这就是Preference 被点击之后跳转的选项,也就是Voice Control 选项
Intent intent = new Intent(
"com.mediatek.voicecommand.VOICE_CONTROL_LANGUAGE");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
return true;
} else if
......
}
~~~
根据 Activity action 检索Acticity 名称
~~~
jsp@ubuntu2015:/mnt/disk3/jsp/xxx8382$ find vendor/mediatek/proprietary/packages/apps/VoiceCommand -name "*.xml"|xargs grep "com.mediatek.voicecommand.VOICE_CONTROL_LANGUAGE" -l
vendor/mediatek/proprietary/packages/apps/VoiceCommand/AndroidManifest.xml
~~~
得到如下 Activity :
~~~
<activity android:name=".ui.settings.VoiceUiAvailableLanguageActivity" android:label="@string/voice_ui_language_title" android:taskAffinity="com.android.settings" android:configChanges="orientation|keyboardHidden|keyboard|navigation" android:parentActivityName=".ui.settings.VoiceUiSettings">
<intent-filter>
<action android:name="com.mediatek.voicecommand.VOICE_CONTROL_LANGUAGE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
~~~
查看 VoiceUiAvailableLanguageActivity 代码
~~~
@Override
public void onCreate(Bundle savedInstanceState) {
Xlog.d(TAG, "OnCreate VoiceUiAvailableLanguageFragment");
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.voice_ui_available_langs);
mVoiceConfigMgr = ConfigurationManager.getInstance(this);
if (mVoiceConfigMgr == null) {
Xlog.e(TAG, "ConfigurationManager is null");
return;
}
mAvailableLangs = mVoiceConfigMgr.getLanguageList(); // 继续查看 ConfigurationManager getLanguageList() 代码
// mDefaultLanguage = mVoiceConfigMgr.getCurrentLanguage();// 这里 mDefaultLanguage int 默认为 0
......
}
}
~~~
ConfigurationManager getLanguageList() 代码
~~~
public String[] getLanguageList() {
int size = mLanguageList.size();
if (size == 0) {
return null;
}
String[] language = new String[size];
// Log.i(VoiceCommandManagerService.TAG, "mLanguageList = "+ size);
for (int i = 0; i < size; i++) {
language[i] = mLanguageList.get(i).mName;
}
return language;
}
~~~
mLanguageList 变量赋值的地方:
~~~
/*
* ConfigurationManager for control configuration
*
* @param context
*/
private ConfigurationManager(Context context) {
......
mCurrentLanguageIndex = mConfigurationXML
.readVoiceLanguangeFromXml(mLanguageList);// 来自 ConfigurationXML 的 readVoiceLanguangeFromXml 函数
......
}
~~~
继续查看 ConfigurationXML 的 readVoiceLanguangeFromXml 函数
~~~
/**
* Read language info from res.
*
* @param languageList
* language list instance
*/
public int readVoiceLanguangeFromXml(
......
XmlPullParser parser = mContext.getResources().getXml(// 这里就是加载语言选项 xml 的地方,下面贴上 xml 内容
R.xml.voicelanguage);
if (parser == null) {
Log.e(TAG, "readVoiceLanguangeFromXml Got execption");
return curIndex;
}
......
}
~~~
voicelanguage.xml 内容:
~~~
<?xml version="1.0" encoding="UTF-8"?>
<!-- Engineer-Jsp add remove 1 and 2 item default 0 -->
<Languages>
<Language TypeName="English" ID="0" Code="en-US" FileName="keyword/3.xml" />
<DefaultLanguage ID="0" />
</Languages>
<!--
<Language TypeName="简体中文" ID="1" Code="zh-CN" FileName="keyword/1.xml" />
<Language TypeName="繁體中文" ID="2" Code="zh-TW" FileName="keyword/2.xml" />
-->
~~~
这里已经是我改过的,需求是去掉所有中文只留英文选项,修改 TypeName="English" 的 ID 和 DefaultLanguage ID 都为 0 之后保存,继续修改java逻辑
回到我们的 VoiceUiAvailableLanguageActivity ,只需要注释掉几句代码就OK了
~~~
@Override
public void onCreate(Bundle savedInstanceState) {
Xlog.d(TAG, "OnCreate VoiceUiAvailableLanguageFragment");
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.voice_ui_available_langs);
mVoiceConfigMgr = ConfigurationManager.getInstance(this);
if (mVoiceConfigMgr == null) {
Xlog.e(TAG, "ConfigurationManager is null");
return;
}
mAvailableLangs = mVoiceConfigMgr.getLanguageList();
// mDefaultLanguage = mVoiceConfigMgr.getCurrentLanguage();//注释此句代码,因为 mDefaultLanguage 默认为0,不再需要其他选项,自己默认为0
......
}
~~~
~~~
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
Preference preference) {
if (preference instanceof RadioButtonPreference) {
// selectLanguage((RadioButtonPreference) preference); // 注释掉此句,不过不注释也不影响,只是多做了一些操作而已,都是多余的
Xlog.d(TAG, "default language changed to " + mAvailableLangs[mDefaultLanguage]);
finish();
}
return true;
}
~~~
selectLanguage 函数代码:
~~~
private void selectLanguage(RadioButtonPreference preference) {
if (mLastSelectedPref != null) {
if (mLastSelectedPref == preference) {
return;
}
mLastSelectedPref.setChecked(false);
}
mDefaultLanguage = Integer.parseInt(preference.getKey().toString());
Xlog.d(TAG, "set default language to " + mAvailableLangs[mDefaultLanguage]);
mVoiceConfigMgr.setCurrentLanguage(mDefaultLanguage);
preference.setChecked(true);
mLastSelectedPref = preference;
}
~~~
最后make自己的系统工程,重新烧录可看效果
效果图:
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a418682.jpg)
Bluetooth bug resolved on Google/关于谷歌蓝牙bug的解决
最后更新于:2022-04-01 14:48:31
MTK 版本蓝牙设置部分有很大修改,L版本去除了蓝牙可见性设置,只有当手机处于蓝牙设置界面(BluetoothSetting)时才会打开可见性,才能被其他手机搜索到,当退出蓝**
牙设置界面时,将关闭可见性。但是,当一直停留在蓝牙设置界面关闭蓝牙,再打开时,即使此时还在蓝牙设置界面,对外也是不可见。这是Google的bug。
如果希望当在蓝牙设置界面时,不管第几次打开蓝牙,蓝牙都能对外可见,修改方式如下:
在BluetoothSettings.java文件的onBluetoothStateChanged方法中,添加如下:
~~~
@Override
public void onBluetoothStateChanged(int bluetoothState) {
super.onBluetoothStateChanged(bluetoothState);
//Engineer-Jsp add by mtk start
if( bluetoothState==BluetoothAdapter.STATE_ON)
{
mInitiateDiscoverable=true;
}
//Engineer-Jsp add by mtk end
updateContent(bluetoothState);
}
~~~
还有一个bug,MTK 版本中,蓝牙只有在蓝牙设置界面(Bluetooth Setting)可见性才会打开,离开此界面蓝牙将对外不可见。如果要修改为只要打开蓝牙,即使离开蓝牙
界面,蓝牙也一直可见,方法如下:
packages\apps\settings\src\com\android\settings\bluetooth\BluetoothSettings.java
~~~
@Override
public void onPause() {
super.onPause();
if (mBluetoothEnabler != null) {
mBluetoothEnabler.pause();
}
// Engineer-Jsp add by mtk
// mLocalAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE);
if (isUiRestricted()) {
return;
}
getActivity().unregisterReceiver(mReceiver);
}
~~~
注释此句:
~~~
// mLocalAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE);
~~~
添加后使用mmm 的方式编译,编译完后通过snod的方式打包进system.img,然后download到手机中烧录固件测试即可
System-Bluetooth name/WiFi AP name/sleep add never/Notification popup
最后更新于:2022-04-01 14:48:29
今天拿到一个客户新的订单需求,大概有40多个需求,今天先讲更改系统的蓝牙/wifi 热点/消息通知/sleep 添加 never选项,分别是:
蓝牙:连接显示名、系统界面显示名字,重命名前的默认名字
wifi 热点:连接名字,重命名前默认 Network name
Notification popup :系统 Notification popup 默认不勾选
休眠添加never选项,默认30s:添加永不休眠,默认30s
首先我们要知道系统默认的蓝牙名字 ANDROID BT
Linux input ...> find 你的源码根目录/ -type f|xargs grep "ANDROID BT" -l
这句命令是找出源码下所有带有字符串 ANDROID BT 所在的文件,搜索无果,直接进入源码
packages\apps\Settings\src\com\android\settings\bluetooth\BluetoothSettins.java
跟踪源码找到如下代码
~~~
@Override
public void onResume() {
......
if (mLocalAdapter != null) {
updateContent(mLocalAdapter.getBluetoothState());
}
}
~~~
跟踪updateContent函数,修改如下代码
~~~
if (mMyDevicePreference == null) {
mMyDevicePreference = new Preference(getActivity());
}
// Engineer-Jsp add default bluetooth name
if (android.os.SystemProperties.isWalPadVersion()) {
mMyDevicePreference.setSummary(getResources().getString(
R.string.bluetooth_is_visible_message, "Walpad C"));
}else{
mMyDevicePreference.setSummary(getResources().getString(
R.string.bluetooth_is_visible_message, mLocalAdapter.getName()));
}
mMyDevicePreference.setSelectable(false);
~~~
其中 isWalpadVersion 函数是我在frameworks/base/core/java/android/os/SystemProperties.java中定义的
~~~
public static boolean isWalPadVersion(){
return SystemProperties.get("ro.product.model").contains("Walpad");
}
~~~
根据编译文件设置的客户平板型号定制产品而定,这样写有人可能会觉得多此一举,显的麻烦,但是作为一个系统,能把它做成兼容模式岂不是更好?
因为下次再有系统定制订单需求,我们只需要修改配置文件和分支就够了,轻松方便,而不需要再去new 代码了
setSummary(...,...)函数就是蓝牙设置打开蓝牙之后在界面显示的效果
R.string.bluetooth.is.visible_message 内容:
~~~
<string name="bluetooth_is_visible_message"><xliff:g id="device_name">%1$s</xliff:g> is visible to nearby devices while Bluetooth Settings is open.</string>
~~~
device_name 即为我们替换的名字,即Walpad C,效果图:
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a2b28b5.jpg)
接下来修改重名命选项的蓝牙设备名称,onOptionsItemSelected(MenuItem item) 根据 item 追踪重命名的 Dialog 找到如下逻辑:
~~~
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
......
mAlertDialog = new AlertDialog.Builder(getActivity())
.setTitle(R.string.bluetooth_rename_device)
.setView(createDialogView(deviceName))// 继续追踪createDialogView(deviceName)方法
......
return mAlertDialog;
}
~~~
根据逻辑,修改如下:
~~~
private View createDialogView(String deviceName) {
......
// Engineer-Jsp add default bluetooth name
if (android.os.SystemProperties.isWalPadVersion()) {// 根据model显示名称
mDeviceNameView.setText("Walpad C");
}else{
mDeviceNameView.setText(deviceName); // set initial value before adding listener
}
......
return view;
}
~~~
效果图:
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a2c417d.jpg)
连接显示名修改:
~~~
// Engineer-Jsp add default bluetooth name
if (android.os.SystemProperties.isWalPadVersion()) {
mMyDevicePreference.setSummary(getResources().getString(
R.string.bluetooth_is_visible_message, "Walpad C"));
mLocalAdapter.setName("Walpad C");//在之前讲到的修改除再添加此句
}else{
mMyDevicePreference.setSummary(getResources().getString(
R.string.bluetooth_is_visible_message, mLocalAdapter.getName()));
}
~~~
效果:
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a317ec8.jpg)
修改wifi重命名前的名字,根据信息搜索到源码packages\apps\Settings\src\com\android\settings\wifi\WifiApDialog.java
根据逻辑,查找到如下代码:
~~~
@Override
protected void onCreate(Bundle savedInstanceState) {
Context context = getContext();
......
if (mWifiConfig != null) {
// Engineer-Jsp add default bluetooth name
if (android.os.SystemProperties.isWalPadVersion()) { //根据型号显示ssid
mSsid.setText("Walpad C");
}else{
mSsid.setText(mWifiConfig.SSID);
}
/// M: set selection
mSecurity.setSelection(mExt.getSelection(mSecurityTypeIndex));
if (mSecurityTypeIndex == WPA2_INDEX) {
mPassword.setText(mWifiConfig.preSharedKey);
}
///M: get configured channel @{
mChannel = mWifiConfig.channel;
mChannelWidth = mWifiConfig.channelWidth;
/// @}
}
......
}
~~~
效果:
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a3397e7.jpg)
连接名字:
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a35bd0a.jpg)
修改系统 Notification popup 默认不勾选
搜索关键字:源码目录...>find ./ -name ".xml" | xargs grep "Popup notification"
找到xml文件之后找到对应string name 名称,发现他被一个布局文件调用,packages\apps\Mms\res\xml\notificationpreferences.xml - pref_summary_popup_notification -
defaultValue="false" 把这个默认false,即可
效果:
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a373ef7.jpg)
修改休眠选项默认 30s 添加永不休眠选项:
默认休眠30s修改:frameworks\base\packages\SettingsProvider\res\values\defaults.xml
~~~
<integer name="def_screen_off_timeout">30000</integer>
~~~
添加永不休眠选项:
~~~
private static final boolean sNeedScreenTimeoutNever = true;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......
if (sNeedScreenTimeoutNever && mScreenTimeoutPreference != null) { //rmt add
Resources res = getResources();
final String[] entries = res.getStringArray(R.array.screen_timeout_entries);
final String[] values = res.getStringArray(R.array.screen_timeout_values);
int entriesLength = entries.length;
final String[] newEntries = new String[entriesLength + 1];
for (int i = 0; i < entriesLength + 1; i++) {
if (i != entriesLength) {
newEntries[i] = entries[i];
} else {
newEntries[i] = res.getString(R.string.zen_mode_when_never);
}
}
int valuesLength = values.length;
final String[] newValues = new String[valuesLength + 1];
for (int i = 0; i < valuesLength + 1; i++) {
if (i != valuesLength) {
newValues[i] = values[i];
} else {
newValues[i] = "2147483647";
}
}
mScreenTimeoutPreference.setEntries(newEntries);
mScreenTimeoutPreference.setEntryValues(newValues);
......
}
private void updateTimeoutPreferenceDescription(long currentTimeout) {
......
} else if(currentTimeout == Integer.MAX_VALUE) { //Engineer-Jsp add
summary = preference.getContext().getString(R.string.zen_mode_when_never);
}
.......
}
~~~
效果:
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a38ac55.jpg)
内置三方apk到Rom可移动/可卸载
最后更新于:2022-04-01 14:48:26
客户给了一个内置他们自己apk的需求,定制到Rom里,我们需要在编译系统源码的时候配置好相关的文件即可将apk一起打包到ROM里面,下面我们就来一起打包apk到系统
首先需要在 [device/mediatek/common/device.mk](http://192.168.180.196/gitweb/?p=c/rmt8735_6tb_s_l1.git;a=blob;f=device/mediatek/common/device.mk;h=a87faad6ee23bff8b3bf69820fa9b8d79058d3ec;hb=a87faad6ee23bff8b3bf69820fa9b8d79058d3ec) 配置如下语句
$(call inherit-product-if-exists, vendor/公司名/product/您的命名.mk)
在mk文件里面配置需要内置的apk label
eg:
~~~
#apps
PRODUCT_PACKAGES += \
BDDataPlan\
Facebook\
MultiLingBengaliPlugin\
Multilingkeyboard\
SHAREit\
Skype\
Viber\
WPSOffice\
WST_WAL_C
~~~
配置好之后还需要导入 apk文件并且配置宏,就写一个例子吧,也在这个文件夹下写
路径:vendor\公司名\ThirdpartyApps\
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a2817b8.jpg)
配置如下mk文件,没有的自己创建
~~~
LOCAL_PATH := $(call my-dir)
#
include $(CLEAR_VARS)
LOCAL_MODULE := BDDataPlan
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/operator/app
#LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/thirdparty_apps
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
#
include $(CLEAR_VARS)
LOCAL_MODULE := Facebook
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/operator/app
#LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/thirdparty_apps
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
#
include $(CLEAR_VARS)
LOCAL_MODULE := MultiLingBengaliPlugin
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/operator/app
#LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/thirdparty_apps
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
#
include $(CLEAR_VARS)
LOCAL_MODULE := Multilingkeyboard
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := APPS
#LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/operator/app
LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/thirdparty_apps
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
#
include $(CLEAR_VARS)
LOCAL_MODULE := SHAREit
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/operator/app
#LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/thirdparty_apps
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
#
include $(CLEAR_VARS)
LOCAL_MODULE := Skype
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/operator/app
#LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/thirdparty_apps
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
#
include $(CLEAR_VARS)
LOCAL_MODULE := Viber
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/operator/app
#LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/thirdparty_apps
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
#
include $(CLEAR_VARS)
LOCAL_MODULE := WPSOffice
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/operator/app
#LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/thirdparty_apps
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
#
include $(CLEAR_VARS)
LOCAL_MODULE := WST_WAL_C
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/operator/app
#LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/thirdparty_apps
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
~~~
工作算是完成了一半,接下来还需要修改frameworks下的java文件,让内置的三分apk可卸载等操作
[/frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java](http://192.168.180.196/gitweb/?p=c/rmt8735_6tb_s_l1.git;a=blob;f=frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java;h=6791cfba6b4e12cb7b2569b5186d2a12aa303687;hb=6791cfba6b4e12cb7b2569b5186d2a12aa303687)
添加:
+ final File thirdpartyAppDir = new File(Environment.getRootDirectory(), "/vendor/thirdparty_apps");
+ scanDirLI(thirdpartyAppDir, PackageParser.PARSE_IS_SYSTEM
+ | PackageParser.PARSE_IS_SYSTEM_DIR, scanFlags, 0);
添加:
+ private static boolean isThirdpartyApp(int parseFlags) {
+ return (parseFlags & PackageParser.PARSE_IS_THIRDPARTY_APP) != 0;
+ }
public static int PackageParser.PARSE_IS_THIRDPARTY_APP = 1<<11;
修改:
+ if (isSystemApp(pkg) && !isUpdatedSystemApp(pkg) && !isThirdpartyApp(parseFlags)) {
不知道在那行的,可以搜索关键字,ctrl+L 索引行
修改完之后编译工程,发现以下异常:
~~~
No rule to make target `vendor/rmt/ThirdpartyApps/WST_WAL_C.apk', needed by `out/target/product/rmt8382_tb_l/obj/APPS/WST_WAL_C_intermediates/package.apk'. Stop
~~~
检查了下配置文件,发现客户提供的apk文件跟我们的mk冲突了,于是修改
WST_WAL_C.APK 为 WST_WAL_C.apk
重新编译工程,完美运行
最终效果,内置9个apk,7个可见,2个后台
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a297ce9.jpg)
设置系统默认语言/客制化可选语言/设置默认时区
最后更新于:2022-04-01 14:48:24
在这一版本的平板系统定制中,客户需要定制系统默认语言,默认英语,可选语种分别是
|语言代码| |国家/地区|
|--|--|
|bn_BD|孟加拉语(孟加拉)|
|en_US|英文|
|ar|阿拉伯文 |
|hi-IN|印地语 |
|ur-PK|乌都语 |
|fr|法语 |
|ru-RU|俄语|
|fa|波斯语|
|es|西班牙语 |
|pt|葡萄牙语|
需要修改的地方
device\公司名字\项目名字\full_项目名字.mk
修改变量:
PRODUCT_LOCALES := en_US es_ES zh_CN zh_TW ru_RU pt_BR fr_FR de_DE tr_TR it_IT in_ID ms_MY vi_VN ar_EG hi_IN th_TH bn_IN pt_PT ur_PK fa_IR nl_NL el_GR hu_HU tl_PH ro_RO cs_CZ iw_IL my_MM km_KH ko_KR pl_PL es_US bg_BG hr_HR lv_LV lt_LT sk_SK uk_UA de_AT da_DK fi_FI nb_NO sv_SE en_GB ja_JP
把此段覆盖上面的语言代码
en_US es_ES ru_RU pt_BR fr_FR hi_IN ur_PK bn_IN ar_EG fa_IR
不过除了这个还有一个地方也可以修改系统默认语言
就是buildinfo.sh的ro.product.locale.language变量,修改默认的为自己的国家语言代码即可
修改完之后保存,make 工程,烧录固件
最终效果:
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a26aed9.jpg)
设置默认的时区也可以在buildinfo.sh里面设置,需要修改的变量分别是:
o.product.locale.region=国家
persist.sys.timezone=地区
**eg:**
ro.product.locale.region=BD
persist.sys.timezone=Asia/Dhaka
默认打开开发者模式默认打开USB调试
最后更新于:2022-04-01 14:48:22
原文地址:[http://blog.csdn.net/ouyang_peng/article/details/49815865](http://blog.csdn.net/ouyang_peng/article/details/49815865)
今天有个用户对【设置】有个特殊的要求,即:
1、开机的时候默认显示【开发者选项】并打开【USB调试】开关 (【Developer options】-->【USB debugging】)
2、开机的时候默认打开【安全】-->【未知来源】的开关 (【Security】--->【Unknown sources】)
1、首先解决【设置】界面默认显示【开发者选项】的问题
查看源代码:packages/apps/Settings/src/com/android/settings/SettingsActivity.java
在updateTilesList(List<DashboardCategory> target)方法中,可以找到【开发者选项】相关的代码:
~~~
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变量定义在该方法最开始处
~~~
final boolean showDev = mDevelopmentPreferences.getBoolean(
DevelopmentSettings.PREF_SHOW,
android.os.Build.TYPE.equals("eng"));
~~~
因此要想特定客户直接显示【开发者选项】,则将showDev的值改变即可,代码如下:
~~~
//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中定义
~~~
public static boolean isJ5Version(){
return SystemProperties.get("ro.product.model").contains("J5");
}
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a228669.jpg)
2、解决【开发者选项】-->【USB调试】开关
首先查看packages/apps/Settings/src/com/android/settings/DevelopmentSettings.java
在updateAllOptions()方法中,有关于【USB调试】的逻辑处理。
~~~
/// M: CR ALPS00244115. Lock and unlock screen, the "USB debugging" is unchecked.
boolean isChecked = (mAdbDialog != null && mAdbDialog.isShowing()) ? true :
(Settings.Global.getInt(cr, Settings.Global.ADB_ENABLED, 0) != 0);
updateSwitchPreference(mEnableAdb, isChecked);
/// M: update usb preference again
mExt.customUSBPreference(mEnableAdb);
~~~
~~~
void updateSwitchPreference(SwitchPreference switchPreference, boolean value) {
switchPreference.setChecked(value);
mHaveDebugSettings |= value;
}
~~~
其中mEnableAdb即【USB调试】开关控件。一开始我直接强制的把isChecked变量设置为true,如下代码所示
~~~
/// M: CR ALPS00244115. Lock and unlock screen, the "USB debugging" is unchecked.
boolean isChecked = (mAdbDialog != null && mAdbDialog.isShowing()) ? true :
(Settings.Global.getInt(cr, Settings.Global.ADB_ENABLED, 0) != 0);
- //added by ouyang 2015-11-10 set mEnableAdb=true if model is J5
- if (android.os.SystemProperties.isJ5Version()) {
- isChecked=true;
- }
- //added by ouyang 2015-11-10 end
updateSwitchPreference(mEnableAdb, isChecked);
/// M: update usb preference again
mExt.customUSBPreference(mEnableAdb);
~~~
但是这样的话,直接刷机后开机的话还是不能直接连接USB调试,还要重新关闭该开关再打开该开关才能进行USB调试,因此该方案被放弃。
因为是否真正打开【USB调试】功能,是看Settings.Global.ADB_ENABLED这个属性的值是0还是1。因此真正的方法是在一个接受开机广播的广播接收者中将Settings.Global.ADB_ENABLED设置为1。
在下面和【未知来源】一起修改,在第4步骤中解决。
3、解决【安全】-->【未知来源】的开关 默认打开的问题
首先查看packages/apps/Settings/src/com/android/settings/SecuritySettings.java文件,在createPreferenceHierarchy()方法中找到【未知来源】的控件,403行附近
~~~
mToggleAppInstallation = (SwitchPreference) findPreference(
KEY_TOGGLE_INSTALL_APPLICATIONS);
mToggleAppInstallation.setChecked(isNonMarketAppsAllowed());
~~~
其中isNonMarketAppsAllowed()方法代码如下
~~~
private boolean isNonMarketAppsAllowed() {
return Settings.Global.getInt(getContentResolver(),
Settings.Global.INSTALL_NON_MARKET_APPS, 0) > 0;
}
~~~
setNonMarketAppsAllowed(boolean enabled)方法代码如下
~~~
private void setNonMarketAppsAllowed(boolean enabled) {
final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
if (um.hasUserRestriction(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES)) {
return;
}
// Change the system setting
Settings.Global.putInt(getContentResolver(), Settings.Global.INSTALL_NON_MARKET_APPS,
enabled ? 1 : 0);
}
~~~
一开始我在判断isNonMarketAppsAllowed()方法之前,先调用setNonMarketAppsAllowed()方法,这样一进入这个界面的话,【未知来源】选项是被勾选的。
~~~
mToggleAppInstallation = (SwitchPreference) findPreference(
KEY_TOGGLE_INSTALL_APPLICATIONS);
-
- //added by ouyang 2015-11-10 setChecked(true) if the model is J5
- if (android.os.SystemProperties.isJ5Version()) {
- setNonMarketAppsAllowed(true);
- }
mToggleAppInstallation.setChecked(isNonMarketAppsAllowed());
- //added by ouyang 2015-11-10 end
~~~
但是,刷完机直接安装一个第三方的apk的话,还是会弹出窗口要我设置【未知来源】选项,如下所示,因此该方案被放弃。
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a23e910.jpg)
点击【设置】按钮进入到界面是,【未知来源】按钮默认勾选了,这个时候退出去,继续安装apk的话就可以安装了,如下所示:
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a2524ec.jpg)
因为这个添加的代码是在SecuritySettings的createPreferenceHierarchy()方法中,也就是说要进入到该Activity才生效。这样明显没达到目的。
因此要和设置【USB调试】一样,在一个接收开机广播的广播接收者中将Settings.Global.INSTALL_NON_MARKET_APPS设置为1。
4、找Settings里面定义的一个接收开机广播的广播接收者,在AndroidManifest.xml中找到一个,当然你也可以自己定义一个这样的广播接收者。
~~~
<!-- Restore Rotation Receiver -->
<receiver android:name="com.mediatek.settings.RestoreRotationReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.ACTION_BOOT_IPO" />
</intent-filter>
</receiver>
~~~
因此在packages/apps/Settings/src/com/mediatek/settings/RestoreRotationReceiver.java的onReceive(Context context, Intent intent)方法中加入以下代码:
~~~
//added by ouyang 2015-11-13
if (android.os.SystemProperties.isJ5Version()) {
// 开机启动时,默认设置 [未知来源] 勾选
Settings.Global.putInt(context.getContentResolver(), Settings.Global.INSTALL_NON_MARKET_APPS,1);
// 开机启动时,默认设置 [USB调试] 勾选
Settings.Global.putInt(context.getContentResolver(),Settings.Global.ADB_ENABLED, 1);
}
//added by ouyang 2015-11-13 end
~~~
而一开始添加的代码可以注释掉了。通过git diff可以看出来
~~~
diff --git a/packages/apps/Settings/src/com/android/settings/DevelopmentSettings.java b/packages/apps/Settings/src/com/android/settings/Devel
index 0a987df..503270a 100755
--- a/packages/apps/Settings/src/com/android/settings/DevelopmentSettings.java
+++ b/packages/apps/Settings/src/com/android/settings/DevelopmentSettings.java
@@ -508,15 +508,9 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
final Context context = getActivity();
final ContentResolver cr = context.getContentResolver();
mHaveDebugSettings = false;
-
/// M: CR ALPS00244115. Lock and unlock screen, the "USB debugging" is unchecked.
boolean isChecked = (mAdbDialog != null && mAdbDialog.isShowing()) ? true :
(Settings.Global.getInt(cr, Settings.Global.ADB_ENABLED, 0) != 0);
- //added by ouyang 2015-11-10 set mEnableAdb=true if model is J5
- if (android.os.SystemProperties.isJ5Version()) {
- isChecked=true;
- }
- //added by ouyang 2015-11-10 end
updateSwitchPreference(mEnableAdb, isChecked);
/// M: update usb preference again
mExt.customUSBPreference(mEnableAdb);
~~~
~~~
diff --git a/packages/apps/Settings/src/com/android/settings/SecuritySettings.java b/packages/apps/Settings/src/com/android/settings/Security
index 4de173a..392e6ee 100755
--- a/packages/apps/Settings/src/com/android/settings/SecuritySettings.java
+++ b/packages/apps/Settings/src/com/android/settings/SecuritySettings.java
@@ -402,14 +402,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
root.findPreference(KEY_DEVICE_ADMIN_CATEGORY);
mToggleAppInstallation = (SwitchPreference) findPreference(
KEY_TOGGLE_INSTALL_APPLICATIONS);
-
- //added by ouyang 2015-11-10 setChecked(true) if the model is J5
- if (android.os.SystemProperties.isJ5Version()) {
- setNonMarketAppsAllowed(true);
- }
mToggleAppInstallation.setChecked(isNonMarketAppsAllowed());
- //added by ouyang 2015-11-10 end
-
// Side loading of apps.
// Disable for restricted profiles. For others, check if policy disallows it.
mToggleAppInstallation.setEnabled(!um.getUserInfo(UserHandle.myUserId()).isRestricted());
~~~
这样改为后,编译,刷机后,插上USB数据线就可以开始进行adb调试了,而且可以直接安装未知来源的apk了。
客制化开机LOGO跟开机动画/系统默认壁纸
最后更新于:2022-04-01 14:48:20
很多订单项目都需要我们去修改开机logo和开机动画,今天说的也是关于这方面的修改,首先我们要知道MTK的工作原理,查看开发板的文档可知,我们需要降编译和打包
之后的文件编译到 system/media 下,下面我就一个一个的来说,先从开机logo开始说吧,这个修改我们只需要替换相关的图片,然后替换下名字就OK了,因为是替换了资
源文件,所以我们不需要再次编译源码,snod 一下就OK了,命令:make snod
开机logo的替换:
替换地址:bootable\bootloader\lk\dev\logo
此地址下分别是多个分辨率的资源,所以我们要根据自己设备的分辨率来替换
查看自己的分辨率:
找到目录:device\公司名字\项目名字\ProjectConfig.mk
搜索关键字:BOOT_LOGO 即可以查看当前设备logo的分辨率
然后在对应去 bootable\bootloader\lk\dev\logo 下进行替换
EG:分辨率是 WSVGA
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a1e5bb1.jpg)
图片所选分别是替换之后的第一页logo和第二页logo
开机动画:
屏蔽 build/core/main.mk 文件宏函数
~~~
#$(call assert-product-vars, __STASHED)
~~~
在自定义或者已存在的目录下配置mk降文件并将动画等资源文件拷贝到此,编译到 system/media 下
EG:自定义编译目录 vendor/media/
配置宏:
~~~
LOCAL_PATH := $(call my-dir)
# ==== Engineer-Jsp bootanimation ========
include $(CLEAR_VARS)
TARGET_PATH:= system/media
PRODUCT_COPY_FILES += \
$(call add-to-product-copy-files-if-exists, $(LOCAL_PATH)/bootanimation.zip:$(TARGET_PATH)/bootanimation.zip)
# ===== Engineer-Jsp bootaudio ===========
PRODUCT_COPY_FILES += \
$(call add-to-product-copy-files-if-exists, $(LOCAL_PATH)/bootaudio.mp3:$(TARGET_PATH)/bootaudio.mp3)
~~~
之后编译源码,再次卡机可看到效果
替换壁纸:
EG:没有文档或者其他提示的情况下
直接使用 find 命令,不知道可以查看下述博客说明
博客地址:[http://blog.csdn.net/jspping/article/details/50467616](http://blog.csdn.net/jspping/article/details/50467616)
不同设备,不同版型对应的目录也大不相同,博主的目录是在:
device\mediatek\common\overlay\tablet\frameworks\base\core\res\res\drawable-sw600dp-nodpi
效果图(替换之后的):
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a20b973.jpg)
另外,开机铃声也在开机动画那里,已经配置好了,可以直接使用mk文件,准备好mp3文件即可,之后编译相关模块源码,如果文件之前已经编译并且存在,请直接替换掉
编译目标地址下的资源文件,然后 make snod 一下,烧录固件即可,再次开机可以看到效果
**本篇博客到此结束,谢谢观博!**
更改设备盘符名称/型号/名称/品牌/Version/Devices/Product……
最后更新于:2022-04-01 14:48:17
在android职业生涯,做了将近2年的application,于是我尝试接触系统,以便更深的了解android,在接到一个平板系统定制订单,需要对相关的原生设备信息进行更改,今天
我们就一起来修改原生代码,客制化我们自己的系统吧
修改上述相关信息需查看源码 buildinfo.sh 它所在的位置是:build\tools\
或者定位到源码根目录下:find out -name "buidnifo.*" 可以查看buildinfo前缀的所有文件所在目录
**EG:**
~~~
android5@ubuntu2015:/mnt/disk3/jsp/RMT8382$ find ../RMT8382 out -name "buildinfo.*"
../RMT8382/build/tools/buildinfo.sh
../RMT8382/external/chromium_org/tools/sheriffing/buildinfo.js
../RMT8382/external/chromium_org/tools/grit/grit/tool/buildinfo.py
../RMT8382/external/chromium_org/tools/grit/grit/testdata/buildinfo.grd
../RMT8382/external/chromium_org/chrome/browser/resources/chromeos/chromevox/common/buildinfo.js
android5@ubuntu2015:/mnt/disk3/jsp/RMT8382$
~~~
找到该文件后,查看内容并且修改我们需要的部分
~~~
ro.build.display.id=版本号
ro.product.model=型号
ro.product.brand=品牌
ro.product.name=名称
ro.product.device=设备
ro.product.board=Board
ro.product.manufacturer=制造商
~~~
效果图:
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a1bdfaa.jpg)
其他信息就不显示了,因为这个改起来不难
需要订做系统,专机1K以上可以联系合作,以下是平板原生launcher主界面
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-10_56e0e2a1cea8d.jpg)
已经替换了默认壁纸,5.0系统,谢谢观博!
前言
最后更新于:2022-04-01 14:48:15
> 原文出处:[Android系统之路-初识MTK](http://blog.csdn.net/column/details/androidmtk.html)
作者:[jspping](http://blog.csdn.net/jspping)
**本系列文章经作者授权在看云整理发布,未经作者允许,请勿转载!**
# Android系统之路-初识MTK
> 关于MTK平台 Android系统开发的一些系统定制常用处理