Support tips card directly changing settings [step-5]
Support clicking tips card directly changing settings. Bug: 333989261 Test: manual Change-Id: Idc485ee7430edff7f6d7265caf8d9d5cf97548b6
This commit is contained in:
@@ -18,9 +18,13 @@ package com.android.settings.fuelgauge.batteryusage;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsActivity;
|
import com.android.settings.SettingsActivity;
|
||||||
import com.android.settings.core.SubSettingLauncher;
|
import com.android.settings.core.SubSettingLauncher;
|
||||||
@@ -49,8 +53,8 @@ final class AnomalyEventWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private <T> T getInfo(
|
private <T> T getInfo(
|
||||||
Function<WarningBannerInfo, T> warningBannerInfoSupplier,
|
@Nullable Function<WarningBannerInfo, T> warningBannerInfoSupplier,
|
||||||
Function<WarningItemInfo, T> warningItemInfoSupplier) {
|
@Nullable Function<WarningItemInfo, T> warningItemInfoSupplier) {
|
||||||
if (warningBannerInfoSupplier != null && mPowerAnomalyEvent.hasWarningBannerInfo()) {
|
if (warningBannerInfoSupplier != null && mPowerAnomalyEvent.hasWarningBannerInfo()) {
|
||||||
return warningBannerInfoSupplier.apply(mPowerAnomalyEvent.getWarningBannerInfo());
|
return warningBannerInfoSupplier.apply(mPowerAnomalyEvent.getWarningBannerInfo());
|
||||||
} else if (warningItemInfoSupplier != null && mPowerAnomalyEvent.hasWarningItemInfo()) {
|
} else if (warningItemInfoSupplier != null && mPowerAnomalyEvent.hasWarningItemInfo()) {
|
||||||
@@ -252,4 +256,32 @@ final class AnomalyEventWrapper {
|
|||||||
mSubSettingLauncher.launch();
|
mSubSettingLauncher.launch();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean updateSystemSettingsIfAvailable() {
|
||||||
|
final String settingsName =
|
||||||
|
getInfo(WarningBannerInfo::getMainButtonConfigSettingsName, null);
|
||||||
|
final Integer settingsValue =
|
||||||
|
getInfo(WarningBannerInfo::getMainButtonConfigSettingsValue, null);
|
||||||
|
if (TextUtils.isEmpty(settingsName) || settingsValue == null) {
|
||||||
|
Log.d(TAG, "Failed to update settings due to invalid key or value");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Settings.System.putInt(mContext.getContentResolver(), settingsName, settingsValue);
|
||||||
|
Log.d(
|
||||||
|
TAG,
|
||||||
|
String.format(
|
||||||
|
"Update settings name=%s to value=%d", settingsName, settingsValue));
|
||||||
|
return true;
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
Log.w(
|
||||||
|
TAG,
|
||||||
|
String.format(
|
||||||
|
"Failed to update settings name=%s to value=%d",
|
||||||
|
settingsName, settingsValue),
|
||||||
|
e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -123,7 +123,8 @@ public class BatteryTipsController extends BasePreferenceController {
|
|||||||
mCardPreference.setVisible(false);
|
mCardPreference.setVisible(false);
|
||||||
if (mOnAnomalyConfirmListener != null) {
|
if (mOnAnomalyConfirmListener != null) {
|
||||||
mOnAnomalyConfirmListener.onAnomalyConfirm();
|
mOnAnomalyConfirmListener.onAnomalyConfirm();
|
||||||
} else if (mAnomalyEventWrapper.launchSubSetting()) {
|
} else if (mAnomalyEventWrapper.updateSystemSettingsIfAvailable()
|
||||||
|
|| mAnomalyEventWrapper.launchSubSetting()) {
|
||||||
mMetricsFeatureProvider.action(
|
mMetricsFeatureProvider.action(
|
||||||
/* attribution= */ SettingsEnums.FUELGAUGE_BATTERY_HISTORY_DETAIL,
|
/* attribution= */ SettingsEnums.FUELGAUGE_BATTERY_HISTORY_DETAIL,
|
||||||
/* action= */ SettingsEnums.ACTION_BATTERY_TIPS_CARD_ACCEPT,
|
/* action= */ SettingsEnums.ACTION_BATTERY_TIPS_CARD_ACCEPT,
|
||||||
|
@@ -30,6 +30,7 @@ import static org.mockito.Mockito.when;
|
|||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
@@ -102,10 +103,10 @@ public final class BatteryTipsCardPreferenceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onClick_mainBtnOfSettingsAnomaly_getAdaptiveBrightnessLauncher() {
|
public void onClick_mainBtnOfSettingsAnomalyLaunchPage_getAdaptiveBrightnessLauncher() {
|
||||||
final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
|
final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
|
||||||
PowerAnomalyEvent adaptiveBrightnessAnomaly =
|
PowerAnomalyEvent adaptiveBrightnessAnomaly =
|
||||||
BatteryTestUtils.createAdaptiveBrightnessAnomalyEvent();
|
BatteryTestUtils.createAdaptiveBrightnessAnomalyEvent(/* changeSettings= */ false);
|
||||||
when(mFeatureFactory.powerUsageFeatureProvider.isBatteryTipsEnabled()).thenReturn(true);
|
when(mFeatureFactory.powerUsageFeatureProvider.isBatteryTipsEnabled()).thenReturn(true);
|
||||||
when(mFakeView.getId()).thenReturn(R.id.main_button);
|
when(mFakeView.getId()).thenReturn(R.id.main_button);
|
||||||
doNothing().when(mContext).startActivity(captor.capture());
|
doNothing().when(mContext).startActivity(captor.capture());
|
||||||
@@ -137,6 +138,47 @@ public final class BatteryTipsCardPreferenceTest {
|
|||||||
PowerAnomalyKey.KEY_BRIGHTNESS.getNumber());
|
PowerAnomalyKey.KEY_BRIGHTNESS.getNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onClick_mainBtnOfSettingsAnomalyChangeSettings_settingsChanged()
|
||||||
|
throws Settings.SettingNotFoundException {
|
||||||
|
Settings.System.putInt(
|
||||||
|
mContext.getContentResolver(),
|
||||||
|
Settings.System.SCREEN_BRIGHTNESS_MODE,
|
||||||
|
Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
|
||||||
|
final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
|
||||||
|
PowerAnomalyEvent adaptiveBrightnessAnomaly =
|
||||||
|
BatteryTestUtils.createAdaptiveBrightnessAnomalyEvent(/* changeSettings= */ true);
|
||||||
|
when(mFeatureFactory.powerUsageFeatureProvider.isBatteryTipsEnabled()).thenReturn(true);
|
||||||
|
when(mFakeView.getId()).thenReturn(R.id.main_button);
|
||||||
|
doNothing().when(mContext).startActivity(captor.capture());
|
||||||
|
|
||||||
|
mPowerUsageAdvanced.onDisplayAnomalyEventUpdated(
|
||||||
|
adaptiveBrightnessAnomaly, adaptiveBrightnessAnomaly);
|
||||||
|
mBatteryTipsCardPreference.onClick(mFakeView);
|
||||||
|
|
||||||
|
assertThat(mBatteryTipsCardPreference.isVisible()).isFalse();
|
||||||
|
assertThat(
|
||||||
|
Settings.System.getInt(
|
||||||
|
mContext.getContentResolver(),
|
||||||
|
Settings.System.SCREEN_BRIGHTNESS_MODE))
|
||||||
|
.isEqualTo(Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
|
||||||
|
verify(mContext, never()).startActivity(any(Intent.class));
|
||||||
|
verify(mFeatureFactory.metricsFeatureProvider)
|
||||||
|
.action(
|
||||||
|
SettingsEnums.FUELGAUGE_BATTERY_HISTORY_DETAIL,
|
||||||
|
SettingsEnums.ACTION_BATTERY_TIPS_CARD_SHOW,
|
||||||
|
SettingsEnums.FUELGAUGE_BATTERY_HISTORY_DETAIL,
|
||||||
|
BatteryTipsController.ANOMALY_KEY,
|
||||||
|
PowerAnomalyKey.KEY_BRIGHTNESS.getNumber());
|
||||||
|
verify(mFeatureFactory.metricsFeatureProvider)
|
||||||
|
.action(
|
||||||
|
SettingsEnums.FUELGAUGE_BATTERY_HISTORY_DETAIL,
|
||||||
|
SettingsEnums.ACTION_BATTERY_TIPS_CARD_ACCEPT,
|
||||||
|
SettingsEnums.FUELGAUGE_BATTERY_HISTORY_DETAIL,
|
||||||
|
BatteryTipsController.ANOMALY_KEY,
|
||||||
|
PowerAnomalyKey.KEY_BRIGHTNESS.getNumber());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onClick_dismissBtnOfSettingsAnomaly_cardDismissAndLogged() {
|
public void onClick_dismissBtnOfSettingsAnomaly_cardDismissAndLogged() {
|
||||||
final PowerAnomalyEvent screenTimeoutAnomaly =
|
final PowerAnomalyEvent screenTimeoutAnomaly =
|
||||||
|
@@ -26,6 +26,7 @@ import android.hardware.usb.UsbPort;
|
|||||||
import android.hardware.usb.UsbPortStatus;
|
import android.hardware.usb.UsbPortStatus;
|
||||||
import android.os.BatteryManager;
|
import android.os.BatteryManager;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
import android.provider.Settings;
|
||||||
|
|
||||||
import androidx.room.Room;
|
import androidx.room.Room;
|
||||||
|
|
||||||
@@ -71,18 +72,14 @@ public class BatteryTestUtils {
|
|||||||
BatteryManager.BATTERY_STATUS_DISCHARGING);
|
BatteryManager.BATTERY_STATUS_DISCHARGING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Sets the work profile mode. */
|
||||||
* Sets the work profile mode.
|
|
||||||
*/
|
|
||||||
public static void setWorkProfile(Context context) {
|
public static void setWorkProfile(Context context) {
|
||||||
final UserManager userManager = context.getSystemService(UserManager.class);
|
final UserManager userManager = context.getSystemService(UserManager.class);
|
||||||
Shadows.shadowOf(userManager).setManagedProfile(true);
|
Shadows.shadowOf(userManager).setManagedProfile(true);
|
||||||
Shadows.shadowOf(userManager).setIsSystemUser(false);
|
Shadows.shadowOf(userManager).setIsSystemUser(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Creates and sets up the in-memory {@link BatteryStateDatabase}. */
|
||||||
* Creates and sets up the in-memory {@link BatteryStateDatabase}.
|
|
||||||
*/
|
|
||||||
public static BatteryStateDatabase setUpBatteryStateDatabase(Context context) {
|
public static BatteryStateDatabase setUpBatteryStateDatabase(Context context) {
|
||||||
final BatteryStateDatabase inMemoryDatabase =
|
final BatteryStateDatabase inMemoryDatabase =
|
||||||
Room.inMemoryDatabaseBuilder(context, BatteryStateDatabase.class)
|
Room.inMemoryDatabaseBuilder(context, BatteryStateDatabase.class)
|
||||||
@@ -92,40 +89,39 @@ public class BatteryTestUtils {
|
|||||||
return inMemoryDatabase;
|
return inMemoryDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Inserts a fake data into the database for testing. */
|
||||||
* Inserts a fake data into the database for testing.
|
|
||||||
*/
|
|
||||||
public static void insertDataToBatteryStateTable(
|
public static void insertDataToBatteryStateTable(
|
||||||
Context context, long timestamp, String packageName) {
|
Context context, long timestamp, String packageName) {
|
||||||
insertDataToBatteryStateTable(
|
insertDataToBatteryStateTable(
|
||||||
context, timestamp, packageName, /*multiple=*/ false, /*isFullChargeStart=*/ false);
|
context,
|
||||||
|
timestamp,
|
||||||
|
packageName,
|
||||||
|
/* multiple= */ false,
|
||||||
|
/* isFullChargeStart= */ false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Inserts a fake data into the database for testing. */
|
||||||
* Inserts a fake data into the database for testing.
|
|
||||||
*/
|
|
||||||
public static void insertDataToBatteryStateTable(
|
public static void insertDataToBatteryStateTable(
|
||||||
Context context, long timestamp, String packageName, boolean isFullChargeStart) {
|
Context context, long timestamp, String packageName, boolean isFullChargeStart) {
|
||||||
insertDataToBatteryStateTable(
|
insertDataToBatteryStateTable(
|
||||||
context, timestamp, packageName, /* multiple= */ false, isFullChargeStart);
|
context, timestamp, packageName, /* multiple= */ false, isFullChargeStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Inserts a fake data into the database for testing. */
|
||||||
* Inserts a fake data into the database for testing.
|
|
||||||
*/
|
|
||||||
public static void insertDataToBatteryStateTable(
|
public static void insertDataToBatteryStateTable(
|
||||||
Context context, long timestamp, String packageName, boolean multiple,
|
Context context,
|
||||||
|
long timestamp,
|
||||||
|
String packageName,
|
||||||
|
boolean multiple,
|
||||||
boolean isFullChargeStart) {
|
boolean isFullChargeStart) {
|
||||||
DeviceBatteryState deviceBatteryState =
|
DeviceBatteryState deviceBatteryState =
|
||||||
DeviceBatteryState
|
DeviceBatteryState.newBuilder()
|
||||||
.newBuilder()
|
|
||||||
.setBatteryLevel(31)
|
.setBatteryLevel(31)
|
||||||
.setBatteryStatus(0)
|
.setBatteryStatus(0)
|
||||||
.setBatteryHealth(0)
|
.setBatteryHealth(0)
|
||||||
.build();
|
.build();
|
||||||
BatteryInformation batteryInformation =
|
BatteryInformation batteryInformation =
|
||||||
BatteryInformation
|
BatteryInformation.newBuilder()
|
||||||
.newBuilder()
|
|
||||||
.setDeviceBatteryState(deviceBatteryState)
|
.setDeviceBatteryState(deviceBatteryState)
|
||||||
.setIsHidden(true)
|
.setIsHidden(true)
|
||||||
.setBootTimestamp(timestamp - 1)
|
.setBootTimestamp(timestamp - 1)
|
||||||
@@ -153,8 +149,7 @@ public class BatteryTestUtils {
|
|||||||
isFullChargeStart,
|
isFullChargeStart,
|
||||||
ConvertUtils.convertBatteryInformationToString(batteryInformation),
|
ConvertUtils.convertBatteryInformationToString(batteryInformation),
|
||||||
"");
|
"");
|
||||||
BatteryStateDao dao =
|
BatteryStateDao dao = BatteryStateDatabase.getInstance(context).batteryStateDao();
|
||||||
BatteryStateDatabase.getInstance(context).batteryStateDao();
|
|
||||||
if (multiple) {
|
if (multiple) {
|
||||||
dao.insertAll(ImmutableList.of(state));
|
dao.insertAll(ImmutableList.of(state));
|
||||||
} else {
|
} else {
|
||||||
@@ -162,18 +157,14 @@ public class BatteryTestUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Inserts a fake data into the database for testing. */
|
||||||
* Inserts a fake data into the database for testing.
|
|
||||||
*/
|
|
||||||
public static void insertDataToAppUsageEventTable(
|
public static void insertDataToAppUsageEventTable(
|
||||||
Context context, long userId, long timestamp, String packageName) {
|
Context context, long userId, long timestamp, String packageName) {
|
||||||
insertDataToAppUsageEventTable(
|
insertDataToAppUsageEventTable(
|
||||||
context, userId, timestamp, packageName, /* multiple= */ false);
|
context, userId, timestamp, packageName, /* multiple= */ false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Inserts a fake data into the database for testing. */
|
||||||
* Inserts a fake data into the database for testing.
|
|
||||||
*/
|
|
||||||
public static void insertDataToAppUsageEventTable(
|
public static void insertDataToAppUsageEventTable(
|
||||||
Context context, long userId, long timestamp, String packageName, boolean multiple) {
|
Context context, long userId, long timestamp, String packageName, boolean multiple) {
|
||||||
final AppUsageEventEntity entity =
|
final AppUsageEventEntity entity =
|
||||||
@@ -185,8 +176,7 @@ public class BatteryTestUtils {
|
|||||||
packageName,
|
packageName,
|
||||||
/* instanceId= */ 10001,
|
/* instanceId= */ 10001,
|
||||||
/* taskRootPackageName= */ "com.android.settings");
|
/* taskRootPackageName= */ "com.android.settings");
|
||||||
AppUsageEventDao dao =
|
AppUsageEventDao dao = BatteryStateDatabase.getInstance(context).appUsageEventDao();
|
||||||
BatteryStateDatabase.getInstance(context).appUsageEventDao();
|
|
||||||
if (multiple) {
|
if (multiple) {
|
||||||
dao.insertAll(ImmutableList.of(entity));
|
dao.insertAll(ImmutableList.of(entity));
|
||||||
} else {
|
} else {
|
||||||
@@ -194,9 +184,7 @@ public class BatteryTestUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Gets customized battery changed intent. */
|
||||||
* Gets customized battery changed intent.
|
|
||||||
*/
|
|
||||||
public static Intent getCustomBatteryIntent(int plugged, int level, int scale, int status) {
|
public static Intent getCustomBatteryIntent(int plugged, int level, int scale, int status) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra(BatteryManager.EXTRA_PLUGGED, plugged);
|
intent.putExtra(BatteryManager.EXTRA_PLUGGED, plugged);
|
||||||
@@ -207,9 +195,7 @@ public class BatteryTestUtils {
|
|||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Configures the incompatible charger environment. */
|
||||||
* Configures the incompatible charger environment.
|
|
||||||
*/
|
|
||||||
public static void setupIncompatibleEvent(
|
public static void setupIncompatibleEvent(
|
||||||
UsbPort mockUsbPort, UsbManager mockUsbManager, UsbPortStatus mockUsbPortStatus) {
|
UsbPort mockUsbPort, UsbManager mockUsbManager, UsbPortStatus mockUsbPortStatus) {
|
||||||
final List<UsbPort> usbPorts = new ArrayList<>();
|
final List<UsbPort> usbPorts = new ArrayList<>();
|
||||||
@@ -222,16 +208,12 @@ public class BatteryTestUtils {
|
|||||||
.thenReturn(new int[] {UsbPortStatus.COMPLIANCE_WARNING_DEBUG_ACCESSORY});
|
.thenReturn(new int[] {UsbPortStatus.COMPLIANCE_WARNING_DEBUG_ACCESSORY});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Create an empty power anomaly event list proto. */
|
||||||
* Create an empty power anomaly event list proto.
|
|
||||||
*/
|
|
||||||
public static PowerAnomalyEventList createEmptyPowerAnomalyEventList() {
|
public static PowerAnomalyEventList createEmptyPowerAnomalyEventList() {
|
||||||
return PowerAnomalyEventList.getDefaultInstance();
|
return PowerAnomalyEventList.getDefaultInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Create an non-empty power anomaly event list proto. */
|
||||||
* Create an non-empty power anomaly event list proto.
|
|
||||||
*/
|
|
||||||
public static PowerAnomalyEventList createNonEmptyPowerAnomalyEventList() {
|
public static PowerAnomalyEventList createNonEmptyPowerAnomalyEventList() {
|
||||||
return PowerAnomalyEventList.newBuilder()
|
return PowerAnomalyEventList.newBuilder()
|
||||||
.addPowerAnomalyEvents(0, createAdaptiveBrightnessAnomalyEvent())
|
.addPowerAnomalyEvents(0, createAdaptiveBrightnessAnomalyEvent())
|
||||||
@@ -239,27 +221,35 @@ public class BatteryTestUtils {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Create a power anomaly event proto of adaptive brightness. */
|
||||||
* Create a power anomaly event proto of adaptive brightness.
|
|
||||||
*/
|
|
||||||
public static PowerAnomalyEvent createAdaptiveBrightnessAnomalyEvent() {
|
public static PowerAnomalyEvent createAdaptiveBrightnessAnomalyEvent() {
|
||||||
|
return createAdaptiveBrightnessAnomalyEvent(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Create a power anomaly event proto of adaptive brightness. */
|
||||||
|
public static PowerAnomalyEvent createAdaptiveBrightnessAnomalyEvent(boolean changeSettings) {
|
||||||
|
WarningBannerInfo.Builder warningBannerInfoBuilder =
|
||||||
|
WarningBannerInfo.newBuilder()
|
||||||
|
.setMainButtonDestination(DisplaySettings.class.getName())
|
||||||
|
.setMainButtonSourceMetricsCategory(SettingsEnums.DISPLAY)
|
||||||
|
.setMainButtonSourceHighlightKey("auto_brightness_entry");
|
||||||
|
if (changeSettings) {
|
||||||
|
warningBannerInfoBuilder
|
||||||
|
.setMainButtonConfigSettingsName(Settings.System.SCREEN_BRIGHTNESS_MODE)
|
||||||
|
.setMainButtonConfigSettingsValue(
|
||||||
|
Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
|
||||||
|
}
|
||||||
return PowerAnomalyEvent.newBuilder()
|
return PowerAnomalyEvent.newBuilder()
|
||||||
.setEventId("BrightnessAnomaly")
|
.setEventId("BrightnessAnomaly")
|
||||||
.setType(PowerAnomalyType.TYPE_SETTINGS_BANNER)
|
.setType(PowerAnomalyType.TYPE_SETTINGS_BANNER)
|
||||||
.setKey(PowerAnomalyKey.KEY_BRIGHTNESS)
|
.setKey(PowerAnomalyKey.KEY_BRIGHTNESS)
|
||||||
.setDismissRecordKey(PowerAnomalyKey.KEY_BRIGHTNESS.name())
|
.setDismissRecordKey(PowerAnomalyKey.KEY_BRIGHTNESS.name())
|
||||||
.setScore(1.2f)
|
.setScore(1.2f)
|
||||||
.setWarningBannerInfo(WarningBannerInfo.newBuilder()
|
.setWarningBannerInfo(warningBannerInfoBuilder.build())
|
||||||
.setMainButtonDestination(DisplaySettings.class.getName())
|
|
||||||
.setMainButtonSourceMetricsCategory(SettingsEnums.DISPLAY)
|
|
||||||
.setMainButtonSourceHighlightKey("auto_brightness_entry")
|
|
||||||
.build())
|
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Create a power anomaly event proto of screen timeout. */
|
||||||
* Create a power anomaly event proto of screen timeout.
|
|
||||||
*/
|
|
||||||
public static PowerAnomalyEvent createScreenTimeoutAnomalyEvent() {
|
public static PowerAnomalyEvent createScreenTimeoutAnomalyEvent() {
|
||||||
return PowerAnomalyEvent.newBuilder()
|
return PowerAnomalyEvent.newBuilder()
|
||||||
.setEventId("ScreenTimeoutAnomaly")
|
.setEventId("ScreenTimeoutAnomaly")
|
||||||
@@ -267,7 +257,8 @@ public class BatteryTestUtils {
|
|||||||
.setKey(PowerAnomalyKey.KEY_SCREEN_TIMEOUT)
|
.setKey(PowerAnomalyKey.KEY_SCREEN_TIMEOUT)
|
||||||
.setDismissRecordKey(PowerAnomalyKey.KEY_SCREEN_TIMEOUT.name())
|
.setDismissRecordKey(PowerAnomalyKey.KEY_SCREEN_TIMEOUT.name())
|
||||||
.setScore(1.1f)
|
.setScore(1.1f)
|
||||||
.setWarningBannerInfo(WarningBannerInfo.newBuilder()
|
.setWarningBannerInfo(
|
||||||
|
WarningBannerInfo.newBuilder()
|
||||||
.setMainButtonDestination(ScreenTimeoutSettings.class.getName())
|
.setMainButtonDestination(ScreenTimeoutSettings.class.getName())
|
||||||
.setMainButtonSourceMetricsCategory(SettingsEnums.SCREEN_TIMEOUT)
|
.setMainButtonSourceMetricsCategory(SettingsEnums.SCREEN_TIMEOUT)
|
||||||
.setMainButtonSourceHighlightKey("60000")
|
.setMainButtonSourceHighlightKey("60000")
|
||||||
@@ -275,9 +266,7 @@ public class BatteryTestUtils {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Create a power anomaly event proto of app anomaly. */
|
||||||
* Create a power anomaly event proto of app anomaly.
|
|
||||||
*/
|
|
||||||
public static PowerAnomalyEvent createAppAnomalyEvent() {
|
public static PowerAnomalyEvent createAppAnomalyEvent() {
|
||||||
return PowerAnomalyEvent.newBuilder()
|
return PowerAnomalyEvent.newBuilder()
|
||||||
.setEventId("AppAnomaly")
|
.setEventId("AppAnomaly")
|
||||||
@@ -285,7 +274,8 @@ public class BatteryTestUtils {
|
|||||||
.setKey(PowerAnomalyKey.KEY_APP_TOTAL_HIGHER_THAN_USUAL)
|
.setKey(PowerAnomalyKey.KEY_APP_TOTAL_HIGHER_THAN_USUAL)
|
||||||
.setDismissRecordKey("KEY_APP_1")
|
.setDismissRecordKey("KEY_APP_1")
|
||||||
.setScore(2.0f)
|
.setScore(2.0f)
|
||||||
.setWarningItemInfo(WarningItemInfo.newBuilder()
|
.setWarningItemInfo(
|
||||||
|
WarningItemInfo.newBuilder()
|
||||||
.setStartTimestamp(1694361600000L) // 2023-09-11 00:00:00
|
.setStartTimestamp(1694361600000L) // 2023-09-11 00:00:00
|
||||||
.setEndTimestamp(1694368800000L) // 2023-09-11 02:00:00
|
.setEndTimestamp(1694368800000L) // 2023-09-11 02:00:00
|
||||||
.build())
|
.build())
|
||||||
|
Reference in New Issue
Block a user