自动设置时间续

客户测试得到结论是“自动获取时间”不选任然会从网络上获取时间及更新。
查看了
        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_TIME_TICK);
        filter.addAction(Intent.ACTION_TIME_CHANGED);
        filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
        registerReceiver(mIntentReceiver, filter, null, null);
这些INTENT都没有结果。
后来在界面中测试发现一个规律:
取消“auto time”,然后“select time zone”,“set time”, “Use 24-hour format”, “Select date format”等选项的改变都不会去更新时间,唯独“set date”这项,在改变year的时候会有去网络更新时间的动作,而且是在改变后的year比当前year要大时才动作,如果小则还是不会触发。 例如2012年改为2013年点确定然后就会自动更新,而2012年改为2010年等小些的年份则不会自动更新。
log如下:
# D/SystemClock(  362): Setting time of day to sec=1363240369
smdkc110-rtc smdkc110-rtc: rtc disabled, re-enabling
I/EventLogService(  330): Aggregate from 1331704345962 (log), 1331962934668 (data)
I/CheckinService(  330): Preparing to send checkin request
I/EventLogService(  330): Accumulating logs since 1363240369496
D/ResourceType(  330): calling getConfigurations
D/ResourceType(  330): called getConfigurations size=243
I/CheckinTask(  330): Sending checkin request (952 bytes)
E/CheckinTask(  330): SSL error, attempting time correction: javax.net.ssl.SSLHandshakeException: org.bouncycastle.jce.exception.ExtCertPathValidatorException: Could not validate certificate: current time: Thu Mar 14 13:52:50 GMT+08:00 2013, expiration time: Fri Mar 08 16:53:51 GMT+08:00 2013
smdkc110-rtc smdkc110-rtc: rtc disabled, re-enabling
W/CheckinTask(  330): Setting time from 1363240370708 to 1331963570459
D/SystemClock(   83): Setting time of day to sec=1331963570
D/ResourceType(  330): calling getConfigurations
D/ResourceType(  330): called getConfigurations size=243
I/CheckinTask(  330): Checkin success: https://android.clients.google.com/checkin (1 requests sent)

在设备中查询可得到 CheckinService其实是在GoogleServiceFramework.apk中的,没有源代码无法修改。
在试过其他方法无果后,决定反编译GoogleServiceFramework.apk看是否能得到一些有用的信息,反编译后查询到
I/CheckinService(  330): Preparing to send checkin request
存在于com.google.android.gsf/checkin/CheckinService$1
class CheckinService$1 extends CheckinTask
{
  public ProtoBuf doInBackground(CheckinTask.Params[] paramArrayOfParams)
  {
    int i = 0;
    ProtoBuf localProtoBuf;
    while (CheckinService.access$100(this.this$0))
    {
      Log.i("CheckinService", "Preparing to send checkin request");
      EventLogService.captureLogs(this.this$0);
      localProtoBuf = super.doInBackground(paramArrayOfParams);
      CheckinService.access$200(this.this$0, localProtoBuf);
    }
    return localProtoBuf;
  }

看到doInBackground就怀疑是不是后台传输的问题,于是到“Accounts & sync settings”中,关掉“Background data”,然后再在时间中设置,果然不会再变化!   测试M9,也是如此。

所以修改系统让后台数据功能默认关闭。
frameworks/base/packages/SettingsProvider/res/values/defaults.xml
    <bool name="def_install_non_market_apps">true</bool>
    <!-- jeff add default background data on/off. -->
    <bool name="def_background_data">false</bool>
frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
private void loadSecureSettings(SQLiteDatabase db) {
            //jeff. def background data.
            loadBooleanSetting(stmt, Settings.Secure.BACKGROUND_DATA,
                    R.bool.def_background_data);
    
默认不开启后台数据,算是对这个问题的一个解决方法。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值