Wrong local time after reboot

97 views
Skip to first unread message

Frédéric Lord

unread,
Jun 20, 2017, 9:41:43 PM6/20/17
to Android-x86
On nougat-x86, after reboot, the system clock is set to local time because the timezone cannot be found.

The commit 2e2704141d51d81e1640db66f5c9af9e7e36b207 modified the function do_sysclktz() to read the persist.sys.timezone property from data/property directory and it used the property value to get the gmtoffset.
The problem I have is that the data partition is not mounted when the function is called, the function do_sysclktz() is called in init.rc during the “init” action and the data partition is mounted in /init.${ro.hardware}.rc during “fs” action by calling “mount_all /fstab.${ro.hardware}”. The “fs” action is processed after the “init” process, so the persist.sys.timezone cannot be read and the system time is set to local time in do_sysclktz(). This makes the clock offset by the timezone because System.currentTimeMillis() returns the local time instead of UTC time.

This happen only when the network is not available, else the clock is auto set after reboot from network.

I can make it works by moving “sysclktz 0” in “post-fs” action in init.rc, but that’s not desirable because I don’t want to modified the android source code files.

If I put the persist.rtc_local_time=0 to store utc time in rtc, the system seems to treat it as localtime. When AlarmManager starts, it set the kernel timezone and after that, System.currentTimeMillis() returns UTC time + timezone offset and the clock is set to UTC time. If I put in comments the line that set the kernel timezone, the right time is displayed. So, there is surely something wrong elsewhere.

Any solutions to make the right clock time displayed without having to modify the system/core/rootdir/init.rc ?

Chih-Wei Huang

unread,
Jun 20, 2017, 9:57:48 PM6/20/17
to Android-x86
2017-06-20 23:01 GMT+08:00 Frédéric Lord <fredl...@gmail.com>:
> On nougat-x86, after reboot, the system clock is set to local time because the timezone cannot be found.
>
> The commit 2e2704141d51d81e1640db66f5c9af9e7e36b207 modified the function do_sysclktz() to read the persist.sys.timezone property from data/property directory and it used the property value to get the gmtoffset.
> The problem I have is that the data partition is not mounted when the function is called, the function do_sysclktz() is called in init.rc during the “init” action and the data partition is mounted in /init.${ro.hardware}.rc during “fs” action by calling “mount_all /fstab.${ro.hardware}”. The “fs” action is processed after the “init” process, so the persist.sys.timezone cannot be read and the system time is set to local time in do_sysclktz(). This makes the clock offset by the timezone because System.currentTimeMillis() returns the local time instead of UTC time.

Android-x86 doesn't mount data in “fs” action.
(that's traditional android devices do)
/data is mounted before entering android's init.
Or did you custom your installation and
use /init.${ro.hardware}.rc to mount /data
like a traditional android device does?


> This happen only when the network is not available, else the clock is auto set after reboot from network.
>
> I can make it works by moving “sysclktz 0” in “post-fs” action in init.rc, but that’s not desirable because I don’t want to modified the android source code files.
>
> If I put the persist.rtc_local_time=0 to store utc time in rtc, the system seems to treat it as localtime. When AlarmManager starts, it set the kernel timezone and after that, System.currentTimeMillis() returns UTC time + timezone offset and the clock is set to UTC time. If I put in comments the line that set the kernel timezone, the right time is displayed. So, there is surely something wrong elsewhere.
>
> Any solutions to make the right clock time displayed without having to modify the system/core/rootdir/init.rc ?

If you have a custom installation,
you probably have to do it.
Or you can modify init.x86.rc under
device/generic/common/.


--
Chih-Wei
Android-x86 project
http://www.android-x86.org

Frédéric Lord

unread,
Jun 21, 2017, 9:48:23 PM6/21/17
to Android-x86
We have a custom installation of Android-x86 and we are trying to used it the most possible like a traditional android device.
So, yes, we used /init.${ro.hardware}.rc to mount /data like a traditional android device.
I will try to modify init.x86.rc.
Reply all
Reply to author
Forward
0 new messages