James Hawkins | 6bff639 | 2016-01-21 15:16:36 -0800 | [diff] [blame] | 1 | # This file is the LOCAL_INIT_RC file for the bootstat command. |
| 2 | |
Wei Wang | 4e9c653 | 2019-02-07 10:05:42 -0800 | [diff] [blame^] | 3 | # Mirror bootloader boot reason to system boot reason |
| 4 | # ro.boot.bootreason should be set by init already |
| 5 | # before post-fs trigger |
| 6 | on post-fs && property:ro.boot.bootreason=* |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 7 | setprop sys.boot.reason ${ro.boot.bootreason} |
| 8 | |
James Hawkins | 6bff639 | 2016-01-21 15:16:36 -0800 | [diff] [blame] | 9 | on post-fs-data |
Mark Salyzyn | c3ad75b | 2017-08-09 14:54:56 -0700 | [diff] [blame] | 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 |
Mark Salyzyn | 25246dd | 2017-09-18 10:27:01 -0700 | [diff] [blame] | 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 |
Mark Salyzyn | c3ad75b | 2017-08-09 14:54:56 -0700 | [diff] [blame] | 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/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 Hawkins | 6bff639 | 2016-01-21 15:16:36 -0800 | [diff] [blame] | 43 | |
James Hawkins | c08e996 | 2016-03-11 14:59:50 -0800 | [diff] [blame] | 44 | # 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 Wang | bd6ab49 | 2017-02-09 09:58:14 -0800 | [diff] [blame] | 49 | # property:ro.crypto.type=block: FDE device |
| 50 | on post-fs-data && property:init.svc.bootanim=running && property:ro.crypto.type=block |
Mark Salyzyn | 557a9d4 | 2017-09-15 13:02:19 -0700 | [diff] [blame] | 51 | exec_background - system log -- /system/bin/bootstat -r post_decrypt_time_elapsed |
James Hawkins | c08e996 | 2016-03-11 14:59:50 -0800 | [diff] [blame] | 52 | |
James Hawkins | 800ceb4 | 2017-01-17 13:27:05 -0800 | [diff] [blame] | 53 | # sys.logbootcomplete is a signal to enable the bootstat logging mechanism. |
James Hawkins | f1c2350 | 2017-01-31 11:52:48 -0800 | [diff] [blame] | 54 | # This signaling is necessary to prevent logging boot metrics after a runtime |
| 55 | # restart (e.g., adb shell stop && adb shell start). /proc/uptime is not reset |
| 56 | # during a runtime restart, which leads to false boot time metrics being reported. |
James Hawkins | 800ceb4 | 2017-01-17 13:27:05 -0800 | [diff] [blame] | 57 | # |
| 58 | # The 'on boot' event occurs once per hard boot (device power on), which |
James Hawkins | f1c2350 | 2017-01-31 11:52:48 -0800 | [diff] [blame] | 59 | # switches the flag on. If the device performs a runtime restart, the flag is |
James Hawkins | 800ceb4 | 2017-01-17 13:27:05 -0800 | [diff] [blame] | 60 | # switched off and cannot be switched on until the device hard boots again. |
| 61 | |
| 62 | # Enable bootstat logging on boot. |
| 63 | on boot |
| 64 | setprop sys.logbootcomplete 1 |
| 65 | |
James Hawkins | f1c2350 | 2017-01-31 11:52:48 -0800 | [diff] [blame] | 66 | # Disable further bootstat logging on a runtime restart. A runtime restart is |
James Hawkins | 800ceb4 | 2017-01-17 13:27:05 -0800 | [diff] [blame] | 67 | # signaled by the zygote stopping. |
| 68 | on property:init.svc.zygote=stopping |
| 69 | setprop sys.logbootcomplete 0 |
| 70 | |
Wei Wang | 4e9c653 | 2019-02-07 10:05:42 -0800 | [diff] [blame^] | 71 | # Set boot reason |
| 72 | on zygote-start |
| 73 | # Converts bootloader boot reason and persist.sys.boot.reason to system boot reason |
| 74 | # Need go after persist peroperties are loaded which is right before zygote-start trigger |
| 75 | exec_background - system log -- /system/bin/bootstat --set_system_boot_reason |
| 76 | |
James Hawkins | e4079fb | 2016-12-01 14:02:17 -0800 | [diff] [blame] | 77 | # Record boot complete metrics. |
James Hawkins | 800ceb4 | 2017-01-17 13:27:05 -0800 | [diff] [blame] | 78 | on property:sys.boot_completed=1 && property:sys.logbootcomplete=1 |
James Hawkins | c08e996 | 2016-03-11 14:59:50 -0800 | [diff] [blame] | 79 | # Record boot_complete and related stats (decryption, etc). |
James Hawkins | a4a1a4a | 2016-02-09 15:32:38 -0800 | [diff] [blame] | 80 | # Record the boot reason. |
James Hawkins | 53684ea | 2016-02-23 16:18:19 -0800 | [diff] [blame] | 81 | # Record time since factory reset. |
James Hawkins | 6bff639 | 2016-01-21 15:16:36 -0800 | [diff] [blame] | 82 | # Log all boot events. |
Wei Wang | 4e9c653 | 2019-02-07 10:05:42 -0800 | [diff] [blame^] | 83 | exec_background - system log -- /system/bin/bootstat --record_boot_complete --record_boot_reason --record_time_since_factory_reset -l |