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

Commit c332b960 authored by Matt Pietal's avatar Matt Pietal Committed by Android (Google) Code Review
Browse files

Merge "FalsingManager - Re-add existing belief listeners" into main

parents d3688a48 9722488b
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.systemui.plugins.annotations.ProvidesInterface;
import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;

/**
 * Interface that decides whether a touch on the phone was accidental. i.e. Pocket Dialing.
@@ -135,8 +136,10 @@ public interface FalsingManager {
     * Don't call this. It's meant for internal use to allow switching between implementations.
     *
     * Tests may also call it.
     *
     * @return existing listeners so they may be reattached
     **/
    void cleanupInternal();
    List<FalsingBeliefListener> cleanupInternal();

    /** Call to report a ProximityEvent to the FalsingManager. */
    void onProximityEvent(ProximityEvent proximityEvent);
+5 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ import com.android.systemui.user.domain.interactor.SelectedUserInteractor;
public abstract class KeyguardPinBasedInputViewController<T extends KeyguardPinBasedInputView>
        extends KeyguardAbsKeyInputViewController<T> implements InputManager.InputDeviceListener {

    private final FalsingCollector mFalsingCollector;
    private FalsingCollector mFalsingCollector = null;
    private final KeyguardKeyboardInteractor mKeyguardKeyboardInteractor;
    protected PasswordTextView mPasswordEntry;
    private Boolean mShowAnimations;
@@ -65,6 +65,9 @@ public abstract class KeyguardPinBasedInputViewController<T extends KeyguardPinB

    private final OnTouchListener mActionButtonTouchListener = (v, event) -> {
        if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
            if (mFalsingCollector != null) {
                mFalsingCollector.avoidGesture();
            }
            mView.doHapticKeyClick();
        }
        return false;
@@ -171,6 +174,7 @@ public abstract class KeyguardPinBasedInputViewController<T extends KeyguardPinB
        if (mBouncerHapticPlayer.isEnabled()) {
            deleteButton.setOnTouchListener((View view, MotionEvent event) -> {
                if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
                    mFalsingCollector.avoidGesture();
                    mBouncerHapticPlayer.playDeleteKeyPressFeedback();
                }
                return false;
+4 −1
Original line number Diff line number Diff line
@@ -496,13 +496,16 @@ public class BrightLineFalsingManager implements FalsingManager {
    }

    @Override
    public void cleanupInternal() {
    public List<FalsingBeliefListener> cleanupInternal() {
        List<FalsingBeliefListener> existingBeliefListeners
                = new ArrayList<>(mFalsingBeliefListeners);
        mDestroyed = true;
        mDataProvider.removeSessionListener(mSessionListener);
        mDataProvider.removeGestureCompleteListener(mGestureFinalizedListener);
        mClassifiers.forEach(FalsingClassifier::cleanup);
        mFalsingBeliefListeners.clear();
        mHistoryTracker.removeBeliefListener(mBeliefListener);
        return existingBeliefListeners;
    }

    private static Collection<FalsingClassifier.Result> getPassedResult(double confidence) {
+21 −10
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ import com.android.systemui.plugins.PluginManager;
import com.android.systemui.util.DeviceConfigProxy;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;

import javax.inject.Inject;
@@ -77,10 +79,7 @@ public class FalsingManagerProxy implements FalsingManager, Dumpable {
        mPluginListener = new PluginListener<FalsingPlugin>() {
            public void onPluginConnected(FalsingPlugin plugin, Context context) {
                FalsingManager pluginFalsingManager = plugin.getFalsingManager(context);
                if (pluginFalsingManager != null) {
                    mInternalFalsingManager.cleanupInternal();
                    mInternalFalsingManager = pluginFalsingManager;
                }
                cleanupAndReattachListeners(mInternalFalsingManager, pluginFalsingManager);
            }

            public void onPluginDisconnected(FalsingPlugin plugin) {
@@ -107,10 +106,8 @@ public class FalsingManagerProxy implements FalsingManager, Dumpable {
     * If multiple implementations are available, this is where the choice is made.
     */
    private void setupFalsingManager() {
        if (mInternalFalsingManager != null) {
            mInternalFalsingManager.cleanupInternal();
        }
        mInternalFalsingManager = mBrightLineFalsingManagerProvider.get();
        cleanupAndReattachListeners(mInternalFalsingManager,
                mBrightLineFalsingManagerProvider.get());
    }

    @Override
@@ -204,10 +201,24 @@ public class FalsingManagerProxy implements FalsingManager, Dumpable {
    }

    @Override
    public void cleanupInternal() {
    public List<FalsingBeliefListener> cleanupInternal() {
        mDeviceConfig.removeOnPropertiesChangedListener(mDeviceConfigListener);
        mPluginManager.removePluginListener(mPluginListener);
        mDumpManager.unregisterDumpable(DUMPABLE_TAG);
        mInternalFalsingManager.cleanupInternal();
        return mInternalFalsingManager.cleanupInternal();
    }

    private void cleanupAndReattachListeners(FalsingManager old, FalsingManager current) {
        List<FalsingBeliefListener> beliefListeners = new ArrayList<>();
        if (old != null) {
            beliefListeners = old.cleanupInternal();
        }

        if (current == null) return;

        for (FalsingBeliefListener listener : beliefListeners) {
            current.addFalsingBeliefListener(listener);
        }
        mInternalFalsingManager = current;
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -164,8 +164,9 @@ public class FalsingManagerFake implements FalsingManager {
    }

    @Override
    public void cleanupInternal() {
    public List<FalsingBeliefListener> cleanupInternal() {
        mDestroyed = true;
        return new ArrayList<FalsingBeliefListener>();
    }

    private void checkDestroyed() {