Snap for 11853201 from 504ac0cf2a to 24Q3-release
Change-Id: I7635ee0bc3c0e93a53158269f2216c479add1026
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
android:orientation="vertical">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/unified_suggestion_content"
|
||||
android:id="@+id/suggestion_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
|
||||
@@ -4088,7 +4088,7 @@
|
||||
<!-- Manage applications, restore updated system application to factory version -->
|
||||
<string name="app_factory_reset">Uninstall updates</string>
|
||||
<!-- [CHAR LIMIT=50] Manage applications, unlock restricted setting from lock screen title -->
|
||||
<string name="app_restricted_settings_lockscreen_title">Allow restricted permissions</string>
|
||||
<string name="app_restricted_settings_lockscreen_title">Allow restricted settings</string>
|
||||
<!-- Manage applications, individual application info screen, screen, message text under Launch by default heading. This is present if the app is set as a default for some actions. -->
|
||||
<string name="auto_launch_enable_text">Some activities you\u2019ve selected open in this app by default.</string>
|
||||
<!-- Manage applications, individual application info screen, screen, message text under Launch by default heading. This is present if the app was given user permission to create widgets. -->
|
||||
@@ -5371,6 +5371,8 @@
|
||||
<string name="daltonizer_mode_tritanomaly_title">Blue-yellow</string>
|
||||
<!-- Title shown for grayscale [CHAR LIMIT=45] -->
|
||||
<string name="daltonizer_mode_grayscale_title">Grayscale</string>
|
||||
<!-- Title shown for settings that controls color correction saturation level [CHAR LIMIT=45] -->
|
||||
<string name="daltonizer_saturation_title">Intensity</string>
|
||||
<!-- Summary shown for deuteranomaly (red-green color blindness) [CHAR LIMIT=45] -->
|
||||
<string name="daltonizer_mode_deuteranomaly_summary">Green weak, deuteranomaly</string>
|
||||
<!-- Summary shown for protanomaly (red-green color blindness) [CHAR LIMIT=45] -->
|
||||
|
||||
@@ -51,4 +51,10 @@
|
||||
android:persistent="false"
|
||||
android:title="@string/daltonizer_mode_grayscale_title" />
|
||||
|
||||
<com.android.settings.widget.SeekBarPreference
|
||||
android:key="daltonizer_saturation"
|
||||
android:persistent="false"
|
||||
android:title="@string/daltonizer_saturation_title"
|
||||
settings:controller="com.android.settings.accessibility.DaltonizerSaturationSeekbarPreferenceController"
|
||||
/>
|
||||
</PreferenceScreen>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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<AbstractPreferenceController> sControllers = new ArrayList<>();
|
||||
|
||||
private static List<AbstractPreferenceController> 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);
|
||||
|
||||
@@ -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<CombinedProviderInfo> 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,
|
||||
|
||||
@@ -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<DefaultAppInfo> getCandidates() {
|
||||
final Context context = getContext();
|
||||
|
||||
@@ -183,16 +183,15 @@ public class DefaultCombinedPreferenceController extends DefaultAppPreferenceCon
|
||||
final List<AutofillServiceInfo> autofillProviders =
|
||||
AutofillServiceInfo.getAvailableServices(mContext, userId);
|
||||
final String selectedAutofillProvider =
|
||||
Settings.Secure.getStringForUser(
|
||||
mContext.getContentResolver(),
|
||||
DefaultCombinedPicker.AUTOFILL_SETTING,
|
||||
userId);
|
||||
CredentialManagerPreferenceController
|
||||
.getSelectedAutofillProvider(mContext, userId, TAG);
|
||||
|
||||
final List<CredentialProviderInfo> 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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<SubscriptionInfo> 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());
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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(
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user