Update power_anomaly_event proto fields
- add enum PowerAnomalyType/PowerAnomalyKey - update the func to get anomaly index Test: manual Bug: 291689623 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:356be9109080bc54232ff801b739ec10cab4fdfa) Change-Id: If4e6684c8169dfa3edd4e18a11d518737a3b2840
This commit is contained in:
@@ -16,8 +16,6 @@
|
||||
|
||||
package com.android.settings.fuelgauge.batteryusage;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -68,21 +66,6 @@ public final class BatteryTipsControllerTest {
|
||||
mBatteryTipsController.mPowerUsageFeatureProvider = mPowerUsageFeatureProvider;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parsePowerAnomalyKey_preDefinedKeys_returnTrue() {
|
||||
final String[] keys = {"adaptive_brightness", "screen_timeout"};
|
||||
for (int index = 0; index < keys.length; index++) {
|
||||
assertThat(mBatteryTipsController.getPowerAnomalyEventIndex(keys[index]))
|
||||
.isEqualTo(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parsePowerAnomalyKey_unknownKey_returnTrue() {
|
||||
final String key = "unknown_key_for_test";
|
||||
assertThat(mBatteryTipsController.getPowerAnomalyEventIndex(key)).isEqualTo(-1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleBatteryTipsCardUpdated_null_hidePreference() {
|
||||
mBatteryTipsController.handleBatteryTipsCardUpdated(/* powerAnomalyEvents= */ null);
|
||||
|
@@ -36,6 +36,8 @@ import com.android.settings.fuelgauge.batteryusage.ConvertUtils;
|
||||
import com.android.settings.fuelgauge.batteryusage.DeviceBatteryState;
|
||||
import com.android.settings.fuelgauge.batteryusage.PowerAnomalyEvent;
|
||||
import com.android.settings.fuelgauge.batteryusage.PowerAnomalyEventList;
|
||||
import com.android.settings.fuelgauge.batteryusage.PowerAnomalyKey;
|
||||
import com.android.settings.fuelgauge.batteryusage.PowerAnomalyType;
|
||||
import com.android.settings.fuelgauge.batteryusage.WarningBannerInfo;
|
||||
import com.android.settings.fuelgauge.batteryusage.db.AppUsageEventDao;
|
||||
import com.android.settings.fuelgauge.batteryusage.db.AppUsageEventEntity;
|
||||
@@ -209,8 +211,8 @@ public class BatteryTestUtils {
|
||||
/** Create a power anomaly event proto of adaptive brightness. */
|
||||
public static PowerAnomalyEvent createAdaptiveBrightnessAnomalyEvent() {
|
||||
return PowerAnomalyEvent.newBuilder()
|
||||
.setType("settings banner")
|
||||
.setKey("adaptive_brightness")
|
||||
.setType(PowerAnomalyType.SETTINGS_BANNER)
|
||||
.setKey(PowerAnomalyKey.BRIGHTNESS)
|
||||
.setWarningBannerInfo(WarningBannerInfo.newBuilder()
|
||||
.setMainButtonDestination(AutoBrightnessSettings.class.getName())
|
||||
.setMainButtonSourceMetricsCategory(SettingsEnums.SETTINGS_AUTO_BRIGHTNESS)
|
||||
@@ -221,8 +223,8 @@ public class BatteryTestUtils {
|
||||
/** Create a power anomaly event proto of screen timeout. */
|
||||
public static PowerAnomalyEvent createScreenTimeoutAnomalyEvent() {
|
||||
return PowerAnomalyEvent.newBuilder()
|
||||
.setType("settings banner")
|
||||
.setKey("screen_timeout")
|
||||
.setType(PowerAnomalyType.SETTINGS_BANNER)
|
||||
.setKey(PowerAnomalyKey.SCREEN_TIMEOUT)
|
||||
.setWarningBannerInfo(WarningBannerInfo.newBuilder()
|
||||
.setMainButtonDestination(ScreenTimeoutSettings.class.getName())
|
||||
.setMainButtonSourceMetricsCategory(SettingsEnums.SCREEN_TIMEOUT)
|
||||
|
Reference in New Issue
Block a user