Merge "Remove condition manager v1 code."
diff --git a/res/values/strings.xml b/res/values/strings.xml
index b1c94df..5bdd578 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -9392,13 +9392,13 @@
<string name="notification_log_details_ranking_none">Ranking object doesn\'t contain this key.</string>
<!-- [CHAR_LIMIT=NONE] Developer Settings: Title of the setting which turns on emulation of a display cutout. -->
- <string name="display_cutout_emulation">Simulate a display with a cutout</string>
+ <string name="display_cutout_emulation">Display cutout</string>
<!-- [CHAR_LIMIT=NONE] Developer Settings: Search keywords for the setting which turns on emulation of a display cutout. -->
<string name="display_cutout_emulation_keywords">display cutout, notch</string>
- <!-- [CHAR_LIMIT=NONE] Developer Settings: Label for the option that turns off display cutout emulation. -->
- <string name="display_cutout_emulation_none">None</string>
+ <!-- [CHAR_LIMIT=NONE] Developer Settings: Label for the option that turns off display cutout emulation, (i.e. on devices whose screen actually has a cutout, selecting this option will show that cutout).-->
+ <string name="display_cutout_emulation_device_default">Device default</string>
<!-- [CHAR_LIMIT=60] Label for special access screen -->
<string name="special_access">Special app access</string>
diff --git a/src/com/android/settings/development/EmulateDisplayCutoutPreferenceController.java b/src/com/android/settings/development/EmulateDisplayCutoutPreferenceController.java
index 01687c6..4ae8cec 100644
--- a/src/com/android/settings/development/EmulateDisplayCutoutPreferenceController.java
+++ b/src/com/android/settings/development/EmulateDisplayCutoutPreferenceController.java
@@ -31,6 +31,7 @@
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
+import java.util.Comparator;
import java.util.List;
import androidx.annotation.VisibleForTesting;
@@ -43,6 +44,8 @@
PreferenceControllerMixin {
private static final String KEY = "display_cutout_emulation";
+ private static final Comparator<OverlayInfo> OVERLAY_INFO_COMPARATOR =
+ Comparator.comparingInt(a -> a.priority);
private final IOverlayManager mOverlayManager;
private final boolean mAvailable;
@@ -128,7 +131,7 @@
int current = 0;
pkgs[0] = "";
- labels[0] = mContext.getString(R.string.display_cutout_emulation_none);
+ labels[0] = mContext.getString(R.string.display_cutout_emulation_device_default);
for (int i = 0; i < overlays.length; i++) {
OverlayInfo o = overlays[i];
@@ -165,6 +168,7 @@
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
+ overlayInfos.sort(OVERLAY_INFO_COMPARATOR);
return overlayInfos.toArray(new OverlayInfo[overlayInfos.size()]);
}
diff --git a/tests/robotests/src/com/android/settings/development/EmulateDisplayCutoutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/EmulateDisplayCutoutPreferenceControllerTest.java
index c77fcab..a213f6a 100644
--- a/tests/robotests/src/com/android/settings/development/EmulateDisplayCutoutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/EmulateDisplayCutoutPreferenceControllerTest.java
@@ -17,6 +17,8 @@
package com.android.settings.development;
import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.AdditionalMatchers.aryEq;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
@@ -36,6 +38,7 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.AdditionalMatchers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -48,10 +51,10 @@
@RunWith(SettingsRobolectricTestRunner.class)
public class EmulateDisplayCutoutPreferenceControllerTest {
- private static final OverlayInfo ONE_DISABLED = createFakeOverlay("emulation.one", false);
- private static final OverlayInfo ONE_ENABLED = createFakeOverlay("emulation.one", true);
- private static final OverlayInfo TWO_DISABLED = createFakeOverlay("emulation.two", false);
- private static final OverlayInfo TWO_ENABLED = createFakeOverlay("emulation.two", true);
+ private static final OverlayInfo ONE_DISABLED = createFakeOverlay("emulation.one", false, 1);
+ private static final OverlayInfo ONE_ENABLED = createFakeOverlay("emulation.one", true, 1);
+ private static final OverlayInfo TWO_DISABLED = createFakeOverlay("emulation.two", false, 2);
+ private static final OverlayInfo TWO_ENABLED = createFakeOverlay("emulation.two", true, 2);
@Mock
private Context mContext;
@@ -135,6 +138,16 @@
}
@Test
+ public void ordered_by_priority() throws Exception {
+ mockCurrentOverlays(TWO_DISABLED, ONE_DISABLED);
+
+ mController.updateState(null);
+
+ verify(mPreference).setEntryValues(
+ aryEq(new String[]{"", ONE_DISABLED.packageName, TWO_DISABLED.packageName}));
+ }
+
+ @Test
public void onDeveloperOptionsSwitchDisabled() throws Exception {
mockCurrentOverlays(ONE_ENABLED, TWO_DISABLED);
final PreferenceScreen screen = mock(PreferenceScreen.class);
@@ -152,16 +165,16 @@
mOverlayManager);
}
- private static OverlayInfo createFakeOverlay(String pkg, boolean enabled) {
+ private static OverlayInfo createFakeOverlay(String pkg, boolean enabled, int priority) {
final int state = (enabled) ? OverlayInfo.STATE_ENABLED : OverlayInfo.STATE_DISABLED;
return new OverlayInfo(pkg /* packageName */,
- pkg + ".target" /* targetPackageName */,
+ "android" /* targetPackageName */,
DisplayCutout.EMULATION_OVERLAY_CATEGORY /* category */,
pkg + ".baseCodePath" /* baseCodePath */,
state /* state */,
0 /* userId */,
- 0 /* priority */,
+ priority,
true /* isStatic */);
}
}
\ No newline at end of file