android设置系统默认开机时间

1.设置RTC时间,该时间是如果RCT时钟断电以后使用的默认时间

Android L之前:

\alps\mediatek\custom\[project]\preloader\ inc\cust_rtc.h

\alps\mediatek\custom\[project]\kernel\rtc\rtc\rtc-mt65XX.h

Android L或M:

bootable\bootloader\preloader\custom\ [project] \inc\ cust_rtc.h

 

#define RTC_DEFAULT_YEA 2019

#define RTC_DEFAULT_MTH 7

#define RTC_DEFAULT_DOM 1

2、修改默认日期:

framework\services\java\com\android\server\NetworkTimeUpdateService.java

/** Initialize the receivers and initiate the first NTP request */
    public void systemReady() {
        registerForTelephonyIntents();
        registerForAlarms();
        registerForConnectivityIntents();

        mThread = new HandlerThread(TAG);
        mThread.start();
        mHandler = new MyHandler(mThread.getLooper());
        // Check the network time on the new thread
        mHandler.obtainMessage(EVENT_POLL_NETWORK_TIME).sendToTarget();

        mSettingsObserver = new SettingsObserver(mHandler, EVENT_AUTO_TIME_CHANGED);
        mSettingsObserver.observe(mContext);
        
        /// M: comment @{ add GPS Time Sync Service
        Log.d(TAG, "add GPS time sync handler and looper");
        mGpsThread = new HandlerThread(TAG);
        mGpsThread.start();
        mGpsHandler = new MyHandler(mGpsThread.getLooper());
        
        mGpsTimeSyncObserver = new GpsTimeSyncObserver(mGpsHandler, EVENT_GPS_TIME_SYNC_CHANGED);
        mGpsTimeSyncObserver.observe(mContext);
        /// @}
        
        /// M: Configure default date/time to current year after factory reset or first bootup @{ 
        String icsString = SystemProperties.get(ICS_BOOT_SYS_PROPERTY, "");
        boolean isIcsVersion = (icsString != null && "".equals(icsString)) ? false : true;
        if(isIcsVersion){
           return;
        }
        
        mDefaultYear  = mContext.getResources().getInteger(com.mediatek.internal.R.integer.default_restore_year);
        mIsOverMobile = mContext.getResources().getBoolean(com.mediatek.internal.R.bool.config_ntp_by_mobile);
        
        String tempString = SystemProperties.get(BOOT_SYS_PROPERTY, "");
        boolean isFirstBoot = (tempString != null && "".equals(tempString)) ? true : false;
        if(isFirstBoot){
           tempString = SystemProperties.get("ro.kernel.qemu", "");
           boolean isEmulator = "1".equals(tempString) ? true : false;
           if(isEmulator){
              Log.d(TAG, "isEmulator:" + tempString);
              return;
           }

           String decryptState = SystemProperties.get("vold.decrypt", "");
           Log.d(TAG, "decryptState:" + decryptState);
           if("".equals(decryptState) || DECRYPT_STATE.equals(decryptState)){
              Time today = new Time(Time.getCurrentTimezone());
              today.setToNow();
              Log.d(TAG, "First boot:" + tempString + " with date:" + today);
              //today.set(today.monthDay, today.month, mDefaultYear);
              today.set(1, 7, mDefaultYear);//2019.7.1
              Log.d(TAG, "Set the year to " + mDefaultYear);
                     SystemProperties.set(BOOT_SYS_PROPERTY, "false");
                 SystemClock.setCurrentTimeMillis(today.toMillis(false));
              }
           }
        ///@}
    }

  

在mediatek\frameworks\base\res\res\values\config.xml里修改

<integer name="default_restore_year">2019</integer>

 

转载于:https://www.cnblogs.com/suxiaoqi/p/11189086.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值