blob: a350fe78f225e57e44515d55f158f8e0cbd6fe02 [file] [log] [blame]
James Hawkins6bff6392016-01-21 15:16:36 -08001# This file is the LOCAL_INIT_RC file for the bootstat command.
2
Wei Wang4e9c6532019-02-07 10:05:42 -08003# 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=*
Mark Salyzynb304f6d2017-08-04 13:35:51 -07007 setprop sys.boot.reason ${ro.boot.bootreason}
8
James Hawkins6bff6392016-01-21 15:16:36 -08009on post-fs-data
Mark Salyzync3ad75b2017-08-09 14:54:56 -070010 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
Mark Salyzyn25246dd2017-09-18 10:27:01 -070017 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
Mark Salyzync3ad75b2017-08-09 14:54:56 -070027 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/post_decrypt_time_elapsed
37 chown system log /data/misc/bootstat/ro.boottime.init
38 chown system log /data/misc/bootstat/ro.boottime.init.cold_boot_wait
39 chown system log /data/misc/bootstat/ro.boottime.init.selinux
40 chown system log /data/misc/bootstat/time_since_factory_reset
41 chown system log /data/misc/bootstat/time_since_last_boot
42 # end ota transitional support
James Hawkins6bff6392016-01-21 15:16:36 -080043
James Hawkinsc08e9962016-03-11 14:59:50 -080044# Record the time at which the user has successfully entered the pin to decrypt
45# the device, /data is decrypted, and the system is entering the main boot phase.
46#
47# post-fs-data: /data is writable
48# property:init.svc.bootanim=running: The boot animation is running
Wei Wangbd6ab492017-02-09 09:58:14 -080049# property:ro.crypto.type=block: FDE device
50on post-fs-data && property:init.svc.bootanim=running && property:ro.crypto.type=block
Mark Salyzyn557a9d42017-09-15 13:02:19 -070051 exec_background - system log -- /system/bin/bootstat -r post_decrypt_time_elapsed
James Hawkinsc08e9962016-03-11 14:59:50 -080052
Nikita Ioffe4d8e3ea2020-01-15 23:52:29 +000053# Initialize bootstat state machine.
James Hawkins800ceb42017-01-17 13:27:05 -080054#
Nikita Ioffe4d8e3ea2020-01-15 23:52:29 +000055# sys.bootstat.first_boot_completed: responsible for making sure that record_boot_complete happens
56# only once per device hard reboot. Possible values:
57#
58# sys.bootstat.first_boot_completed=0 - first boot completed trigger wasn't processed yet.
59# sys.bootstat.first_boot_completed=1 - first boot completed trigger was processed and
60# record_boot_complete was called. Subsequent boot completed
61# triggers (e.g. due to userspace reboot) won't retrigger
62# record_boot_complete
63#
64# IMPORTANT, ro.persistent_properties.ready=1 trigger is used here to ensure that we initialize
65# state machine only once, which as result ensures that bootstat --set_system_boot_reason and
66# bootstat --record_boot_complete will be called only once per full reboot.
67on property:ro.persistent_properties.ready=true
68 setprop sys.bootstat.first_boot_completed 0
James Hawkins800ceb42017-01-17 13:27:05 -080069
Wei Wang4e9c6532019-02-07 10:05:42 -080070# Set boot reason
Nikita Ioffe4d8e3ea2020-01-15 23:52:29 +000071on property:ro.persistent_properties.ready=true
Wei Wang4e9c6532019-02-07 10:05:42 -080072 # Converts bootloader boot reason and persist.sys.boot.reason to system boot reason
73 # Need go after persist peroperties are loaded which is right before zygote-start trigger
74 exec_background - system log -- /system/bin/bootstat --set_system_boot_reason
75
James Hawkinse4079fb2016-12-01 14:02:17 -080076# Record boot complete metrics.
Nikita Ioffe4d8e3ea2020-01-15 23:52:29 +000077on property:sys.boot_completed=1 && property:sys.bootstat.first_boot_completed=0
James Hawkinsc08e9962016-03-11 14:59:50 -080078 # Record boot_complete and related stats (decryption, etc).
James Hawkinsa4a1a4a2016-02-09 15:32:38 -080079 # Record the boot reason.
James Hawkins53684ea2016-02-23 16:18:19 -080080 # Record time since factory reset.
James Hawkins6bff6392016-01-21 15:16:36 -080081 # Log all boot events.
Wei Wang4e9c6532019-02-07 10:05:42 -080082 exec_background - system log -- /system/bin/bootstat --record_boot_complete --record_boot_reason --record_time_since_factory_reset -l
Nikita Ioffe4d8e3ea2020-01-15 23:52:29 +000083 setprop sys.bootstat.first_boot_completed 1