Add base class for new falsing manager and classifiers.
This adds no functional changes. It merely adds the framework
for a new FalsingManager.
Change-Id: I7f0e3b1363c847fa1eefa54bf7793508fefd1926
Test: manual.
Bug: 111394067
diff --git a/packages/SystemUI/src/com/android/systemui/classifier/brightline/FalsingClassifier.java b/packages/SystemUI/src/com/android/systemui/classifier/brightline/FalsingClassifier.java
new file mode 100644
index 0000000..c6ac2dd
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/classifier/brightline/FalsingClassifier.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2019 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.brightline;
+
+import android.hardware.SensorEvent;
+import android.view.MotionEvent;
+
+import com.android.systemui.classifier.Classifier;
+
+import java.util.List;
+
+/**
+ * Base class for rules that determine False touches.
+ */
+abstract class FalsingClassifier {
+ private final FalsingDataProvider mDataProvider;
+
+ FalsingClassifier(FalsingDataProvider dataProvider) {
+ this.mDataProvider = dataProvider;
+ }
+
+ List<MotionEvent> getRecentMotionEvents() {
+ return mDataProvider.getRecentMotionEvents();
+ }
+
+ MotionEvent getFirstMotionEvent() {
+ return mDataProvider.getFirstRecentMotionEvent();
+ }
+
+ MotionEvent getLastMotionEvent() {
+ return mDataProvider.getLastMotionEvent();
+ }
+
+ boolean isHorizontal() {
+ return mDataProvider.isHorizontal();
+ }
+
+ boolean isRight() {
+ return mDataProvider.isRight();
+ }
+
+ boolean isVertical() {
+ return mDataProvider.isVertical();
+ }
+
+ boolean isUp() {
+ return mDataProvider.isUp();
+ }
+
+ float getAngle() {
+ return mDataProvider.getAngle();
+ }
+
+ int getWidthPixels() {
+ return mDataProvider.mWidthPixels;
+ }
+
+ int getHeightPixels() {
+ return mDataProvider.mHeightPixels;
+ }
+
+ float getXdpi() {
+ return mDataProvider.mXdpi;
+ }
+
+ float getYdpi() {
+ return mDataProvider.mYdpi;
+ }
+
+ final @Classifier.InteractionType int getInteractionType() {
+ return mDataProvider.getInteractionType();
+ }
+
+ final void setInteractionType(@Classifier.InteractionType int interactionType) {
+ mDataProvider.setInteractionType(interactionType);
+ }
+
+ /**
+ * Called whenever a MotionEvent occurs.
+ *
+ * Useful for classifiers that need to see every MotionEvent, but most can probably
+ * use {@link #getRecentMotionEvents()} instead, which will return a list of MotionEvents.
+ */
+ void onTouchEvent(MotionEvent motionEvent) {};
+
+ /**
+ * Called whenever a SensorEvent occurs, specifically the ProximitySensor.
+ */
+ void onSensorEvent(SensorEvent sensorEvent) {};
+
+ /**
+ * The phone screen has turned on and we need to begin falsing detection.
+ */
+ void onSessionStarted() {};
+
+ /**
+ * The phone screen has turned off and falsing data can be discarded.
+ */
+ void onSessionEnded() {};
+
+ /**
+ * Returns true if the data captured so far looks like a false touch.
+ */
+ abstract boolean isFalseTouch();
+
+ static void logDebug(String msg) {
+ BrightLineFalsingManager.logDebug(msg);
+ }
+
+ static void logInfo(String msg) {
+ BrightLineFalsingManager.logInfo(msg);
+ }
+
+ static void logError(String msg) {
+ BrightLineFalsingManager.logError(msg);
+ }
+}