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;
|
||||
|
||||
final int state = powerSaveModeOn
|
||||
? BatteryTip.StateType.HANDLED
|
||||
? BatteryTip.StateType.INVISIBLE
|
||||
: mPolicy.batterySaverTipEnabled && discharging && earlyWarning
|
||||
? BatteryTip.StateType.NEW
|
||||
: BatteryTip.StateType.INVISIBLE;
|
||||
|
@@ -49,16 +49,16 @@ public class LowBatteryDetector implements BatteryTipDetector {
|
||||
final boolean lowBattery = mBatteryInfo.batteryLevel <= mWarningLevel
|
||||
|| (mBatteryInfo.discharging && mBatteryInfo.remainingTimeUs != 0
|
||||
&& 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;
|
||||
if (mPolicy.lowBatteryEnabled) {
|
||||
if (powerSaveModeOn) {
|
||||
// Show it is handled if battery saver is on
|
||||
state = BatteryTip.StateType.HANDLED;
|
||||
} else if (mPolicy.testLowBatteryTip || (mBatteryInfo.discharging && lowBattery)) {
|
||||
// Show it is new if in test or in discharging low battery state
|
||||
state = BatteryTip.StateType.NEW;
|
||||
}
|
||||
|
||||
// Show it as new if in test or in discharging low battery state,
|
||||
// dismiss it if battery saver is on or disabled by config.
|
||||
if (lowBatteryEnabled && dischargingLowBatteryState) {
|
||||
state = BatteryTip.StateType.NEW;
|
||||
}
|
||||
|
||||
return new LowBatteryTip(
|
||||
|
@@ -18,7 +18,6 @@ package com.android.settings.fuelgauge.batterytip.tips;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.os.Parcel;
|
||||
|
||||
import com.android.settings.R;
|
||||
@@ -43,31 +42,23 @@ public class EarlyWarningTip extends BatteryTip {
|
||||
@Override
|
||||
public CharSequence getTitle(Context context) {
|
||||
return context.getString(
|
||||
mState == StateType.HANDLED
|
||||
? R.string.battery_tip_early_heads_up_done_title
|
||||
: R.string.battery_tip_early_heads_up_title);
|
||||
mState = R.string.battery_tip_early_heads_up_title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary(Context context) {
|
||||
return context.getString(
|
||||
mState == StateType.HANDLED
|
||||
? R.string.battery_tip_early_heads_up_done_summary
|
||||
: R.string.battery_tip_early_heads_up_summary);
|
||||
mState = R.string.battery_tip_early_heads_up_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconId() {
|
||||
return mState == StateType.HANDLED
|
||||
? R.drawable.ic_battery_status_maybe_24dp
|
||||
: R.drawable.ic_battery_status_bad_24dp;
|
||||
return mState = R.drawable.ic_battery_status_bad_24dp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconTintColorId() {
|
||||
return mState == StateType.HANDLED
|
||||
? R.color.battery_maybe_color_light
|
||||
: R.color.battery_bad_color_light;
|
||||
return mState = R.color.battery_bad_color_light;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,9 +67,9 @@ public class EarlyWarningTip extends BatteryTip {
|
||||
if (earlyWarningTip.mState == StateType.NEW) {
|
||||
// Display it if there is early warning
|
||||
mState = StateType.NEW;
|
||||
} else if (mState == StateType.NEW && earlyWarningTip.mState == StateType.INVISIBLE) {
|
||||
// If powerSaveMode is really on, show it as handled, otherwise just dismiss it.
|
||||
mState = earlyWarningTip.mPowerSaveModeOn ? StateType.HANDLED : StateType.INVISIBLE;
|
||||
} else if (earlyWarningTip.mPowerSaveModeOn) {
|
||||
// If powerSaveMode is really on, dismiss it.
|
||||
mState = StateType.INVISIBLE;
|
||||
} else {
|
||||
mState = earlyWarningTip.getState();
|
||||
}
|
||||
|
@@ -21,7 +21,6 @@ import android.content.Context;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
/**
|
||||
@@ -43,8 +42,7 @@ public class LowBatteryTip extends EarlyWarningTip {
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary(Context context) {
|
||||
return mState == StateType.HANDLED ? context.getString(
|
||||
R.string.battery_tip_early_heads_up_done_summary) : mSummary;
|
||||
return mSummary;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -86,11 +86,11 @@ public class EarlyWarningDetectorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDetect_batterySaverOn_tipHandled() {
|
||||
public void testDetect_batterySaverOn_tipInvisible() {
|
||||
doReturn(true).when(mPowerManager).isPowerSaveMode();
|
||||
|
||||
assertThat(mEarlyWarningDetector.detect().getState())
|
||||
.isEqualTo(BatteryTip.StateType.HANDLED);
|
||||
.isEqualTo(BatteryTip.StateType.INVISIBLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -91,10 +91,11 @@ public class LowBatteryDetectorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDetect_batterySaverOn_tipHandled() {
|
||||
public void testDetect_batterySaverOn_tipInvisible() {
|
||||
mShadowPowerManager.setIsPowerSaveMode(true);
|
||||
|
||||
assertThat(mLowBatteryDetector.detect().getState()).isEqualTo(BatteryTip.StateType.HANDLED);
|
||||
assertThat(mLowBatteryDetector.detect().getState())
|
||||
.isEqualTo(BatteryTip.StateType.INVISIBLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -74,24 +74,13 @@ public class EarlyWarningTipTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInfo_stateHandled_displayPowerModeHandledInfo() {
|
||||
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() {
|
||||
public void testUpdate_powerModeTurnedOn_typeBecomeInvisible() {
|
||||
final EarlyWarningTip nextTip =
|
||||
new EarlyWarningTip(BatteryTip.StateType.INVISIBLE, true /* powerModeOn */);
|
||||
|
||||
mEarlyWarningTip.updateState(nextTip);
|
||||
|
||||
assertThat(mEarlyWarningTip.getState()).isEqualTo(BatteryTip.StateType.HANDLED);
|
||||
assertThat(mEarlyWarningTip.getState()).isEqualTo(BatteryTip.StateType.INVISIBLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -64,13 +64,6 @@ public class LowBatteryTipTest {
|
||||
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
|
||||
public void getSummary_tipNew_showSummary() {
|
||||
mLowBatteryTip.mState = BatteryTip.StateType.NEW;
|
||||
|
Reference in New Issue
Block a user