android 如何修改出厂默认日期和默认时区

时间信息预设信息都是0, 在rtc 初试化 时候设置的.
由于RTC 基本上不会断电,所以它的初试化只做一次,即使重新download bin 档.
用FlashTool 执行Format, 再执行download (不要用format -->download button), 或者RTC断电一段时间,就可以观察到日期恢复到出厂值。
修改默认日期:
修改文件
\alps\mediatek\custom\[project]\preloader\ inc\cust_rtc.h
\alps\mediatek\custom\[project]\kernel\rtc\rtc\rtc-mt65XX.h
 
#define RTC_DEFAULT_YEA         2012
#define RTC_DEFAULT_MTH        2
#define RTC_DEFAULT_DOM        1
 
在JB之前,进行以上修改即可,如果是JB,还需要进行以下修改:
[File]
framework\services\java\com\android\server\NetworkTimeUpdateService.java
[Function]
systemReady()
[Code]
           if(isFirstBoot){
              Time today = new Time(Time.getCurrentTimezone());
              today.setToNow();   // 请添加此行
 
如果要设置出厂默认年份需要修改
 
1)      JB.SP/JB2.MP
alps\mediatek\frameworks\base\res\res\values\config.xml
将 default_restore_year 修改成 2013
   
    2013
 
2)      JB.MP
alps\frameworks\base\services\java\com\android\server\NetworkTimeUpdateService.java
              if(today.year <= 2010){
                 today.set(today.monthDay, today.month, 2013);
                 Log.d(TAG, "Set the year to 2013");
                     SystemProperties.set(BOOT_SYS_PROPERTY, "false");
                 SystemClock.setCurrentTimeMillis(today.toMillis(false));
              }
 
修改后的表现可通过Setting菜单->时间日期设置):


修改默认时区:
1)\alps\mediatek\config\[project]\system.prop中增加下面字段(假设改为上海时区)
      persist.sys.defaulttimezone=Asia/Shanghai
2)RuntimeInit.java 中
private static final void commonInit() {
。。。。。。
修改如下的函数:
TimezoneGetter.setInstance(new TimezoneGetter() {
            @Override
            public String getId() {
              String zoneinfo = SystemProperties.get("persist.sys.timezone");
              Slog.i(TAG, "zoneinfo is " + zoneinfo);
              if (zoneinfo == null || zoneinfo.length() == 0)
              {
                         String zonedefaultinfo =
SystemProperties.get("persist.sys.defaulttimezone");
                     if (zonedefaultinfo != null && zonedefaultinfo.length() > 0)
                     {
                                                                      SystemProperties.set("persist.sys.timezone", zonedefaultinfo);   
                         Slog.i(TAG, "zonedefaultinfo is " + zonedefaultinfo);
                     }                          
              }
  Slog.i(TAG, "persist.sys.timezone is " + SystemProperties.get("persist.sys.timezone"));
                    
return SystemProperties.get("persist.sys.timezone");
            }
        });
注意:默认时区的修改会影响默认时间的值,会根据与格林尼治标准时间差来更新时间,这是正常现象。如当前设置为中国标准时间GMT+8:00,则手机的出厂时间会变为8:00。

你可能感兴趣的:(android 如何修改出厂默认日期和默认时区)