[Android 9.0][RK3399/RK3328]Android9

上网导航 2023-12-05 155 0条评论
摘要: 文章浏览阅读1.2k次。frameworks/base/services/core/java/com/android/server/AlarmManagerService...

测试平台

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);
            }
        }

解决办法

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

文章版权及转载声明:

作者:上网导航本文地址:https://www.90xe.com/post/6764.html发布于 2023-12-05
文章转载或复制请以超链接形式并注明出处技术导航

分享到:

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏