Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b2b54eec authored by Jeff Brown's avatar Jeff Brown
Browse files

Add new setting to control overlay displays.

Change-Id: I9582bb149dca716699ef5977ef8f84bb3136e0c0
parent c6015d2f
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -652,6 +652,24 @@
        <item>10</item>
    </string-array>

    <!-- Titles for overlay display devices preference. [CHAR LIMIT=35] -->
    <string-array name="overlay_display_devices_entries">
        <item>None</item>
        <item>720x480 mdpi</item>
        <item>1280x720 tvdpi</item>
        <item>1920x1080 xhdpi</item>
        <item>1280x720 tvdpi and 1920x1080 xhdpi</item>
    </string-array>

    <!-- Values for overlay display devices preference. -->
    <string-array name="overlay_display_devices_values" translatable="false" >
        <item></item>
        <item>720x480/160</item>
        <item>1280x720/213</item>
        <item>1920x1080/320</item>
        <item>1280x720/213;1920x1080/320</item>
    </string-array>

    <!-- Titles for app process limit preference. [CHAR LIMIT=35] -->
    <string-array name="app_process_limit_entries">
        <item>Standard limit</item>
+3 −0
Original line number Diff line number Diff line
@@ -3813,6 +3813,9 @@
    <!-- UI debug setting: scaling factor for all Animator-based animations [CHAR LIMIT=25] -->
    <string name="animator_duration_scale_title">Animator duration scale</string>

    <!-- UI debug setting: simulate secondary display devices using overlays [CHAR LIMIT=25] -->
    <string name="overlay_display_devices_title">Simulate secondary displays</string>

    <!-- Preference category for application debugging development settings. [CHAR LIMIT=25] -->
    <string name="debug_applications_category">Apps</string>

+7 −0
Original line number Diff line number Diff line
@@ -146,6 +146,13 @@
            android:title="@string/force_hw_ui"
            android:summary="@string/force_hw_ui_summary"/>

        <ListPreference
            android:key="overlay_display_devices"
            android:title="@string/overlay_display_devices_title"
            android:persistent="false"
            android:entries="@array/overlay_display_devices_entries"
            android:entryValues="@array/overlay_display_devices_values" />

    </PreferenceCategory>

    <PreferenceCategory android:key="debug_monitoring_category"
+35 −0
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ public class DevelopmentSettings extends PreferenceFragment
    private static final String WINDOW_ANIMATION_SCALE_KEY = "window_animation_scale";
    private static final String TRANSITION_ANIMATION_SCALE_KEY = "transition_animation_scale";
    private static final String ANIMATOR_DURATION_SCALE_KEY = "animator_duration_scale";
    private static final String OVERLAY_DISPLAY_DEVICES_KEY = "overlay_display_devices";

    private static final String ENABLE_TRACES_KEY = "enable_traces";

@@ -144,6 +145,7 @@ public class DevelopmentSettings extends PreferenceFragment
    private ListPreference mWindowAnimationScale;
    private ListPreference mTransitionAnimationScale;
    private ListPreference mAnimatorDurationScale;
    private ListPreference mOverlayDisplayDevices;
    private MultiCheckPreference mEnableTracesPref;

    private CheckBoxPreference mImmediatelyDestroyActivities;
@@ -204,6 +206,9 @@ public class DevelopmentSettings extends PreferenceFragment
        mAnimatorDurationScale = (ListPreference) findPreference(ANIMATOR_DURATION_SCALE_KEY);
        mAllPrefs.add(mAnimatorDurationScale);
        mAnimatorDurationScale.setOnPreferenceChangeListener(this);
        mOverlayDisplayDevices = (ListPreference) findPreference(OVERLAY_DISPLAY_DEVICES_KEY);
        mAllPrefs.add(mOverlayDisplayDevices);
        mOverlayDisplayDevices.setOnPreferenceChangeListener(this);
        mEnableTracesPref = (MultiCheckPreference)findPreference(ENABLE_TRACES_KEY);
        String[] traceValues = new String[Trace.TRACE_TAGS.length];
        for (int i=Trace.TRACE_FLAGS_START_BIT; i<traceValues.length; i++) {
@@ -360,6 +365,7 @@ public class DevelopmentSettings extends PreferenceFragment
        updateShowHwLayersUpdatesOptions();
        updateDebugLayoutOptions();
        updateAnimationScaleOptions();
        updateOverlayDisplayDevicesOptions();
        updateEnableTracesOptions();
        updateImmediatelyDestroyActivitiesOptions();
        updateAppProcessLimitOptions();
@@ -379,6 +385,7 @@ public class DevelopmentSettings extends PreferenceFragment
        writeAnimationScaleOption(0, mWindowAnimationScale, null);
        writeAnimationScaleOption(1, mTransitionAnimationScale, null);
        writeAnimationScaleOption(2, mAnimatorDurationScale, null);
        writeOverlayDisplayDevicesOptions(null);
        writeEnableTracesOptions(0);
        writeAppProcessLimitOptions(null);
        mHaveDebugSettings = false;
@@ -683,6 +690,31 @@ public class DevelopmentSettings extends PreferenceFragment
        }
    }

    private void updateOverlayDisplayDevicesOptions() {
        String value = Settings.System.getString(getActivity().getContentResolver(),
                Settings.Secure.OVERLAY_DISPLAY_DEVICES);
        if (value == null) {
            value = "";
        }

        CharSequence[] values = mOverlayDisplayDevices.getEntryValues();
        for (int i = 0; i < values.length; i++) {
            if (value.contentEquals(values[i])) {
                mOverlayDisplayDevices.setValueIndex(i);
                mOverlayDisplayDevices.setSummary(mOverlayDisplayDevices.getEntries()[i]);
                return;
            }
        }
        mOverlayDisplayDevices.setValueIndex(0);
        mOverlayDisplayDevices.setSummary(mOverlayDisplayDevices.getEntries()[0]);
    }

    private void writeOverlayDisplayDevicesOptions(Object newValue) {
        Settings.System.putString(getActivity().getContentResolver(),
                Settings.Secure.OVERLAY_DISPLAY_DEVICES, (String)newValue);
        updateOverlayDisplayDevicesOptions();
    }

    private void updateAppProcessLimitOptions() {
        try {
            int limit = ActivityManagerNative.getDefault().getProcessLimit();
@@ -898,6 +930,9 @@ public class DevelopmentSettings extends PreferenceFragment
        } else if (preference == mAnimatorDurationScale) {
            writeAnimationScaleOption(2, mAnimatorDurationScale, newValue);
            return true;
        } else if (preference == mOverlayDisplayDevices) {
            writeOverlayDisplayDevicesOptions(newValue);
            return true;
        } else if (preference == mEnableTracesPref) {
            writeEnableTracesOptions();
            return true;