Merge "Don't destroy the FalsingManager in Wallet." into sc-dev
This commit is contained in:
@@ -105,11 +105,21 @@ android_library {
|
|||||||
filegroup {
|
filegroup {
|
||||||
name: "SystemUI-tests-utils",
|
name: "SystemUI-tests-utils",
|
||||||
srcs: [
|
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/notification/collection/NotificationEntryBuilder.java",
|
||||||
"tests/src/com/android/systemui/statusbar/RankingBuilder.java",
|
"tests/src/com/android/systemui/statusbar/RankingBuilder.java",
|
||||||
"tests/src/com/android/systemui/statusbar/SbnBuilder.java",
|
"tests/src/com/android/systemui/statusbar/SbnBuilder.java",
|
||||||
"tests/src/com/android/systemui/util/concurrency/FakeExecutor.java",
|
"tests/src/com/android/systemui/SysuiTestableContext.java",
|
||||||
"tests/src/com/android/systemui/util/time/FakeSystemClock.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",
|
path: "tests/src",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,12 @@ public interface FalsingManager {
|
|||||||
/** From com.android.systemui.Dumpable. */
|
/** From com.android.systemui.Dumpable. */
|
||||||
void dump(FileDescriptor fd, PrintWriter pw, String[] args);
|
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. */
|
/** Call to report a ProximityEvent to the FalsingManager. */
|
||||||
void onProximityEvent(ProximityEvent proximityEvent);
|
void onProximityEvent(ProximityEvent proximityEvent);
|
||||||
@@ -136,7 +141,9 @@ public interface FalsingManager {
|
|||||||
void onFalse();
|
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 {
|
interface FalsingTapListener {
|
||||||
void onDoubleTapRequired();
|
void onDoubleTapRequired();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,8 @@ public class BrightLineFalsingManager implements FalsingManager {
|
|||||||
private final List<FalsingBeliefListener> mFalsingBeliefListeners = new ArrayList<>();
|
private final List<FalsingBeliefListener> mFalsingBeliefListeners = new ArrayList<>();
|
||||||
private List<FalsingTapListener> mFalsingTapListeners = new ArrayList<>();
|
private List<FalsingTapListener> mFalsingTapListeners = new ArrayList<>();
|
||||||
|
|
||||||
|
private boolean mDestroyed;
|
||||||
|
|
||||||
private final SessionListener mSessionListener = new SessionListener() {
|
private final SessionListener mSessionListener = new SessionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSessionEnded() {
|
public void onSessionEnded() {
|
||||||
@@ -196,6 +198,8 @@ public class BrightLineFalsingManager implements FalsingManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFalseTouch(@Classifier.InteractionType int interactionType) {
|
public boolean isFalseTouch(@Classifier.InteractionType int interactionType) {
|
||||||
|
checkDestroyed();
|
||||||
|
|
||||||
mPriorInteractionType = interactionType;
|
mPriorInteractionType = interactionType;
|
||||||
if (skipFalsing(interactionType)) {
|
if (skipFalsing(interactionType)) {
|
||||||
mPriorResults = getPassedResult(1);
|
mPriorResults = getPassedResult(1);
|
||||||
@@ -221,6 +225,8 @@ public class BrightLineFalsingManager implements FalsingManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSimpleTap() {
|
public boolean isSimpleTap() {
|
||||||
|
checkDestroyed();
|
||||||
|
|
||||||
FalsingClassifier.Result result = mSingleTapClassifier.isTap(
|
FalsingClassifier.Result result = mSingleTapClassifier.isTap(
|
||||||
mDataProvider.getRecentMotionEvents(), 0);
|
mDataProvider.getRecentMotionEvents(), 0);
|
||||||
mPriorResults = Collections.singleton(result);
|
mPriorResults = Collections.singleton(result);
|
||||||
@@ -228,8 +234,16 @@ public class BrightLineFalsingManager implements FalsingManager {
|
|||||||
return !result.isFalse();
|
return !result.isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkDestroyed() {
|
||||||
|
if (mDestroyed) {
|
||||||
|
Log.wtf(TAG, "Tried to use FalsingManager after being destroyed!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFalseTap(@Penalty int penalty) {
|
public boolean isFalseTap(@Penalty int penalty) {
|
||||||
|
checkDestroyed();
|
||||||
|
|
||||||
if (skipFalsing(GENERIC)) {
|
if (skipFalsing(GENERIC)) {
|
||||||
mPriorResults = getPassedResult(1);
|
mPriorResults = getPassedResult(1);
|
||||||
logDebug("Skipped falsing");
|
logDebug("Skipped falsing");
|
||||||
@@ -292,6 +306,8 @@ public class BrightLineFalsingManager implements FalsingManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFalseDoubleTap() {
|
public boolean isFalseDoubleTap() {
|
||||||
|
checkDestroyed();
|
||||||
|
|
||||||
if (skipFalsing(GENERIC)) {
|
if (skipFalsing(GENERIC)) {
|
||||||
mPriorResults = getPassedResult(1);
|
mPriorResults = getPassedResult(1);
|
||||||
logDebug("Skipped falsing");
|
logDebug("Skipped falsing");
|
||||||
@@ -406,7 +422,8 @@ public class BrightLineFalsingManager implements FalsingManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cleanup() {
|
public void cleanupInternal() {
|
||||||
|
mDestroyed = true;
|
||||||
mDataProvider.removeSessionListener(mSessionListener);
|
mDataProvider.removeSessionListener(mSessionListener);
|
||||||
mDataProvider.removeGestureCompleteListener(mGestureFinalizedListener);
|
mDataProvider.removeGestureCompleteListener(mGestureFinalizedListener);
|
||||||
mClassifiers.forEach(FalsingClassifier::cleanup);
|
mClassifiers.forEach(FalsingClassifier::cleanup);
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class FalsingManagerProxy implements FalsingManager, Dumpable {
|
|||||||
public void onPluginConnected(FalsingPlugin plugin, Context context) {
|
public void onPluginConnected(FalsingPlugin plugin, Context context) {
|
||||||
FalsingManager pluginFalsingManager = plugin.getFalsingManager(context);
|
FalsingManager pluginFalsingManager = plugin.getFalsingManager(context);
|
||||||
if (pluginFalsingManager != null) {
|
if (pluginFalsingManager != null) {
|
||||||
mInternalFalsingManager.cleanup();
|
mInternalFalsingManager.cleanupInternal();
|
||||||
mInternalFalsingManager = pluginFalsingManager;
|
mInternalFalsingManager = pluginFalsingManager;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ public class FalsingManagerProxy implements FalsingManager, Dumpable {
|
|||||||
*/
|
*/
|
||||||
private void setupFalsingManager() {
|
private void setupFalsingManager() {
|
||||||
if (mInternalFalsingManager != null) {
|
if (mInternalFalsingManager != null) {
|
||||||
mInternalFalsingManager.cleanup();
|
mInternalFalsingManager.cleanupInternal();
|
||||||
}
|
}
|
||||||
mInternalFalsingManager = mBrightLineFalsingManagerProvider.get();
|
mInternalFalsingManager = mBrightLineFalsingManagerProvider.get();
|
||||||
}
|
}
|
||||||
@@ -195,10 +195,10 @@ public class FalsingManagerProxy implements FalsingManager, Dumpable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cleanup() {
|
public void cleanupInternal() {
|
||||||
mDeviceConfig.removeOnPropertiesChangedListener(mDeviceConfigListener);
|
mDeviceConfig.removeOnPropertiesChangedListener(mDeviceConfigListener);
|
||||||
mPluginManager.removePluginListener(mPluginListener);
|
mPluginManager.removePluginListener(mPluginListener);
|
||||||
mDumpManager.unregisterDumpable(DUMPABLE_TAG);
|
mDumpManager.unregisterDumpable(DUMPABLE_TAG);
|
||||||
mInternalFalsingManager.cleanup();
|
mInternalFalsingManager.cleanupInternal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,7 +260,6 @@ public class WalletScreenController implements
|
|||||||
mIsDismissed = true;
|
mIsDismissed = true;
|
||||||
mSelectedCardId = null;
|
mSelectedCardId = null;
|
||||||
mHandler.removeCallbacks(mSelectionRunnable);
|
mHandler.removeCallbacks(mSelectionRunnable);
|
||||||
mFalsingManager.cleanup();
|
|
||||||
mWalletClient.notifyWalletDismissed();
|
mWalletClient.notifyWalletDismissed();
|
||||||
mWalletClient.removeWalletServiceEventListener(this);
|
mWalletClient.removeWalletServiceEventListener(this);
|
||||||
mWalletView.animateDismissal();
|
mWalletView.animateDismissal();
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ public class BrightLineClassifierTest extends SysuiTestCase {
|
|||||||
verify(mFalsingDataProvider).addSessionListener(
|
verify(mFalsingDataProvider).addSessionListener(
|
||||||
any(FalsingDataProvider.SessionListener.class));
|
any(FalsingDataProvider.SessionListener.class));
|
||||||
|
|
||||||
mBrightLineFalsingManager.cleanup();
|
mBrightLineFalsingManager.cleanupInternal();
|
||||||
verify(mFalsingDataProvider).removeSessionListener(
|
verify(mFalsingDataProvider).removeSessionListener(
|
||||||
any(FalsingDataProvider.SessionListener.class));
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.systemui.classifier;
|
package com.android.systemui.classifier;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertWithMessage;
|
||||||
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
@@ -34,10 +36,11 @@ public class FalsingManagerFake implements FalsingManager {
|
|||||||
private boolean mIsSimpleTap;
|
private boolean mIsSimpleTap;
|
||||||
private boolean mIsFalseDoubleTap;
|
private boolean mIsFalseDoubleTap;
|
||||||
private boolean mIsUnlockingDisabled;
|
private boolean mIsUnlockingDisabled;
|
||||||
private boolean mIsClassiferEnabled;
|
private boolean mIsClassifierEnabled;
|
||||||
private boolean mShouldEnforceBouncer;
|
private boolean mShouldEnforceBouncer;
|
||||||
private boolean mIsReportingEnabled;
|
private boolean mIsReportingEnabled;
|
||||||
private boolean mIsFalseRobustTap;
|
private boolean mIsFalseRobustTap;
|
||||||
|
private boolean mDestroyed;
|
||||||
|
|
||||||
private final List<FalsingBeliefListener> mFalsingBeliefListeners = new ArrayList<>();
|
private final List<FalsingBeliefListener> mFalsingBeliefListeners = new ArrayList<>();
|
||||||
private final List<FalsingTapListener> mTapListeners = new ArrayList<>();
|
private final List<FalsingTapListener> mTapListeners = new ArrayList<>();
|
||||||
@@ -64,6 +67,7 @@ public class FalsingManagerFake implements FalsingManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFalseTouch(@Classifier.InteractionType int interactionType) {
|
public boolean isFalseTouch(@Classifier.InteractionType int interactionType) {
|
||||||
|
checkDestroyed();
|
||||||
return mIsFalseTouch;
|
return mIsFalseTouch;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,27 +85,30 @@ public class FalsingManagerFake implements FalsingManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSimpleTap() {
|
public boolean isSimpleTap() {
|
||||||
|
checkDestroyed();
|
||||||
return mIsSimpleTap;
|
return mIsSimpleTap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFalseTap(@Penalty int penalty) {
|
public boolean isFalseTap(@Penalty int penalty) {
|
||||||
|
checkDestroyed();
|
||||||
return mIsFalseRobustTap;
|
return mIsFalseRobustTap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFalseDoubleTap() {
|
public boolean isFalseDoubleTap() {
|
||||||
|
checkDestroyed();
|
||||||
return mIsFalseDoubleTap;
|
return mIsFalseDoubleTap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public void setIsClassiferEnabled(boolean isClassiferEnabled) {
|
public void setIsClassifierEnabled(boolean isClassifierEnabled) {
|
||||||
mIsClassiferEnabled = isClassiferEnabled;
|
mIsClassifierEnabled = isClassifierEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isClassifierEnabled() {
|
public boolean isClassifierEnabled() {
|
||||||
return mIsClassiferEnabled;
|
return mIsClassifierEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -129,7 +136,13 @@ public class FalsingManagerFake implements FalsingManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cleanup() {
|
public void cleanupInternal() {
|
||||||
|
mDestroyed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkDestroyed() {
|
||||||
|
assertWithMessage("FakeFasingManager has been destroyed")
|
||||||
|
.that(mDestroyed).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
Reference in New Issue
Block a user