Merge "Fix b/284496479: Crash when opening App Info page" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c8af2bdcc5
@@ -196,6 +196,9 @@ public class BatteryStatus {
|
|||||||
|
|
||||||
/** Gets the battery level from the intent. */
|
/** Gets the battery level from the intent. */
|
||||||
public static int getBatteryLevel(Intent batteryChangedIntent) {
|
public static int getBatteryLevel(Intent batteryChangedIntent) {
|
||||||
|
if (batteryChangedIntent == null) {
|
||||||
|
return -1; /*invalid battery level*/
|
||||||
|
}
|
||||||
final int level = batteryChangedIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
|
final int level = batteryChangedIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
|
||||||
final int scale = batteryChangedIntent.getIntExtra(BatteryManager.EXTRA_SCALE, 0);
|
final int scale = batteryChangedIntent.getIntExtra(BatteryManager.EXTRA_SCALE, 0);
|
||||||
return scale == 0
|
return scale == 0
|
||||||
|
|||||||
Reference in New Issue
Block a user