Merge "Fix b/279120121: Unplug 100% Pixel phone won't reset the battery usage data when the phone is just started." into udc-dev

This commit is contained in:
Treehugger Robot
2023-04-25 03:59:03 +00:00
committed by Android (Google) Code Review
2 changed files with 30 additions and 10 deletions

View File

@@ -106,9 +106,13 @@ public final class BatteryUsageBroadcastReceiver extends BroadcastReceiver {
return;
}
final boolean delayHourlyJobWhenBooting =
FeatureFactory.getFactory(context)
.getPowerUsageFeatureProvider(context)
.delayHourlyJobWhenBooting();
final long broadcastDelay = sBroadcastDelayFromBoot - SystemClock.elapsedRealtime();
// If current boot time is smaller than expected delay, cancel sending the broadcast.
if (broadcastDelay > 0) {
if (delayHourlyJobWhenBooting && broadcastDelay > 0) {
Log.d(TAG, "cancel sendBroadcastToFetchUsageData when broadcastDelay is "
+ broadcastDelay + "ms.");
return;