[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:
@@ -162,7 +162,9 @@ public class BatteryInfo {
|
||||
.getBatteryUsageStats();
|
||||
} catch (RuntimeException e) {
|
||||
Log.e(TAG, "getBatteryInfo() from getBatteryUsageStats()", e);
|
||||
return null;
|
||||
// Use default BatteryUsageStats.
|
||||
stats = new BatteryUsageStats.Builder(
|
||||
new String[0], /* includePowerModels */ false).build();
|
||||
}
|
||||
}
|
||||
return getBatteryInfo(context, stats, shortString);
|
||||
|
Reference in New Issue
Block a user