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

Commit 12136eef authored by Alejandro Nijamkin's avatar Alejandro Nijamkin
Browse files

[flexiglass] Falsing system changes.

Flexiglass needs to report signals into the Falsing system. This CL
prepares the Falsing system for that. There are several parts:

1. Elimination of no-op methods in the FalsingCollector interface. These
   were being invoked by parts of system UI but their implementation was
   empty; might as well drop these.
2. Creation of a Dagger mechanism to provide 2 implementations of
   FalsingCollector: FalsingCollectorImpl and FalsingCollectorNoOp; the
   latter does nothing (except logging so we can compare traffic between
   the two). The Dagger provider checks the Flexiglass scence_container
   feaeture flag to know which one to provide.
3. A FalsingCollectorActual-qualified second provider was also added.
   This is to let systems that are "blessed" and know that they need to
   use the actual FalsingCollector, regardless of the Flexiglass flag state.

Bug: 297262816
Test: Manually verified, together with the rest of the CL chain that the
correct signals are being sent to the REAL FalsingCollector at the right
times.

Change-Id: I01777c7f70f06a6cba55bd9bf19f8633a8b619b9
parent 792aab22
Loading
Loading
Loading
Loading
+0 −57
Original line number Diff line number Diff line
@@ -28,78 +28,21 @@ public interface FalsingCollector {
    /** */
    void setShowingAod(boolean showingAod);

    /** */
    void onNotificationStartDraggingDown();

    /** */
    void onNotificationStopDraggingDown();

    /** */
    void setNotificationExpanded();

    /** */
    void onQsDown();

    /** */
    boolean shouldEnforceBouncer();

    /** */
    void onTrackingStarted(boolean secure);

    /** */
    void onTrackingStopped();

    /** */
    void onLeftAffordanceOn();

    /** */
    void onCameraOn();

    /** */
    void onAffordanceSwipingStarted(boolean rightCorner);

    /** */
    void onAffordanceSwipingAborted();

    /** */
    void onStartExpandingFromPulse();

    /** */
    void onExpansionFromPulseStopped();

    /** */
    void onScreenOnFromTouch();

    /** */
    boolean isReportingEnabled();

    /** */
    void onUnlockHintStarted();

    /** */
    void onCameraHintStarted();

    /** */
    void onLeftAffordanceHintStarted();

    /** */
    void onScreenTurningOn();

    /** */
    void onScreenOff();

    /** */
    void onNotificationStopDismissing();

    /** */
    void onNotificationDismissed();

    /** */
    void onNotificationStartDismissing();

    /** */
    void onNotificationDoubleTap(boolean accepted, float dx, float dy);

    /** */
    void onBouncerShown();

+24 −0
Original line number Diff line number Diff line
/*
 * Copyright 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.classifier

import javax.inject.Qualifier

@Qualifier
@MustBeDocumented
@Retention(AnnotationRetention.RUNTIME)
annotation class FalsingCollectorActual
+0 −76
Original line number Diff line number Diff line
@@ -28,59 +28,11 @@ public class FalsingCollectorFake implements FalsingCollector {
    public void setShowingAod(boolean showingAod) {
    }

    @Override
    public void onNotificationStartDraggingDown() {
    }

    @Override
    public void onNotificationStopDraggingDown() {
    }

    @Override
    public void setNotificationExpanded() {
    }

    @Override
    public void onQsDown() {
    }

    @Override
    public boolean shouldEnforceBouncer() {
        return false;
    }

    @Override
    public void onTrackingStarted(boolean secure) {
    }

    @Override
    public void onTrackingStopped() {
    }

    @Override
    public void onLeftAffordanceOn() {
    }

    @Override
    public void onCameraOn() {
    }

    @Override
    public void onAffordanceSwipingStarted(boolean rightCorner) {
    }

    @Override
    public void onAffordanceSwipingAborted() {
    }

    @Override
    public void onStartExpandingFromPulse() {
    }

    @Override
    public void onExpansionFromPulseStopped() {
    }

    @Override
    public void onScreenOnFromTouch() {
    }
@@ -90,18 +42,6 @@ public class FalsingCollectorFake implements FalsingCollector {
        return false;
    }

    @Override
    public void onUnlockHintStarted() {
    }

    @Override
    public void onCameraHintStarted() {
    }

    @Override
    public void onLeftAffordanceHintStarted() {
    }

    @Override
    public void onScreenTurningOn() {
    }
@@ -110,22 +50,6 @@ public class FalsingCollectorFake implements FalsingCollector {
    public void onScreenOff() {
    }

    @Override
    public void onNotificationStopDismissing() {
    }

    @Override
    public void onNotificationDismissed() {
    }

    @Override
    public void onNotificationStartDismissing() {
    }

    @Override
    public void onNotificationDoubleTap(boolean accepted, float dx, float dy) {
    }

    @Override
    public void onBouncerShown() {
    }
+16 −86
Original line number Diff line number Diff line
@@ -102,10 +102,6 @@ class FalsingCollectorImpl implements FalsingCollector {


    private final BatteryStateChangeCallback mBatteryListener = new BatteryStateChangeCallback() {
        @Override
        public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) {
        }

        @Override
        public void onWirelessChargingChanged(boolean isWirelessCharging) {
            if (isWirelessCharging || mDockManager.isDocked()) {
@@ -169,34 +165,21 @@ class FalsingCollectorImpl implements FalsingCollector {

    @Override
    public void onSuccessfulUnlock() {
        logDebug("REAL: onSuccessfulUnlock");
        mFalsingManager.onSuccessfulUnlock();
        sessionEnd();
    }

    @Override
    public void setShowingAod(boolean showingAod) {
        logDebug("REAL: setShowingAod(" + showingAod + ")");
        mShowingAod = showingAod;
        updateSessionActive();
    }

    @Override
    public void onNotificationStartDraggingDown() {
    }

    @Override
    public void onNotificationStopDraggingDown() {
    }

    @Override
    public void setNotificationExpanded() {
    }

    @Override
    public void onQsDown() {
    }

    @VisibleForTesting
    void onQsExpansionChanged(Boolean expanded) {
        logDebug("REAL: onQsExpansionChanged(" + expanded + ")");
        if (expanded) {
            unregisterSensors();
        } else if (mSessionStarted) {
@@ -209,40 +192,9 @@ class FalsingCollectorImpl implements FalsingCollector {
        return false;
    }

    @Override
    public void onTrackingStarted(boolean secure) {
    }

    @Override
    public void onTrackingStopped() {
    }

    @Override
    public void onLeftAffordanceOn() {
    }

    @Override
    public void onCameraOn() {
    }

    @Override
    public void onAffordanceSwipingStarted(boolean rightCorner) {
    }

    @Override
    public void onAffordanceSwipingAborted() {
    }

    @Override
    public void onStartExpandingFromPulse() {
    }

    @Override
    public void onExpansionFromPulseStopped() {
    }

    @Override
    public void onScreenOnFromTouch() {
        logDebug("REAL: onScreenOnFromTouch");
        onScreenTurningOn();
    }

@@ -251,53 +203,29 @@ class FalsingCollectorImpl implements FalsingCollector {
        return false;
    }

    @Override
    public void onUnlockHintStarted() {
    }

    @Override
    public void onCameraHintStarted() {
    }

    @Override
    public void onLeftAffordanceHintStarted() {
    }

    @Override
    public void onScreenTurningOn() {
        logDebug("REAL: onScreenTurningOn");
        mScreenOn = true;
        updateSessionActive();
    }

    @Override
    public void onScreenOff() {
        logDebug("REAL: onScreenOff");
        mScreenOn = false;
        updateSessionActive();
    }

    @Override
    public void onNotificationStopDismissing() {
    }

    @Override
    public void onNotificationDismissed() {
    }

    @Override
    public void onNotificationStartDismissing() {
    }

    @Override
    public void onNotificationDoubleTap(boolean accepted, float dx, float dy) {
    }

    @Override
    public void onBouncerShown() {
        logDebug("REAL: onBouncerShown");
        unregisterSensors();
    }

    @Override
    public void onBouncerHidden() {
        logDebug("REAL: onBouncerHidden");
        if (mSessionStarted) {
            registerSensors();
        }
@@ -305,6 +233,7 @@ class FalsingCollectorImpl implements FalsingCollector {

    @Override
    public void onTouchEvent(MotionEvent ev) {
        logDebug("REAL: onTouchEvent(" + ev.getActionMasked() + ")");
        if (!mKeyguardStateController.isShowing()) {
            avoidGesture();
            return;
@@ -334,6 +263,7 @@ class FalsingCollectorImpl implements FalsingCollector {

    @Override
    public void onMotionEventComplete() {
        logDebug("REAL: onMotionEventComplete");
        // We must delay processing the completion because of the way Android handles click events.
        // It generally delays executing them immediately, instead choosing to give the UI a chance
        // to respond to touch events before acknowledging the click. As such, we must also delay,
@@ -350,6 +280,7 @@ class FalsingCollectorImpl implements FalsingCollector {

    @Override
    public void avoidGesture() {
        logDebug("REAL: avoidGesture");
        mAvoidGesture = true;
        if (mPendingDownEvent != null) {
            mPendingDownEvent.recycle();
@@ -359,6 +290,7 @@ class FalsingCollectorImpl implements FalsingCollector {

    @Override
    public void cleanup() {
        logDebug("REAL: cleanup");
        unregisterSensors();
        mKeyguardUpdateMonitor.removeCallback(mKeyguardUpdateCallback);
        mStatusBarStateController.removeCallback(mStatusBarStateListener);
@@ -368,11 +300,13 @@ class FalsingCollectorImpl implements FalsingCollector {

    @Override
    public void updateFalseConfidence(FalsingClassifier.Result result) {
        logDebug("REAL: updateFalseConfidence(" + result.isFalse() + ")");
        mHistoryTracker.addResults(Collections.singleton(result), mSystemClock.uptimeMillis());
    }

    @Override
    public void onA11yAction() {
        logDebug("REAL: onA11yAction");
        if (mPendingDownEvent != null) {
            mPendingDownEvent.recycle();
            mPendingDownEvent = null;
@@ -427,17 +361,13 @@ class FalsingCollectorImpl implements FalsingCollector {


    static void logDebug(String msg) {
        logDebug(msg, null);
    }

    static void logDebug(String msg, Throwable throwable) {
        if (DEBUG) {
            Log.d(TAG, msg, throwable);
            logDebug(msg);
        }
    }

    private static class ProximityEventImpl implements FalsingManager.ProximityEvent {
        private ThresholdSensorEvent mThresholdSensorEvent;
        private final ThresholdSensorEvent mThresholdSensorEvent;

        ProximityEventImpl(ThresholdSensorEvent thresholdSensorEvent) {
            mThresholdSensorEvent = thresholdSensorEvent;
+81 −0
Original line number Diff line number Diff line
/*
 * Copyright 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.classifier

import android.view.MotionEvent
import com.android.systemui.classifier.FalsingCollectorImpl.logDebug
import com.android.systemui.dagger.SysUISingleton
import javax.inject.Inject

@SysUISingleton
class FalsingCollectorNoOp @Inject constructor() : FalsingCollector {
    override fun onSuccessfulUnlock() {
        logDebug("NOOP: onSuccessfulUnlock")
    }

    override fun setShowingAod(showingAod: Boolean) {
        logDebug("NOOP: setShowingAod($showingAod)")
    }

    override fun shouldEnforceBouncer(): Boolean = false

    override fun onScreenOnFromTouch() {
        logDebug("NOOP: onScreenOnFromTouch")
    }

    override fun isReportingEnabled(): Boolean = false

    override fun onScreenTurningOn() {
        logDebug("NOOP: onScreenTurningOn")
    }

    override fun onScreenOff() {
        logDebug("NOOP: onScreenOff")
    }

    override fun onBouncerShown() {
        logDebug("NOOP: onBouncerShown")
    }

    override fun onBouncerHidden() {
        logDebug("NOOP: onBouncerHidden")
    }

    override fun onTouchEvent(ev: MotionEvent) {
        logDebug("NOOP: onTouchEvent(${ev.actionMasked})")
    }

    override fun onMotionEventComplete() {
        logDebug("NOOP: onMotionEventComplete")
    }

    override fun avoidGesture() {
        logDebug("NOOP: avoidGesture")
    }

    override fun cleanup() {
        logDebug("NOOP: cleanup")
    }

    override fun updateFalseConfidence(result: FalsingClassifier.Result) {
        logDebug("NOOP: updateFalseConfidence(${result.isFalse})")
    }

    override fun onA11yAction() {
        logDebug("NOOP: onA11yAction")
    }
}
Loading