Fix NullPointerException when full charge unplug a device with work profile

Block BatteryUsageBroadcastReceiver when context is work profile.

Bug: 304441610
Fix: 304441610
Test: manual
Change-Id: I91a41d5570e7cacf77a8d126c7700ee4bd766d40
This commit is contained in:
Zaiyue Xue
2023-10-10 16:09:34 +08:00
parent 1735474987
commit 0e277429cb
2 changed files with 15 additions and 0 deletions

View File

@@ -63,6 +63,10 @@ public final class BatteryUsageBroadcastReceiver extends BroadcastReceiver {
}
final String action = intent.getAction();
Log.d(TAG, "onReceive:" + action);
if (DatabaseUtils.isWorkProfile(context)) {
Log.w(TAG, "do nothing for work profile action=" + action);
return;
}
DatabaseUtils.recordDateTime(context, action);
final String fullChargeIntentAction = FeatureFactory.getFeatureFactory()
.getPowerUsageFeatureProvider()