Ensure that falsing is turned off when a11y is on.

Fixes: 192111575
Test: manual
Change-Id: Ie2fc70b4079c7bb429cf9511574aa898f611ed3a
This commit is contained in:
Dave Mankoff
2021-06-30 13:28:32 -04:00
parent 06327bba21
commit b9bff43b5d
3 changed files with 128 additions and 2 deletions

View File

@@ -25,6 +25,7 @@ import android.net.Uri;
import android.os.Build;
import android.util.IndentingPrintWriter;
import android.util.Log;
import android.view.accessibility.AccessibilityManager;
import androidx.annotation.NonNull;
@@ -70,6 +71,7 @@ public class BrightLineFalsingManager implements FalsingManager {
private final DoubleTapClassifier mDoubleTapClassifier;
private final HistoryTracker mHistoryTracker;
private final KeyguardStateController mKeyguardStateController;
private AccessibilityManager mAccessibilityManager;
private final boolean mTestHarness;
private final MetricsLogger mMetricsLogger;
private int mIsFalseTouchCalls;
@@ -175,6 +177,7 @@ public class BrightLineFalsingManager implements FalsingManager {
@Named(BRIGHT_LINE_GESTURE_CLASSIFERS) Set<FalsingClassifier> classifiers,
SingleTapClassifier singleTapClassifier, DoubleTapClassifier doubleTapClassifier,
HistoryTracker historyTracker, KeyguardStateController keyguardStateController,
AccessibilityManager accessibilityManager,
@TestHarness boolean testHarness) {
mDataProvider = falsingDataProvider;
mDockManager = dockManager;
@@ -184,6 +187,7 @@ public class BrightLineFalsingManager implements FalsingManager {
mDoubleTapClassifier = doubleTapClassifier;
mHistoryTracker = historyTracker;
mKeyguardStateController = keyguardStateController;
mAccessibilityManager = accessibilityManager;
mTestHarness = testHarness;
mDataProvider.addSessionListener(mSessionListener);
@@ -328,7 +332,8 @@ public class BrightLineFalsingManager implements FalsingManager {
|| !mKeyguardStateController.isShowing()
|| mTestHarness
|| mDataProvider.isJustUnlockedWithFace()
|| mDockManager.isDocked();
|| mDockManager.isDocked()
|| mAccessibilityManager.isEnabled();
}
@Override

View File

@@ -31,6 +31,7 @@ import static org.mockito.Mockito.when;
import android.testing.AndroidTestingRunner;
import android.view.MotionEvent;
import android.view.accessibility.AccessibilityManager;
import androidx.test.filters.SmallTest;
@@ -77,6 +78,8 @@ public class BrightLineClassifierTest extends SysuiTestCase {
private HistoryTracker mHistoryTracker;
@Mock
private KeyguardStateController mKeyguardStateController;
@Mock
private AccessibilityManager mAccessibilityManager;
private final FakeExecutor mFakeExecutor = new FakeExecutor(new FakeSystemClock());
@@ -101,7 +104,8 @@ public class BrightLineClassifierTest extends SysuiTestCase {
when(mKeyguardStateController.isShowing()).thenReturn(true);
mBrightLineFalsingManager = new BrightLineFalsingManager(mFalsingDataProvider, mDockManager,
mMetricsLogger, mClassifiers, mSingleTapClassfier, mDoubleTapClassifier,
mHistoryTracker, mKeyguardStateController, false);
mHistoryTracker, mKeyguardStateController, mAccessibilityManager,
false);
ArgumentCaptor<GestureFinalizedListener> gestureCompleteListenerCaptor =

View File

@@ -0,0 +1,117 @@
/*
* Copyright (C) 2020 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.classifier;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyDouble;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.when;
import android.testing.AndroidTestingRunner;
import android.view.MotionEvent;
import android.view.accessibility.AccessibilityManager;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.testing.FakeMetricsLogger;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.dock.DockManagerFake;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@SmallTest
@RunWith(AndroidTestingRunner.class)
public class BrightLineFalsingManagerTest extends SysuiTestCase {
private BrightLineFalsingManager mBrightLineFalsingManager;
@Mock
private FalsingDataProvider mFalsingDataProvider;
private final DockManagerFake mDockManager = new DockManagerFake();
private final MetricsLogger mMetricsLogger = new FakeMetricsLogger();
private final Set<FalsingClassifier> mClassifiers = new HashSet<>();
@Mock
private SingleTapClassifier mSingleTapClassifier;
@Mock
private DoubleTapClassifier mDoubleTapClassifier;
@Mock
private FalsingClassifier mClassifierA;
private final List<MotionEvent> mMotionEventList = new ArrayList<>();
@Mock
private HistoryTracker mHistoryTracker;
@Mock
private KeyguardStateController mKeyguardStateController;
@Mock
private AccessibilityManager mAccessibilityManager;
private final FalsingClassifier.Result mPassedResult = FalsingClassifier.Result.passed(1);
private final FalsingClassifier.Result mFalsedResult =
FalsingClassifier.Result.falsed(1, getClass().getSimpleName(), "");
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
when(mClassifierA.classifyGesture(anyInt(), anyDouble(), anyDouble()))
.thenReturn(mFalsedResult);
when(mSingleTapClassifier.isTap(any(List.class), anyDouble())).thenReturn(mFalsedResult);
when(mDoubleTapClassifier.classifyGesture(anyInt(), anyDouble(), anyDouble()))
.thenReturn(mFalsedResult);
mClassifiers.add(mClassifierA);
when(mFalsingDataProvider.getRecentMotionEvents()).thenReturn(mMotionEventList);
when(mKeyguardStateController.isShowing()).thenReturn(true);
mBrightLineFalsingManager = new BrightLineFalsingManager(mFalsingDataProvider, mDockManager,
mMetricsLogger, mClassifiers, mSingleTapClassifier, mDoubleTapClassifier,
mHistoryTracker, mKeyguardStateController, mAccessibilityManager,
false);
}
@Test
public void testA11yDisablesGesture() {
assertThat(mBrightLineFalsingManager.isFalseTap(1)).isTrue();
when(mAccessibilityManager.isEnabled()).thenReturn(true);
assertThat(mBrightLineFalsingManager.isFalseTap(1)).isFalse();
}
@Test
public void testA11yDisablesTap() {
assertThat(mBrightLineFalsingManager.isFalseTouch(Classifier.GENERIC)).isTrue();
when(mAccessibilityManager.isEnabled()).thenReturn(true);
assertThat(mBrightLineFalsingManager.isFalseTouch(Classifier.GENERIC)).isFalse();
}
@Test
public void testA11yDisablesDoubleTap() {
assertThat(mBrightLineFalsingManager.isFalseDoubleTap()).isTrue();
when(mAccessibilityManager.isEnabled()).thenReturn(true);
assertThat(mBrightLineFalsingManager.isFalseDoubleTap()).isFalse();
}
}