UsageStats DEVICE_SHUTDOWN event.
DEVICE_SHUTDOWN event is used to close all open usage events that do not have matching closing event when device is shut down. For example, ACTIVITY_RESUMED or FOREGROUND_SERVICE_START are open events, the DEVICE_SHUTDOWN event will close the usage session of the open events. At orderly shutdown like selecting Power Off or Restart after pressing power button, a DEVICE_SHUTDOWN event is sent to UsageStats. UsageStats persists UsageStatsDatabase to disk immediately. When power button is pressed for 3.5 seconds (configured by config_veryLongPressTimeout in config.xml). A DEVICE_SHUTDOWN event is sent to UsageStats. UsageStats persists UsageStatsDatabase to disk immediately. This is the mechanism that we do not lose UsageStats data when the device is shut down. When the device boots up, if the last event is not DEVICE_SHUTDOWN, we add a DEVICE_SHUTDOWN with timestamp set to be the last time database file is persisted. This is to handle the case device shutdown abruptly due to power drained or cold temperature. Bug: 111464278 Test: atest UsageStatsTest.java Change-Id: I1e88063ba71d09042d02c6deb9f07d8581a15c30
Loading
Please register or sign in to comment