Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> Android開發 >> 關於android開發 >> Android系統之路(初識MTK) ------ 默認第一次開機屏幕亮度/日期格式/picture makeer model

Android系統之路(初識MTK) ------ 默認第一次開機屏幕亮度/日期格式/picture makeer model

編輯:關於android開發

Android系統之路(初識MTK) ------ 默認第一次開機屏幕亮度/日期格式/picture makeer model


今天給大家分享下關於修改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">
        <!--{cke_protected}{C}%3C!%2D%2D%20The%20blank%20item%20means%20to%20use%20whatever%20the%20locale%20calls%20for.%20%2D%2D%3E-->
        <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] ==dd-MM-yyyy

③picture makeer model ,修改 buildinfo.sh 文件,model\product 屬性

修改之前:

\

修改之後:

\

第③是編譯之後的效果圖,前面兩個的效果圖就沒有貼出來了

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved