Merge "Fix talkback reading battery 0% on boot" into nyc-mr1-dev
This commit is contained in:
@@ -53,6 +53,7 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC
|
||||
protected boolean mCharged;
|
||||
protected boolean mPowerSave;
|
||||
private boolean mTestmode = false;
|
||||
private boolean mHasReceivedBattery = false;
|
||||
|
||||
public BatteryControllerImpl(Context context) {
|
||||
mContext = context;
|
||||
@@ -92,6 +93,7 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC
|
||||
synchronized (mChangeCallbacks) {
|
||||
mChangeCallbacks.add(cb);
|
||||
}
|
||||
if (!mHasReceivedBattery) return;
|
||||
cb.onBatteryLevelChanged(mLevel, mPluggedIn, mCharging);
|
||||
cb.onPowerSaveChanged(mPowerSave);
|
||||
}
|
||||
@@ -108,6 +110,7 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC
|
||||
final String action = intent.getAction();
|
||||
if (action.equals(Intent.ACTION_BATTERY_CHANGED)) {
|
||||
if (mTestmode && !intent.getBooleanExtra("testmode", false)) return;
|
||||
mHasReceivedBattery = true;
|
||||
mLevel = (int)(100f
|
||||
* intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0)
|
||||
/ intent.getIntExtra(BatteryManager.EXTRA_SCALE, 100));
|
||||
|
||||
Reference in New Issue
Block a user