blob: 0ca0a117f6e6ec8729d402d15693923af249ac1f [file] [log] [blame]
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -07001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
15 */
16
17package com.android.systemui.classifier;
18
19import android.content.Context;
20import android.database.ContentObserver;
21import android.hardware.Sensor;
22import android.hardware.SensorEvent;
23import android.hardware.SensorEventListener;
24import android.hardware.SensorManager;
Adrian Roos7bb38a92016-07-21 11:44:01 -070025import android.net.Uri;
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -070026import android.os.Handler;
Selim Cinekf8c4add2017-06-08 09:54:58 -070027import android.os.Looper;
Adrian Roosc5584ce2016-02-24 14:17:19 -080028import android.os.PowerManager;
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -070029import android.os.UserHandle;
30import android.provider.Settings;
Adrian Roos004437e2017-08-16 11:58:02 +020031import android.view.InputDevice;
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -070032import android.view.MotionEvent;
Adrian Roosca664b92016-04-18 14:40:27 -070033import android.view.accessibility.AccessibilityManager;
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -070034
Jorim Jaggie549a8d2017-05-15 02:40:05 +020035import com.android.systemui.Dependency;
36import com.android.systemui.UiOffloadThread;
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -070037import com.android.systemui.analytics.DataCollector;
38import com.android.systemui.statusbar.StatusBarState;
Adrian Roos7a8ae8a2017-08-02 16:26:50 +020039import com.android.systemui.util.AsyncSensorManager;
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -070040
Adrian Roos401caae2016-03-04 13:35:21 -080041import java.io.PrintWriter;
42
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -070043/**
44 * When the phone is locked, listens to touch, sensor and phone events and sends them to
45 * DataCollector and HumanInteractionClassifier.
46 *
47 * It does not collect touch events when the bouncer shows up.
48 */
49public class FalsingManager implements SensorEventListener {
50 private static final String ENFORCE_BOUNCER = "falsing_manager_enforce_bouncer";
51
Blazej Magnowski6dc59b42015-09-22 15:14:20 -070052 private static final int[] CLASSIFIER_SENSORS = new int[] {
53 Sensor.TYPE_PROXIMITY,
54 };
55
56 private static final int[] COLLECTOR_SENSORS = new int[] {
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -070057 Sensor.TYPE_ACCELEROMETER,
58 Sensor.TYPE_GYROSCOPE,
59 Sensor.TYPE_PROXIMITY,
60 Sensor.TYPE_LIGHT,
61 Sensor.TYPE_ROTATION_VECTOR,
62 };
63
Selim Cinekf8c4add2017-06-08 09:54:58 -070064 private final Handler mHandler = new Handler(Looper.getMainLooper());
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -070065 private final Context mContext;
66
67 private final SensorManager mSensorManager;
68 private final DataCollector mDataCollector;
69 private final HumanInteractionClassifier mHumanInteractionClassifier;
Adrian Roosca664b92016-04-18 14:40:27 -070070 private final AccessibilityManager mAccessibilityManager;
Jorim Jaggie549a8d2017-05-15 02:40:05 +020071 private final UiOffloadThread mUiOffloadThread;
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -070072
73 private static FalsingManager sInstance = null;
74
75 private boolean mEnforceBouncer = false;
76 private boolean mBouncerOn = false;
Siarhei Vishniakou81e1ffd2018-05-04 16:08:22 -070077 private boolean mBouncerOffOnDown = false;
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -070078 private boolean mSessionActive = false;
Adrian Roos004437e2017-08-16 11:58:02 +020079 private boolean mIsTouchScreen = true;
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -070080 private int mState = StatusBarState.SHADE;
Adrian Roosc5584ce2016-02-24 14:17:19 -080081 private boolean mScreenOn;
Adrian Roose395b5d2017-06-28 16:52:37 +020082 private boolean mShowingAod;
Adrian Roos8e291a52016-12-09 16:10:19 -080083 private Runnable mPendingWtf;
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -070084
85 protected final ContentObserver mSettingsObserver = new ContentObserver(mHandler) {
86 @Override
87 public void onChange(boolean selfChange) {
88 updateConfiguration();
89 }
90 };
91
92 private FalsingManager(Context context) {
93 mContext = context;
Adrian Roos7a8ae8a2017-08-02 16:26:50 +020094 mSensorManager = Dependency.get(AsyncSensorManager.class);
Adrian Roosca664b92016-04-18 14:40:27 -070095 mAccessibilityManager = context.getSystemService(AccessibilityManager.class);
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -070096 mDataCollector = DataCollector.getInstance(mContext);
97 mHumanInteractionClassifier = HumanInteractionClassifier.getInstance(mContext);
Jorim Jaggie549a8d2017-05-15 02:40:05 +020098 mUiOffloadThread = Dependency.get(UiOffloadThread.class);
Adrian Roosc5584ce2016-02-24 14:17:19 -080099 mScreenOn = context.getSystemService(PowerManager.class).isInteractive();
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700100
101 mContext.getContentResolver().registerContentObserver(
102 Settings.Secure.getUriFor(ENFORCE_BOUNCER), false,
103 mSettingsObserver,
104 UserHandle.USER_ALL);
105
106 updateConfiguration();
107 }
108
109 public static FalsingManager getInstance(Context context) {
110 if (sInstance == null) {
111 sInstance = new FalsingManager(context);
112 }
113 return sInstance;
114 }
115
116 private void updateConfiguration() {
117 mEnforceBouncer = 0 != Settings.Secure.getInt(mContext.getContentResolver(),
118 ENFORCE_BOUNCER, 0);
119 }
120
Adrian Roosc5584ce2016-02-24 14:17:19 -0800121 private boolean shouldSessionBeActive() {
Adrian Roos401caae2016-03-04 13:35:21 -0800122 if (FalsingLog.ENABLED && FalsingLog.VERBOSE)
123 FalsingLog.v("shouldBeActive", new StringBuilder()
124 .append("enabled=").append(isEnabled() ? 1 : 0)
125 .append(" mScreenOn=").append(mScreenOn ? 1 : 0)
126 .append(" mState=").append(StatusBarState.toShortString(mState))
127 .toString()
128 );
Adrian Roose395b5d2017-06-28 16:52:37 +0200129 return isEnabled() && mScreenOn && (mState == StatusBarState.KEYGUARD) && !mShowingAod;
Adrian Roosc5584ce2016-02-24 14:17:19 -0800130 }
131
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700132 private boolean sessionEntrypoint() {
Adrian Roosc5584ce2016-02-24 14:17:19 -0800133 if (!mSessionActive && shouldSessionBeActive()) {
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700134 onSessionStart();
135 return true;
136 }
137 return false;
138 }
139
Adrian Roosc5584ce2016-02-24 14:17:19 -0800140 private void sessionExitpoint(boolean force) {
141 if (mSessionActive && (force || !shouldSessionBeActive())) {
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700142 mSessionActive = false;
Jorim Jaggie549a8d2017-05-15 02:40:05 +0200143
144 // This can be expensive, and doesn't need to happen on the main thread.
145 mUiOffloadThread.submit(() -> {
146 mSensorManager.unregisterListener(this);
147 });
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700148 }
149 }
150
Adrian Roose395b5d2017-06-28 16:52:37 +0200151 public void updateSessionActive() {
152 if (shouldSessionBeActive()) {
153 sessionEntrypoint();
154 } else {
155 sessionExitpoint(false /* force */);
156 }
157 }
158
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700159 private void onSessionStart() {
Adrian Roos401caae2016-03-04 13:35:21 -0800160 if (FalsingLog.ENABLED) {
161 FalsingLog.i("onSessionStart", "classifierEnabled=" + isClassiferEnabled());
Adrian Roos8e291a52016-12-09 16:10:19 -0800162 clearPendingWtf();
Adrian Roos401caae2016-03-04 13:35:21 -0800163 }
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700164 mBouncerOn = false;
165 mSessionActive = true;
Blazej Magnowski6dc59b42015-09-22 15:14:20 -0700166
167 if (mHumanInteractionClassifier.isEnabled()) {
168 registerSensors(CLASSIFIER_SENSORS);
169 }
Adrian Roos7bb38a92016-07-21 11:44:01 -0700170 if (mDataCollector.isEnabledFull()) {
Blazej Magnowski6dc59b42015-09-22 15:14:20 -0700171 registerSensors(COLLECTOR_SENSORS);
172 }
Selim Cinek1ed50042018-01-18 17:12:32 -0800173 if (mDataCollector.isEnabled()) {
174 mDataCollector.onFalsingSessionStarted();
175 }
Blazej Magnowski6dc59b42015-09-22 15:14:20 -0700176 }
177
178 private void registerSensors(int [] sensors) {
179 for (int sensorType : sensors) {
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700180 Sensor s = mSensorManager.getDefaultSensor(sensorType);
181 if (s != null) {
Jorim Jaggie549a8d2017-05-15 02:40:05 +0200182
183 // This can be expensive, and doesn't need to happen on the main thread.
184 mUiOffloadThread.submit(() -> {
185 mSensorManager.registerListener(this, s, SensorManager.SENSOR_DELAY_GAME);
186 });
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700187 }
188 }
189 }
190
Blazej Magnowski6dc59b42015-09-22 15:14:20 -0700191 public boolean isClassiferEnabled() {
192 return mHumanInteractionClassifier.isEnabled();
193 }
194
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700195 private boolean isEnabled() {
196 return mHumanInteractionClassifier.isEnabled() || mDataCollector.isEnabled();
197 }
198
199 /**
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700200 * @return true if the classifier determined that this is not a human interacting with the phone
201 */
Blazej Magnowski9f01c5b2015-09-17 15:14:29 -0700202 public boolean isFalseTouch() {
Adrian Roos401caae2016-03-04 13:35:21 -0800203 if (FalsingLog.ENABLED) {
Adrian Roos6a04cb12016-03-14 20:21:02 -0700204 // We're getting some false wtfs from touches that happen after the device went
205 // to sleep. Only report missing sessions that happen when the device is interactive.
Adrian Roos8e291a52016-12-09 16:10:19 -0800206 if (!mSessionActive && mContext.getSystemService(PowerManager.class).isInteractive()
207 && mPendingWtf == null) {
208 int enabled = isEnabled() ? 1 : 0;
209 int screenOn = mScreenOn ? 1 : 0;
210 String state = StatusBarState.toShortString(mState);
211 Throwable here = new Throwable("here");
212 FalsingLog.wLogcat("isFalseTouch", new StringBuilder()
Adrian Roos401caae2016-03-04 13:35:21 -0800213 .append("Session is not active, yet there's a query for a false touch.")
Adrian Roos8e291a52016-12-09 16:10:19 -0800214 .append(" enabled=").append(enabled)
215 .append(" mScreenOn=").append(screenOn)
216 .append(" mState=").append(state)
217 .append(". Escalating to WTF if screen does not turn on soon.")
Adrian Roos401caae2016-03-04 13:35:21 -0800218 .toString());
Adrian Roos8e291a52016-12-09 16:10:19 -0800219
220 // Unfortunately we're also getting false positives for touches that happen right
221 // after the screen turns on, but before that notification has made it to us.
222 // Unfortunately there's no good way to catch that, except to wait and see if we get
223 // the screen on notification soon.
224 mPendingWtf = () -> FalsingLog.wtf("isFalseTouch", new StringBuilder()
225 .append("Session did not become active after query for a false touch.")
226 .append(" enabled=").append(enabled)
227 .append('/').append(isEnabled() ? 1 : 0)
228 .append(" mScreenOn=").append(screenOn)
229 .append('/').append(mScreenOn ? 1 : 0)
230 .append(" mState=").append(state)
231 .append('/').append(StatusBarState.toShortString(mState))
232 .append(". Look for warnings ~1000ms earlier to see root cause.")
233 .toString(), here);
234 mHandler.postDelayed(mPendingWtf, 1000);
Adrian Roos401caae2016-03-04 13:35:21 -0800235 }
236 }
Adrian Roosca664b92016-04-18 14:40:27 -0700237 if (mAccessibilityManager.isTouchExplorationEnabled()) {
238 // Touch exploration triggers false positives in the classifier and
239 // already sufficiently prevents false unlocks.
240 return false;
241 }
Adrian Roos004437e2017-08-16 11:58:02 +0200242 if (!mIsTouchScreen) {
243 // Unlocking with input devices besides the touchscreen should already be sufficiently
244 // anti-falsed.
245 return false;
246 }
Blazej Magnowski9f01c5b2015-09-17 15:14:29 -0700247 return mHumanInteractionClassifier.isFalseTouch();
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700248 }
249
Adrian Roos8e291a52016-12-09 16:10:19 -0800250 private void clearPendingWtf() {
251 if (mPendingWtf != null) {
252 mHandler.removeCallbacks(mPendingWtf);
253 mPendingWtf = null;
254 }
255 }
256
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700257 @Override
258 public synchronized void onSensorChanged(SensorEvent event) {
259 mDataCollector.onSensorChanged(event);
260 mHumanInteractionClassifier.onSensorChanged(event);
261 }
262
263 @Override
264 public void onAccuracyChanged(Sensor sensor, int accuracy) {
265 mDataCollector.onAccuracyChanged(sensor, accuracy);
266 }
267
268 public boolean shouldEnforceBouncer() {
269 return mEnforceBouncer;
270 }
271
Adrian Roose395b5d2017-06-28 16:52:37 +0200272 public void setShowingAod(boolean showingAod) {
273 mShowingAod = showingAod;
274 updateSessionActive();
275 }
276
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700277 public void setStatusBarState(int state) {
Adrian Roos401caae2016-03-04 13:35:21 -0800278 if (FalsingLog.ENABLED) {
279 FalsingLog.i("setStatusBarState", new StringBuilder()
280 .append("from=").append(StatusBarState.toShortString(mState))
281 .append(" to=").append(StatusBarState.toShortString(state))
282 .toString());
283 }
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700284 mState = state;
Adrian Roose395b5d2017-06-28 16:52:37 +0200285 updateSessionActive();
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700286 }
287
288 public void onScreenTurningOn() {
Adrian Roos401caae2016-03-04 13:35:21 -0800289 if (FalsingLog.ENABLED) {
290 FalsingLog.i("onScreenTurningOn", new StringBuilder()
291 .append("from=").append(mScreenOn ? 1 : 0)
292 .toString());
Adrian Roos8e291a52016-12-09 16:10:19 -0800293 clearPendingWtf();
Adrian Roos401caae2016-03-04 13:35:21 -0800294 }
Adrian Roosc5584ce2016-02-24 14:17:19 -0800295 mScreenOn = true;
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700296 if (sessionEntrypoint()) {
297 mDataCollector.onScreenTurningOn();
298 }
299 }
300
301 public void onScreenOnFromTouch() {
Adrian Roos401caae2016-03-04 13:35:21 -0800302 if (FalsingLog.ENABLED) {
303 FalsingLog.i("onScreenOnFromTouch", new StringBuilder()
304 .append("from=").append(mScreenOn ? 1 : 0)
305 .toString());
306 }
Adrian Roosc5584ce2016-02-24 14:17:19 -0800307 mScreenOn = true;
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700308 if (sessionEntrypoint()) {
309 mDataCollector.onScreenOnFromTouch();
310 }
311 }
312
313 public void onScreenOff() {
Adrian Roos401caae2016-03-04 13:35:21 -0800314 if (FalsingLog.ENABLED) {
315 FalsingLog.i("onScreenOff", new StringBuilder()
316 .append("from=").append(mScreenOn ? 1 : 0)
317 .toString());
318 }
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700319 mDataCollector.onScreenOff();
Adrian Roosc5584ce2016-02-24 14:17:19 -0800320 mScreenOn = false;
321 sessionExitpoint(false /* force */);
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700322 }
323
324 public void onSucccessfulUnlock() {
Adrian Roos401caae2016-03-04 13:35:21 -0800325 if (FalsingLog.ENABLED) {
326 FalsingLog.i("onSucccessfulUnlock", "");
327 }
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700328 mDataCollector.onSucccessfulUnlock();
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700329 }
330
331 public void onBouncerShown() {
Adrian Roos401caae2016-03-04 13:35:21 -0800332 if (FalsingLog.ENABLED) {
333 FalsingLog.i("onBouncerShown", new StringBuilder()
334 .append("from=").append(mBouncerOn ? 1 : 0)
335 .toString());
336 }
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700337 if (!mBouncerOn) {
338 mBouncerOn = true;
339 mDataCollector.onBouncerShown();
340 }
341 }
342
343 public void onBouncerHidden() {
Adrian Roos401caae2016-03-04 13:35:21 -0800344 if (FalsingLog.ENABLED) {
345 FalsingLog.i("onBouncerHidden", new StringBuilder()
346 .append("from=").append(mBouncerOn ? 1 : 0)
347 .toString());
348 }
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700349 if (mBouncerOn) {
350 mBouncerOn = false;
351 mDataCollector.onBouncerHidden();
352 }
353 }
354
355 public void onQsDown() {
Adrian Roos401caae2016-03-04 13:35:21 -0800356 if (FalsingLog.ENABLED) {
357 FalsingLog.i("onQsDown", "");
358 }
Blazej Magnowski9f01c5b2015-09-17 15:14:29 -0700359 mHumanInteractionClassifier.setType(Classifier.QUICK_SETTINGS);
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700360 mDataCollector.onQsDown();
361 }
362
363 public void setQsExpanded(boolean expanded) {
364 mDataCollector.setQsExpanded(expanded);
365 }
366
Lucas Dupinbc9aac12018-03-04 20:18:15 -0800367 public void onTrackingStarted(boolean secure) {
Adrian Roos401caae2016-03-04 13:35:21 -0800368 if (FalsingLog.ENABLED) {
369 FalsingLog.i("onTrackingStarted", "");
370 }
Lucas Dupinbc9aac12018-03-04 20:18:15 -0800371 mHumanInteractionClassifier.setType(secure ?
372 Classifier.BOUNCER_UNLOCK : Classifier.UNLOCK);
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700373 mDataCollector.onTrackingStarted();
374 }
375
376 public void onTrackingStopped() {
377 mDataCollector.onTrackingStopped();
378 }
379
380 public void onNotificationActive() {
381 mDataCollector.onNotificationActive();
382 }
383
Adrian Roos9f0b0022016-11-09 15:56:50 -0800384 public void onNotificationDoubleTap(boolean accepted, float dx, float dy) {
385 if (FalsingLog.ENABLED) {
386 FalsingLog.i("onNotificationDoubleTap", "accepted=" + accepted
387 + " dx=" + dx + " dy=" + dy + " (px)");
388 }
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700389 mDataCollector.onNotificationDoubleTap();
390 }
391
392 public void setNotificationExpanded() {
393 mDataCollector.setNotificationExpanded();
394 }
395
396 public void onNotificatonStartDraggingDown() {
Adrian Roos401caae2016-03-04 13:35:21 -0800397 if (FalsingLog.ENABLED) {
398 FalsingLog.i("onNotificatonStartDraggingDown", "");
399 }
Blazej Magnowski9f01c5b2015-09-17 15:14:29 -0700400 mHumanInteractionClassifier.setType(Classifier.NOTIFICATION_DRAG_DOWN);
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700401 mDataCollector.onNotificatonStartDraggingDown();
402 }
403
404 public void onNotificatonStopDraggingDown() {
405 mDataCollector.onNotificatonStopDraggingDown();
406 }
407
408 public void onNotificationDismissed() {
409 mDataCollector.onNotificationDismissed();
410 }
411
412 public void onNotificatonStartDismissing() {
Adrian Roos401caae2016-03-04 13:35:21 -0800413 if (FalsingLog.ENABLED) {
414 FalsingLog.i("onNotificatonStartDismissing", "");
415 }
Blazej Magnowski9f01c5b2015-09-17 15:14:29 -0700416 mHumanInteractionClassifier.setType(Classifier.NOTIFICATION_DISMISS);
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700417 mDataCollector.onNotificatonStartDismissing();
418 }
419
420 public void onNotificatonStopDismissing() {
421 mDataCollector.onNotificatonStopDismissing();
422 }
423
424 public void onCameraOn() {
425 mDataCollector.onCameraOn();
426 }
427
428 public void onLeftAffordanceOn() {
429 mDataCollector.onLeftAffordanceOn();
430 }
431
432 public void onAffordanceSwipingStarted(boolean rightCorner) {
Adrian Roos401caae2016-03-04 13:35:21 -0800433 if (FalsingLog.ENABLED) {
434 FalsingLog.i("onAffordanceSwipingStarted", "");
435 }
Blazej Magnowski9f01c5b2015-09-17 15:14:29 -0700436 if (rightCorner) {
437 mHumanInteractionClassifier.setType(Classifier.RIGHT_AFFORDANCE);
438 } else {
439 mHumanInteractionClassifier.setType(Classifier.LEFT_AFFORDANCE);
440 }
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700441 mDataCollector.onAffordanceSwipingStarted(rightCorner);
442 }
443
444 public void onAffordanceSwipingAborted() {
445 mDataCollector.onAffordanceSwipingAborted();
446 }
447
448 public void onUnlockHintStarted() {
449 mDataCollector.onUnlockHintStarted();
450 }
451
452 public void onCameraHintStarted() {
453 mDataCollector.onCameraHintStarted();
454 }
455
456 public void onLeftAffordanceHintStarted() {
457 mDataCollector.onLeftAffordanceHintStarted();
458 }
459
460 public void onTouchEvent(MotionEvent event, int width, int height) {
Adrian Roos004437e2017-08-16 11:58:02 +0200461 if (event.getAction() == MotionEvent.ACTION_DOWN) {
462 mIsTouchScreen = event.isFromSource(InputDevice.SOURCE_TOUCHSCREEN);
Siarhei Vishniakou81e1ffd2018-05-04 16:08:22 -0700463 // If the bouncer was not shown during the down event,
464 // we want the entire gesture going to HumanInteractionClassifier
465 mBouncerOffOnDown = !mBouncerOn;
Adrian Roos004437e2017-08-16 11:58:02 +0200466 }
Siarhei Vishniakou81e1ffd2018-05-04 16:08:22 -0700467 if (mSessionActive) {
468 if (!mBouncerOn) {
469 // In case bouncer is "visible", but onFullyShown has not yet been called,
470 // avoid adding the event to DataCollector
471 mDataCollector.onTouchEvent(event, width, height);
472 }
473 if (mBouncerOffOnDown) {
474 mHumanInteractionClassifier.onTouchEvent(event);
475 }
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700476 }
477 }
Adrian Roos401caae2016-03-04 13:35:21 -0800478
479 public void dump(PrintWriter pw) {
480 pw.println("FALSING MANAGER");
481 pw.print("classifierEnabled="); pw.println(isClassiferEnabled() ? 1 : 0);
482 pw.print("mSessionActive="); pw.println(mSessionActive ? 1 : 0);
483 pw.print("mBouncerOn="); pw.println(mSessionActive ? 1 : 0);
484 pw.print("mState="); pw.println(StatusBarState.toShortString(mState));
485 pw.print("mScreenOn="); pw.println(mScreenOn ? 1 : 0);
486 pw.println();
487 }
Adrian Roos7bb38a92016-07-21 11:44:01 -0700488
489 public Uri reportRejectedTouch() {
490 if (mDataCollector.isEnabled()) {
491 return mDataCollector.reportRejectedTouch();
492 }
493 return null;
494 }
495
496 public boolean isReportingEnabled() {
497 return mDataCollector.isReportingEnabled();
498 }
Blazej Magnowski0e2ffbd2015-09-10 14:37:17 -0700499}