Merge "Ignore ACTION_OUTSIDE in FalsingManager" into tm-dev
This commit is contained in:
@@ -309,6 +309,10 @@ class FalsingCollectorImpl implements FalsingCollector {
|
|||||||
avoidGesture();
|
avoidGesture();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (ev.getActionMasked() == MotionEvent.ACTION_OUTSIDE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// We delay processing down events to see if another component wants to process them.
|
// We delay processing down events to see if another component wants to process them.
|
||||||
// If #avoidGesture is called after a MotionEvent.ACTION_DOWN, all following motion events
|
// If #avoidGesture is called after a MotionEvent.ACTION_DOWN, all following motion events
|
||||||
// will be ignored by the collector until another MotionEvent.ACTION_DOWN is passed in.
|
// will be ignored by the collector until another MotionEvent.ACTION_DOWN is passed in.
|
||||||
|
|||||||
@@ -152,8 +152,7 @@ public class WalletActivity extends LifecycleActivity implements
|
|||||||
Log.w(TAG, "Unable to create wallet app intent.");
|
Log.w(TAG, "Unable to create wallet app intent.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!mKeyguardStateController.isUnlocked()
|
if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) {
|
||||||
&& mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,12 @@ public class WalletCardCarousel extends RecyclerView {
|
|||||||
private float mCardCenterToScreenCenterDistancePx = Float.MAX_VALUE;
|
private float mCardCenterToScreenCenterDistancePx = Float.MAX_VALUE;
|
||||||
|
|
||||||
interface OnSelectionListener {
|
interface OnSelectionListener {
|
||||||
|
/**
|
||||||
|
* A non-centered card was clicked.
|
||||||
|
* @param position
|
||||||
|
*/
|
||||||
|
void onUncenteredClick(int position);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The card was moved to the center, thus selecting it.
|
* The card was moved to the center, thus selecting it.
|
||||||
*/
|
*/
|
||||||
@@ -403,7 +409,7 @@ public class WalletCardCarousel extends RecyclerView {
|
|||||||
viewHolder.mCardView.setOnClickListener(
|
viewHolder.mCardView.setOnClickListener(
|
||||||
v -> {
|
v -> {
|
||||||
if (position != mCenteredAdapterPosition) {
|
if (position != mCenteredAdapterPosition) {
|
||||||
smoothScrollToPosition(position);
|
mSelectionListener.onUncenteredClick(position);
|
||||||
} else {
|
} else {
|
||||||
mSelectionListener.onCardClicked(cardViewInfo);
|
mSelectionListener.onCardClicked(cardViewInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,6 +180,14 @@ public class WalletScreenController implements
|
|||||||
queryWalletCards();
|
queryWalletCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUncenteredClick(int position) {
|
||||||
|
if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mCardCarousel.smoothScrollToPosition(position);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCardSelected(@NonNull WalletCardViewInfo card) {
|
public void onCardSelected(@NonNull WalletCardViewInfo card) {
|
||||||
if (mIsDismissed) {
|
if (mIsDismissed) {
|
||||||
@@ -208,8 +216,7 @@ public class WalletScreenController implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCardClicked(@NonNull WalletCardViewInfo cardInfo) {
|
public void onCardClicked(@NonNull WalletCardViewInfo cardInfo) {
|
||||||
if (!mKeyguardStateController.isUnlocked()
|
if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) {
|
||||||
&& mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(cardInfo instanceof QAWalletCardViewInfo)
|
if (!(cardInfo instanceof QAWalletCardViewInfo)
|
||||||
|
|||||||
@@ -198,6 +198,20 @@ public class FalsingCollectorImplTest extends SysuiTestCase {
|
|||||||
verify(mFalsingDataProvider, never()).onMotionEvent(any(MotionEvent.class));
|
verify(mFalsingDataProvider, never()).onMotionEvent(any(MotionEvent.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIgnoreActionOutside() {
|
||||||
|
MotionEvent outside = MotionEvent.obtain(0, 0, MotionEvent.ACTION_OUTSIDE, 0, 0, 0);
|
||||||
|
MotionEvent up = MotionEvent.obtain(0, 0, MotionEvent.ACTION_UP, 0, 0, 0);
|
||||||
|
|
||||||
|
// Nothing passed initially. The outside event will be completely ignored.
|
||||||
|
mFalsingCollector.onTouchEvent(outside);
|
||||||
|
verify(mFalsingDataProvider, never()).onMotionEvent(any(MotionEvent.class));
|
||||||
|
|
||||||
|
// Up event flushes, and the outside event isn't passed through.
|
||||||
|
mFalsingCollector.onTouchEvent(up);
|
||||||
|
verify(mFalsingDataProvider).onMotionEvent(up);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAvoidUnlocked() {
|
public void testAvoidUnlocked() {
|
||||||
MotionEvent down = MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0, 0, 0);
|
MotionEvent down = MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0, 0, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user