diff --git a/res/layout/settings_homepage_container_v2.xml b/res/layout/settings_homepage_container_v2.xml index 73b8f21cebf..55fb1dac57f 100644 --- a/res/layout/settings_homepage_container_v2.xml +++ b/res/layout/settings_homepage_container_v2.xml @@ -35,7 +35,7 @@ android:orientation="vertical"> Uninstall updates - Allow restricted permissions + Allow restricted settings Some activities you\u2019ve selected open in this app by default. @@ -5371,6 +5371,8 @@ Blue-yellow Grayscale + + Intensity Green weak, deuteranomaly diff --git a/res/xml/accessibility_daltonizer_settings.xml b/res/xml/accessibility_daltonizer_settings.xml index 91b163bf68c..1f770306890 100644 --- a/res/xml/accessibility_daltonizer_settings.xml +++ b/res/xml/accessibility_daltonizer_settings.xml @@ -51,4 +51,10 @@ android:persistent="false" android:title="@string/daltonizer_mode_grayscale_title" /> + diff --git a/src/com/android/settings/accessibility/DaltonizerSaturationSeekbarPreferenceController.java b/src/com/android/settings/accessibility/DaltonizerSaturationSeekbarPreferenceController.java new file mode 100644 index 00000000000..7dcd6612ac4 --- /dev/null +++ b/src/com/android/settings/accessibility/DaltonizerSaturationSeekbarPreferenceController.java @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.settings.accessibility; + +import android.content.ContentResolver; +import android.content.Context; +import android.provider.Settings; + +import androidx.preference.PreferenceScreen; + +import com.android.server.accessibility.Flags; +import com.android.settings.core.SliderPreferenceController; +import com.android.settings.widget.SeekBarPreference; + +/** + * The controller of the seekbar preference for the saturation level of color correction. + */ +public class DaltonizerSaturationSeekbarPreferenceController extends SliderPreferenceController { + + private static final int DEFAULT_SATURATION_LEVEL = 7; + private static final int SATURATION_MAX = 10; + private static final int SATURATION_MIN = 0; + + private int mSliderPosition; + private final ContentResolver mContentResolver; + + public DaltonizerSaturationSeekbarPreferenceController(Context context, + String preferenceKey) { + super(context, preferenceKey); + mContentResolver = context.getContentResolver(); + mSliderPosition = Settings.Secure.getInt( + mContentResolver, + Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_SATURATION_LEVEL, + DEFAULT_SATURATION_LEVEL); + setSliderPosition(mSliderPosition); + // TODO: Observer color correction on/off and enable/disable based on secure settings. + } + + @Override + public void displayPreference(PreferenceScreen screen) { + super.displayPreference(screen); + SeekBarPreference preference = screen.findPreference(getPreferenceKey()); + preference.setMax(getMax()); + preference.setMin(getMin()); + preference.setProgress(mSliderPosition); + preference.setContinuousUpdates(true); + } + + @Override + public int getAvailabilityStatus() { + if (Flags.enableColorCorrectionSaturation()) { + return AVAILABLE; + } + return CONDITIONALLY_UNAVAILABLE; + } + + @Override + public int getSliderPosition() { + return mSliderPosition; + } + + @Override + public boolean setSliderPosition(int position) { + if (position < getMin() || position > getMax()) { + return false; + } + mSliderPosition = position; + Settings.Secure.putInt( + mContentResolver, + Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_SATURATION_LEVEL, + mSliderPosition); + return true; + } + + @Override + public int getMax() { + return SATURATION_MAX; + } + + @Override + public int getMin() { + return SATURATION_MIN; + } +} diff --git a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java index bc34e01ee8d..0cfa756778e 100644 --- a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java +++ b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java @@ -62,6 +62,9 @@ public class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePreferenceF static final String KEY_TRITANOMEALY = "daltonizer_mode_tritanomaly"; @VisibleForTesting static final String KEY_GRAYSCALE = "daltonizer_mode_grayscale"; + @VisibleForTesting + static final String KEY_SATURATION = "daltonizer_saturation"; + private static final List sControllers = new ArrayList<>(); private static List buildPreferenceControllers(Context context, @@ -79,7 +82,6 @@ public class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePreferenceF return sControllers; } - @Override protected void registerKeysToObserverCallback( AccessibilitySettingsContentObserver contentObserver) { @@ -138,6 +140,8 @@ public class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePreferenceF lists.add(KEY_TOP_INTRO_PREFERENCE); lists.add(KEY_PREVIEW); lists.add(KEY_USE_SERVICE_PREFERENCE); + // Putting saturation level close to the preview so users can see what is changing. + lists.add(KEY_SATURATION); lists.add(KEY_DEUTERANOMALY); lists.add(KEY_PROTANOMALY); lists.add(KEY_TRITANOMEALY); diff --git a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java index 1adbbaf5963..f07241a2fe4 100644 --- a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java +++ b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java @@ -521,16 +521,7 @@ public class CredentialManagerPreferenceController extends BasePreferenceControl // Get the selected autofill provider. If it is the placeholder then replace it with an // empty string. String selectedAutofillProvider = - DefaultCombinedPicker.getSelectedAutofillProvider(mContext, getUser()); - String credentialAutofillService = ""; - if (android.service.autofill.Flags.autofillCredmanDevIntegration()) { - credentialAutofillService = getCredentialAutofillService(mContext, TAG); - } - if (TextUtils.equals(selectedAutofillProvider, credentialAutofillService) - || TextUtils.equals( - selectedAutofillProvider, AUTOFILL_CREDMAN_ONLY_PROVIDER_PLACEHOLDER)) { - selectedAutofillProvider = ""; - } + getSelectedAutofillProvider(mContext, getUser(), TAG); // Get the list of combined providers. List providers = @@ -695,6 +686,31 @@ public class CredentialManagerPreferenceController extends BasePreferenceControl return ""; } + /** Gets the selected autofill provider name. This will filter out place holder names. **/ + public static @Nullable String getSelectedAutofillProvider( + Context context, int userId, String tag) { + String providerName = Settings.Secure.getStringForUser( + context.getContentResolver(), Settings.Secure.AUTOFILL_SERVICE, userId); + + if (TextUtils.isEmpty(providerName)) { + return providerName; + } + + if (providerName.equals(AUTOFILL_CREDMAN_ONLY_PROVIDER_PLACEHOLDER)) { + return ""; + } + + String credentialAutofillService = ""; + if (android.service.autofill.Flags.autofillCredmanDevIntegration()) { + credentialAutofillService = getCredentialAutofillService(context, tag); + } + if (providerName.equals(credentialAutofillService)) { + return ""; + } + + return providerName; + } + private CombiPreference addProviderPreference( @NonNull Context prefContext, @NonNull CharSequence title, diff --git a/src/com/android/settings/applications/credentials/DefaultCombinedPicker.java b/src/com/android/settings/applications/credentials/DefaultCombinedPicker.java index 8bc0bca627b..f4224114a6c 100644 --- a/src/com/android/settings/applications/credentials/DefaultCombinedPicker.java +++ b/src/com/android/settings/applications/credentials/DefaultCombinedPicker.java @@ -275,15 +275,13 @@ public class DefaultCombinedPicker extends DefaultAppPickerFragment { CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_INCLUDING_HIDDEN)); } - final String selectedAutofillProvider = getSelectedAutofillProvider(context, userId); + final String selectedAutofillProvider = + CredentialManagerPreferenceController + .getSelectedAutofillProvider(context, userId, TAG); return CombinedProviderInfo.buildMergedList( autofillProviders, credManProviders, selectedAutofillProvider); } - public static String getSelectedAutofillProvider(Context context, int userId) { - return Settings.Secure.getStringForUser( - context.getContentResolver(), AUTOFILL_SETTING, userId); - } protected List getCandidates() { final Context context = getContext(); diff --git a/src/com/android/settings/applications/credentials/DefaultCombinedPreferenceController.java b/src/com/android/settings/applications/credentials/DefaultCombinedPreferenceController.java index 57cd1d2d8da..33d9067eec5 100644 --- a/src/com/android/settings/applications/credentials/DefaultCombinedPreferenceController.java +++ b/src/com/android/settings/applications/credentials/DefaultCombinedPreferenceController.java @@ -183,16 +183,15 @@ public class DefaultCombinedPreferenceController extends DefaultAppPreferenceCon final List autofillProviders = AutofillServiceInfo.getAvailableServices(mContext, userId); final String selectedAutofillProvider = - Settings.Secure.getStringForUser( - mContext.getContentResolver(), - DefaultCombinedPicker.AUTOFILL_SETTING, - userId); + CredentialManagerPreferenceController + .getSelectedAutofillProvider(mContext, userId, TAG); final List credManProviders = new ArrayList<>(); if (mCredentialManager != null) { credManProviders.addAll( mCredentialManager.getCredentialProviderServices( - userId, CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_ONLY)); + userId, + CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_INCLUDING_HIDDEN)); } return CombinedProviderInfo.buildMergedList( @@ -226,6 +225,12 @@ public class DefaultCombinedPreferenceController extends DefaultAppPreferenceCon return; } + // Clean the autofill provider settings + Settings.Secure.putStringForUser( + mContext.getContentResolver(), + DefaultCombinedPicker.AUTOFILL_SETTING, null, getUser()); + + // Clean the credman provider settings. mCredentialManager.setEnabledProviders( List.of(), // empty primary provider. List.of(), // empty enabled providers. diff --git a/src/com/android/settings/fuelgauge/batteryusage/SpinnerPreference.java b/src/com/android/settings/fuelgauge/batteryusage/SpinnerPreference.java index 2bcc7bfd51f..886d00de67e 100644 --- a/src/com/android/settings/fuelgauge/batteryusage/SpinnerPreference.java +++ b/src/com/android/settings/fuelgauge/batteryusage/SpinnerPreference.java @@ -60,6 +60,7 @@ public class SpinnerPreference extends Preference { mSpinner = (Spinner) view.findViewById(R.id.spinner); mSpinner.setAdapter(new SpinnerAdapter(getContext(), mItems)); mSpinner.setSelection(mSavedSpinnerPosition); + mSpinner.setLongClickable(false); if (mOnItemSelectedListener != null) { mSpinner.setOnItemSelectedListener(mOnItemSelectedListener); } diff --git a/src/com/android/settings/homepage/SettingsHomepageActivity.java b/src/com/android/settings/homepage/SettingsHomepageActivity.java index e2557ed54ce..e422ce956ce 100644 --- a/src/com/android/settings/homepage/SettingsHomepageActivity.java +++ b/src/com/android/settings/homepage/SettingsHomepageActivity.java @@ -479,7 +479,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements } if (Flags.homepageRevamp()) { - mSuggestionView = findViewById(R.id.unified_suggestion_content); + mSuggestionView = findViewById(R.id.suggestion_content); } else { mSuggestionView = findViewById(R.id.suggestion_content); mTwoPaneSuggestionView = findViewById(R.id.two_pane_suggestion_content); @@ -493,7 +493,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements HOMEPAGE_LOADING_TIMEOUT_MS); if (Flags.homepageRevamp()) { showFragment(new SuggestionFragCreator(fragmentClass, true), - R.id.unified_suggestion_content); + R.id.suggestion_content); } else { showFragment(new SuggestionFragCreator(fragmentClass, /* isTwoPaneLayout= */ false), R.id.suggestion_content); diff --git a/src/com/android/settings/sim/receivers/SimSlotChangeHandler.java b/src/com/android/settings/sim/receivers/SimSlotChangeHandler.java index be40f2961a6..8f934d7e887 100644 --- a/src/com/android/settings/sim/receivers/SimSlotChangeHandler.java +++ b/src/com/android/settings/sim/receivers/SimSlotChangeHandler.java @@ -108,19 +108,18 @@ public class SimSlotChangeHandler { setRemovableSimSlotState(mContext, currentRemovableSlotState); if (mTelMgr.getActiveModemCount() > 1) { - if (!Flags.isDualSimOnboardingEnabled() && !isMultipleEnabledProfilesSupported()) { - Log.d(TAG, "The device is already in DSDS mode and no MEP. Do nothing."); - return; - } if (!isRemovableSimInserted) { Log.d(TAG, "Removable Sim is not inserted in DSDS mode. Do nothing."); return; } - boolean isDdsInvalidForNewUi = Flags.isDualSimOnboardingEnabled() - && SubscriptionManager.getDefaultDataSubscriptionId() - == SubscriptionManager.INVALID_SUBSCRIPTION_ID; - if (isDdsInvalidForNewUi) { - handleRemovableSimInsertWhenDsdsAndNoDds(); + + if (Flags.isDualSimOnboardingEnabled()) { + // ForNewUi, when the user inserts the psim, showing the sim onboarding for the user + // to setup the sim switching or the default data subscription. + handleRemovableSimInsertWhenDsds(); + } else if (!isMultipleEnabledProfilesSupported()) { + Log.d(TAG, "The device is already in DSDS mode and no MEP. Do nothing."); + return; } else if (isMultipleEnabledProfilesSupported()) { handleRemovableSimInsertUnderDsdsMep(removableSlotInfo); return; @@ -259,13 +258,13 @@ public class SimSlotChangeHandler { startChooseSimActivity(false); } - private void handleRemovableSimInsertWhenDsdsAndNoDds() { + private void handleRemovableSimInsertWhenDsds() { List subscriptionInfos = getAvailableRemovableSubscription(); if (subscriptionInfos.isEmpty()) { Log.e(TAG, "Unable to find the removable subscriptionInfo. Do nothing."); return; } - Log.d(TAG, "isDdsInvalidForNewUi and getAvailableRemovableSubscription:" + Log.d(TAG, "ForNewUi and getAvailableRemovableSubscription:" + subscriptionInfos); startSimConfirmDialogActivity(subscriptionInfos.get(0).getSubscriptionId()); } diff --git a/tests/robotests/src/com/android/settings/accessibility/DaltonizerSaturationSeekbarPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/DaltonizerSaturationSeekbarPreferenceControllerTest.java new file mode 100644 index 00000000000..98ed4422dc8 --- /dev/null +++ b/tests/robotests/src/com/android/settings/accessibility/DaltonizerSaturationSeekbarPreferenceControllerTest.java @@ -0,0 +1,197 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.accessibility; + +import static com.android.settings.core.BasePreferenceController.AVAILABLE; +import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE; + +import static com.google.common.truth.Truth.assertThat; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import android.content.ContentResolver; +import android.content.Context; +import android.platform.test.annotations.DisableFlags; +import android.platform.test.annotations.EnableFlags; +import android.platform.test.flag.junit.SetFlagsRule; +import android.provider.Settings; + +import androidx.preference.PreferenceScreen; +import androidx.test.core.app.ApplicationProvider; + +import com.android.server.accessibility.Flags; +import com.android.settings.widget.SeekBarPreference; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.robolectric.RobolectricTestRunner; + +/** Tests for {@link DaltonizerSaturationSeekbarPreferenceController}. */ +@RunWith(RobolectricTestRunner.class) +public class DaltonizerSaturationSeekbarPreferenceControllerTest { + + private ContentResolver mContentResolver; + private DaltonizerSaturationSeekbarPreferenceController mController; + + private int mOriginalSaturationLevel = -1; + + private PreferenceScreen mScreen; + + @Mock + private SeekBarPreference mPreference; + + @Rule + public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + Context context = ApplicationProvider.getApplicationContext(); + mContentResolver = context.getContentResolver(); + mOriginalSaturationLevel = Settings.Secure.getInt( + mContentResolver, + Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_SATURATION_LEVEL, + 7); + + mScreen = spy(new PreferenceScreen(context, /* attrs= */ null)); + when(mScreen.findPreference(ToggleDaltonizerPreferenceFragment.KEY_SATURATION)) + .thenReturn(mPreference); + + mController = new DaltonizerSaturationSeekbarPreferenceController( + context, + ToggleDaltonizerPreferenceFragment.KEY_SATURATION); + } + + @After + public void cleanup() { + Settings.Secure.putInt( + mContentResolver, + Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_SATURATION_LEVEL, + mOriginalSaturationLevel); + } + + + @Test + @DisableFlags(Flags.FLAG_ENABLE_COLOR_CORRECTION_SATURATION) + public void getAvailabilityStatus_flagDisabled_unavailable() { + assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE); + } + + @Test + @EnableFlags(Flags.FLAG_ENABLE_COLOR_CORRECTION_SATURATION) + public void getAvailabilityStatus_flagEnabled_available() { + assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE); + } + + @Test + public void constructor_defaultValuesMatch() { + assertThat(mController.getSliderPosition()).isEqualTo(7); + assertThat(mController.getMax()).isEqualTo(10); + assertThat(mController.getMin()).isEqualTo(0); + } + + @Test + @EnableFlags(Flags.FLAG_ENABLE_COLOR_CORRECTION_SATURATION) + public void displayPreference_enabled_visible() { + mController.displayPreference(mScreen); + + verify(mPreference).setMax(eq(10)); + verify(mPreference).setMin(eq(0)); + verify(mPreference).setProgress(eq(7)); + verify(mPreference).setContinuousUpdates(eq(true)); + verify(mPreference).setOnPreferenceChangeListener(eq(mController)); + verify(mPreference).setVisible(eq(true)); + } + + @Test + @DisableFlags(Flags.FLAG_ENABLE_COLOR_CORRECTION_SATURATION) + public void displayPreference_disabled_notVisible() { + mController.displayPreference(mScreen); + + verify(mPreference).setMax(eq(10)); + verify(mPreference).setMin(eq(0)); + verify(mPreference).setProgress(eq(7)); + verify(mPreference).setContinuousUpdates(eq(true)); + verify(mPreference, never()).setOnPreferenceChangeListener(any()); + verify(mPreference).setVisible(eq(false)); + } + + @Test + public void setSliderPosition_inRange_secureSettingsUpdated() { + var isSliderSet = mController.setSliderPosition(9); + + assertThat(isSliderSet).isTrue(); + assertThat(Settings.Secure.getInt( + mContentResolver, + Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_SATURATION_LEVEL, + 7)).isEqualTo(9); + } + + @Test + public void setSliderPosition_min_secureSettingsUpdated() { + var isSliderSet = mController.setSliderPosition(0); + + assertThat(isSliderSet).isTrue(); + assertThat(Settings.Secure.getInt( + mContentResolver, + Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_SATURATION_LEVEL, + 7)).isEqualTo(0); + } + + @Test + public void setSliderPosition_max_secureSettingsUpdated() { + var isSliderSet = mController.setSliderPosition(10); + + assertThat(isSliderSet).isTrue(); + assertThat(Settings.Secure.getInt( + mContentResolver, + Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_SATURATION_LEVEL, + 7)).isEqualTo(10); + } + + @Test + public void setSliderPosition_tooLarge_secureSettingsNotUpdated() { + var isSliderSet = mController.setSliderPosition(11); + + assertThat(isSliderSet).isFalse(); + assertThat(Settings.Secure.getInt( + mContentResolver, + Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_SATURATION_LEVEL, + 7)).isEqualTo(7); + } + + @Test + public void setSliderPosition_tooSmall_secureSettingsNotUpdated() { + var isSliderSet = mController.setSliderPosition(-1); + + assertThat(isSliderSet).isFalse(); + assertThat(Settings.Secure.getInt( + mContentResolver, + Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_SATURATION_LEVEL, + 7)).isEqualTo(7); + } +} diff --git a/tests/robotests/src/com/android/settings/homepage/SettingsHomepageActivityTest.java b/tests/robotests/src/com/android/settings/homepage/SettingsHomepageActivityTest.java index 785313d83ab..333d72f6966 100644 --- a/tests/robotests/src/com/android/settings/homepage/SettingsHomepageActivityTest.java +++ b/tests/robotests/src/com/android/settings/homepage/SettingsHomepageActivityTest.java @@ -41,6 +41,7 @@ import android.content.pm.PackageManager; import android.net.Uri; import android.os.Build; import android.os.UserHandle; +import android.platform.test.annotations.DisableFlags; import android.provider.Settings; import android.util.ArraySet; import android.view.View; @@ -53,6 +54,7 @@ import androidx.test.core.app.ApplicationProvider; import com.android.settings.R; import com.android.settings.dashboard.suggestions.SuggestionFeatureProviderImpl; +import com.android.settings.flags.Flags; import com.android.settings.testutils.shadow.ShadowActivityEmbeddingUtils; import com.android.settings.testutils.shadow.ShadowPasswordUtils; import com.android.settings.testutils.shadow.ShadowUserManager; @@ -120,6 +122,7 @@ public class SettingsHomepageActivityTest { } @Test + @DisableFlags(Flags.FLAG_HOMEPAGE_REVAMP) public void launch_configDisabled_shouldHideAvatar() { final SettingsHomepageActivity activity = Robolectric.buildActivity( SettingsHomepageActivity.class).create().get(); @@ -130,6 +133,7 @@ public class SettingsHomepageActivityTest { @Test @Config(qualifiers = "mcc999") + @DisableFlags(Flags.FLAG_HOMEPAGE_REVAMP) public void launch_configEnabled_shouldShowAvatar() { final SettingsHomepageActivity activity = Robolectric.buildActivity( SettingsHomepageActivity.class).create().get(); @@ -140,6 +144,7 @@ public class SettingsHomepageActivityTest { @Test @Config(qualifiers = "mcc999") + @DisableFlags(Flags.FLAG_HOMEPAGE_REVAMP) public void launch_LowRamDevice_shouldHideAvatar() { final ShadowActivityManager activityManager = Shadow.extract( ApplicationProvider.getApplicationContext().getSystemService( diff --git a/tests/unit/src/com/android/settings/localepicker/TermsOfAddressFeminineControllerTest.java b/tests/unit/src/com/android/settings/localepicker/TermsOfAddressFeminineControllerTest.java index 215e58f6dc8..246fad62af9 100644 --- a/tests/unit/src/com/android/settings/localepicker/TermsOfAddressFeminineControllerTest.java +++ b/tests/unit/src/com/android/settings/localepicker/TermsOfAddressFeminineControllerTest.java @@ -18,6 +18,8 @@ package com.android.settings.localepicker; import static com.google.common.truth.Truth.assertThat; +import static org.mockito.Mockito.spy; + import android.app.GrammaticalInflectionManager; import android.content.Context; import android.content.res.Configuration; @@ -32,6 +34,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import com.android.settings.widget.TickButtonPreference; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.MockitoAnnotations; @@ -59,7 +62,7 @@ public class TermsOfAddressFeminineControllerTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - mContext = ApplicationProvider.getApplicationContext(); + mContext = spy(ApplicationProvider.getApplicationContext()); if (Looper.myLooper() == null) { Looper.prepare(); @@ -90,6 +93,7 @@ public class TermsOfAddressFeminineControllerTest { } @Test + @Ignore("b/339543490") public void displayPreference_setGrammaticalGenderIsFeminine_FeminineIsSelected() { TickButtonPreference selectedPreference = (TickButtonPreference) mPreferenceScreen.getPreference(2); diff --git a/tests/unit/src/com/android/settings/localepicker/TermsOfAddressMasculineControllerTest.java b/tests/unit/src/com/android/settings/localepicker/TermsOfAddressMasculineControllerTest.java index b4c88937d8e..f5ed3959b76 100644 --- a/tests/unit/src/com/android/settings/localepicker/TermsOfAddressMasculineControllerTest.java +++ b/tests/unit/src/com/android/settings/localepicker/TermsOfAddressMasculineControllerTest.java @@ -18,6 +18,8 @@ package com.android.settings.localepicker; import static com.google.common.truth.Truth.assertThat; +import static org.mockito.Mockito.spy; + import android.app.GrammaticalInflectionManager; import android.content.Context; import android.content.res.Configuration; @@ -32,6 +34,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import com.android.settings.widget.TickButtonPreference; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.MockitoAnnotations; @@ -59,7 +62,7 @@ public class TermsOfAddressMasculineControllerTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - mContext = ApplicationProvider.getApplicationContext(); + mContext = spy(ApplicationProvider.getApplicationContext()); if (Looper.myLooper() == null) { Looper.prepare(); @@ -90,6 +93,7 @@ public class TermsOfAddressMasculineControllerTest { } @Test + @Ignore("b/339543490") public void displayPreference_setGrammaticalGenderIsMasculine_MasculineIsSelected() { TickButtonPreference selectedPreference = (TickButtonPreference) mPreferenceScreen.getPreference(3); diff --git a/tests/unit/src/com/android/settings/localepicker/TermsOfAddressNeutralControllerTest.java b/tests/unit/src/com/android/settings/localepicker/TermsOfAddressNeutralControllerTest.java index 76aed0ac9ac..0e53198188e 100644 --- a/tests/unit/src/com/android/settings/localepicker/TermsOfAddressNeutralControllerTest.java +++ b/tests/unit/src/com/android/settings/localepicker/TermsOfAddressNeutralControllerTest.java @@ -18,6 +18,8 @@ package com.android.settings.localepicker; import static com.google.common.truth.Truth.assertThat; +import static org.mockito.Mockito.spy; + import android.app.GrammaticalInflectionManager; import android.content.Context; import android.content.res.Configuration; @@ -32,6 +34,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import com.android.settings.widget.TickButtonPreference; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.MockitoAnnotations; @@ -59,7 +62,7 @@ public class TermsOfAddressNeutralControllerTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - mContext = ApplicationProvider.getApplicationContext(); + mContext = spy(ApplicationProvider.getApplicationContext()); if (Looper.myLooper() == null) { Looper.prepare(); @@ -90,6 +93,7 @@ public class TermsOfAddressNeutralControllerTest { } @Test + @Ignore("b/339543490") public void displayPreference_setGrammaticalGenderIsNotSpecified_NeutralIsSelected() { TickButtonPreference selectedPreference = (TickButtonPreference) mPreferenceScreen.getPreference(4); diff --git a/tests/unit/src/com/android/settings/localepicker/TermsOfAddressNotSpecifiedControllerTest.java b/tests/unit/src/com/android/settings/localepicker/TermsOfAddressNotSpecifiedControllerTest.java index 0f51b7dfff9..96bac08dde1 100644 --- a/tests/unit/src/com/android/settings/localepicker/TermsOfAddressNotSpecifiedControllerTest.java +++ b/tests/unit/src/com/android/settings/localepicker/TermsOfAddressNotSpecifiedControllerTest.java @@ -18,6 +18,8 @@ package com.android.settings.localepicker; import static com.google.common.truth.Truth.assertThat; +import static org.mockito.Mockito.spy; + import android.app.GrammaticalInflectionManager; import android.content.Context; import android.content.res.Configuration; @@ -32,6 +34,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import com.android.settings.widget.TickButtonPreference; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.MockitoAnnotations; @@ -59,7 +62,7 @@ public class TermsOfAddressNotSpecifiedControllerTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - mContext = ApplicationProvider.getApplicationContext(); + mContext = spy(ApplicationProvider.getApplicationContext()); if (Looper.myLooper() == null) { Looper.prepare(); @@ -90,6 +93,7 @@ public class TermsOfAddressNotSpecifiedControllerTest { } @Test + @Ignore("b/339543490") public void displayPreference_setGrammaticalGenderIsNotSpecified_NotSpecifiedIsSelected() { TickButtonPreference selectedPreference = (TickButtonPreference) mPreferenceScreen.getPreference(1);