<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>
import com.android.settings.wrapper.OverlayManagerWrapper.OverlayInfo;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
+import java.util.Comparator;
import java.util.List;
public class EmulateDisplayCutoutPreferenceController extends
PreferenceControllerMixin {
private static final String KEY = "display_cutout_emulation";
+ private static final Comparator<OverlayInfo> OVERLAY_INFO_COMPARATOR =
+ Comparator.comparingInt(a -> a.priority);
private final OverlayManagerWrapper mOverlayManager;
private final boolean mAvailable;
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];
overlayInfos.remove(i);
}
}
+ overlayInfos.sort(OVERLAY_INFO_COMPARATOR);
return overlayInfos.toArray(new OverlayInfo[overlayInfos.size()]);
}
public static final String CATEGORY_THEME = android.content.om.OverlayInfo.CATEGORY_THEME;
public final String packageName;
public final String category;
+ public final int priority;
private final boolean mEnabled;
- public OverlayInfo(String packageName, String category, boolean enabled) {
+ public OverlayInfo(String packageName, String category, boolean enabled, int priority) {
this.packageName = packageName;
this.category = category;
mEnabled = enabled;
+ this.priority = priority;
}
public OverlayInfo(android.content.om.OverlayInfo info) {
mEnabled = info.isEnabled();
category = info.category;
packageName = info.packageName;
+ priority = info.priority;
}
public boolean isEnabled() {
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;
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;
@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;
}
@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);
mOverlayManager);
}
- private static OverlayInfo createFakeOverlay(String pkg, boolean enabled) {
- return new OverlayInfo(pkg, DisplayCutout.EMULATION_OVERLAY_CATEGORY, enabled);
+ private static OverlayInfo createFakeOverlay(String pkg, boolean enabled, int priority) {
+ return new OverlayInfo(pkg, DisplayCutout.EMULATION_OVERLAY_CATEGORY, enabled,
+ priority);
}
}
\ No newline at end of file