Merge "Update battery charging status string" into sc-dev
This commit is contained in:
@@ -22,15 +22,13 @@
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="header_view"
|
||||
android:layout="@layout/settings_entity_header"
|
||||
android:selectable="false"
|
||||
settings:allowDividerBelow="true"/>
|
||||
android:selectable="false"/>
|
||||
|
||||
<com.android.settingslib.widget.ActionButtonsPreference
|
||||
android:key="action_buttons"/>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/battery_detail_manage_title"
|
||||
settings:allowDividerAbove="true">
|
||||
android:title="@string/battery_detail_manage_title">
|
||||
|
||||
<com.android.settingslib.widget.RadioButtonPreference
|
||||
android:key="unrestricted_pref"
|
||||
|
@@ -23,16 +23,14 @@
|
||||
android:key="header_view"
|
||||
android:layout="@layout/settings_entity_header"
|
||||
android:selectable="false"
|
||||
android:order="-10000"
|
||||
settings:allowDividerBelow="true"/>
|
||||
android:order="-10000"/>
|
||||
|
||||
<com.android.settingslib.widget.ActionButtonsPreference
|
||||
android:key="action_buttons"
|
||||
android:order="-9999"/>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/battery_detail_manage_title"
|
||||
settings:allowDividerAbove="true">
|
||||
android:title="@string/battery_detail_manage_title">
|
||||
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="background_activity"
|
||||
|
@@ -111,8 +111,9 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
|
||||
private CharSequence generateLabel(BatteryInfo info) {
|
||||
if (BatteryUtils.isBatteryDefenderOn(info)) {
|
||||
return null;
|
||||
} else if (info.remainingLabel == null) {
|
||||
// Present status independently if no remaining time
|
||||
} else if (info.remainingLabel == null
|
||||
|| info.batteryStatus == BatteryManager.BATTERY_STATUS_NOT_CHARGING) {
|
||||
// Present status only if no remaining time or status anomalous
|
||||
return info.statusLabel;
|
||||
} else if (info.statusLabel != null && !info.discharging) {
|
||||
// Charging state
|
||||
|
@@ -46,6 +46,7 @@ public class BatteryInfo {
|
||||
public CharSequence chargeLabel;
|
||||
public CharSequence remainingLabel;
|
||||
public int batteryLevel;
|
||||
public int batteryStatus;
|
||||
public boolean discharging = true;
|
||||
public boolean isOverheated;
|
||||
public long remainingTimeUs = 0;
|
||||
@@ -238,6 +239,8 @@ public class BatteryInfo {
|
||||
== BatteryManager.BATTERY_HEALTH_OVERHEAT;
|
||||
|
||||
info.statusLabel = Utils.getBatteryStatus(context, batteryBroadcast);
|
||||
info.batteryStatus = batteryBroadcast.getIntExtra(
|
||||
BatteryManager.EXTRA_STATUS, BatteryManager.BATTERY_STATUS_UNKNOWN);
|
||||
if (!info.mCharging) {
|
||||
updateBatteryInfoDischarging(context, shortString, estimate, info);
|
||||
} else {
|
||||
|
@@ -167,6 +167,17 @@ public class BatteryHeaderPreferenceControllerTest {
|
||||
verify(mBatteryUsageProgressBarPref).setBottomSummary(BATTERY_STATUS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updatePreference_statusAnomalous_showStatusLabel() {
|
||||
mBatteryInfo.remainingLabel = TIME_LEFT;
|
||||
mBatteryInfo.statusLabel = BATTERY_STATUS;
|
||||
mBatteryInfo.batteryStatus = BatteryManager.BATTERY_STATUS_NOT_CHARGING;
|
||||
|
||||
mController.updateHeaderPreference(mBatteryInfo);
|
||||
|
||||
verify(mBatteryUsageProgressBarPref).setBottomSummary(BATTERY_STATUS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updatePreference_charging_showFullText() {
|
||||
setChargingState(/* isDischarging */ false, /* updatedByStatusFeature */ false);
|
||||
|
Reference in New Issue
Block a user