diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 78436ad9ca0ed..6c01cfd2cae4f 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -3477,4 +3477,6 @@ false + + true diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index da78fa2e6e739..b90034e2fd697 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2200,6 +2200,7 @@ + diff --git a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java index 59501f0970c24..81dd5eb7fed88 100644 --- a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java +++ b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java @@ -55,6 +55,7 @@ import com.android.systemui.statusbar.policy.IconLogger; import com.android.systemui.tuner.TunerService; import com.android.systemui.tuner.TunerService.Tunable; import com.android.systemui.util.Utils.DisableStateTracker; +import com.android.systemui.R; import java.text.NumberFormat; @@ -72,6 +73,7 @@ public class BatteryMeterView extends LinearLayout implements private int mTextColor; private int mLevel; private boolean mForceShowPercent; + private boolean mShowPercentAvailable; private int mDarkModeBackgroundColor; private int mDarkModeFillColor; @@ -111,6 +113,9 @@ public class BatteryMeterView extends LinearLayout implements atts.recycle(); mSettingObserver = new SettingObserver(new Handler(context.getMainLooper())); + mShowPercentAvailable = context.getResources().getBoolean( + com.android.internal.R.bool.config_battery_percentage_setting_available); + addOnAttachStateChangeListener( new DisableStateTracker(DISABLE_NONE, DISABLE2_SYSTEM_ICONS)); @@ -259,8 +264,11 @@ public class BatteryMeterView extends LinearLayout implements private void updateShowPercent() { final boolean showing = mBatteryPercentView != null; - if (0 != Settings.System.getIntForUser(getContext().getContentResolver(), - SHOW_BATTERY_PERCENT, 0, mUser) || mForceShowPercent) { + final boolean systemSetting = 0 != Settings.System + .getIntForUser(getContext().getContentResolver(), + SHOW_BATTERY_PERCENT, 0, mUser); + + if ((mShowPercentAvailable && systemSetting) || mForceShowPercent) { if (!showing) { mBatteryPercentView = loadPercentView(); if (mTextColor != 0) mBatteryPercentView.setTextColor(mTextColor); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java index 0bd3cc795bc3f..db84222ec5a64 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java @@ -67,6 +67,7 @@ public class KeyguardStatusBarView extends RelativeLayout private static final int LAYOUT_CUTOUT = 1; private static final int LAYOUT_NO_CUTOUT = 2; + private boolean mShowPercentAvailable; private boolean mBatteryCharging; private boolean mKeyguardUserSwitcherShowing; private boolean mBatteryListening; @@ -165,6 +166,8 @@ public class KeyguardStatusBarView extends RelativeLayout R.dimen.system_icons_super_container_avatarless_margin_end); mCutoutSideNudge = getResources().getDimensionPixelSize( R.dimen.display_cutout_margin_consumption); + mShowPercentAvailable = getContext().getResources().getBoolean( + com.android.internal.R.bool.config_battery_percentage_setting_available); } private void updateVisibilities() { @@ -186,7 +189,7 @@ public class KeyguardStatusBarView extends RelativeLayout mMultiUserSwitch.setVisibility(View.GONE); } } - mBatteryView.setForceShowPercent(mBatteryCharging); + mBatteryView.setForceShowPercent(mBatteryCharging && mShowPercentAvailable); } private void updateSystemIconsLayoutParams() {