Fix talkback reading battery 0% on boot

am: 159dfb78e9

Change-Id: Iec739c53af9e41664da6b62cb839f1c42912abc8
This commit is contained in:
Jason Monk
2016-09-30 16:48:12 +00:00
committed by android-build-merger

View File

@@ -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));