Loading packages/SystemUI/src/com/android/systemui/battery/BatteryMeterView.java +11 −1 Original line number Diff line number Diff line Loading @@ -86,6 +86,7 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver { private int mShowPercentMode = MODE_DEFAULT; private String mEstimateText = null; private boolean mCharging; private boolean mPresent; private boolean mIsOverheated; private boolean mDisplayShieldEnabled; // Error state where we know nothing about the current battery state Loading Loading @@ -268,6 +269,10 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver { mBatteryEstimateFetcher = fetcher; } void setBatteryPresence(boolean isPresent) { mPresent = isPresent; } void setDisplayShieldEnabled(boolean displayShieldEnabled) { mDisplayShieldEnabled = displayShieldEnabled; } Loading Loading @@ -410,7 +415,7 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver { mBatteryStateUnknown = isUnknown; updateContentDescription(); if (mBatteryStateUnknown) { if (mBatteryStateUnknown && mPresent) { mBatteryIconView.setImageDrawable(getUnknownStateDrawable()); } else { updateDrawable(); Loading Loading @@ -471,6 +476,10 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver { } private void updateDrawable() { if (!mPresent) { return; } switch (getBatteryStyle()) { case BATTERY_STYLE_PORTRAIT: mBatteryIconView.setImageDrawable(mAccessorizedDrawable); Loading Loading @@ -536,6 +545,7 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver { pw.println(" mBatteryStateUnknown: " + mBatteryStateUnknown); pw.println(" mLevel: " + mLevel); pw.println(" mMode: " + mShowPercentMode); pw.println(" mPresent: " + mPresent); } @VisibleForTesting Loading packages/SystemUI/src/com/android/systemui/battery/BatteryMeterViewController.java +4 −0 Original line number Diff line number Diff line Loading @@ -139,7 +139,11 @@ public class BatteryMeterViewController extends ViewController<BatteryMeterView> mBatteryController = batteryController; mView.setBatteryEstimateFetcher(mBatteryController::getEstimatedTimeRemainingString); mView.setBatteryPresence(mBatteryController.isPresent()); mView.setDisplayShieldEnabled(featureFlags.isEnabled(Flags.BATTERY_SHIELD_ICON)); if (!mBatteryController.isPresent()) { mView.setVisibility(View.GONE); } mSlotBattery = getResources().getString(com.android.internal.R.string.status_bar_battery); mSettingObserver = new SettingObserver(mMainHandler); Loading packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +2 −2 Original line number Diff line number Diff line Loading @@ -497,7 +497,7 @@ public class KeyguardIndicationController { } private void updateLockScreenBatteryMsg(boolean animate) { if (mPowerPluggedIn || mEnableBatteryDefender) { if (mBatteryPresent && (mPowerPluggedIn || mEnableBatteryDefender)) { String powerIndication = computePowerIndication(); if (DEBUG_CHARGING_SPEED) { powerIndication += ", " + (mChargingWattage / 1000) + " mW"; Loading @@ -513,7 +513,7 @@ public class KeyguardIndicationController { animate); } else { mKeyguardLogger.log(TAG, LogLevel.DEBUG, "hide battery indication"); // don't show the charging information if device isn't plugged in // don't show the charging information mRotateTextViewController.hideIndication(INDICATION_TYPE_BATTERY); } } Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java +5 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,11 @@ public interface BatteryController extends DemoMode, return false; } /** * Returns {@code true} if there's a battery present in the device. */ boolean isPresent(); /** * Returns {@code true} if the device is currently in power save mode. */ Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryControllerImpl.java +9 −2 Original line number Diff line number Diff line Loading @@ -85,6 +85,7 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC protected int mLevel; protected boolean mPluggedIn; protected boolean mPresent; private int mPluggedChargingSource; protected boolean mCharging; private boolean mStateUnknown = false; Loading Loading @@ -159,6 +160,7 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC pw.println("BatteryController state:"); pw.print(" mLevel="); pw.println(mLevel); pw.print(" mPluggedIn="); pw.println(mPluggedIn); pw.print(" mPresent="); pw.println(mPresent); pw.print(" mCharging="); pw.println(mCharging); pw.print(" mCharged="); pw.println(mCharged); pw.print(" mIsOverheated="); pw.println(mIsOverheated); Loading Loading @@ -226,8 +228,8 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC fireWirelessChargingChanged(); } boolean present = intent.getBooleanExtra(EXTRA_PRESENT, true); boolean unknown = !present; mPresent = intent.getBooleanExtra(EXTRA_PRESENT, true); boolean unknown = !mPresent; if (unknown != mStateUnknown) { mStateUnknown = unknown; fireBatteryUnknownStateChanged(); Loading Loading @@ -290,6 +292,11 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC return mPluggedIn; } @Override public boolean isPresent() { return mPresent; } @Override public boolean isPowerSave() { return mPowerSave; Loading Loading
packages/SystemUI/src/com/android/systemui/battery/BatteryMeterView.java +11 −1 Original line number Diff line number Diff line Loading @@ -86,6 +86,7 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver { private int mShowPercentMode = MODE_DEFAULT; private String mEstimateText = null; private boolean mCharging; private boolean mPresent; private boolean mIsOverheated; private boolean mDisplayShieldEnabled; // Error state where we know nothing about the current battery state Loading Loading @@ -268,6 +269,10 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver { mBatteryEstimateFetcher = fetcher; } void setBatteryPresence(boolean isPresent) { mPresent = isPresent; } void setDisplayShieldEnabled(boolean displayShieldEnabled) { mDisplayShieldEnabled = displayShieldEnabled; } Loading Loading @@ -410,7 +415,7 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver { mBatteryStateUnknown = isUnknown; updateContentDescription(); if (mBatteryStateUnknown) { if (mBatteryStateUnknown && mPresent) { mBatteryIconView.setImageDrawable(getUnknownStateDrawable()); } else { updateDrawable(); Loading Loading @@ -471,6 +476,10 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver { } private void updateDrawable() { if (!mPresent) { return; } switch (getBatteryStyle()) { case BATTERY_STYLE_PORTRAIT: mBatteryIconView.setImageDrawable(mAccessorizedDrawable); Loading Loading @@ -536,6 +545,7 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver { pw.println(" mBatteryStateUnknown: " + mBatteryStateUnknown); pw.println(" mLevel: " + mLevel); pw.println(" mMode: " + mShowPercentMode); pw.println(" mPresent: " + mPresent); } @VisibleForTesting Loading
packages/SystemUI/src/com/android/systemui/battery/BatteryMeterViewController.java +4 −0 Original line number Diff line number Diff line Loading @@ -139,7 +139,11 @@ public class BatteryMeterViewController extends ViewController<BatteryMeterView> mBatteryController = batteryController; mView.setBatteryEstimateFetcher(mBatteryController::getEstimatedTimeRemainingString); mView.setBatteryPresence(mBatteryController.isPresent()); mView.setDisplayShieldEnabled(featureFlags.isEnabled(Flags.BATTERY_SHIELD_ICON)); if (!mBatteryController.isPresent()) { mView.setVisibility(View.GONE); } mSlotBattery = getResources().getString(com.android.internal.R.string.status_bar_battery); mSettingObserver = new SettingObserver(mMainHandler); Loading
packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +2 −2 Original line number Diff line number Diff line Loading @@ -497,7 +497,7 @@ public class KeyguardIndicationController { } private void updateLockScreenBatteryMsg(boolean animate) { if (mPowerPluggedIn || mEnableBatteryDefender) { if (mBatteryPresent && (mPowerPluggedIn || mEnableBatteryDefender)) { String powerIndication = computePowerIndication(); if (DEBUG_CHARGING_SPEED) { powerIndication += ", " + (mChargingWattage / 1000) + " mW"; Loading @@ -513,7 +513,7 @@ public class KeyguardIndicationController { animate); } else { mKeyguardLogger.log(TAG, LogLevel.DEBUG, "hide battery indication"); // don't show the charging information if device isn't plugged in // don't show the charging information mRotateTextViewController.hideIndication(INDICATION_TYPE_BATTERY); } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java +5 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,11 @@ public interface BatteryController extends DemoMode, return false; } /** * Returns {@code true} if there's a battery present in the device. */ boolean isPresent(); /** * Returns {@code true} if the device is currently in power save mode. */ Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryControllerImpl.java +9 −2 Original line number Diff line number Diff line Loading @@ -85,6 +85,7 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC protected int mLevel; protected boolean mPluggedIn; protected boolean mPresent; private int mPluggedChargingSource; protected boolean mCharging; private boolean mStateUnknown = false; Loading Loading @@ -159,6 +160,7 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC pw.println("BatteryController state:"); pw.print(" mLevel="); pw.println(mLevel); pw.print(" mPluggedIn="); pw.println(mPluggedIn); pw.print(" mPresent="); pw.println(mPresent); pw.print(" mCharging="); pw.println(mCharging); pw.print(" mCharged="); pw.println(mCharged); pw.print(" mIsOverheated="); pw.println(mIsOverheated); Loading Loading @@ -226,8 +228,8 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC fireWirelessChargingChanged(); } boolean present = intent.getBooleanExtra(EXTRA_PRESENT, true); boolean unknown = !present; mPresent = intent.getBooleanExtra(EXTRA_PRESENT, true); boolean unknown = !mPresent; if (unknown != mStateUnknown) { mStateUnknown = unknown; fireBatteryUnknownStateChanged(); Loading Loading @@ -290,6 +292,11 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC return mPluggedIn; } @Override public boolean isPresent() { return mPresent; } @Override public boolean isPowerSave() { return mPowerSave; Loading