| 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 |  | 
|  | 3 | on post-fs-data | 
|  | 4 | mkdir /data/misc/bootstat 0700 root root | 
|  | 5 |  | 
| James Hawkins | c08e996 | 2016-03-11 14:59:50 -0800 | [diff] [blame] | 6 | # Record the time at which the user has successfully entered the pin to decrypt | 
|  | 7 | # the device, /data is decrypted, and the system is entering the main boot phase. | 
|  | 8 | # | 
|  | 9 | # post-fs-data: /data is writable | 
|  | 10 | # property:init.svc.bootanim=running: The boot animation is running | 
| Wei Wang | bd6ab49 | 2017-02-09 09:58:14 -0800 | [diff] [blame] | 11 | # property:ro.crypto.type=block: FDE device | 
|  | 12 | on post-fs-data && property:init.svc.bootanim=running && property:ro.crypto.type=block | 
| James Hawkins | c08e996 | 2016-03-11 14:59:50 -0800 | [diff] [blame] | 13 | exec - root root -- /system/bin/bootstat -r post_decrypt_time_elapsed | 
|  | 14 |  | 
| James Hawkins | 800ceb4 | 2017-01-17 13:27:05 -0800 | [diff] [blame] | 15 | # sys.logbootcomplete is a signal to enable the bootstat logging mechanism. | 
| James Hawkins | f1c2350 | 2017-01-31 11:52:48 -0800 | [diff] [blame] | 16 | # This signaling is necessary to prevent logging boot metrics after a runtime | 
|  | 17 | # restart (e.g., adb shell stop && adb shell start).  /proc/uptime is not reset | 
|  | 18 | # 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] | 19 | # | 
|  | 20 | # 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] | 21 | # 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] | 22 | # switched off and cannot be switched on until the device hard boots again. | 
|  | 23 |  | 
|  | 24 | # Enable bootstat logging on boot. | 
|  | 25 | on boot | 
|  | 26 | setprop sys.logbootcomplete 1 | 
|  | 27 |  | 
| James Hawkins | f1c2350 | 2017-01-31 11:52:48 -0800 | [diff] [blame] | 28 | # Disable further bootstat logging on a runtime restart. A runtime restart is | 
| James Hawkins | 800ceb4 | 2017-01-17 13:27:05 -0800 | [diff] [blame] | 29 | # signaled by the zygote stopping. | 
|  | 30 | on property:init.svc.zygote=stopping | 
|  | 31 | setprop sys.logbootcomplete 0 | 
|  | 32 |  | 
| James Hawkins | e4079fb | 2016-12-01 14:02:17 -0800 | [diff] [blame] | 33 | # Record boot complete metrics. | 
| James Hawkins | 800ceb4 | 2017-01-17 13:27:05 -0800 | [diff] [blame] | 34 | on property:sys.boot_completed=1 && property:sys.logbootcomplete=1 | 
| James Hawkins | c08e996 | 2016-03-11 14:59:50 -0800 | [diff] [blame] | 35 | # Record boot_complete and related stats (decryption, etc). | 
|  | 36 | exec - root root -- /system/bin/bootstat --record_boot_complete | 
| James Hawkins | 6bff639 | 2016-01-21 15:16:36 -0800 | [diff] [blame] | 37 |  | 
| James Hawkins | a4a1a4a | 2016-02-09 15:32:38 -0800 | [diff] [blame] | 38 | # Record the boot reason. | 
|  | 39 | exec - root root -- /system/bin/bootstat --record_boot_reason | 
|  | 40 |  | 
| James Hawkins | 53684ea | 2016-02-23 16:18:19 -0800 | [diff] [blame] | 41 | # Record time since factory reset. | 
|  | 42 | exec - root root -- /system/bin/bootstat --record_time_since_factory_reset | 
|  | 43 |  | 
| James Hawkins | 6bff639 | 2016-01-21 15:16:36 -0800 | [diff] [blame] | 44 | # Log all boot events. | 
|  | 45 | exec - root root -- /system/bin/bootstat -l |