Fix the NPE in the tryToFetchUsageData() method

Test: atest
Bug: 371490669
Fix: 371490669
Flag: EXEMPT for simple fix
Change-Id: I4167becf373a6279135261bbaff44ef0888728fa
This commit is contained in:
YK Hung
2024-10-07 23:46:43 +00:00
parent efd16c7df9
commit 291e92d649

View File

@@ -106,6 +106,10 @@ public final class BatteryUsageBroadcastReceiver extends BroadcastReceiver {
private void tryToFetchUsageData(Context context) {
final Intent batteryIntent = BatteryUtils.getBatteryIntent(context);
if (batteryIntent == null) {
Log.w(TAG, "tryToFetchUsageData: ignore from null battery intent");
return;
}
// Returns when battery is not fully charged.
if (!BatteryStatus.isCharged(batteryIntent)) {
return;