Merge "Cleaning up quick settings flag in Settings app" into main

This commit is contained in:
Riley Jones
2024-12-03 22:03:04 +00:00
committed by Android (Google) Code Review
38 changed files with 159 additions and 1535 deletions

View File

@@ -25,12 +25,7 @@ import static com.google.common.truth.Truth.assertThat;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.platform.test.annotations.RequiresFlagsDisabled;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.provider.Settings;
import android.view.accessibility.Flags;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -41,7 +36,6 @@ import com.android.internal.accessibility.util.ShortcutUtils;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -61,8 +55,6 @@ public class PreferredShortcutsTest {
CLASS_NAME_2);
private static final ContentResolver sContentResolver =
ApplicationProvider.getApplicationContext().getContentResolver();
@Rule
public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
private final Context mContext = ApplicationProvider.getApplicationContext();
@Before
@@ -175,7 +167,6 @@ public class PreferredShortcutsTest {
}
@Test
@RequiresFlagsEnabled(Flags.FLAG_A11Y_QS_SHORTCUT)
public void updatePreferredShortcutFromSettings_colorInversionWithQsAndSoftwareShortcut_preferredShortcutsMatches() {
String target = COLOR_INVERSION_COMPONENT_NAME.flattenToString();
Settings.Secure.putString(sContentResolver,
@@ -192,23 +183,6 @@ public class PreferredShortcutsTest {
}
@Test
@RequiresFlagsDisabled(Flags.FLAG_A11Y_QS_SHORTCUT)
public void updatePreferredShortcutFromSettings_colorInversionWithQsAndHardwareShortcut_qsShortcutNotSaved() {
String target = COLOR_INVERSION_COMPONENT_NAME.flattenToString();
Settings.Secure.putString(sContentResolver,
Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE, target);
Settings.Secure.putString(sContentResolver,
Settings.Secure.ACCESSIBILITY_QS_TARGETS, target);
assertThat(!android.view.accessibility.Flags.a11yQsShortcut()).isTrue();
PreferredShortcuts.updatePreferredShortcutsFromSettings(mContext, Set.of(target));
int savedPreferredShortcut = PreferredShortcuts.retrieveUserShortcutType(
mContext, target);
assertThat(savedPreferredShortcut).isEqualTo(UserShortcutType.HARDWARE);
}
@Test
public void retrieveUserShortcutTypeWithoutDefault_noUserPreferredShortcuts_returnSoftwareShortcut() {
String target = COMPONENT_NAME_1.flattenToString();

View File

@@ -16,8 +16,6 @@
package com.android.settings.accessibility;
import static com.android.internal.accessibility.AccessibilityShortcutController.REDUCE_BRIGHT_COLORS_TILE_SERVICE_COMPONENT_NAME;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
@@ -26,12 +24,7 @@ import static org.mockito.Mockito.when;
import android.content.Context;
import android.content.res.Resources;
import android.platform.test.annotations.RequiresFlagsDisabled;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.provider.Settings;
import android.view.accessibility.Flags;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -40,7 +33,6 @@ import com.android.internal.R;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -48,8 +40,6 @@ import org.junit.runner.RunWith;
public class ReduceBrightColorsPreferenceControllerTest {
private static final String PREF_KEY = "rbc_preference";
@Rule
public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
private Context mContext;
private Resources mResources;;
private ReduceBrightColorsPreferenceController mController;
@@ -98,20 +88,6 @@ public class ReduceBrightColorsPreferenceControllerTest {
assertThat(mController.isAvailable()).isFalse();
}
@Test
@RequiresFlagsDisabled(Flags.FLAG_A11Y_QS_SHORTCUT)
public void getTileComponentName_a11yQsFlagOff_returnComponentName() {
assertThat(mController.getTileComponentName())
.isEqualTo(REDUCE_BRIGHT_COLORS_TILE_SERVICE_COMPONENT_NAME);
}
@Test
@RequiresFlagsEnabled(Flags.FLAG_A11Y_QS_SHORTCUT)
public void getTileComponentName_a11yQsFlagOff_returnNull() {
assertThat(mController.getTileComponentName()).isNull();
}
private int resourceId(String type, String name) {
return mContext.getResources().getIdentifier(name, type, mContext.getPackageName());
}