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

Commit a0517656 authored by Lucas Dupin's avatar Lucas Dupin Committed by android-build-merger
Browse files

Merge "Merge "Assume sensors perform prox check" into qt-qpr1-dev am:...

Merge "Merge "Assume sensors perform prox check" into qt-qpr1-dev am: e28124af" into qt-qpr1-dev-plus-aosp
am: 4b8e02d1

Change-Id: I8440d2ea116495209f2fb76ff73c299d5d13c4f6
parents 47d10e66 4b8e02d1
Loading
Loading
Loading
Loading
+0 −3
Original line number Original line Diff line number Diff line
@@ -196,9 +196,6 @@
    <!-- Doze: duration to avoid false pickup gestures triggered by notification vibrations -->
    <!-- Doze: duration to avoid false pickup gestures triggered by notification vibrations -->
    <integer name="doze_pickup_vibration_threshold">2000</integer>
    <integer name="doze_pickup_vibration_threshold">2000</integer>


    <!-- Doze: can we assume the pickup sensor includes a proximity check? -->
    <bool name="doze_pickup_performs_proximity_check">false</bool>

    <!-- Type of a sensor that provides a low-power estimate of the desired display
    <!-- Type of a sensor that provides a low-power estimate of the desired display
         brightness, suitable to listen to while the device is asleep (e.g. during
         brightness, suitable to listen to while the device is asleep (e.g. during
         always-on display) -->
         always-on display) -->
+9 −30
Original line number Original line Diff line number Diff line
@@ -107,8 +107,7 @@ public class DozeSensors {
                        config.dozePickupSensorAvailable(),
                        config.dozePickupSensorAvailable(),
                        DozeLog.REASON_SENSOR_PICKUP, false /* touchCoords */,
                        DozeLog.REASON_SENSOR_PICKUP, false /* touchCoords */,
                        false /* touchscreen */,
                        false /* touchscreen */,
                        false /* ignoresSetting */,
                        false /* ignoresSetting */),
                        mDozeParameters.getPickupPerformsProxCheck()),
                new TriggerSensor(
                new TriggerSensor(
                        findSensorWithType(config.doubleTapSensorType()),
                        findSensorWithType(config.doubleTapSensorType()),
                        Settings.Secure.DOZE_DOUBLE_TAP_GESTURE,
                        Settings.Secure.DOZE_DOUBLE_TAP_GESTURE,
@@ -205,11 +204,8 @@ public class DozeSensors {
    public void updateListening() {
    public void updateListening() {
        boolean anyListening = false;
        boolean anyListening = false;
        for (TriggerSensor s : mSensors) {
        for (TriggerSensor s : mSensors) {
            // We don't want to be listening while we're PAUSED (prox sensor is covered)
            s.setListening(mListening);
            // except when the sensor is already gated by prox.
            if (mListening) {
            boolean listen = mListening && (!mPaused || s.performsProxCheck());
            s.setListening(listen);
            if (listen) {
                anyListening = true;
                anyListening = true;
            }
            }
        }
        }
@@ -384,7 +380,6 @@ public class DozeSensors {
        private final boolean mReportsTouchCoordinates;
        private final boolean mReportsTouchCoordinates;
        private final boolean mSettingDefault;
        private final boolean mSettingDefault;
        private final boolean mRequiresTouchscreen;
        private final boolean mRequiresTouchscreen;
        private final boolean mSensorPerformsProxCheck;


        protected boolean mRequested;
        protected boolean mRequested;
        protected boolean mRegistered;
        protected boolean mRegistered;
@@ -401,14 +396,12 @@ public class DozeSensors {
                boolean configured, int pulseReason, boolean reportsTouchCoordinates,
                boolean configured, int pulseReason, boolean reportsTouchCoordinates,
                boolean requiresTouchscreen) {
                boolean requiresTouchscreen) {
            this(sensor, setting, settingDef, configured, pulseReason, reportsTouchCoordinates,
            this(sensor, setting, settingDef, configured, pulseReason, reportsTouchCoordinates,
                    requiresTouchscreen, false /* ignoresSetting */,
                    requiresTouchscreen, false /* ignoresSetting */);
                    false /* sensorPerformsProxCheck */);
        }
        }


        private TriggerSensor(Sensor sensor, String setting, boolean settingDef,
        private TriggerSensor(Sensor sensor, String setting, boolean settingDef,
                boolean configured, int pulseReason, boolean reportsTouchCoordinates,
                boolean configured, int pulseReason, boolean reportsTouchCoordinates,
                boolean requiresTouchscreen, boolean ignoresSetting,
                boolean requiresTouchscreen, boolean ignoresSetting) {
                boolean sensorPerformsProxCheck) {
            mSensor = sensor;
            mSensor = sensor;
            mSetting = setting;
            mSetting = setting;
            mSettingDefault = settingDef;
            mSettingDefault = settingDef;
@@ -417,7 +410,6 @@ public class DozeSensors {
            mReportsTouchCoordinates = reportsTouchCoordinates;
            mReportsTouchCoordinates = reportsTouchCoordinates;
            mRequiresTouchscreen = requiresTouchscreen;
            mRequiresTouchscreen = requiresTouchscreen;
            mIgnoresSetting = ignoresSetting;
            mIgnoresSetting = ignoresSetting;
            mSensorPerformsProxCheck = sensorPerformsProxCheck;
        }
        }


        public void setListening(boolean listen) {
        public void setListening(boolean listen) {
@@ -491,23 +483,13 @@ public class DozeSensors {
                    screenX = event.values[0];
                    screenX = event.values[0];
                    screenY = event.values[1];
                    screenY = event.values[1];
                }
                }
                mCallback.onSensorPulse(mPulseReason, mSensorPerformsProxCheck, screenX, screenY,
                mCallback.onSensorPulse(mPulseReason, screenX, screenY, event.values);
                        event.values);
                if (!mRegistered) {
                if (!mRegistered) {
                    updateListening();  // reregister, this sensor only fires once
                    updateListening();  // reregister, this sensor only fires once
                }
                }
            }));
            }));
        }
        }


        /**
         * If the sensor itself performs proximity checks, to avoid pocket dialing.
         * Gated sensors don't need to be stopped when the {@link DozeMachine} is
         * {@link DozeMachine.State#DOZE_AOD_PAUSED}.
         */
        public boolean performsProxCheck() {
            return mSensorPerformsProxCheck;
        }

        public void registerSettingsObserver(ContentObserver settingsObserver) {
        public void registerSettingsObserver(ContentObserver settingsObserver) {
            if (mConfigured && !TextUtils.isEmpty(mSetting)) {
            if (mConfigured && !TextUtils.isEmpty(mSetting)) {
                mResolver.registerContentObserver(
                mResolver.registerContentObserver(
@@ -603,8 +585,7 @@ public class DozeSensors {
                    return;
                    return;
                }
                }
                if (DEBUG) Log.d(TAG, "onSensorEvent: " + triggerEventToString(event));
                if (DEBUG) Log.d(TAG, "onSensorEvent: " + triggerEventToString(event));
                mCallback.onSensorPulse(mPulseReason, true /* sensorPerformsProxCheck */, -1, -1,
                mCallback.onSensorPulse(mPulseReason, -1, -1, event.getValues());
                        event.getValues());
            }));
            }));
        }
        }
    }
    }
@@ -614,13 +595,11 @@ public class DozeSensors {
        /**
        /**
         * Called when a sensor requests a pulse
         * Called when a sensor requests a pulse
         * @param pulseReason Requesting sensor, e.g. {@link DozeLog#REASON_SENSOR_PICKUP}
         * @param pulseReason Requesting sensor, e.g. {@link DozeLog#REASON_SENSOR_PICKUP}
         * @param sensorPerformedProxCheck true if the sensor already checked for FAR proximity.
         * @param screenX the location on the screen where the sensor fired or -1
         * @param screenX the location on the screen where the sensor fired or -1
         *                if the sensor doesn't support reporting screen locations.
         *                if the sensor doesn't support reporting screen locations.
         * @param screenY the location on the screen where the sensor fired or -1
         * @param screenY the location on the screen where the sensor fired or -1
         * @param rawValues raw values array from the event.
         * @param rawValues raw values array from the event.
         */
         */
        void onSensorPulse(int pulseReason, boolean sensorPerformedProxCheck,
        void onSensorPulse(int pulseReason, float screenX, float screenY, float[] rawValues);
                float screenX, float screenY, float[] rawValues);
    }
    }
}
}
+12 −8
Original line number Original line Diff line number Diff line
@@ -41,6 +41,7 @@ import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.util.Preconditions;
import com.android.internal.util.Preconditions;
import com.android.systemui.Dependency;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.dock.DockManager;
import com.android.systemui.dock.DockManager;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.util.Assert;
import com.android.systemui.util.Assert;
@@ -156,8 +157,7 @@ public class DozeTriggers implements DozeMachine.Part {
    }
    }


    @VisibleForTesting
    @VisibleForTesting
    void onSensor(int pulseReason, boolean sensorPerformedProxCheck,
    void onSensor(int pulseReason, float screenX, float screenY, float[] rawValues) {
            float screenX, float screenY, float[] rawValues) {
        boolean isDoubleTap = pulseReason == DozeLog.REASON_SENSOR_DOUBLE_TAP;
        boolean isDoubleTap = pulseReason == DozeLog.REASON_SENSOR_DOUBLE_TAP;
        boolean isTap = pulseReason == DozeLog.REASON_SENSOR_TAP;
        boolean isTap = pulseReason == DozeLog.REASON_SENSOR_TAP;
        boolean isPickup = pulseReason == DozeLog.REASON_SENSOR_PICKUP;
        boolean isPickup = pulseReason == DozeLog.REASON_SENSOR_PICKUP;
@@ -169,10 +169,11 @@ public class DozeTriggers implements DozeMachine.Part {
        if (isWakeDisplay) {
        if (isWakeDisplay) {
            onWakeScreen(wakeEvent, mMachine.isExecutingTransition() ? null : mMachine.getState());
            onWakeScreen(wakeEvent, mMachine.isExecutingTransition() ? null : mMachine.getState());
        } else if (isLongPress) {
        } else if (isLongPress) {
            requestPulse(pulseReason, sensorPerformedProxCheck, null /* onPulseSupressedListener */);
            requestPulse(pulseReason, true /* alreadyPerformedProxCheck */,
                    null /* onPulseSupressedListener */);
        } else if (isWakeLockScreen) {
        } else if (isWakeLockScreen) {
            if (wakeEvent) {
            if (wakeEvent) {
                requestPulse(pulseReason, sensorPerformedProxCheck,
                requestPulse(pulseReason, true /* alreadyPerformedProxCheck */,
                        null /* onPulseSupressedListener */);
                        null /* onPulseSupressedListener */);
            }
            }
        } else {
        } else {
@@ -191,8 +192,7 @@ public class DozeTriggers implements DozeMachine.Part {
                } else {
                } else {
                    mDozeHost.extendPulse(pulseReason);
                    mDozeHost.extendPulse(pulseReason);
                }
                }
            }, sensorPerformedProxCheck
            }, true /* alreadyPerformedProxCheck */, pulseReason);
                    || (mDockManager != null && mDockManager.isDocked()), pulseReason);
        }
        }


        if (isPickup) {
        if (isPickup) {
@@ -278,7 +278,7 @@ public class DozeTriggers implements DozeMachine.Part {
                            .setType(MetricsEvent.TYPE_OPEN)
                            .setType(MetricsEvent.TYPE_OPEN)
                            .setSubtype(DozeLog.REASON_SENSOR_WAKE_UP));
                            .setSubtype(DozeLog.REASON_SENSOR_WAKE_UP));
                }
                }
            }, false /* alreadyPerformedProxCheck */, DozeLog.REASON_SENSOR_WAKE_UP);
            }, true /* alreadyPerformedProxCheck */, DozeLog.REASON_SENSOR_WAKE_UP);
        } else {
        } else {
            boolean paused = (state == DozeMachine.State.DOZE_AOD_PAUSED);
            boolean paused = (state == DozeMachine.State.DOZE_AOD_PAUSED);
            boolean pausing = (state == DozeMachine.State.DOZE_AOD_PAUSING);
            boolean pausing = (state == DozeMachine.State.DOZE_AOD_PAUSING);
@@ -433,7 +433,11 @@ public class DozeTriggers implements DozeMachine.Part {


        public void check() {
        public void check() {
            Preconditions.checkState(!mFinished && !mRegistered);
            Preconditions.checkState(!mFinished && !mRegistered);
            final Sensor sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
            Sensor sensor = DozeSensors.findSensorWithType(mSensorManager,
                    mContext.getString(R.string.doze_brightness_sensor_type));
            if (sensor == null) {
                sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
            }
            if (sensor == null) {
            if (sensor == null) {
                if (DozeMachine.DEBUG) Log.d(TAG, "ProxCheck: No sensor found");
                if (DozeMachine.DEBUG) Log.d(TAG, "ProxCheck: No sensor found");
                finishWithResult(RESULT_UNKNOWN);
                finishWithResult(RESULT_UNKNOWN);
+0 −4
Original line number Original line Diff line number Diff line
@@ -207,10 +207,6 @@ public class DozeParameters implements TunerService.Tunable,
        return SystemProperties.get(propName, mContext.getString(resId));
        return SystemProperties.get(propName, mContext.getString(resId));
    }
    }


    public boolean getPickupPerformsProxCheck() {
        return mContext.getResources().getBoolean(R.bool.doze_pickup_performs_proximity_check);
    }

    public int getPulseVisibleDurationExtended() {
    public int getPulseVisibleDurationExtended() {
        return 2 * getPulseVisibleDuration();
        return 2 * getPulseVisibleDuration();
    }
    }
+0 −1
Original line number Original line Diff line number Diff line
@@ -37,7 +37,6 @@ public class DozeConfigurationUtil {
        when(params.getPulseOnSigMotion()).thenReturn(false);
        when(params.getPulseOnSigMotion()).thenReturn(false);
        when(params.getPickupVibrationThreshold()).thenReturn(0);
        when(params.getPickupVibrationThreshold()).thenReturn(0);
        when(params.getProxCheckBeforePulse()).thenReturn(true);
        when(params.getProxCheckBeforePulse()).thenReturn(true);
        when(params.getPickupPerformsProxCheck()).thenReturn(true);
        when(params.getPolicy()).thenReturn(mock(AlwaysOnDisplayPolicy.class));
        when(params.getPolicy()).thenReturn(mock(AlwaysOnDisplayPolicy.class));
        when(params.doubleTapReportsTouchCoordinates()).thenReturn(false);
        when(params.doubleTapReportsTouchCoordinates()).thenReturn(false);
        when(params.getDisplayNeedsBlanking()).thenReturn(false);
        when(params.getDisplayNeedsBlanking()).thenReturn(false);
Loading