Fix b/279120121: Unplug 100% Pixel phone won't reset the battery usage data when the phone is just started.

Bug: 279120121
Fix: 279120121
Test: manual
Change-Id: Ie793266f8453a2902d7e16e5c58443a3c7bf55ef
This commit is contained in:
Zaiyue Xue
2023-04-21 13:41:22 +08:00
parent 85e5174132
commit aea4d365a6
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;