init.qti.time.daemon.sh 830 B

1234567891011121314151617181920212223
  1. #! /vendor/bin/sh
  2. LOG_HEAD="[time-services]"
  3. current_time=$(date +%s)
  4. echo "${LOG_HEAD} current time : ${current_time}" > /dev/kmsg
  5. # if time-service initialization is required
  6. if [ "$1" != "1" ]; then
  7. #FIXME : date cmd could return 0 without broadcasting SET_TIME intent, the time diff b/w old & new must be enough
  8. new_time=$((current_time+5))
  9. date -s @${new_time}
  10. ret=$?
  11. # echo "${LOG_HEAD} date return code : ${ret} " > /dev/kmsg
  12. if [ "$ret" -ne 0 ]; then
  13. echo "${LOG_HEAD} failed to exec date cmd : ${current_time} to ${new_time} with ${ret}" > /dev/kmsg
  14. echo c > /proc/sysrq-trigger #it's not working due to selinux
  15. exit 1
  16. else
  17. echo "${LOG_HEAD} initialized : ${current_time} to ${new_time}" > /dev/kmsg
  18. fi
  19. setprop persist.vendor.time_services.init 1
  20. fi