From 2b4830720ce560658d93059d6deac8298e9d01b4 Mon Sep 17 00:00:00 2001 From: Angela Wang Date: Fri, 24 Feb 2023 07:15:29 +0000 Subject: [PATCH 1/8] Fix duplicated order in notification settings layout There has 2 preferences with android:order="18" in the xml. Reorders all the preferences to remove the duplication. Bug: 270638515 Test: manual test Change-Id: I275effcd0e8a9c304dc045e17086fdb688be96b7 --- res/xml/configure_notification_settings.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/res/xml/configure_notification_settings.xml b/res/xml/configure_notification_settings.xml index 0f0aeff7aa5..f80fe571d82 100644 --- a/res/xml/configure_notification_settings.xml +++ b/res/xml/configure_notification_settings.xml @@ -131,14 +131,14 @@ From d32647d8908ec91dbd7936e51803a38b70094bd1 Mon Sep 17 00:00:00 2001 From: Sunny Shao Date: Thu, 2 Mar 2023 21:23:12 +0800 Subject: [PATCH 2/8] Fix checkcolor_hook error Bug: 271373417 Test: repo upload OK Change-Id: I60fd9ec6c6f47c5885bf7176d2143ab8131ea9a5 --- color-check-baseline.xml | 856 +++++++++++++++++++-------------------- 1 file changed, 428 insertions(+), 428 deletions(-) diff --git a/color-check-baseline.xml b/color-check-baseline.xml index 410acade269..3ba943b8e90 100644 --- a/color-check-baseline.xml +++ b/color-check-baseline.xml @@ -13,6 +13,198 @@ file="."/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -40,8 +232,8 @@ errorLine1=" <item android:offset="0" android:color="#001A73E8"/>" errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -56,8 +248,8 @@ errorLine1=" <item android:offset="0.69" android:color="#FF669DF6"/>" errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -72,8 +264,8 @@ errorLine1=" <item android:offset="0.69" android:color="#FF1A73E8"/>" errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -88,8 +280,8 @@ errorLine1=" <item android:offset="0" android:color="#00669DF6"/>" errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -104,8 +296,8 @@ errorLine1=" <item android:offset="0" android:color="#001A73E8"/>" errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -120,8 +312,8 @@ errorLine1=" <item android:offset="0.69" android:color="#FF669DF6"/>" errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -136,8 +328,8 @@ errorLine1=" <item android:offset="0.69" android:color="#FF1A73E8"/>" errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -152,8 +344,8 @@ errorLine1=" <item android:offset="0" android:color="#00669DF6"/>" errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -168,8 +360,8 @@ errorLine1=" <item android:offset="0" android:color="#001A73E8"/>" errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -184,8 +376,8 @@ errorLine1=" <item android:offset="0.69" android:color="#FF669DF6"/>" errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -200,8 +392,200 @@ errorLine1=" <item android:offset="0.69" android:color="#FF1A73E8"/>" errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -216,8 +600,8 @@ errorLine1=" <item android:offset="0" android:color="#00669DF6"/>" errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -232,8 +616,8 @@ errorLine1=" <item android:offset="0" android:color="#001A73E8"/>" errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -248,8 +632,8 @@ errorLine1=" <item android:offset="0.69" android:color="#FF669DF6"/>" errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -264,72 +648,8 @@ errorLine1=" <item android:offset="0.69" android:color="#FF1A73E8"/>" errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> - - - - - - - - - - - - - - - - @@ -4157,326 +4477,6 @@ column="13"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -5817,7 +5817,7 @@ errorLine2=" ^"> @@ -5833,7 +5833,7 @@ errorLine2=" ^"> @@ -5849,7 +5849,7 @@ errorLine2=" ^"> @@ -5865,7 +5865,7 @@ errorLine2=" ^"> @@ -5881,7 +5881,7 @@ errorLine2=" ^"> @@ -5897,7 +5897,7 @@ errorLine2=" ^"> @@ -5913,7 +5913,7 @@ errorLine2=" ^"> @@ -5929,7 +5929,7 @@ errorLine2=" ^"> @@ -5945,7 +5945,7 @@ errorLine2=" ^"> @@ -5961,7 +5961,7 @@ errorLine2=" ^"> @@ -5977,7 +5977,7 @@ errorLine2=" ^"> From 81ee016a6e19e09c14a23aed015f4c3a8f079c81 Mon Sep 17 00:00:00 2001 From: Chris Li Date: Wed, 22 Feb 2023 11:12:50 +0800 Subject: [PATCH 3/8] Update EmbeddingAspectRatio to the latest alwaysAllow() is changed to ALWAYS_ALLOW per API Council feedback. Bug: 270160592 Test: build Change-Id: I44c7e97932456ec5b5bb0339ee2ee060cb6e42e0 (cherry picked from commit af2b07b248730bc9dff48d29c1dfdb7a77f41aed) (cherry picked from commit 10924868730d9cbfc4567ed08cc1c9380426b188) --- .../activityembedding/ActivityEmbeddingRulesController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java b/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java index 381466f0031..e7ed5a04a45 100644 --- a/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java +++ b/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java @@ -111,7 +111,7 @@ public class ActivityEmbeddingRulesController { .setClearTop(clearTop) .setMinWidthDp(ActivityEmbeddingUtils.getMinCurrentScreenSplitWidthDp()) .setMinSmallestWidthDp(ActivityEmbeddingUtils.getMinSmallestScreenSplitWidthDp()) - .setMaxAspectRatioInPortrait(EmbeddingAspectRatio.alwaysAllow()) + .setMaxAspectRatioInPortrait(EmbeddingAspectRatio.ALWAYS_ALLOW) .setDefaultSplitAttributes(attributes) .build(); RuleController.getInstance(context).addRule(splitPairRule); @@ -232,7 +232,7 @@ public class ActivityEmbeddingRulesController { activityFilters, intent) .setMinWidthDp(ActivityEmbeddingUtils.getMinCurrentScreenSplitWidthDp()) .setMinSmallestWidthDp(ActivityEmbeddingUtils.getMinSmallestScreenSplitWidthDp()) - .setMaxAspectRatioInPortrait(EmbeddingAspectRatio.alwaysAllow()) + .setMaxAspectRatioInPortrait(EmbeddingAspectRatio.ALWAYS_ALLOW) .setSticky(false) .setFinishPrimaryWithPlaceholder(SplitRule.FinishBehavior.ADJACENT) .setDefaultSplitAttributes(attributes) From 03442225a3860829712677e10631e3829ac0c386 Mon Sep 17 00:00:00 2001 From: ykhung Date: Fri, 3 Mar 2023 00:50:59 +0800 Subject: [PATCH 4/8] Update incompatible charging string based on UXR suggestion Bug: 246960554 Test: atest Change-Id: I19ed65d17a538bf6c3c95a121d699e4a1a8ca7b1 --- res/values/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 6a184141957..8f9ad0fa690 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -5121,9 +5121,9 @@ Charge to full - Incompatible charging setup + Issue with charging accessory - Your battery is not charging or is charging very slowly + Battery charging slowly or won\'t charge. Check if the cable and power adapter work with your phone Learn more about incompatible charging From 327eaf16fb686273e6018b884ad64dc10b79df05 Mon Sep 17 00:00:00 2001 From: Diya Bera Date: Mon, 27 Feb 2023 19:33:18 +0000 Subject: [PATCH 5/8] Removed subtext from side fps enrollment flow Test: Manual (Try to enroll your fingerprint in a side fps device, and observe that there is no subtext in landscape mode) Bug: 267271891 Change-Id: Iba4c13e8083ecb92f8033882af9147f14071e726 Merged-in: Iba4c13e8083ecb92f8033882af9147f14071e726 --- .../FingerprintEnrollEnrolling.java | 49 ++++++++----------- .../FingerprintEnrollEnrollingTest.java | 27 ++++++++++ 2 files changed, 47 insertions(+), 29 deletions(-) diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java index 74069050f6d..9ed284cee61 100644 --- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java +++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java @@ -17,6 +17,7 @@ package com.android.settings.biometrics.fingerprint; import static android.hardware.biometrics.BiometricFingerprintConstants.FINGERPRINT_ERROR_USER_CANCELED; +import static android.text.Layout.HYPHENATION_FREQUENCY_NONE; import android.animation.Animator; import android.animation.ObjectAnimator; @@ -278,7 +279,6 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling { setDescriptionText(R.string.security_settings_udfps_enroll_start_message); } else if (mCanAssumeSfps) { setContentView(R.layout.sfps_enroll_enrolling); - setDescriptionText(R.string.security_settings_fingerprint_enroll_start_message); setHelpAnimation(); } else { setContentView(R.layout.fingerprint_enroll_enrolling); @@ -544,7 +544,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling { mIllustrationLottie.setContentDescription( getString(R.string.security_settings_udfps_tip_fingerprint_help) ); - configureEnrollmentStage("", R.raw.udfps_tip_hint_lottie); + configureEnrollmentStage(R.raw.udfps_tip_hint_lottie); } break; @@ -555,7 +555,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling { mIllustrationLottie.setContentDescription( getString(R.string.security_settings_udfps_side_fingerprint_help) ); - configureEnrollmentStage("", R.raw.udfps_left_edge_hint_lottie); + configureEnrollmentStage(R.raw.udfps_left_edge_hint_lottie); } else if (mIllustrationLottie == null) { if (isStageHalfCompleted()) { setDescriptionText( @@ -572,7 +572,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling { mIllustrationLottie.setContentDescription( getString(R.string.security_settings_udfps_side_fingerprint_help) ); - configureEnrollmentStage("", R.raw.udfps_right_edge_hint_lottie); + configureEnrollmentStage(R.raw.udfps_right_edge_hint_lottie); } else if (mIllustrationLottie == null) { if (isStageHalfCompleted()) { @@ -624,10 +624,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling { 0 ) ); - configureEnrollmentStage( - getString(R.string.security_settings_sfps_enroll_start_message), - R.raw.sfps_lottie_no_animation - ); + configureEnrollmentStage(R.raw.sfps_lottie_no_animation); } break; @@ -635,10 +632,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling { setHeaderText(R.string.security_settings_sfps_enroll_finger_center_title); if (!mHaveShownSfpsCenterLottie && mIllustrationLottie != null) { mHaveShownSfpsCenterLottie = true; - configureEnrollmentStage( - getString(R.string.security_settings_sfps_enroll_start_message), - R.raw.sfps_lottie_pad_center - ); + configureEnrollmentStage(R.raw.sfps_lottie_pad_center); } break; @@ -646,7 +640,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling { setHeaderText(R.string.security_settings_sfps_enroll_fingertip_title); if (!mHaveShownSfpsTipLottie && mIllustrationLottie != null) { mHaveShownSfpsTipLottie = true; - configureEnrollmentStage("", R.raw.sfps_lottie_tip); + configureEnrollmentStage(R.raw.sfps_lottie_tip); } break; @@ -654,7 +648,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling { setHeaderText(R.string.security_settings_sfps_enroll_left_edge_title); if (!mHaveShownSfpsLeftEdgeLottie && mIllustrationLottie != null) { mHaveShownSfpsLeftEdgeLottie = true; - configureEnrollmentStage("", R.raw.sfps_lottie_left_edge); + configureEnrollmentStage(R.raw.sfps_lottie_left_edge); } break; @@ -662,7 +656,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling { setHeaderText(R.string.security_settings_sfps_enroll_right_edge_title); if (!mHaveShownSfpsRightEdgeLottie && mIllustrationLottie != null) { mHaveShownSfpsRightEdgeLottie = true; - configureEnrollmentStage("", R.raw.sfps_lottie_right_edge); + configureEnrollmentStage(R.raw.sfps_lottie_right_edge); } break; @@ -673,7 +667,6 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling { // announce a different string for a11y upon entering the page. getLayout().setHeaderText( R.string.security_settings_sfps_enroll_find_sensor_title); - setDescriptionText(R.string.security_settings_sfps_enroll_start_message); final CharSequence description = getString( R.string.security_settings_sfps_enroll_find_sensor_message); getLayout().getHeaderTextView().setContentDescription(description); @@ -683,8 +676,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling { } } - private void configureEnrollmentStage(CharSequence description, @RawRes int lottie) { - setDescriptionText(description); + private void configureEnrollmentStage(@RawRes int lottie) { LottieCompositionFactory.fromRawRes(this, lottie) .addListener((c) -> { mIllustrationLottie.setComposition(c); @@ -858,16 +850,16 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling { } private void showError(CharSequence error) { - if (mCanAssumeUdfps || mCanAssumeSfps) { + if (mCanAssumeSfps) { + setHeaderText(error); + if (!mHelpAnimation.isRunning()) { + mHelpAnimation.start(); + } + applySfpsErrorDynamicColors(getApplicationContext(), true); + } else if (mCanAssumeUdfps) { setHeaderText(error); // Show nothing for subtitle when getting an error message. setDescriptionText(""); - if (mCanAssumeSfps) { - if (!mHelpAnimation.isRunning()) { - mHelpAnimation.start(); - } - applySfpsErrorDynamicColors(getApplicationContext(), true); - } } else { mErrorText.setText(error); if (mErrorText.getVisibility() == View.INVISIBLE) { @@ -1090,17 +1082,16 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling { final boolean isLandscape = newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE; if (mCanAssumeSfps) { + // hide the description + descriptionMixin.getTextView().setVisibility(View.GONE); + headerMixin.getTextView().setHyphenationFrequency(HYPHENATION_FREQUENCY_NONE); if (isLandscape) { headerMixin.setAutoTextSizeEnabled(true); headerMixin.getTextView().setMinLines(0); headerMixin.getTextView().setMaxLines(10); - descriptionMixin.getTextView().setMinLines(0); - descriptionMixin.getTextView().setMaxLines(10); } else { headerMixin.setAutoTextSizeEnabled(false); headerMixin.getTextView().setLines(4); - // hide the description - descriptionMixin.getTextView().setLines(0); } } } diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java index 9052322f8c3..439abc6f61d 100644 --- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java +++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java @@ -51,12 +51,14 @@ import android.os.CancellationSignal; import android.os.Vibrator; import android.view.Display; import android.view.Surface; +import android.view.View; import com.android.settings.R; import com.android.settings.testutils.FakeFeatureFactory; import com.android.settings.widget.RingProgressBar; import com.airbnb.lottie.LottieAnimationView; +import com.google.android.setupdesign.GlifLayout; import org.junit.Before; import org.junit.Test; @@ -263,6 +265,28 @@ public class FingerprintEnrollEnrollingTest { assertThat(appliedThemes.contains("SetupWizardPartnerResource")).isTrue(); } + @Test + public void fingerprintSfpsEnroll_descriptionTextVisibility() { + initializeActivityFor(TYPE_POWER_BUTTON); + + mActivity.onEnrollmentProgressChange(1 /* steps */, 1 /* remaining */); + + assertThat(getLayout().getDescriptionTextView().getVisibility()).isEqualTo(View.GONE); + } + + @Test + public void fingerprintUdfpsEnroll_descriptionTextVisibility() { + initializeActivityFor(TYPE_UDFPS_OPTICAL); + + mActivity.onEnrollmentProgressChange(1 /* steps */, 1 /* remaining */); + + assertThat(getLayout().getDescriptionTextView().getVisibility()).isEqualTo(View.VISIBLE); + } + + private GlifLayout getLayout() { + return (GlifLayout) mActivity.findViewById(R.id.setup_wizard_layout); + } + private void initializeActivityFor(int sensorType) { final List componentInfo = new ArrayList<>(); final FingerprintSensorPropertiesInternal prop = @@ -297,6 +321,9 @@ public class FingerprintEnrollEnrollingTest { doReturn(mSfpsStageThresholds[stage]).when(mActivity).getStageThresholdSteps(stage); } doReturn(true).when(mSidecar).isEnrolling(); + ReflectionHelpers.setField(mActivity, "mCanAssumeSfps", true); + } else if (sensorType == TYPE_UDFPS_OPTICAL) { + ReflectionHelpers.setField(mActivity, "mCanAssumeUdfps", true); } ActivityController.of(mActivity).create(savedInstanceState); From 961b32ca289f1d5df49a759703f53c29ce716ac5 Mon Sep 17 00:00:00 2001 From: Diya Bera Date: Sat, 25 Feb 2023 00:09:23 +0000 Subject: [PATCH 6/8] Learn more updated in Fingerprint Settings for side fps Test: Manual - Go to Fingerprint Settings and check the string Bug: 258338293 Change-Id: Ia22fcd1289bec85642993b22fe3cb3ebaf647cbd Merged-in: Ia22fcd1289bec85642993b22fe3cb3ebaf647cbd --- res/values/strings.xml | 2 ++ .../biometrics/fingerprint/FingerprintSettings.java | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/res/values/strings.xml b/res/values/strings.xml index ecf378d5bd6..f4393845b4f 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1038,6 +1038,8 @@ Allow fingerprint unlock Use your fingerprint + + Learn more about Fingerprint Unlock Use your fingerprint to unlock your tablet or verify it\u2019s you, like when you sign in to apps or approve a purchase. diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java index a1d84da2176..7f99ae9552a 100644 --- a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java +++ b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java @@ -442,6 +442,10 @@ public class FingerprintSettings extends SubSettings { column2.mTitle = getText( R.string.security_fingerprint_disclaimer_lockscreen_disabled_2 ); + if (isSfps()) { + column2.mLearnMoreOverrideText = getText( + R.string.security_settings_fingerprint_settings_footer_learn_more); + } column2.mLearnMoreClickListener = learnMoreClickListener; mFooterColumns.add(column2); } else { @@ -449,6 +453,10 @@ public class FingerprintSettings extends SubSettings { column.mTitle = getText( R.string.security_settings_fingerprint_enroll_introduction_v2_message); column.mLearnMoreClickListener = learnMoreClickListener; + if (isSfps()) { + column.mLearnMoreOverrideText = getText( + R.string.security_settings_fingerprint_settings_footer_learn_more); + } mFooterColumns.add(column); } } From b25a824f5061323310d0f8095f46f7484bbef6c3 Mon Sep 17 00:00:00 2001 From: ykhung Date: Fri, 3 Mar 2023 01:19:02 +0800 Subject: [PATCH 7/8] Update the battery saver scheduler string Fix: 266030870 Test: presubmit Change-Id: I271f02b6a6044ba39d23e9ad1eb1decebe4eec85 --- res/values/strings.xml | 3 +++ .../BatterySaverStickyPreferenceController.java | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 8f9ad0fa690..1aac6442e11 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -5273,6 +5273,9 @@ Turn off when charged + + Turn off at %1$s + Battery Saver turns off when battery reaches %1$s diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java index d11fe8a3b88..f06083abfae 100644 --- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java +++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java @@ -14,6 +14,7 @@ import com.android.settings.core.TogglePreferenceController; public class BatterySaverStickyPreferenceController extends TogglePreferenceController implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener { + private static final int DEFAULT_STICKY_SHUTOFF_LEVEL = 90; private Context mContext; @@ -39,10 +40,13 @@ public class BatterySaverStickyPreferenceController extends TogglePreferenceCont @Override protected void refreshSummary(Preference preference) { super.refreshSummary(preference); - final int stickyShutoffLevel = Settings.Global.getInt( - mContext.getContentResolver(), Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL, 90); + final int stickyShutoffLevel = Settings.Global.getInt(mContext.getContentResolver(), + Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL, DEFAULT_STICKY_SHUTOFF_LEVEL); + final String formatPercentage = Utils.formatPercentage(stickyShutoffLevel); + preference.setTitle(mContext.getString(R.string.battery_saver_sticky_title_percentage, + formatPercentage)); preference.setSummary(mContext.getString(R.string.battery_saver_sticky_description_new, - Utils.formatPercentage(stickyShutoffLevel))); + formatPercentage)); } @Override From 82d5103f07026cba1fbfc3fe70a956b669808a82 Mon Sep 17 00:00:00 2001 From: ykhung Date: Fri, 3 Mar 2023 17:10:13 +0800 Subject: [PATCH 8/8] Hide BatteryManagerPreference if there is no adaptive charging Fix: 271387663 Test: presubmit Change-Id: I12c511f17f23b21f6a584d86e854683fba037047 --- .../batterytip/BatteryManagerPreferenceController.java | 1 + .../TopLevelBatteryPreferenceControllerTest.java | 8 +------- .../BatteryManagerPreferenceControllerTest.java | 10 ++++++++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryManagerPreferenceController.java b/src/com/android/settings/fuelgauge/batterytip/BatteryManagerPreferenceController.java index 1c4c67c8781..ff747e36791 100644 --- a/src/com/android/settings/fuelgauge/batterytip/BatteryManagerPreferenceController.java +++ b/src/com/android/settings/fuelgauge/batterytip/BatteryManagerPreferenceController.java @@ -51,6 +51,7 @@ public class BatteryManagerPreferenceController extends BasePreferenceController @Override public int getAvailabilityStatus() { return mPowerUsageFeatureProvider.isBatteryManagerSupported() + && mPowerUsageFeatureProvider.isAdaptiveChargingSupported() ? AVAILABLE_UNSEARCHABLE : UNSUPPORTED_ON_DEVICE; } diff --git a/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java index da0002c50a4..f9cac5640a5 100644 --- a/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java @@ -61,12 +61,6 @@ public class TopLevelBatteryPreferenceControllerTest { assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE); } - @Test - @Config(qualifiers = "mcc999") - public void getAvailabilityStatus_unsupportedWhenSet() { - assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE); - } - @Test public void convertClassPathToComponentName_nullInput_returnsNull() { assertThat(mController.convertClassPathToComponentName(null)).isNull(); @@ -118,4 +112,4 @@ public class TopLevelBatteryPreferenceControllerTest { assertThat(mController.getSummary()) .isEqualTo(mContext.getString(R.string.battery_missing_message)); } -} \ No newline at end of file +} diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryManagerPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryManagerPreferenceControllerTest.java index 36f891edb1a..218fa9e5a51 100644 --- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryManagerPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryManagerPreferenceControllerTest.java @@ -86,6 +86,7 @@ public class BatteryManagerPreferenceControllerTest { @Test public void getAvailabilityStatus_supportBatteryManager_showPrefPage() { when(mPowerUsageFeatureProvider.isBatteryManagerSupported()).thenReturn(true); + when(mPowerUsageFeatureProvider.isAdaptiveChargingSupported()).thenReturn(true); assertThat(mController.getAvailabilityStatus()).isEqualTo( BatteryManagerPreferenceController.AVAILABLE_UNSEARCHABLE); @@ -98,4 +99,13 @@ public class BatteryManagerPreferenceControllerTest { assertThat(mController.getAvailabilityStatus()).isEqualTo( BatteryManagerPreferenceController.UNSUPPORTED_ON_DEVICE); } + + @Test + public void getAvailabilityStatus_supportBatteryManagerWithoutAC_notShowPrefPage() { + when(mPowerUsageFeatureProvider.isBatteryManagerSupported()).thenReturn(true); + when(mPowerUsageFeatureProvider.isAdaptiveChargingSupported()).thenReturn(false); + + assertThat(mController.getAvailabilityStatus()).isEqualTo( + BatteryManagerPreferenceController.UNSUPPORTED_ON_DEVICE); + } }