From 2284c8495a0a920de517f1d21e2c0c30be231e67 Mon Sep 17 00:00:00 2001 From: Naveen Kalla Date: Wed, 14 Jun 2017 15:35:34 -0700 Subject: [PATCH] Set system time early to get more accurate timezones Zygote reads the system time and caches the timezone information. So start time_daemon early so that it can set the time before zygote starts up and reads the time. Bug: 62473512 Test: Manual: Check adb logs to ensure Zygote starts after system time is set. Change-Id: I98fca37928e1822614f9fcb39869e664453a2c3e --- init.hardware.rc | 7 ++++++- sepolicy/vendor/property.te | 1 + sepolicy/vendor/property_contexts | 1 + sepolicy/vendor/time_daemon.te | 3 +++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/init.hardware.rc b/init.hardware.rc index 10788ff6..35a55308 100644 --- a/init.hardware.rc +++ b/init.hardware.rc @@ -185,6 +185,9 @@ on late-fs # Mount RW partitions which need run fsck mount_all /vendor/etc/fstab.${ro.hardware} --late + # Start time daemon early so that the system time can be set early + start time_daemon + on post-fs # set RLIMIT_MEMLOCK to 64MB setrlimit 8 67108864 67108864 @@ -223,6 +226,8 @@ on post-fs-data # Set indication (checked by vold) that we have finished this action setprop vold.post_fs_data_done 1 + # Wait until the system time is set + wait_for_prop sys.time.set true # zygote need to be started after otapreopt which will be done on post-fs-data on zygote-start @@ -491,7 +496,7 @@ service qseecomd /vendor/bin/qseecomd group root service time_daemon /vendor/bin/time_daemon - class late_start + class core user root group root diff --git a/sepolicy/vendor/property.te b/sepolicy/vendor/property.te index 9c56ec41..371170bf 100644 --- a/sepolicy/vendor/property.te +++ b/sepolicy/vendor/property.te @@ -12,3 +12,4 @@ type wc_prop, property_type; type thermal_prop, property_type; type modem_diag_prop, property_type; type tel_mon_prop, property_type; +type sys_time_prop, property_type; diff --git a/sepolicy/vendor/property_contexts b/sepolicy/vendor/property_contexts index fcfd1046..a5eb880a 100644 --- a/sepolicy/vendor/property_contexts +++ b/sepolicy/vendor/property_contexts @@ -20,3 +20,4 @@ ctl.thermal-engine u:object_r:thermal_prop:s0 persist.sys.modem.diag. u:object_r:modem_diag_prop:s0 sys.modem.diag. u:object_r:modem_diag_prop:s0 persist.radio.enable_tel_mon u:object_r:tel_mon_prop:s0 +sys.time.set u:object_r:sys_time_prop:s0 diff --git a/sepolicy/vendor/time_daemon.te b/sepolicy/vendor/time_daemon.te index 51e97920..607d7d47 100644 --- a/sepolicy/vendor/time_daemon.te +++ b/sepolicy/vendor/time_daemon.te @@ -13,6 +13,9 @@ allow time_daemon sysfs_soc:dir search; allow time_daemon sysfs_soc:file r_file_perms; allow time_daemon sysfs_msm_subsys:dir search; +# Set sys.time.set property +set_prop(time_daemon, sys_time_prop); + allow time_daemon persist_file:dir w_dir_perms; allow time_daemon persist_file:file rw_file_perms;