mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 727477 - Workaround Galaxy Nexus bug that prevented Battery API to work. r=dougt
This is also changing the default values sent if the device has no battery.
This commit is contained in:
parent
2224cef968
commit
8a0a3831de
@ -47,6 +47,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.os.SystemClock;
|
||||
|
||||
public class GeckoBatteryManager
|
||||
@ -77,7 +78,14 @@ public class GeckoBatteryManager
|
||||
boolean previousCharging = isCharging();
|
||||
double previousLevel = getLevel();
|
||||
|
||||
if (intent.getBooleanExtra(BatteryManager.EXTRA_PRESENT, false)) {
|
||||
// NOTE: it might not be common (in 2012) but technically, Android can run
|
||||
// on a device that has no battery so we want to make sure it's not the case
|
||||
// before bothering checking for battery state.
|
||||
// However, the Galaxy Nexus phone advertizes itself as battery-less which
|
||||
// force us to special-case the logic.
|
||||
// See the Google bug: https://code.google.com/p/android/issues/detail?id=22035
|
||||
if (intent.getBooleanExtra(BatteryManager.EXTRA_PRESENT, false) ||
|
||||
Build.MODEL.equals("Galaxy Nexus")) {
|
||||
int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
|
||||
if (plugged == -1) {
|
||||
sCharging = kDefaultCharging;
|
||||
@ -140,7 +148,7 @@ public class GeckoBatteryManager
|
||||
} else {
|
||||
sLevel = kDefaultLevel;
|
||||
sCharging = kDefaultCharging;
|
||||
sRemainingTime = kDefaultRemainingTime;
|
||||
sRemainingTime = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user