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

Commit 07182d52 authored by Dave Mankoff's avatar Dave Mankoff
Browse files

Add Falsing to the QS BrightnessSlider

This ensures that interactions with the BrightnessSlider are
classified as valid gestures by the FalsingManager.

Bug: 172655679
Test: manual
Change-Id: Ifeb235befc6b1342fc64b671b7704d0fdaa39349
parent fa7aca14
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -37,6 +37,7 @@ public abstract class Classifier {
    public static final int GENERIC = 7;
    public static final int GENERIC = 7;
    public static final int BOUNCER_UNLOCK = 8;
    public static final int BOUNCER_UNLOCK = 8;
    public static final int PULSE_EXPAND = 9;
    public static final int PULSE_EXPAND = 9;
    public static final int BRIGHTNESS_SLIDER = 10;


    @IntDef({
    @IntDef({
            QUICK_SETTINGS,
            QUICK_SETTINGS,
@@ -48,7 +49,8 @@ public abstract class Classifier {
            RIGHT_AFFORDANCE,
            RIGHT_AFFORDANCE,
            GENERIC,
            GENERIC,
            BOUNCER_UNLOCK,
            BOUNCER_UNLOCK,
            PULSE_EXPAND
            PULSE_EXPAND,
            BRIGHTNESS_SLIDER
    })
    })
    @Retention(RetentionPolicy.SOURCE)
    @Retention(RetentionPolicy.SOURCE)
    public @interface InteractionType {}
    public @interface InteractionType {}
+4 −0
Original line number Original line Diff line number Diff line
@@ -148,6 +148,10 @@ class DistanceClassifier extends FalsingClassifier {
    Result calculateFalsingResult(
    Result calculateFalsingResult(
            @Classifier.InteractionType int interactionType,
            @Classifier.InteractionType int interactionType,
            double historyBelief, double historyConfidence) {
            double historyBelief, double historyConfidence) {
        if (interactionType == Classifier.BRIGHTNESS_SLIDER) {
            return Result.passed(0);
        }

        return !getPassedFlingThreshold() ? falsed(0.5, getReason()) : Result.passed(0.5);
        return !getPassedFlingThreshold() ? falsed(0.5, getReason()) : Result.passed(0.5);
    }
    }


+2 −1
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.classifier;
package com.android.systemui.classifier;


import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_PROXIMITY_PERCENT_COVERED_THRESHOLD;
import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_PROXIMITY_PERCENT_COVERED_THRESHOLD;
import static com.android.systemui.classifier.Classifier.BRIGHTNESS_SLIDER;
import static com.android.systemui.classifier.Classifier.QUICK_SETTINGS;
import static com.android.systemui.classifier.Classifier.QUICK_SETTINGS;


import android.provider.DeviceConfig;
import android.provider.DeviceConfig;
@@ -115,7 +116,7 @@ class ProximityClassifier extends FalsingClassifier {
    Result calculateFalsingResult(
    Result calculateFalsingResult(
            @Classifier.InteractionType int interactionType,
            @Classifier.InteractionType int interactionType,
            double historyBelief, double historyConfidence) {
            double historyBelief, double historyConfidence) {
        if (interactionType == QUICK_SETTINGS) {
        if (interactionType == QUICK_SETTINGS || interactionType == BRIGHTNESS_SLIDER) {
            return Result.passed(0);
            return Result.passed(0);
        }
        }


+8 −1
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.classifier;




import static com.android.systemui.classifier.Classifier.BOUNCER_UNLOCK;
import static com.android.systemui.classifier.Classifier.BOUNCER_UNLOCK;
import static com.android.systemui.classifier.Classifier.BRIGHTNESS_SLIDER;
import static com.android.systemui.classifier.Classifier.LEFT_AFFORDANCE;
import static com.android.systemui.classifier.Classifier.LEFT_AFFORDANCE;
import static com.android.systemui.classifier.Classifier.NOTIFICATION_DISMISS;
import static com.android.systemui.classifier.Classifier.NOTIFICATION_DISMISS;
import static com.android.systemui.classifier.Classifier.NOTIFICATION_DRAG_DOWN;
import static com.android.systemui.classifier.Classifier.NOTIFICATION_DRAG_DOWN;
@@ -45,6 +46,7 @@ public class TypeClassifier extends FalsingClassifier {
        boolean up = isUp();
        boolean up = isUp();
        boolean right = isRight();
        boolean right = isRight();


        double confidence = 1;
        boolean wrongDirection = true;
        boolean wrongDirection = true;
        switch (interactionType) {
        switch (interactionType) {
            case QUICK_SETTINGS:
            case QUICK_SETTINGS:
@@ -52,6 +54,11 @@ public class TypeClassifier extends FalsingClassifier {
            case NOTIFICATION_DRAG_DOWN:
            case NOTIFICATION_DRAG_DOWN:
                wrongDirection = !vertical || up;
                wrongDirection = !vertical || up;
                break;
                break;
            case BRIGHTNESS_SLIDER:
                confidence = 0;  // Owners may return to original brightness.
                // A more sophisticated thing to do here would be to look at the size of the
                // vertical change relative to the screen size. _Some_ amount of vertical
                // change should be expected.
            case NOTIFICATION_DISMISS:
            case NOTIFICATION_DISMISS:
                wrongDirection = vertical;
                wrongDirection = vertical;
                break;
                break;
@@ -70,7 +77,7 @@ public class TypeClassifier extends FalsingClassifier {
                break;
                break;
        }
        }


        return wrongDirection ? falsed(1, getReason(interactionType)) : Result.passed(0.5);
        return wrongDirection ? falsed(confidence, getReason(interactionType)) : Result.passed(0.5);
    }
    }


    private String getReason(int interactionType) {
    private String getReason(int interactionType) {
+5 −0
Original line number Original line Diff line number Diff line
@@ -20,6 +20,7 @@ import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHT
import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_ZIGZAG_X_SECONDARY_DEVIANCE;
import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_ZIGZAG_X_SECONDARY_DEVIANCE;
import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_ZIGZAG_Y_PRIMARY_DEVIANCE;
import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_ZIGZAG_Y_PRIMARY_DEVIANCE;
import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_ZIGZAG_Y_SECONDARY_DEVIANCE;
import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_ZIGZAG_Y_SECONDARY_DEVIANCE;
import static com.android.systemui.classifier.Classifier.BRIGHTNESS_SLIDER;


import android.graphics.Point;
import android.graphics.Point;
import android.provider.DeviceConfig;
import android.provider.DeviceConfig;
@@ -87,6 +88,10 @@ class ZigZagClassifier extends FalsingClassifier {
    Result calculateFalsingResult(
    Result calculateFalsingResult(
            @Classifier.InteractionType int interactionType,
            @Classifier.InteractionType int interactionType,
            double historyBelief, double historyConfidence) {
            double historyBelief, double historyConfidence) {
        if (interactionType == BRIGHTNESS_SLIDER) {
            return Result.passed(0);
        }

        List<MotionEvent> motionEvents = getRecentMotionEvents();
        List<MotionEvent> motionEvents = getRecentMotionEvents();
        // Rotate horizontal gestures to be horizontal between their first and last point.
        // Rotate horizontal gestures to be horizontal between their first and last point.
        // Rotate vertical gestures to be vertical between their first and last point.
        // Rotate vertical gestures to be vertical between their first and last point.
Loading