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

Commit 44198f51 authored by Adrian Roos's avatar Adrian Roos
Browse files

AOD: Use double tap coordinates to trigger Ambient Indication

Bug: 38386446
Test: Double tap on AOD, verify that it still works. On device that supports double tap coordinates, verify that double tapping on ambient music opens ambient music.
Change-Id: Ic75ba731a980c9598c85927e83d2032f01da4822
parent a9861756
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -262,6 +262,9 @@
    <!-- Doze: alpha to apply to small icons when dozing -->
    <integer name="doze_small_icon_alpha">222</integer><!-- 87% of 0xff -->

    <!-- Doze: whether the double tap sensor reports 2D touch coordinates -->
    <bool name="doze_double_tap_reports_touch_coordinates">false</bool>

    <!-- Hotspot tile: number of days to show after feature is used. -->
    <integer name="days_to_show_hotspot_tile">30</integer>

+2 −0
Original line number Diff line number Diff line
@@ -38,6 +38,8 @@ public interface DozeHost {

    void setAnimateWakeup(boolean animateWakeup);

    void onDoubleTap(float x, float y);

    interface Callback {
        default void onNotificationHeadsUp() {}
        default void onPowerSaveChanged(boolean active) {}
+21 −6
Original line number Diff line number Diff line
@@ -81,17 +81,18 @@ public class DozeSensors {
                        mSensorManager.getDefaultSensor(Sensor.TYPE_SIGNIFICANT_MOTION),
                        null /* setting */,
                        dozeParameters.getPulseOnSigMotion(),
                        DozeLog.PULSE_REASON_SENSOR_SIGMOTION),
                        DozeLog.PULSE_REASON_SENSOR_SIGMOTION, false /* touchCoords */),
                mPickupSensor = new TriggerSensor(
                        mSensorManager.getDefaultSensor(Sensor.TYPE_PICK_UP_GESTURE),
                        Settings.Secure.DOZE_PULSE_ON_PICK_UP,
                        config.pulseOnPickupAvailable(),
                        DozeLog.PULSE_REASON_SENSOR_PICKUP),
                        DozeLog.PULSE_REASON_SENSOR_PICKUP, false /* touchCoords */),
                new TriggerSensor(
                        findSensorWithType(config.doubleTapSensorType()),
                        Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP,
                        true /* configured */,
                        DozeLog.PULSE_REASON_SENSOR_DOUBLE_TAP)
                        DozeLog.PULSE_REASON_SENSOR_DOUBLE_TAP,
                        dozeParameters.doubleTapReportsTouchCoordinates())
        };

        mProxSensor = new ProxSensor();
@@ -207,16 +208,19 @@ public class DozeSensors {
        final boolean mConfigured;
        final int mPulseReason;
        final String mSetting;
        final boolean mReportsTouchCoordinates;

        private boolean mRequested;
        private boolean mRegistered;
        private boolean mDisabled;

        public TriggerSensor(Sensor sensor, String setting, boolean configured, int pulseReason) {
        public TriggerSensor(Sensor sensor, String setting, boolean configured, int pulseReason,
                boolean reportsTouchCoordinates) {
            mSensor = sensor;
            mSetting = setting;
            mConfigured = configured;
            mPulseReason = pulseReason;
            mReportsTouchCoordinates = reportsTouchCoordinates;
        }

        public void setListening(boolean listen) {
@@ -276,7 +280,13 @@ public class DozeSensors {
                }

                mRegistered = false;
                mCallback.onSensorPulse(mPulseReason, sensorPerformsProxCheck);
                float screenX = -1;
                float screenY = -1;
                if (mReportsTouchCoordinates && event.values.length >= 2) {
                    screenX = event.values[0];
                    screenY = event.values[1];
                }
                mCallback.onSensorPulse(mPulseReason, sensorPerformsProxCheck, screenX, screenY);
                updateListener();  // reregister, this sensor only fires once
            }));
        }
@@ -309,7 +319,12 @@ public class DozeSensors {
         * Called when a sensor requests a pulse
         * @param pulseReason Requesting sensor, e.g. {@link DozeLog#PULSE_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
         *                if the sensor doesn't support reporting screen locations.
         */
        void onSensorPulse(int pulseReason, boolean sensorPerformedProxCheck);
        void onSensorPulse(int pulseReason, boolean sensorPerformedProxCheck,
                float screenX, float screenY);
    }
}
+3 −1
Original line number Diff line number Diff line
@@ -98,12 +98,14 @@ public class DozeTriggers implements DozeMachine.Part {
        requestPulse(DozeLog.PULSE_REASON_NOTIFICATION, false /* performedProxCheck */);
    }

    private void onSensor(int pulseReason, boolean sensorPerformedProxCheck) {
    private void onSensor(int pulseReason, boolean sensorPerformedProxCheck,
            float screenX, float screenY) {
        boolean isDoubleTap = pulseReason == DozeLog.PULSE_REASON_SENSOR_DOUBLE_TAP;
        boolean isPickup = pulseReason == DozeLog.PULSE_REASON_SENSOR_PICKUP;

        if (mConfig.alwaysOnEnabled(UserHandle.USER_CURRENT)) {
            if (isDoubleTap) {
                mDozeHost.onDoubleTap(screenX, screenY);
                mMachine.wakeUp();
            } else {
                mDozeHost.extendPulse();
+4 −0
Original line number Diff line number Diff line
@@ -157,6 +157,10 @@ public class DozeParameters {
        return 2 * getPulseVisibleDuration();
    }

    public boolean doubleTapReportsTouchCoordinates() {
        return mContext.getResources().getBoolean(R.bool.doze_double_tap_reports_touch_coordinates);
    }


    /**
     * Parses a spec of the form `1,2,3,!5,*`. The resulting object will match numbers that are
Loading