Loading core/java/android/provider/Settings.java +7 −0 Original line number Diff line number Diff line Loading @@ -2642,6 +2642,12 @@ public final class Settings { */ public static final String LOCKSCREEN_CALENDAR_REMINDERS_ONLY = "lockscreen_calendar_reminders_only"; /** * Always show the battery status on the lockscreen * @hide */ public static final String LOCKSCREEN_ALWAYS_SHOW_BATTERY = "lockscreen_always_show_battery"; /** * Show the pending notification counts as overlays on the status bar * @hide Loading Loading @@ -2733,6 +2739,7 @@ public final class Settings { QUIET_HOURS_MUTE, QUIET_HOURS_STILL, QUIET_HOURS_DIM, LOCKSCREEN_ALWAYS_SHOW_BATTERY, }; // Settings moved to Settings.Secure Loading core/res/res/values/public.xml +3 −0 Original line number Diff line number Diff line Loading @@ -3834,4 +3834,7 @@ <java-symbol type="string" name="second" /> <java-symbol type="string" name="seconds" /> <!-- Lock screen always show battery --> <java-symbol type="string" name="lockscreen_discharging" /> </resources> core/res/res/values/strings.xml +4 −3 Original line number Diff line number Diff line Loading @@ -1979,15 +1979,16 @@ <!-- When the lock screen is showing and the phone plugged in, and the battery is not fully charged, show the current charge %. --> <string name="lockscreen_plugged_in">Charging, <xliff:g id="number">%d</xliff:g><xliff:g id="percent">%%</xliff:g></string> <string name="lockscreen_discharging">Discharging, <xliff:g id="number">%d</xliff:g><xliff:g id="percent">%%</xliff:g></string> <!-- When the lock screen is showing, the phone is plugged in and the battery is fully charged, say that it is charged. --> <string name="lockscreen_charged">Charged.</string> <string name="lockscreen_charged">Charged</string> <!-- A short representation of charging information, e.g "34%" --> <string name="lockscreen_battery_short"><xliff:g id="number">%d</xliff:g><xliff:g id="percent">%%</xliff:g></string> <!-- When the lock screen is showing and the battery is low, warn user to plug in the phone soon. --> <string name="lockscreen_low_battery">Connect your charger.</string> in the phone soon and show current percentage. --> <string name="lockscreen_low_battery">Connect your charger, <xliff:g id="number">%d</xliff:g><xliff:g id="percent">%%</xliff:g></string> <!-- Shown in the lock screen when there is no SIM card. --> <string name="lockscreen_missing_sim_message_short">No SIM card.</string> Loading policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java +15 −2 Original line number Diff line number Diff line Loading @@ -81,6 +81,7 @@ class KeyguardStatusViewManager implements OnClickListener { public static final int LOCK_ICON = 0; // R.drawable.ic_lock_idle_lock; public static final int ALARM_ICON = R.drawable.ic_lock_idle_alarm; public static final int CHARGING_ICON = 0; //R.drawable.ic_lock_idle_charging; public static final int DISCHARGING_ICON = 0; // no icon used in ics+ currently public static final int BATTERY_LOW_ICON = 0; //R.drawable.ic_lock_idle_low_battery; private static final long INSTRUCTION_RESET_DELAY = 2000; // time until instruction text resets Loading Loading @@ -121,6 +122,9 @@ class KeyguardStatusViewManager implements OnClickListener { // last known battery level private int mBatteryLevel = 100; // always show battery status? private boolean mAlwaysShowBattery = false; // last known SIM state protected State mSimState; Loading Loading @@ -675,6 +679,7 @@ class KeyguardStatusViewManager implements OnClickListener { mShowingBatteryInfo = mUpdateMonitor.shouldShowBatteryInfo(); mPluggedIn = mUpdateMonitor.isDevicePluggedIn(); mBatteryLevel = mUpdateMonitor.getBatteryLevel(); mAlwaysShowBattery = KeyguardUpdateMonitor.shouldAlwaysShowBatteryInfo(getContext()); updateStatusLines(true); } Loading Loading @@ -748,8 +753,12 @@ class KeyguardStatusViewManager implements OnClickListener { icon.value = CHARGING_ICON; } else if (mBatteryLevel < KeyguardUpdateMonitor.LOW_BATTERY_THRESHOLD) { // Battery is low string = getContext().getString(R.string.lockscreen_low_battery); string = getContext().getString(R.string.lockscreen_low_battery, mBatteryLevel); icon.value = BATTERY_LOW_ICON; } else if (mAlwaysShowBattery) { // Discharging string = getContext().getString(R.string.lockscreen_discharging, mBatteryLevel); icon.value = DISCHARGING_ICON; } } else { string = mCarrierText; Loading @@ -775,8 +784,12 @@ class KeyguardStatusViewManager implements OnClickListener { icon.value = CHARGING_ICON; } else if (mBatteryLevel < KeyguardUpdateMonitor.LOW_BATTERY_THRESHOLD) { // Battery is low string = getContext().getString(R.string.lockscreen_low_battery); string = getContext().getString(R.string.lockscreen_low_battery, mBatteryLevel); icon.value = BATTERY_LOW_ICON; } else if (mAlwaysShowBattery) { // Discharging string = getContext().getString(R.string.lockscreen_discharging, mBatteryLevel); icon.value = DISCHARGING_ICON; } } else if (!inWidgetMode() && mOwnerInfoView == null && mOwnerInfoText != null) { // OwnerInfo shows in status if we don't have a dedicated widget Loading policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java +11 −5 Original line number Diff line number Diff line Loading @@ -378,7 +378,7 @@ public class KeyguardUpdateMonitor { private void handleBatteryUpdate(BatteryStatus batteryStatus) { if (DEBUG) Log.d(TAG, "handleBatteryUpdate"); final boolean batteryUpdateInteresting = isBatteryUpdateInteresting(mBatteryStatus, batteryStatus); isBatteryUpdateInteresting(mBatteryStatus, batteryStatus, mContext); mBatteryStatus = batteryStatus; if (batteryUpdateInteresting) { for (int i = 0; i < mInfoCallbacks.size(); i++) { Loading Loading @@ -437,7 +437,7 @@ public class KeyguardUpdateMonitor { || status.plugged == BatteryManager.BATTERY_PLUGGED_USB; } private static boolean isBatteryUpdateInteresting(BatteryStatus old, BatteryStatus current) { private static boolean isBatteryUpdateInteresting(BatteryStatus old, BatteryStatus current, Context context) { final boolean nowPluggedIn = isPluggedIn(current); final boolean wasPluggedIn = isPluggedIn(old); final boolean stateChangedWhilePluggedIn = Loading @@ -449,8 +449,8 @@ public class KeyguardUpdateMonitor { return true; } // change in battery level while plugged in if (nowPluggedIn && old.level != current.level) { // change in battery level while plugged in or always interested if ((nowPluggedIn || shouldAlwaysShowBatteryInfo(context)) && old.level != current.level) { return true; } Loading Loading @@ -676,7 +676,13 @@ public class KeyguardUpdateMonitor { } public boolean shouldShowBatteryInfo() { return isPluggedIn(mBatteryStatus) || isBatteryLow(mBatteryStatus); return isPluggedIn(mBatteryStatus) || isBatteryLow(mBatteryStatus) || shouldAlwaysShowBatteryInfo(mContext); } public static boolean shouldAlwaysShowBatteryInfo(Context context) { return Settings.System.getInt(context.getContentResolver(), Settings.System.LOCKSCREEN_ALWAYS_SHOW_BATTERY, 0) == 1; } public CharSequence getTelephonyPlmn() { Loading Loading
core/java/android/provider/Settings.java +7 −0 Original line number Diff line number Diff line Loading @@ -2642,6 +2642,12 @@ public final class Settings { */ public static final String LOCKSCREEN_CALENDAR_REMINDERS_ONLY = "lockscreen_calendar_reminders_only"; /** * Always show the battery status on the lockscreen * @hide */ public static final String LOCKSCREEN_ALWAYS_SHOW_BATTERY = "lockscreen_always_show_battery"; /** * Show the pending notification counts as overlays on the status bar * @hide Loading Loading @@ -2733,6 +2739,7 @@ public final class Settings { QUIET_HOURS_MUTE, QUIET_HOURS_STILL, QUIET_HOURS_DIM, LOCKSCREEN_ALWAYS_SHOW_BATTERY, }; // Settings moved to Settings.Secure Loading
core/res/res/values/public.xml +3 −0 Original line number Diff line number Diff line Loading @@ -3834,4 +3834,7 @@ <java-symbol type="string" name="second" /> <java-symbol type="string" name="seconds" /> <!-- Lock screen always show battery --> <java-symbol type="string" name="lockscreen_discharging" /> </resources>
core/res/res/values/strings.xml +4 −3 Original line number Diff line number Diff line Loading @@ -1979,15 +1979,16 @@ <!-- When the lock screen is showing and the phone plugged in, and the battery is not fully charged, show the current charge %. --> <string name="lockscreen_plugged_in">Charging, <xliff:g id="number">%d</xliff:g><xliff:g id="percent">%%</xliff:g></string> <string name="lockscreen_discharging">Discharging, <xliff:g id="number">%d</xliff:g><xliff:g id="percent">%%</xliff:g></string> <!-- When the lock screen is showing, the phone is plugged in and the battery is fully charged, say that it is charged. --> <string name="lockscreen_charged">Charged.</string> <string name="lockscreen_charged">Charged</string> <!-- A short representation of charging information, e.g "34%" --> <string name="lockscreen_battery_short"><xliff:g id="number">%d</xliff:g><xliff:g id="percent">%%</xliff:g></string> <!-- When the lock screen is showing and the battery is low, warn user to plug in the phone soon. --> <string name="lockscreen_low_battery">Connect your charger.</string> in the phone soon and show current percentage. --> <string name="lockscreen_low_battery">Connect your charger, <xliff:g id="number">%d</xliff:g><xliff:g id="percent">%%</xliff:g></string> <!-- Shown in the lock screen when there is no SIM card. --> <string name="lockscreen_missing_sim_message_short">No SIM card.</string> Loading
policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java +15 −2 Original line number Diff line number Diff line Loading @@ -81,6 +81,7 @@ class KeyguardStatusViewManager implements OnClickListener { public static final int LOCK_ICON = 0; // R.drawable.ic_lock_idle_lock; public static final int ALARM_ICON = R.drawable.ic_lock_idle_alarm; public static final int CHARGING_ICON = 0; //R.drawable.ic_lock_idle_charging; public static final int DISCHARGING_ICON = 0; // no icon used in ics+ currently public static final int BATTERY_LOW_ICON = 0; //R.drawable.ic_lock_idle_low_battery; private static final long INSTRUCTION_RESET_DELAY = 2000; // time until instruction text resets Loading Loading @@ -121,6 +122,9 @@ class KeyguardStatusViewManager implements OnClickListener { // last known battery level private int mBatteryLevel = 100; // always show battery status? private boolean mAlwaysShowBattery = false; // last known SIM state protected State mSimState; Loading Loading @@ -675,6 +679,7 @@ class KeyguardStatusViewManager implements OnClickListener { mShowingBatteryInfo = mUpdateMonitor.shouldShowBatteryInfo(); mPluggedIn = mUpdateMonitor.isDevicePluggedIn(); mBatteryLevel = mUpdateMonitor.getBatteryLevel(); mAlwaysShowBattery = KeyguardUpdateMonitor.shouldAlwaysShowBatteryInfo(getContext()); updateStatusLines(true); } Loading Loading @@ -748,8 +753,12 @@ class KeyguardStatusViewManager implements OnClickListener { icon.value = CHARGING_ICON; } else if (mBatteryLevel < KeyguardUpdateMonitor.LOW_BATTERY_THRESHOLD) { // Battery is low string = getContext().getString(R.string.lockscreen_low_battery); string = getContext().getString(R.string.lockscreen_low_battery, mBatteryLevel); icon.value = BATTERY_LOW_ICON; } else if (mAlwaysShowBattery) { // Discharging string = getContext().getString(R.string.lockscreen_discharging, mBatteryLevel); icon.value = DISCHARGING_ICON; } } else { string = mCarrierText; Loading @@ -775,8 +784,12 @@ class KeyguardStatusViewManager implements OnClickListener { icon.value = CHARGING_ICON; } else if (mBatteryLevel < KeyguardUpdateMonitor.LOW_BATTERY_THRESHOLD) { // Battery is low string = getContext().getString(R.string.lockscreen_low_battery); string = getContext().getString(R.string.lockscreen_low_battery, mBatteryLevel); icon.value = BATTERY_LOW_ICON; } else if (mAlwaysShowBattery) { // Discharging string = getContext().getString(R.string.lockscreen_discharging, mBatteryLevel); icon.value = DISCHARGING_ICON; } } else if (!inWidgetMode() && mOwnerInfoView == null && mOwnerInfoText != null) { // OwnerInfo shows in status if we don't have a dedicated widget Loading
policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java +11 −5 Original line number Diff line number Diff line Loading @@ -378,7 +378,7 @@ public class KeyguardUpdateMonitor { private void handleBatteryUpdate(BatteryStatus batteryStatus) { if (DEBUG) Log.d(TAG, "handleBatteryUpdate"); final boolean batteryUpdateInteresting = isBatteryUpdateInteresting(mBatteryStatus, batteryStatus); isBatteryUpdateInteresting(mBatteryStatus, batteryStatus, mContext); mBatteryStatus = batteryStatus; if (batteryUpdateInteresting) { for (int i = 0; i < mInfoCallbacks.size(); i++) { Loading Loading @@ -437,7 +437,7 @@ public class KeyguardUpdateMonitor { || status.plugged == BatteryManager.BATTERY_PLUGGED_USB; } private static boolean isBatteryUpdateInteresting(BatteryStatus old, BatteryStatus current) { private static boolean isBatteryUpdateInteresting(BatteryStatus old, BatteryStatus current, Context context) { final boolean nowPluggedIn = isPluggedIn(current); final boolean wasPluggedIn = isPluggedIn(old); final boolean stateChangedWhilePluggedIn = Loading @@ -449,8 +449,8 @@ public class KeyguardUpdateMonitor { return true; } // change in battery level while plugged in if (nowPluggedIn && old.level != current.level) { // change in battery level while plugged in or always interested if ((nowPluggedIn || shouldAlwaysShowBatteryInfo(context)) && old.level != current.level) { return true; } Loading Loading @@ -676,7 +676,13 @@ public class KeyguardUpdateMonitor { } public boolean shouldShowBatteryInfo() { return isPluggedIn(mBatteryStatus) || isBatteryLow(mBatteryStatus); return isPluggedIn(mBatteryStatus) || isBatteryLow(mBatteryStatus) || shouldAlwaysShowBatteryInfo(mContext); } public static boolean shouldAlwaysShowBatteryInfo(Context context) { return Settings.System.getInt(context.getContentResolver(), Settings.System.LOCKSCREEN_ALWAYS_SHOW_BATTERY, 0) == 1; } public CharSequence getTelephonyPlmn() { Loading