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

Commit 293fd61a authored by Dave Mankoff's avatar Dave Mankoff Committed by android-build-team Robot
Browse files

Don't destroy the FalsingManager in Wallet.

When FalsingManager#cleanupInternal is called, it no longer produces
valid results. With this change, we check that the FalsingManager
is not used after being destroyed, and also avoid destroying it in
WalletScreenController.

Fixes: 188174214
Test: manual
Change-Id: I0ce67de5a326b56dee11c1d63c1d592640c0713d
(cherry picked from commit dbdeb8da5ab0dad02f25edfe313e59d506e718f3)
parent c76db1f2
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -114,7 +114,12 @@ public interface FalsingManager {
    /** From com.android.systemui.Dumpable. */
    void dump(FileDescriptor fd, PrintWriter pw, String[] args);

    void cleanup();
    /**
     *  Don't call this. It's meant for internal use to allow switching between implementations.
     *
     * Tests may also call it.
     **/
    void cleanupInternal();

    /** Call to report a ProximityEvent to the FalsingManager. */
    void onProximityEvent(ProximityEvent proximityEvent);
@@ -136,7 +141,9 @@ public interface FalsingManager {
        void onFalse();
    }

    /** Listener that is alerted when a double tap is required to confirm a single tap. */
    /**
     * Listener that is alerted when a double tap is required to confirm a single tap.
     **/
    interface FalsingTapListener {
        void onDoubleTapRequired();
    }
+18 −1
Original line number Diff line number Diff line
@@ -82,6 +82,8 @@ public class BrightLineFalsingManager implements FalsingManager {
    private final List<FalsingBeliefListener> mFalsingBeliefListeners = new ArrayList<>();
    private List<FalsingTapListener> mFalsingTapListeners = new ArrayList<>();

    private boolean mDestroyed;

    private final SessionListener mSessionListener = new SessionListener() {
        @Override
        public void onSessionEnded() {
@@ -196,6 +198,8 @@ public class BrightLineFalsingManager implements FalsingManager {

    @Override
    public boolean isFalseTouch(@Classifier.InteractionType int interactionType) {
        checkDestroyed();

        mPriorInteractionType = interactionType;
        if (skipFalsing(interactionType)) {
            mPriorResults = getPassedResult(1);
@@ -221,6 +225,8 @@ public class BrightLineFalsingManager implements FalsingManager {

    @Override
    public boolean isSimpleTap() {
        checkDestroyed();

        FalsingClassifier.Result result = mSingleTapClassifier.isTap(
                mDataProvider.getRecentMotionEvents(), 0);
        mPriorResults = Collections.singleton(result);
@@ -228,8 +234,16 @@ public class BrightLineFalsingManager implements FalsingManager {
        return !result.isFalse();
    }

    private void checkDestroyed() {
        if (mDestroyed) {
            Log.wtf(TAG, "Tried to use FalsingManager after being destroyed!");
        }
    }

    @Override
    public boolean isFalseTap(@Penalty int penalty) {
        checkDestroyed();

        if (skipFalsing(GENERIC)) {
            mPriorResults = getPassedResult(1);
            logDebug("Skipped falsing");
@@ -292,6 +306,8 @@ public class BrightLineFalsingManager implements FalsingManager {

    @Override
    public boolean isFalseDoubleTap() {
        checkDestroyed();

        if (skipFalsing(GENERIC)) {
            mPriorResults = getPassedResult(1);
            logDebug("Skipped falsing");
@@ -406,7 +422,8 @@ public class BrightLineFalsingManager implements FalsingManager {
    }

    @Override
    public void cleanup() {
    public void cleanupInternal() {
        mDestroyed = true;
        mDataProvider.removeSessionListener(mSessionListener);
        mDataProvider.removeGestureCompleteListener(mGestureFinalizedListener);
        mClassifiers.forEach(FalsingClassifier::cleanup);
+4 −4
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ public class FalsingManagerProxy implements FalsingManager, Dumpable {
            public void onPluginConnected(FalsingPlugin plugin, Context context) {
                FalsingManager pluginFalsingManager = plugin.getFalsingManager(context);
                if (pluginFalsingManager != null) {
                    mInternalFalsingManager.cleanup();
                    mInternalFalsingManager.cleanupInternal();
                    mInternalFalsingManager = pluginFalsingManager;
                }
            }
@@ -109,7 +109,7 @@ public class FalsingManagerProxy implements FalsingManager, Dumpable {
     */
    private void setupFalsingManager() {
        if (mInternalFalsingManager != null) {
            mInternalFalsingManager.cleanup();
            mInternalFalsingManager.cleanupInternal();
        }
        mInternalFalsingManager = mBrightLineFalsingManagerProvider.get();
    }
@@ -195,10 +195,10 @@ public class FalsingManagerProxy implements FalsingManager, Dumpable {
    }

    @Override
    public void cleanup() {
    public void cleanupInternal() {
        mDeviceConfig.removeOnPropertiesChangedListener(mDeviceConfigListener);
        mPluginManager.removePluginListener(mPluginListener);
        mDumpManager.unregisterDumpable(DUMPABLE_TAG);
        mInternalFalsingManager.cleanup();
        mInternalFalsingManager.cleanupInternal();
    }
}
+0 −1
Original line number Diff line number Diff line
@@ -260,7 +260,6 @@ public class WalletScreenController implements
        mIsDismissed = true;
        mSelectedCardId = null;
        mHandler.removeCallbacks(mSelectionRunnable);
        mFalsingManager.cleanup();
        mWalletClient.notifyWalletDismissed();
        mWalletClient.removeWalletServiceEventListener(this);
        mWalletView.animateDismissal();
+1 −1
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@ public class BrightLineClassifierTest extends SysuiTestCase {
        verify(mFalsingDataProvider).addSessionListener(
                any(FalsingDataProvider.SessionListener.class));

        mBrightLineFalsingManager.cleanup();
        mBrightLineFalsingManager.cleanupInternal();
        verify(mFalsingDataProvider).removeSessionListener(
                any(FalsingDataProvider.SessionListener.class));
    }
Loading