瑞芯微Rockchip开发者社区
直播中

刘杰

7年用户 1292经验值
私信 关注
[经验]

RK3399/RK3328 Android9.0设置系统时间无效的问题如何解决

测试平台

Platform: RK3399/RK3328
OS: Android9.0

现象

使用系统接口设置时间生效,查看rtc也设置成功。但是重启后时间为首次开机的时间.

分析

多次测试后发现,设置时间在第一次开机时系统显示的时间之后,重启后时间设置生效;设置在之前,则会还原成第一次系统开机时显示的时间。

所以怀疑时,系统在开机的时候做了时间有效检测.查看AlarmManagerService.java后发现系统会用当前时间和编译固件的时间做对比,如果早于编译时间则使用编译时间为当前时间。

frameworks/base/services/core/java/com/android/server/AlarmManagerService.java

@Override
public void onStart() {
mNativeData = init();
mNextWakeup = mNextNonWakeup = 0;

// We have to set current TimeZone info to kernel
    // because kernel doesn't keep this after reboot
    setTimeZoneImpl(SystemProperties.get(TIMEZONE_PROPERTY));

    if (mNativeData != 0) {
        // Ensure that we're booting with a halfway sensible current time.  Use the
        // most recent of Build.TIME, the root file system's timestamp, and the
        // value of the ro.build.date.utc system property (which is in seconds).
        final long systemBuildTime =  Long.max(
                1000L * SystemProperties.getLong("ro.build.date.utc", -1L),
                Long.max(Environment.getRootDirectory().lastModified(), Build.TIME));
        if (System.currentTimeMillis() < systemBuildTime) {
            Slog.i(TAG, "Current time only " + System.currentTimeMillis()
                    + ", advancing to build time " + systemBuildTime);
            setKernelTime(mNativeData, systemBuildTime);
        }
    }

解决办法

屏蔽此处的时间检验即可或者向客户说明情况。

原作者:风之空响

更多回帖

发帖
×
20
完善资料,
赚取积分