Merge "Don't destroy the FalsingManager in Wallet." into sc-dev
This commit is contained in:
@@ -105,11 +105,21 @@ android_library {
|
||||
filegroup {
|
||||
name: "SystemUI-tests-utils",
|
||||
srcs: [
|
||||
"tests/src/com/android/systemui/SysuiTestCase.java",
|
||||
"tests/src/com/android/systemui/TestableDependency.java",
|
||||
"tests/src/com/android/systemui/classifier/FalsingManagerFake.java",
|
||||
"tests/src/com/android/systemui/statusbar/notification/collection/NotificationEntryBuilder.java",
|
||||
"tests/src/com/android/systemui/statusbar/RankingBuilder.java",
|
||||
"tests/src/com/android/systemui/statusbar/SbnBuilder.java",
|
||||
"tests/src/com/android/systemui/util/concurrency/FakeExecutor.java",
|
||||
"tests/src/com/android/systemui/util/time/FakeSystemClock.java",
|
||||
"tests/src/com/android/systemui/SysuiTestableContext.java",
|
||||
"tests/src/com/android/systemui/utils/leaks/BaseLeakChecker.java",
|
||||
"tests/src/com/android/systemui/utils/leaks/LeakCheckedTest.java",
|
||||
"tests/src/com/android/systemui/**/Fake*.java",
|
||||
"tests/src/com/android/systemui/**/Fake*.kt",
|
||||
],
|
||||
exclude_srcs: [
|
||||
"tests/src/com/android/systemui/**/*Test.java",
|
||||
"tests/src/com/android/systemui/**/*Test.kt",
|
||||
],
|
||||
path: "tests/src",
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,7 +260,6 @@ public class WalletScreenController implements
|
||||
mIsDismissed = true;
|
||||
mSelectedCardId = null;
|
||||
mHandler.removeCallbacks(mSelectionRunnable);
|
||||
mFalsingManager.cleanup();
|
||||
mWalletClient.notifyWalletDismissed();
|
||||
mWalletClient.removeWalletServiceEventListener(this);
|
||||
mWalletView.animateDismissal();
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
* Copyright (C) 2021 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.
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.systemui.classifier;
|
||||
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
@@ -34,10 +36,11 @@ public class FalsingManagerFake implements FalsingManager {
|
||||
private boolean mIsSimpleTap;
|
||||
private boolean mIsFalseDoubleTap;
|
||||
private boolean mIsUnlockingDisabled;
|
||||
private boolean mIsClassiferEnabled;
|
||||
private boolean mIsClassifierEnabled;
|
||||
private boolean mShouldEnforceBouncer;
|
||||
private boolean mIsReportingEnabled;
|
||||
private boolean mIsFalseRobustTap;
|
||||
private boolean mDestroyed;
|
||||
|
||||
private final List<FalsingBeliefListener> mFalsingBeliefListeners = new ArrayList<>();
|
||||
private final List<FalsingTapListener> mTapListeners = new ArrayList<>();
|
||||
@@ -64,6 +67,7 @@ public class FalsingManagerFake implements FalsingManager {
|
||||
|
||||
@Override
|
||||
public boolean isFalseTouch(@Classifier.InteractionType int interactionType) {
|
||||
checkDestroyed();
|
||||
return mIsFalseTouch;
|
||||
}
|
||||
|
||||
@@ -81,27 +85,30 @@ public class FalsingManagerFake implements FalsingManager {
|
||||
|
||||
@Override
|
||||
public boolean isSimpleTap() {
|
||||
checkDestroyed();
|
||||
return mIsSimpleTap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFalseTap(@Penalty int penalty) {
|
||||
checkDestroyed();
|
||||
return mIsFalseRobustTap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFalseDoubleTap() {
|
||||
checkDestroyed();
|
||||
return mIsFalseDoubleTap;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void setIsClassiferEnabled(boolean isClassiferEnabled) {
|
||||
mIsClassiferEnabled = isClassiferEnabled;
|
||||
public void setIsClassifierEnabled(boolean isClassifierEnabled) {
|
||||
mIsClassifierEnabled = isClassifierEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClassifierEnabled() {
|
||||
return mIsClassiferEnabled;
|
||||
return mIsClassifierEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -129,7 +136,13 @@ public class FalsingManagerFake implements FalsingManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup() {
|
||||
public void cleanupInternal() {
|
||||
mDestroyed = true;
|
||||
}
|
||||
|
||||
private void checkDestroyed() {
|
||||
assertWithMessage("FakeFasingManager has been destroyed")
|
||||
.that(mDestroyed).isFalse();
|
||||
}
|
||||
|
||||
@Override
|
||||
Reference in New Issue
Block a user