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 | |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 3 | # mirror bootloader boot reason to system boot reason |
| 4 | on property:ro.boot.bootreason=* |
| 5 | setprop sys.boot.reason ${ro.boot.bootreason} |
| 6 | |
James Hawkins | 6bff639 | 2016-01-21 15:16:36 -0800 | [diff] [blame] | 7 | on post-fs-data |
Mark Salyzyn | c3ad75b | 2017-08-09 14:54:56 -0700 | [diff] [blame] | 8 | mkdir /data/misc/bootstat 0700 system log |
| 9 | # To deal with ota transition resulting from a change in DAC from |
| 10 | # root.root to system.log, may be deleted after ota has settled. |
| 11 | chown system log /data/misc/bootstat/absolute_boot_time |
| 12 | chown system log /data/misc/bootstat/boot_complete |
| 13 | chown system log /data/misc/bootstat/boot_complete_no_encryption |
| 14 | chown system log /data/misc/bootstat/boot_reason |
Mark Salyzyn | 25246dd | 2017-09-18 10:27:01 -0700 | [diff] [blame] | 15 | chown system log /data/misc/bootstat/boottime.bootloader.1BLE |
| 16 | chown system log /data/misc/bootstat/boottime.bootloader.1BLL |
| 17 | chown system log /data/misc/bootstat/boottime.bootloader.2BLE |
| 18 | chown system log /data/misc/bootstat/boottime.bootloader.2BLL |
| 19 | chown system log /data/misc/bootstat/boottime.bootloader.AVB |
| 20 | chown system log /data/misc/bootstat/boottime.bootloader.KD |
| 21 | chown system log /data/misc/bootstat/boottime.bootloader.KL |
| 22 | chown system log /data/misc/bootstat/boottime.bootloader.ODT |
| 23 | chown system log /data/misc/bootstat/boottime.bootloader.SW |
| 24 | chown system log /data/misc/bootstat/boottime.bootloader.total |
Mark Salyzyn | c3ad75b | 2017-08-09 14:54:56 -0700 | [diff] [blame] | 25 | chown system log /data/misc/bootstat/build_date |
| 26 | chown system log /data/misc/bootstat/factory_reset |
| 27 | chown system log /data/misc/bootstat/factory_reset_boot_complete |
| 28 | chown system log /data/misc/bootstat/factory_reset_boot_complete_no_encryption |
| 29 | chown system log /data/misc/bootstat/factory_reset_current_time |
| 30 | chown system log /data/misc/bootstat/factory_reset_record_value |
| 31 | chown system log /data/misc/bootstat/last_boot_time_utc |
| 32 | chown system log /data/misc/bootstat/ota_boot_complete |
| 33 | chown system log /data/misc/bootstat/ota_boot_complete_no_encryption |
| 34 | chown system log /data/misc/bootstat/post_decrypt_time_elapsed |
| 35 | chown system log /data/misc/bootstat/ro.boottime.init |
| 36 | chown system log /data/misc/bootstat/ro.boottime.init.cold_boot_wait |
| 37 | chown system log /data/misc/bootstat/ro.boottime.init.selinux |
| 38 | chown system log /data/misc/bootstat/time_since_factory_reset |
| 39 | chown system log /data/misc/bootstat/time_since_last_boot |
| 40 | # end ota transitional support |
James Hawkins | 6bff639 | 2016-01-21 15:16:36 -0800 | [diff] [blame] | 41 | |
James Hawkins | c08e996 | 2016-03-11 14:59:50 -0800 | [diff] [blame] | 42 | # Record the time at which the user has successfully entered the pin to decrypt |
| 43 | # the device, /data is decrypted, and the system is entering the main boot phase. |
| 44 | # |
| 45 | # post-fs-data: /data is writable |
| 46 | # property:init.svc.bootanim=running: The boot animation is running |
Wei Wang | bd6ab49 | 2017-02-09 09:58:14 -0800 | [diff] [blame] | 47 | # property:ro.crypto.type=block: FDE device |
| 48 | 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] | 49 | exec_background - system log -- /system/bin/bootstat -r post_decrypt_time_elapsed |
James Hawkins | c08e996 | 2016-03-11 14:59:50 -0800 | [diff] [blame] | 50 | |
James Hawkins | 800ceb4 | 2017-01-17 13:27:05 -0800 | [diff] [blame] | 51 | # sys.logbootcomplete is a signal to enable the bootstat logging mechanism. |
James Hawkins | f1c2350 | 2017-01-31 11:52:48 -0800 | [diff] [blame] | 52 | # This signaling is necessary to prevent logging boot metrics after a runtime |
| 53 | # restart (e.g., adb shell stop && adb shell start). /proc/uptime is not reset |
| 54 | # 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] | 55 | # |
| 56 | # 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] | 57 | # 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] | 58 | # switched off and cannot be switched on until the device hard boots again. |
| 59 | |
| 60 | # Enable bootstat logging on boot. |
| 61 | on boot |
| 62 | setprop sys.logbootcomplete 1 |
| 63 | |
James Hawkins | f1c2350 | 2017-01-31 11:52:48 -0800 | [diff] [blame] | 64 | # Disable further bootstat logging on a runtime restart. A runtime restart is |
James Hawkins | 800ceb4 | 2017-01-17 13:27:05 -0800 | [diff] [blame] | 65 | # signaled by the zygote stopping. |
| 66 | on property:init.svc.zygote=stopping |
| 67 | setprop sys.logbootcomplete 0 |
| 68 | |
James Hawkins | e4079fb | 2016-12-01 14:02:17 -0800 | [diff] [blame] | 69 | # Record boot complete metrics. |
James Hawkins | 800ceb4 | 2017-01-17 13:27:05 -0800 | [diff] [blame] | 70 | on property:sys.boot_completed=1 && property:sys.logbootcomplete=1 |
Tej Singh | 993f656 | 2018-02-06 15:57:38 -0800 | [diff] [blame] | 71 | # Converts bootloader boot reason to system boot reason |
James Hawkins | c08e996 | 2016-03-11 14:59:50 -0800 | [diff] [blame] | 72 | # Record boot_complete and related stats (decryption, etc). |
James Hawkins | a4a1a4a | 2016-02-09 15:32:38 -0800 | [diff] [blame] | 73 | # Record the boot reason. |
James Hawkins | 53684ea | 2016-02-23 16:18:19 -0800 | [diff] [blame] | 74 | # Record time since factory reset. |
James Hawkins | 6bff639 | 2016-01-21 15:16:36 -0800 | [diff] [blame] | 75 | # Log all boot events. |
Tej Singh | 993f656 | 2018-02-06 15:57:38 -0800 | [diff] [blame] | 76 | exec_background - system log -- /system/bin/bootstat --set_system_boot_reason --record_boot_complete --record_boot_reason --record_time_since_factory_reset -l |