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

Commit 4be1126d authored by Fiona Campbell's avatar Fiona Campbell
Browse files

Allow No Sensor to be Specified in DDC

Adding the following:
<proxSensor/>

to the DDC, will stop any fallback from being used, and allow the usage
of no sensor to be used for that display. This is useful for when a
display has no sensor and the fallback should not be used. If this is
not added to the ddc, the fallback will still only occur if the display
is the default display.

Bug: 202604469
Test: dumpsys display | grep mProximitySensor
Test: com.android.server.display
Change-Id: I018b334a443f6b9a36aaeca70c673bac86446402
Merged-In: I8508a191b7c7c5990929e4d020ffd144c7faeef7
parent 120867a3
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -1412,7 +1412,7 @@ public class DisplayDeviceConfig {
        loadBrightnessRampsFromConfigXml();
        loadAmbientLightSensorFromConfigXml();
        loadBrightnessChangeThresholdsFromXml();
        setProxSensorUnspecified();
        useFallbackProxSensor();
        loadAutoBrightnessConfigsFromConfigXml();
        loadAutoBrightnessAvailableFromConfigXml();
        mLoadedFrom = "<config.xml>";
@@ -1432,7 +1432,7 @@ public class DisplayDeviceConfig {
        mBrightnessRampIncreaseMaxMillis = 0;
        setSimpleMappingStrategyValues();
        loadAmbientLightSensorFromConfigXml();
        setProxSensorUnspecified();
        useFallbackProxSensor();
        loadAutoBrightnessAvailableFromConfigXml();
    }

@@ -1941,7 +1941,12 @@ public class DisplayDeviceConfig {
        }
    }

    private void setProxSensorUnspecified() {
    private void useFallbackProxSensor() {
        mProximitySensor.name = null;
        mProximitySensor.type = null;
    }

    private void useNullProxSensor() {
        mProximitySensor.name = "";
        mProximitySensor.type = "";
    }
@@ -1949,6 +1954,12 @@ public class DisplayDeviceConfig {
    private void loadProxSensorFromDdc(DisplayConfiguration config) {
        SensorDetails sensorDetails = config.getProxSensor();
        if (sensorDetails != null) {
            if (sensorDetails.getName() == null && sensorDetails.getType() == null) {
                // If prox sensor is defined, but no details given, this is assumed that
                // the display does not have or wish to use a prox sensor for it.
                useNullProxSensor();
                return;
            }
            mProximitySensor.name = sensorDetails.getName();
            mProximitySensor.type = sensorDetails.getType();
            final RefreshRateRange rr = sensorDetails.getRefreshRate();
@@ -1957,7 +1968,8 @@ public class DisplayDeviceConfig {
                mProximitySensor.maxRefreshRate = rr.getMaximum().floatValue();
            }
        } else {
            setProxSensorUnspecified();
            // If prox sensor is unspecified, then use a fallback.
            useFallbackProxSensor();
        }
    }

+3 −0
Original line number Diff line number Diff line
@@ -33,6 +33,9 @@ public class SensorUtils {
     */
    public static Sensor findSensor(SensorManager sensorManager, String sensorType,
            String sensorName, int fallbackType) {
        if ("".equals(sensorName) && "".equals(sensorType)) {
            return null;
        }
        final boolean isNameSpecified = !TextUtils.isEmpty(sensorName);
        final boolean isTypeSpecified = !TextUtils.isEmpty(sensorType);
        if (isNameSpecified || isTypeSpecified) {
+6 −0
Original line number Diff line number Diff line
@@ -148,6 +148,8 @@ public final class DisplayDeviceConfigTest {
        assertArrayEquals(new float[]{23, 24, 25},
                mDisplayDeviceConfig.getAmbientDarkeningPercentagesIdle(), ZERO_DELTA);

        assertEquals("ProximitySensor123", mDisplayDeviceConfig.getProximitySensor().name);
        assertEquals("prox_type_1", mDisplayDeviceConfig.getProximitySensor().type);

        // Todo(brup): Add asserts for BrightnessThrottlingData, DensityMapping,
        // HighBrightnessModeData AmbientLightSensor, RefreshRateLimitations and ProximitySensor.
@@ -420,6 +422,10 @@ public final class DisplayDeviceConfigTest {
                +           "</brightnessThrottlingPoint>\n"
                +       "</brightnessThrottlingMap>\n"
                +   "</thermalThrottling>\n"
                +   "<proxSensor>\n"
                +       "<name>ProximitySensor123</name>\n"
                +       "<type>prox_type_1</type>\n"
                +   "</proxSensor>\n"
                + "</displayConfiguration>\n";
    }