From f322a43a57a4c682cde25cd1b01fdd7b7e302f4a Mon Sep 17 00:00:00 2001 From: Zoey Chen Date: Sat, 17 Feb 2024 07:35:52 +0000 Subject: [PATCH 1/3] [ToA] Add the metrics in Settings Bug: 323462103 Test: manual + presubmit Change-Id: Ic7ad80ed0829b11de4f8f7278149292d0cd80622 --- .../settings/localepicker/TermsOfAddressFeminineController.java | 2 +- .../localepicker/TermsOfAddressMasculineController.java | 2 +- .../settings/localepicker/TermsOfAddressNeutralController.java | 2 +- .../localepicker/TermsOfAddressFeminineControllerTest.java | 1 + .../localepicker/TermsOfAddressMasculineControllerTest.java | 1 + .../localepicker/TermsOfAddressNeutralControllerTest.java | 1 + 6 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/localepicker/TermsOfAddressFeminineController.java b/src/com/android/settings/localepicker/TermsOfAddressFeminineController.java index fdc4589cf5d..2227297c1a4 100644 --- a/src/com/android/settings/localepicker/TermsOfAddressFeminineController.java +++ b/src/com/android/settings/localepicker/TermsOfAddressFeminineController.java @@ -35,7 +35,7 @@ public class TermsOfAddressFeminineController extends TermsOfAddressBaseControll @Override protected int getMetricsActionKey() { - return 0; + return SettingsEnums.ACTION_TERMS_OF_ADDRESS_SPECIFIED; } @Override diff --git a/src/com/android/settings/localepicker/TermsOfAddressMasculineController.java b/src/com/android/settings/localepicker/TermsOfAddressMasculineController.java index 86011136e10..1548be2a90a 100644 --- a/src/com/android/settings/localepicker/TermsOfAddressMasculineController.java +++ b/src/com/android/settings/localepicker/TermsOfAddressMasculineController.java @@ -35,7 +35,7 @@ public class TermsOfAddressMasculineController extends TermsOfAddressBaseControl @Override protected int getMetricsActionKey() { - return 0; + return SettingsEnums.ACTION_TERMS_OF_ADDRESS_SPECIFIED; } @Override diff --git a/src/com/android/settings/localepicker/TermsOfAddressNeutralController.java b/src/com/android/settings/localepicker/TermsOfAddressNeutralController.java index e67bd4d12d8..0863c4fa682 100644 --- a/src/com/android/settings/localepicker/TermsOfAddressNeutralController.java +++ b/src/com/android/settings/localepicker/TermsOfAddressNeutralController.java @@ -35,7 +35,7 @@ public class TermsOfAddressNeutralController extends TermsOfAddressBaseControlle @Override protected int getMetricsActionKey() { - return 0; + return SettingsEnums.ACTION_TERMS_OF_ADDRESS_SPECIFIED; } @Override diff --git a/tests/unit/src/com/android/settings/localepicker/TermsOfAddressFeminineControllerTest.java b/tests/unit/src/com/android/settings/localepicker/TermsOfAddressFeminineControllerTest.java index d1e30784e13..c04e5f92a63 100644 --- a/tests/unit/src/com/android/settings/localepicker/TermsOfAddressFeminineControllerTest.java +++ b/tests/unit/src/com/android/settings/localepicker/TermsOfAddressFeminineControllerTest.java @@ -97,6 +97,7 @@ public class TermsOfAddressFeminineControllerTest { selectedPreference.performClick(); + assertThat(selectedPreference.getKey()).isEqualTo(KEY_FEMININE); assertThat(selectedPreference.isSelected()).isTrue(); assertThat(pref.isSelected()).isFalse(); } diff --git a/tests/unit/src/com/android/settings/localepicker/TermsOfAddressMasculineControllerTest.java b/tests/unit/src/com/android/settings/localepicker/TermsOfAddressMasculineControllerTest.java index 5bf30731295..c2298be6faf 100644 --- a/tests/unit/src/com/android/settings/localepicker/TermsOfAddressMasculineControllerTest.java +++ b/tests/unit/src/com/android/settings/localepicker/TermsOfAddressMasculineControllerTest.java @@ -97,6 +97,7 @@ public class TermsOfAddressMasculineControllerTest { selectedPreference.performClick(); + assertThat(selectedPreference.getKey()).isEqualTo(KEY_MASCULINE); assertThat(selectedPreference.isSelected()).isTrue(); assertThat(pref.isSelected()).isFalse(); } diff --git a/tests/unit/src/com/android/settings/localepicker/TermsOfAddressNeutralControllerTest.java b/tests/unit/src/com/android/settings/localepicker/TermsOfAddressNeutralControllerTest.java index e83f3cdfcd8..fb207fc8cfe 100644 --- a/tests/unit/src/com/android/settings/localepicker/TermsOfAddressNeutralControllerTest.java +++ b/tests/unit/src/com/android/settings/localepicker/TermsOfAddressNeutralControllerTest.java @@ -97,6 +97,7 @@ public class TermsOfAddressNeutralControllerTest { selectedPreference.performClick(); + assertThat(selectedPreference.getKey()).isEqualTo(KEY_NEUTRAL); assertThat(selectedPreference.isSelected()).isTrue(); assertThat(pref.isSelected()).isFalse(); } From f33597b41d5ff20067b4e869aa2e2948b40d7a52 Mon Sep 17 00:00:00 2001 From: mxyyiyi Date: Sun, 18 Feb 2024 14:47:07 +0800 Subject: [PATCH 2/3] Update log metrics in battery usage. - Remove redundant logs - Update action id Bug: 323495266 Test: manual Change-Id: I3146405912f3df152c7a0d525ba06ba76e2e02df --- .../settings/fuelgauge/AdvancedPowerUsageDetail.java | 12 ------------ .../fuelgauge/PowerBackgroundUsageDetail.java | 12 ------------ .../fuelgauge/RestrictAppPreferenceController.java | 2 +- 3 files changed, 1 insertion(+), 25 deletions(-) diff --git a/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java b/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java index 3df6b1a9ef7..6b04d3ce4f4 100644 --- a/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java +++ b/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java @@ -266,18 +266,6 @@ public class AdvancedPowerUsageDetail extends DashboardFragment initHeader(); mOptimizationMode = mBatteryOptimizeUtils.getAppOptimizationMode(); initFooter(); - mExecutor.execute( - () -> { - final String packageName = - BatteryUtils.getLoggingPackageName( - getContext(), mBatteryOptimizeUtils.getPackageName()); - FeatureFactory.getFeatureFactory() - .getMetricsFeatureProvider() - .action( - getContext(), - SettingsEnums.OPEN_APP_BATTERY_USAGE, - packageName); - }); mLogStringBuilder = new StringBuilder("onResume mode = ").append(mOptimizationMode); } diff --git a/src/com/android/settings/fuelgauge/PowerBackgroundUsageDetail.java b/src/com/android/settings/fuelgauge/PowerBackgroundUsageDetail.java index 2bf4d96fe52..206745647c6 100644 --- a/src/com/android/settings/fuelgauge/PowerBackgroundUsageDetail.java +++ b/src/com/android/settings/fuelgauge/PowerBackgroundUsageDetail.java @@ -110,18 +110,6 @@ public class PowerBackgroundUsageDetail extends DashboardFragment initHeader(); mOptimizationMode = mBatteryOptimizeUtils.getAppOptimizationMode(); initFooter(); - mExecutor.execute( - () -> { - String packageName = - BatteryUtils.getLoggingPackageName( - getContext(), mBatteryOptimizeUtils.getPackageName()); - FeatureFactory.getFeatureFactory() - .getMetricsFeatureProvider() - .action( - getContext(), - SettingsEnums.OPEN_POWER_USAGE_MANAGE_BACKGROUND, - packageName); - }); mLogStringBuilder = new StringBuilder("onResume mode = ").append(mOptimizationMode); } diff --git a/src/com/android/settings/fuelgauge/RestrictAppPreferenceController.java b/src/com/android/settings/fuelgauge/RestrictAppPreferenceController.java index ea59afa0a8e..9969f2467e7 100644 --- a/src/com/android/settings/fuelgauge/RestrictAppPreferenceController.java +++ b/src/com/android/settings/fuelgauge/RestrictAppPreferenceController.java @@ -84,7 +84,7 @@ public class RestrictAppPreferenceController extends BasePreferenceController { RestrictedAppDetails.startRestrictedAppDetails(mPreferenceFragment, mAppInfos); FeatureFactory.getFeatureFactory() .getMetricsFeatureProvider() - .action(mContext, SettingsEnums.OPEN_APP_RESTRICTED_LIST); + .action(mContext, SettingsEnums.ACTION_APP_RESTRICTED_LIST_MANAGED); return true; } From 1abc13fe29cb81d993580d9140ed9c0b55716438 Mon Sep 17 00:00:00 2001 From: pajacechen Date: Sat, 17 Feb 2024 15:20:19 +0800 Subject: [PATCH 3/3] [Shadow] Update the string and the dismiss button - Disable the dismiss button for incompatible charging - Update the button string for battery defender tips - Update settings banner icon for defender Test: Manual Test Bug: 315748218 Change-Id: I0cfe03e7984be02eff4fb6dce68cc22fe7edf8e2 --- res/drawable/ic_battery_defender_tip_shield.xml | 9 +++++++++ res/values/strings.xml | 4 ++-- .../fuelgauge/batterytip/tips/BatteryDefenderTip.java | 2 +- .../batterytip/tips/IncompatibleChargerTip.java | 1 + 4 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 res/drawable/ic_battery_defender_tip_shield.xml diff --git a/res/drawable/ic_battery_defender_tip_shield.xml b/res/drawable/ic_battery_defender_tip_shield.xml new file mode 100644 index 00000000000..1f1f73a609b --- /dev/null +++ b/res/drawable/ic_battery_defender_tip_shield.xml @@ -0,0 +1,9 @@ + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index 45305ece4f6..746dbf51f36 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -5679,8 +5679,8 @@ Remove Cancel - - Charge to full + + Override Check charging accessory diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTip.java b/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTip.java index 319ba7a16c8..37162448b1b 100644 --- a/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTip.java +++ b/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTip.java @@ -62,7 +62,7 @@ public class BatteryDefenderTip extends BatteryTip { @Override public int getIconId() { - return R.drawable.ic_battery_status_good_theme; + return R.drawable.ic_battery_defender_tip_shield; } @Override diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/IncompatibleChargerTip.java b/src/com/android/settings/fuelgauge/batterytip/tips/IncompatibleChargerTip.java index c9ff8641ceb..72c710c023f 100644 --- a/src/com/android/settings/fuelgauge/batterytip/tips/IncompatibleChargerTip.java +++ b/src/com/android/settings/fuelgauge/batterytip/tips/IncompatibleChargerTip.java @@ -81,6 +81,7 @@ public final class IncompatibleChargerTip extends BatteryTip { } cardPreference.setSelectable(false); + cardPreference.enableDismiss(false); cardPreference.setIconResId(getIconId()); cardPreference.setPrimaryButtonText(context.getString(R.string.learn_more)); cardPreference.setPrimaryButtonAction(