默认第一次开机屏幕亮度/日期格式/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) 第③是编译之后的效果图,前面两个的效果图就没有贴出来了
';