[Robustness] protect get battery stats from DeadSystemException
Refine the original workaround patch in the ag/15527095 from NPE to return default BatteryUsageStats instance as we merged in the ag/15919139 (align the same solution). Bug: 195306545 Test: make SettingsRoboTests Change-Id: Ic03e8296d16ecb8629155f75727e9cde48c303eb
This commit is contained in:
@@ -25,7 +25,6 @@ import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.provider.Settings.Global;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.loader.app.LoaderManager;
|
||||
@@ -104,10 +103,6 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<BatteryInfo> loader, BatteryInfo batteryInfo) {
|
||||
if (batteryInfo == null) {
|
||||
Log.w(TAG, "mBatteryInfoLoaderCallbacks: batteryInfo = null");
|
||||
return;
|
||||
}
|
||||
mBatteryHeaderPreferenceController.updateHeaderPreference(batteryInfo);
|
||||
mBatteryHeaderPreferenceController.updateHeaderByBatteryTips(
|
||||
mBatteryTipPreferenceController.getCurrentBatteryTip(), batteryInfo);
|
||||
@@ -131,10 +126,6 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
||||
@Override
|
||||
public void onLoadFinished(Loader<List<BatteryTip>> loader,
|
||||
List<BatteryTip> data) {
|
||||
if (mBatteryInfo == null) {
|
||||
Log.w(TAG, "mBatteryTipsCallbacks: batteryInfo = null");
|
||||
return;
|
||||
}
|
||||
mBatteryTipPreferenceController.updateBatteryTips(data);
|
||||
mBatteryHeaderPreferenceController.updateHeaderByBatteryTips(
|
||||
mBatteryTipPreferenceController.getCurrentBatteryTip(), mBatteryInfo);
|
||||
|
||||
Reference in New Issue
Block a user