From 51a3a37b1bcde73e34800fe8aec0ae69a554856c Mon Sep 17 00:00:00 2001 From: Bernardo Rufino Date: Tue, 15 Dec 2020 17:23:56 +0000 Subject: [PATCH] [Attempt #2] Block untrusted touches in enforcing mode ag/13253804 fixes test we broke in attempt #1 (ag/13228932). -- Original CL description (update "Test:" line): After getting enough feedback from dogfooders, the issues left open that we know of (that will still be addressed ofc) either don't hurt dogfood experience (eg. b/172627742 touch is blocked only during AGSA's -1 screen <> launcher side animation) or are 3p apps that will have to change their code at some point. So, turning the feature on in its final enforcing mode. Also removing toast since at this point this is more noise than signal. We're seeing many duplicate bugs (many of which are WAI) that the dogfooder would likely not notice if it wasn't for the toast. If there is a real issue the user will still notice by the unresponsiveness and given a bugreport we will be able to check via logcat. However, I have not removed the code completely and left that as part of b/169067926 since we may decide to turn it back on before or on DP/Beta. Bug: 158002302 Test: atest WindowUntrustedTouchTest WindowInputTests inputflinger_tests inputflinger_benchmarks libinput_tests libgui_test Test: Verify untrusted touches are blocked via logcat but no toast. Change-Id: I709711e60f5f4f563e018ee079ef89418e161d14 --- core/java/android/hardware/input/InputManager.java | 2 +- .../java/com/android/server/input/InputManagerService.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/java/android/hardware/input/InputManager.java b/core/java/android/hardware/input/InputManager.java index 300d99bbd6895..9d20f6d72d03a 100644 --- a/core/java/android/hardware/input/InputManager.java +++ b/core/java/android/hardware/input/InputManager.java @@ -195,7 +195,7 @@ public final class InputManager { */ @BlockUntrustedTouchesMode public static final int DEFAULT_BLOCK_UNTRUSTED_TOUCHES_MODE = - BlockUntrustedTouchesMode.PERMISSIVE; + BlockUntrustedTouchesMode.BLOCK; /** * Prevent touches from being consumed by apps if these touches passed through a non-trusted diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java index bff81e66ced30..71fcd1de3b8fc 100644 --- a/services/core/java/com/android/server/input/InputManagerService.java +++ b/services/core/java/com/android/server/input/InputManagerService.java @@ -161,6 +161,9 @@ public class InputManagerService extends IInputManager.Stub "com.snapchat.android" // b/173297887 }; + /** TODO(b/169067926): Remove this. */ + private static final boolean UNTRUSTED_TOUCHES_TOAST = false; + // Pointer to native input manager service object. private final long mPtr; @@ -2307,7 +2310,8 @@ public class InputManagerService extends IInputManager.Stub // Native callback private void notifyUntrustedTouch(String packageName) { // TODO(b/169067926): Remove toast after gathering feedback on dogfood. - if (ArrayUtils.contains(PACKAGE_BLOCKLIST_FOR_UNTRUSTED_TOUCHES_TOAST, packageName)) { + if (!UNTRUSTED_TOUCHES_TOAST || ArrayUtils.contains( + PACKAGE_BLOCKLIST_FOR_UNTRUSTED_TOUCHES_TOAST, packageName)) { Log.i(TAG, "Suppressing untrusted touch toast for " + packageName); return; }