1# This file is the LOCAL_INIT_RC file for the bootstat command. 2 3# Mirror bootloader boot reason to system boot reason 4# ro.boot.bootreason should be set by init already 5# before post-fs trigger 6on post-fs && property:ro.boot.bootreason=* 7 setprop sys.boot.reason ${ro.boot.bootreason} 8 9on post-fs-data 10 mkdir /data/misc/bootstat 0700 system log 11 # To deal with ota transition resulting from a change in DAC from 12 # root.root to system.log, may be deleted after ota has settled. 13 chown system log /data/misc/bootstat/absolute_boot_time 14 chown system log /data/misc/bootstat/boot_complete 15 chown system log /data/misc/bootstat/boot_complete_no_encryption 16 chown system log /data/misc/bootstat/boot_reason 17 chown system log /data/misc/bootstat/boottime.bootloader.1BLE 18 chown system log /data/misc/bootstat/boottime.bootloader.1BLL 19 chown system log /data/misc/bootstat/boottime.bootloader.2BLE 20 chown system log /data/misc/bootstat/boottime.bootloader.2BLL 21 chown system log /data/misc/bootstat/boottime.bootloader.AVB 22 chown system log /data/misc/bootstat/boottime.bootloader.KD 23 chown system log /data/misc/bootstat/boottime.bootloader.KL 24 chown system log /data/misc/bootstat/boottime.bootloader.ODT 25 chown system log /data/misc/bootstat/boottime.bootloader.SW 26 chown system log /data/misc/bootstat/boottime.bootloader.total 27 chown system log /data/misc/bootstat/build_date 28 chown system log /data/misc/bootstat/factory_reset 29 chown system log /data/misc/bootstat/factory_reset_boot_complete 30 chown system log /data/misc/bootstat/factory_reset_boot_complete_no_encryption 31 chown system log /data/misc/bootstat/factory_reset_current_time 32 chown system log /data/misc/bootstat/factory_reset_record_value 33 chown system log /data/misc/bootstat/last_boot_time_utc 34 chown system log /data/misc/bootstat/ota_boot_complete 35 chown system log /data/misc/bootstat/ota_boot_complete_no_encryption 36 chown system log /data/misc/bootstat/ro.boottime.init 37 chown system log /data/misc/bootstat/ro.boottime.init.cold_boot_wait 38 chown system log /data/misc/bootstat/ro.boottime.init.selinux 39 chown system log /data/misc/bootstat/time_since_factory_reset 40 chown system log /data/misc/bootstat/time_since_last_boot 41 # end ota transitional support 42 43# Initialize bootstat state machine. 44# 45# sys.bootstat.first_boot_completed: responsible for making sure that record_boot_complete happens 46# only once per device hard reboot. Possible values: 47# 48# sys.bootstat.first_boot_completed=0 - first boot completed trigger wasn't processed yet. 49# sys.bootstat.first_boot_completed=1 - first boot completed trigger was processed and 50# record_boot_complete was called. Subsequent boot completed 51# triggers (e.g. due to userspace reboot) won't retrigger 52# record_boot_complete 53# 54# IMPORTANT, ro.persistent_properties.ready=1 trigger is used here to ensure that we initialize 55# state machine only once, which as result ensures that bootstat --set_system_boot_reason and 56# bootstat --record_boot_complete will be called only once per full reboot. 57on property:ro.persistent_properties.ready=true 58 setprop sys.bootstat.first_boot_completed 0 59 60# Set boot reason 61on property:ro.persistent_properties.ready=true 62 # Converts bootloader boot reason and persist.sys.boot.reason to system boot reason 63 # Need go after persist peroperties are loaded which is right before zygote-start trigger 64 exec_background - system log -- /system/bin/bootstat --set_system_boot_reason 65 66# Record boot complete metrics. 67on property:sys.boot_completed=1 && property:sys.bootstat.first_boot_completed=0 68 # Record boot_complete and related stats (decryption, etc). 69 # Record the boot reason. 70 # Record time since factory reset. 71 # Log all boot events. 72 exec_background - system log -- /system/bin/bootstat --record_boot_complete --record_boot_reason --record_time_since_factory_reset -l 73 setprop sys.bootstat.first_boot_completed 1 74