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