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

Commit 4b8e02d1 authored by Android Build Merger (Role)'s avatar Android Build Merger (Role) Committed by Android (Google) Code Review
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
parents f4f194cc b36ff62a
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -196,9 +196,6 @@
    <!-- Doze: duration to avoid false pickup gestures triggered by notification vibrations -->
    <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
         brightness, suitable to listen to while the device is asleep (e.g. during
         always-on display) -->
+9 −30
Original line number Diff line number Diff line
@@ -107,8 +107,7 @@ public class DozeSensors {
                        config.dozePickupSensorAvailable(),
                        DozeLog.REASON_SENSOR_PICKUP, false /* touchCoords */,
                        false /* touchscreen */,
                        false /* ignoresSetting */,
                        mDozeParameters.getPickupPerformsProxCheck()),
                        false /* ignoresSetting */),
                new TriggerSensor(
                        findSensorWithType(config.doubleTapSensorType()),
                        Settings.Secure.DOZE_DOUBLE_TAP_GESTURE,
@@ -205,11 +204,8 @@ public class DozeSensors {
    public void updateListening() {
        boolean anyListening = false;
        for (TriggerSensor s : mSensors) {
            // We don't want to be listening while we're PAUSED (prox sensor is covered)
            // except when the sensor is already gated by prox.
            boolean listen = mListening && (!mPaused || s.performsProxCheck());
            s.setListening(listen);
            if (listen) {
            s.setListening(mListening);
            if (mListening) {
                anyListening = true;
            }
        }
@@ -384,7 +380,6 @@ public class DozeSensors {
        private final boolean mReportsTouchCoordinates;
        private final boolean mSettingDefault;
        private final boolean mRequiresTouchscreen;
        private final boolean mSensorPerformsProxCheck;

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

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

        public void setListening(boolean listen) {
@@ -491,23 +483,13 @@ public class DozeSensors {
                    screenX = event.values[0];
                    screenY = event.values[1];
                }
                mCallback.onSensorPulse(mPulseReason, mSensorPerformsProxCheck, screenX, screenY,
                        event.values);
                mCallback.onSensorPulse(mPulseReason, screenX, screenY, event.values);
                if (!mRegistered) {
                    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) {
            if (mConfigured && !TextUtils.isEmpty(mSetting)) {
                mResolver.registerContentObserver(
@@ -603,8 +585,7 @@ public class DozeSensors {
                    return;
                }
                if (DEBUG) Log.d(TAG, "onSensorEvent: " + triggerEventToString(event));
                mCallback.onSensorPulse(mPulseReason, true /* sensorPerformsProxCheck */, -1, -1,
                        event.getValues());
                mCallback.onSensorPulse(mPulseReason, -1, -1, event.getValues());
            }));
        }
    }
@@ -614,13 +595,11 @@ public class DozeSensors {
        /**
         * Called when a sensor requests a pulse
         * @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
         *                if the sensor doesn't support reporting screen locations.
         * @param screenY the location on the screen where the sensor fired or -1
         * @param rawValues raw values array from the event.
         */
        void onSensorPulse(int pulseReason, boolean sensorPerformedProxCheck,
                float screenX, float screenY, float[] rawValues);
        void onSensorPulse(int pulseReason, float screenX, float screenY, float[] rawValues);
    }
}
+12 −8
Original line number 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.util.Preconditions;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.dock.DockManager;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.util.Assert;
@@ -156,8 +157,7 @@ public class DozeTriggers implements DozeMachine.Part {
    }

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

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

        public void check() {
            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 (DozeMachine.DEBUG) Log.d(TAG, "ProxCheck: No sensor found");
                finishWithResult(RESULT_UNKNOWN);
+0 −4
Original line number Diff line number Diff line
@@ -207,10 +207,6 @@ public class DozeParameters implements TunerService.Tunable,
        return SystemProperties.get(propName, mContext.getString(resId));
    }

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

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