Loading services/usage/java/com/android/server/usage/UserUsageStatsService.java +5 −6 Original line number Original line Diff line number Diff line Loading @@ -136,17 +136,16 @@ class UserUsageStatsService { } } // During system reboot, add a DEVICE_SHUTDOWN event to the end of event list, the timestamp // During system reboot, add a DEVICE_SHUTDOWN event to the end of event list, the timestamp // is last time UsageStatsDatabase is persisted to disk. // is last time UsageStatsDatabase is persisted to disk or the last event's time whichever // is higher (because the file system timestamp is round down to integral seconds). // Also add a DEVICE_STARTUP event with current system timestamp. // Also add a DEVICE_STARTUP event with current system timestamp. final IntervalStats currentDailyStats = mCurrentStats[INTERVAL_DAILY]; final IntervalStats currentDailyStats = mCurrentStats[INTERVAL_DAILY]; if (currentDailyStats != null) { if (currentDailyStats != null) { // File system timestamp only has precision of 1 second, add 1000ms to make up final Event shutdownEvent = new Event(DEVICE_SHUTDOWN, // for the loss of round up. Math.max(currentDailyStats.lastTimeSaved, currentDailyStats.endTime)); final Event shutdownEvent = new Event(DEVICE_SHUTDOWN, currentDailyStats.lastTimeSaved + 1000); shutdownEvent.mPackage = Event.DEVICE_EVENT_PACKAGE_NAME; shutdownEvent.mPackage = Event.DEVICE_EVENT_PACKAGE_NAME; currentDailyStats.addEvent(shutdownEvent); currentDailyStats.addEvent(shutdownEvent); final Event startupEvent = new Event(DEVICE_STARTUP, currentTimeMillis); final Event startupEvent = new Event(DEVICE_STARTUP, System.currentTimeMillis()); startupEvent.mPackage = Event.DEVICE_EVENT_PACKAGE_NAME; startupEvent.mPackage = Event.DEVICE_EVENT_PACKAGE_NAME; currentDailyStats.addEvent(startupEvent); currentDailyStats.addEvent(startupEvent); } } Loading Loading
services/usage/java/com/android/server/usage/UserUsageStatsService.java +5 −6 Original line number Original line Diff line number Diff line Loading @@ -136,17 +136,16 @@ class UserUsageStatsService { } } // During system reboot, add a DEVICE_SHUTDOWN event to the end of event list, the timestamp // During system reboot, add a DEVICE_SHUTDOWN event to the end of event list, the timestamp // is last time UsageStatsDatabase is persisted to disk. // is last time UsageStatsDatabase is persisted to disk or the last event's time whichever // is higher (because the file system timestamp is round down to integral seconds). // Also add a DEVICE_STARTUP event with current system timestamp. // Also add a DEVICE_STARTUP event with current system timestamp. final IntervalStats currentDailyStats = mCurrentStats[INTERVAL_DAILY]; final IntervalStats currentDailyStats = mCurrentStats[INTERVAL_DAILY]; if (currentDailyStats != null) { if (currentDailyStats != null) { // File system timestamp only has precision of 1 second, add 1000ms to make up final Event shutdownEvent = new Event(DEVICE_SHUTDOWN, // for the loss of round up. Math.max(currentDailyStats.lastTimeSaved, currentDailyStats.endTime)); final Event shutdownEvent = new Event(DEVICE_SHUTDOWN, currentDailyStats.lastTimeSaved + 1000); shutdownEvent.mPackage = Event.DEVICE_EVENT_PACKAGE_NAME; shutdownEvent.mPackage = Event.DEVICE_EVENT_PACKAGE_NAME; currentDailyStats.addEvent(shutdownEvent); currentDailyStats.addEvent(shutdownEvent); final Event startupEvent = new Event(DEVICE_STARTUP, currentTimeMillis); final Event startupEvent = new Event(DEVICE_STARTUP, System.currentTimeMillis()); startupEvent.mPackage = Event.DEVICE_EVENT_PACKAGE_NAME; startupEvent.mPackage = Event.DEVICE_EVENT_PACKAGE_NAME; currentDailyStats.addEvent(startupEvent); currentDailyStats.addEvent(startupEvent); } } Loading