Remove Battery Settings page battery saver tips
- Not present Battery saver tips when it's enabled - Not redirect Low battery tips to saver tips when saver is enabled Screenshots: https://screenshot.googleplex.com/4ehKSRs8gM64wfm.png https://screenshot.googleplex.com/92pd3q9jnTEXd8o.png https://screenshot.googleplex.com/BzLYwTjdi3kH4RF.png https://screenshot.googleplex.com/4w9ubmHaajNxB9b.png Bug: 183079415 Test: make RunSettingsRoboTests -j40 Change-Id: Ib9783a95df88753342ff217b1a402f2dbb99079d
This commit is contained in:
committed by
Wesley Wang
parent
59aa4f9cb1
commit
3da3bf7a21
@@ -56,7 +56,7 @@ public class EarlyWarningDetector implements BatteryTipDetector {
|
|||||||
EarlyWarningDetector.class.getName()) || mPolicy.testBatterySaverTip;
|
EarlyWarningDetector.class.getName()) || mPolicy.testBatterySaverTip;
|
||||||
|
|
||||||
final int state = powerSaveModeOn
|
final int state = powerSaveModeOn
|
||||||
? BatteryTip.StateType.HANDLED
|
? BatteryTip.StateType.INVISIBLE
|
||||||
: mPolicy.batterySaverTipEnabled && discharging && earlyWarning
|
: mPolicy.batterySaverTipEnabled && discharging && earlyWarning
|
||||||
? BatteryTip.StateType.NEW
|
? BatteryTip.StateType.NEW
|
||||||
: BatteryTip.StateType.INVISIBLE;
|
: BatteryTip.StateType.INVISIBLE;
|
||||||
|
@@ -49,16 +49,16 @@ public class LowBatteryDetector implements BatteryTipDetector {
|
|||||||
final boolean lowBattery = mBatteryInfo.batteryLevel <= mWarningLevel
|
final boolean lowBattery = mBatteryInfo.batteryLevel <= mWarningLevel
|
||||||
|| (mBatteryInfo.discharging && mBatteryInfo.remainingTimeUs != 0
|
|| (mBatteryInfo.discharging && mBatteryInfo.remainingTimeUs != 0
|
||||||
&& mBatteryInfo.remainingTimeUs < TimeUnit.HOURS.toMicros(mPolicy.lowBatteryHour));
|
&& mBatteryInfo.remainingTimeUs < TimeUnit.HOURS.toMicros(mPolicy.lowBatteryHour));
|
||||||
|
final boolean lowBatteryEnabled = mPolicy.lowBatteryEnabled && !powerSaveModeOn;
|
||||||
|
final boolean dischargingLowBatteryState =
|
||||||
|
mPolicy.testLowBatteryTip || (mBatteryInfo.discharging && lowBattery);
|
||||||
|
|
||||||
int state = BatteryTip.StateType.INVISIBLE;
|
int state = BatteryTip.StateType.INVISIBLE;
|
||||||
if (mPolicy.lowBatteryEnabled) {
|
|
||||||
if (powerSaveModeOn) {
|
// Show it as new if in test or in discharging low battery state,
|
||||||
// Show it is handled if battery saver is on
|
// dismiss it if battery saver is on or disabled by config.
|
||||||
state = BatteryTip.StateType.HANDLED;
|
if (lowBatteryEnabled && dischargingLowBatteryState) {
|
||||||
} else if (mPolicy.testLowBatteryTip || (mBatteryInfo.discharging && lowBattery)) {
|
state = BatteryTip.StateType.NEW;
|
||||||
// Show it is new if in test or in discharging low battery state
|
|
||||||
state = BatteryTip.StateType.NEW;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new LowBatteryTip(
|
return new LowBatteryTip(
|
||||||
|
@@ -18,7 +18,6 @@ package com.android.settings.fuelgauge.batterytip.tips;
|
|||||||
|
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.ColorStateList;
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -43,31 +42,23 @@ public class EarlyWarningTip extends BatteryTip {
|
|||||||
@Override
|
@Override
|
||||||
public CharSequence getTitle(Context context) {
|
public CharSequence getTitle(Context context) {
|
||||||
return context.getString(
|
return context.getString(
|
||||||
mState == StateType.HANDLED
|
mState = R.string.battery_tip_early_heads_up_title);
|
||||||
? R.string.battery_tip_early_heads_up_done_title
|
|
||||||
: R.string.battery_tip_early_heads_up_title);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getSummary(Context context) {
|
public CharSequence getSummary(Context context) {
|
||||||
return context.getString(
|
return context.getString(
|
||||||
mState == StateType.HANDLED
|
mState = R.string.battery_tip_early_heads_up_summary);
|
||||||
? R.string.battery_tip_early_heads_up_done_summary
|
|
||||||
: R.string.battery_tip_early_heads_up_summary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIconId() {
|
public int getIconId() {
|
||||||
return mState == StateType.HANDLED
|
return mState = R.drawable.ic_battery_status_bad_24dp;
|
||||||
? R.drawable.ic_battery_status_maybe_24dp
|
|
||||||
: R.drawable.ic_battery_status_bad_24dp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIconTintColorId() {
|
public int getIconTintColorId() {
|
||||||
return mState == StateType.HANDLED
|
return mState = R.color.battery_bad_color_light;
|
||||||
? R.color.battery_maybe_color_light
|
|
||||||
: R.color.battery_bad_color_light;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -76,9 +67,9 @@ public class EarlyWarningTip extends BatteryTip {
|
|||||||
if (earlyWarningTip.mState == StateType.NEW) {
|
if (earlyWarningTip.mState == StateType.NEW) {
|
||||||
// Display it if there is early warning
|
// Display it if there is early warning
|
||||||
mState = StateType.NEW;
|
mState = StateType.NEW;
|
||||||
} else if (mState == StateType.NEW && earlyWarningTip.mState == StateType.INVISIBLE) {
|
} else if (earlyWarningTip.mPowerSaveModeOn) {
|
||||||
// If powerSaveMode is really on, show it as handled, otherwise just dismiss it.
|
// If powerSaveMode is really on, dismiss it.
|
||||||
mState = earlyWarningTip.mPowerSaveModeOn ? StateType.HANDLED : StateType.INVISIBLE;
|
mState = StateType.INVISIBLE;
|
||||||
} else {
|
} else {
|
||||||
mState = earlyWarningTip.getState();
|
mState = earlyWarningTip.getState();
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,6 @@ import android.content.Context;
|
|||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,8 +42,7 @@ public class LowBatteryTip extends EarlyWarningTip {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getSummary(Context context) {
|
public CharSequence getSummary(Context context) {
|
||||||
return mState == StateType.HANDLED ? context.getString(
|
return mSummary;
|
||||||
R.string.battery_tip_early_heads_up_done_summary) : mSummary;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -86,11 +86,11 @@ public class EarlyWarningDetectorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDetect_batterySaverOn_tipHandled() {
|
public void testDetect_batterySaverOn_tipInvisible() {
|
||||||
doReturn(true).when(mPowerManager).isPowerSaveMode();
|
doReturn(true).when(mPowerManager).isPowerSaveMode();
|
||||||
|
|
||||||
assertThat(mEarlyWarningDetector.detect().getState())
|
assertThat(mEarlyWarningDetector.detect().getState())
|
||||||
.isEqualTo(BatteryTip.StateType.HANDLED);
|
.isEqualTo(BatteryTip.StateType.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -91,10 +91,11 @@ public class LowBatteryDetectorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDetect_batterySaverOn_tipHandled() {
|
public void testDetect_batterySaverOn_tipInvisible() {
|
||||||
mShadowPowerManager.setIsPowerSaveMode(true);
|
mShadowPowerManager.setIsPowerSaveMode(true);
|
||||||
|
|
||||||
assertThat(mLowBatteryDetector.detect().getState()).isEqualTo(BatteryTip.StateType.HANDLED);
|
assertThat(mLowBatteryDetector.detect().getState())
|
||||||
|
.isEqualTo(BatteryTip.StateType.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -74,24 +74,13 @@ public class EarlyWarningTipTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInfo_stateHandled_displayPowerModeHandledInfo() {
|
public void testUpdate_powerModeTurnedOn_typeBecomeInvisible() {
|
||||||
final EarlyWarningTip tip =
|
|
||||||
new EarlyWarningTip(BatteryTip.StateType.HANDLED, false /* powerModeOn */);
|
|
||||||
|
|
||||||
assertThat(tip.getTitle(mContext)).isEqualTo("Battery Saver is on");
|
|
||||||
assertThat(tip.getSummary(mContext)).isEqualTo("Some features may be limited");
|
|
||||||
assertThat(tip.getIconId()).isEqualTo(R.drawable.ic_battery_status_maybe_24dp);
|
|
||||||
assertThat(tip.getIconTintColorId()).isEqualTo(R.color.battery_maybe_color_light);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUpdate_powerModeTurnedOn_typeBecomeHandled() {
|
|
||||||
final EarlyWarningTip nextTip =
|
final EarlyWarningTip nextTip =
|
||||||
new EarlyWarningTip(BatteryTip.StateType.INVISIBLE, true /* powerModeOn */);
|
new EarlyWarningTip(BatteryTip.StateType.INVISIBLE, true /* powerModeOn */);
|
||||||
|
|
||||||
mEarlyWarningTip.updateState(nextTip);
|
mEarlyWarningTip.updateState(nextTip);
|
||||||
|
|
||||||
assertThat(mEarlyWarningTip.getState()).isEqualTo(BatteryTip.StateType.HANDLED);
|
assertThat(mEarlyWarningTip.getState()).isEqualTo(BatteryTip.StateType.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -64,13 +64,6 @@ public class LowBatteryTipTest {
|
|||||||
assertThat(parcelTip.getSummary(mContext)).isEqualTo(SUMMARY);
|
assertThat(parcelTip.getSummary(mContext)).isEqualTo(SUMMARY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getSummary_tipHandled_showSummary() {
|
|
||||||
mLowBatteryTip.mState = BatteryTip.StateType.HANDLED;
|
|
||||||
|
|
||||||
assertThat(mLowBatteryTip.getSummary(mContext)).isEqualTo("Some features may be limited");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSummary_tipNew_showSummary() {
|
public void getSummary_tipNew_showSummary() {
|
||||||
mLowBatteryTip.mState = BatteryTip.StateType.NEW;
|
mLowBatteryTip.mState = BatteryTip.StateType.NEW;
|
||||||
|
Reference in New Issue
Block a user