diff --git a/core/api/test-current.txt b/core/api/test-current.txt index 5168e914a1c19..7bf51d14f06bd 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -1252,12 +1252,10 @@ package android.hardware.input { public final class InputManager { method public void addUniqueIdAssociation(@NonNull String, @NonNull String); - method public int getBlockUntrustedTouchesMode(@NonNull android.content.Context); method @Nullable public String getCurrentKeyboardLayoutForInputDevice(@NonNull android.hardware.input.InputDeviceIdentifier); method @NonNull public java.util.List getKeyboardLayoutDescriptorsForInputDevice(@NonNull android.view.InputDevice); method @RequiresPermission(android.Manifest.permission.SET_KEYBOARD_LAYOUT) public void removeKeyboardLayoutForInputDevice(@NonNull android.hardware.input.InputDeviceIdentifier, @NonNull String); method public void removeUniqueIdAssociation(@NonNull String); - method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void setBlockUntrustedTouchesMode(@NonNull android.content.Context, int); method @RequiresPermission(android.Manifest.permission.SET_KEYBOARD_LAYOUT) public void setCurrentKeyboardLayoutForInputDevice(@NonNull android.hardware.input.InputDeviceIdentifier, @NonNull String); method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void setMaximumObscuringOpacityForTouch(@FloatRange(from=0, to=1) float); field public static final long BLOCK_UNTRUSTED_TOUCHES = 158002302L; // 0x96aec7eL diff --git a/core/java/android/hardware/input/InputManager.java b/core/java/android/hardware/input/InputManager.java index 90db4614bf63e..54f6fef3c3299 100644 --- a/core/java/android/hardware/input/InputManager.java +++ b/core/java/android/hardware/input/InputManager.java @@ -36,7 +36,6 @@ import android.hardware.lights.LightState; import android.hardware.lights.LightsManager; import android.hardware.lights.LightsRequest; import android.os.Binder; -import android.os.BlockUntrustedTouchesMode; import android.os.Build; import android.os.CombinedVibration; import android.os.Handler; @@ -67,7 +66,6 @@ import android.view.WindowManager.LayoutParams; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.os.SomeArgs; -import com.android.internal.util.ArrayUtils; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -87,13 +85,6 @@ public final class InputManager { private static final int MSG_DEVICE_REMOVED = 2; private static final int MSG_DEVICE_CHANGED = 3; - /** @hide */ - public static final int[] BLOCK_UNTRUSTED_TOUCHES_MODES = { - BlockUntrustedTouchesMode.DISABLED, - BlockUntrustedTouchesMode.PERMISSIVE, - BlockUntrustedTouchesMode.BLOCK - }; - private static InputManager sInstance; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) @@ -199,14 +190,6 @@ public final class InputManager { */ public static final float DEFAULT_MAXIMUM_OBSCURING_OPACITY_FOR_TOUCH = .8f; - /** - * Default mode of the block untrusted touches mode feature. - * @hide - */ - @BlockUntrustedTouchesMode - public static final int DEFAULT_BLOCK_UNTRUSTED_TOUCHES_MODE = - BlockUntrustedTouchesMode.BLOCK; - /** * Prevent touches from being consumed by apps if these touches passed through a non-trusted * window from a different UID and are considered unsafe. @@ -1014,50 +997,6 @@ public final class InputManager { Settings.Global.MAXIMUM_OBSCURING_OPACITY_FOR_TOUCH, opacity); } - /** - * Returns the current mode of the block untrusted touches feature, one of: - * - * - * @hide - */ - @TestApi - @BlockUntrustedTouchesMode - public int getBlockUntrustedTouchesMode(@NonNull Context context) { - int mode = Settings.Global.getInt(context.getContentResolver(), - Settings.Global.BLOCK_UNTRUSTED_TOUCHES_MODE, DEFAULT_BLOCK_UNTRUSTED_TOUCHES_MODE); - if (!ArrayUtils.contains(BLOCK_UNTRUSTED_TOUCHES_MODES, mode)) { - Log.w(TAG, "Unknown block untrusted touches feature mode " + mode + ", using " - + "default " + DEFAULT_BLOCK_UNTRUSTED_TOUCHES_MODE); - return DEFAULT_BLOCK_UNTRUSTED_TOUCHES_MODE; - } - return mode; - } - - /** - * Sets the mode of the block untrusted touches feature to one of: - * - * - * @hide - */ - @TestApi - @RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS) - public void setBlockUntrustedTouchesMode(@NonNull Context context, - @BlockUntrustedTouchesMode int mode) { - if (!ArrayUtils.contains(BLOCK_UNTRUSTED_TOUCHES_MODES, mode)) { - throw new IllegalArgumentException("Invalid feature mode " + mode); - } - Settings.Global.putInt(context.getContentResolver(), - Settings.Global.BLOCK_UNTRUSTED_TOUCHES_MODE, mode); - } - /** * Queries the framework about whether any physical keys exist on any currently attached input * devices that are capable of producing the given array of key codes. diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 1528f6a59dcb0..60b14299e6718 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -16884,22 +16884,6 @@ public final class Settings { */ public static final String SHOW_NEW_NOTIF_DISMISS = "show_new_notif_dismiss"; - /** - * Block untrusted touches mode. - * - * Can be one of: - * - * - * @hide - */ - @Readable - public static final String BLOCK_UNTRUSTED_TOUCHES_MODE = "block_untrusted_touches"; - /** * The maximum allowed obscuring opacity by UID to propagate touches. * diff --git a/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java b/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java index 0371dccaf55a2..990c2e2272804 100644 --- a/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java +++ b/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java @@ -156,7 +156,6 @@ public class SettingsBackupTest { Settings.Global.BLE_SCAN_LOW_LATENCY_WINDOW_MS, Settings.Global.BLE_SCAN_LOW_LATENCY_INTERVAL_MS, Settings.Global.BLE_SCAN_BACKGROUND_MODE, - Settings.Global.BLOCK_UNTRUSTED_TOUCHES_MODE, Settings.Global.BLOCKED_SLICES, Settings.Global.BLOCKING_HELPER_DISMISS_TO_VIEW_RATIO_LIMIT, Settings.Global.BLOCKING_HELPER_STREAK_LIMIT, diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java index 125307ca73b0b..d04006a4b97a7 100644 --- a/services/core/java/com/android/server/input/InputManagerService.java +++ b/services/core/java/com/android/server/input/InputManagerService.java @@ -115,7 +115,6 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.internal.messages.nano.SystemMessageProto.SystemMessage; import com.android.internal.notification.SystemNotificationChannels; import com.android.internal.os.SomeArgs; -import com.android.internal.util.ArrayUtils; import com.android.internal.util.DumpUtils; import com.android.internal.util.Preconditions; import com.android.internal.util.XmlUtils; @@ -171,19 +170,6 @@ public class InputManagerService extends IInputManager.Stub private static final int DEFAULT_VIBRATION_MAGNITUDE = 192; - /** - * We know the issue and are working to fix it, so suppressing the toast to not annoy - * dogfooders. - * - * TODO(b/169067926): Remove this - */ - private static final String[] PACKAGE_BLOCKLIST_FOR_UNTRUSTED_TOUCHES_TOAST = { - "com.snapchat.android" // b/173297887 - }; - - /** TODO(b/169067926): Remove this. */ - private static final boolean UNTRUSTED_TOUCHES_TOAST = false; - private final NativeInputManagerService mNative; private final Context mContext; @@ -462,7 +448,6 @@ public class InputManagerService extends IInputManager.Stub registerAccessibilityLargePointerSettingObserver(); registerLongPressTimeoutObserver(); registerMaximumObscuringOpacityForTouchSettingObserver(); - registerBlockUntrustedTouchesModeSettingObserver(); mContext.registerReceiver(new BroadcastReceiver() { @Override @@ -479,7 +464,6 @@ public class InputManagerService extends IInputManager.Stub updateAccessibilityLargePointerFromSettings(); updateDeepPressStatusFromSettings("just booted"); updateMaximumObscuringOpacityForTouchFromSettings(); - updateBlockUntrustedTouchesModeFromSettings(); } // TODO(BT) Pass in parameter for bluetooth system @@ -1938,23 +1922,6 @@ public class InputManagerService extends IInputManager.Stub }, UserHandle.USER_ALL); } - private void registerBlockUntrustedTouchesModeSettingObserver() { - mContext.getContentResolver().registerContentObserver( - Settings.Global.getUriFor(Settings.Global.BLOCK_UNTRUSTED_TOUCHES_MODE), - /* notifyForDescendants */ true, - new ContentObserver(mHandler) { - @Override - public void onChange(boolean selfChange) { - updateBlockUntrustedTouchesModeFromSettings(); - } - }, UserHandle.USER_ALL); - } - - private void updateBlockUntrustedTouchesModeFromSettings() { - final int mode = InputManager.getInstance().getBlockUntrustedTouchesMode(mContext); - mNative.setBlockUntrustedTouchesMode(mode); - } - private void registerMaximumObscuringOpacityForTouchSettingObserver() { mContext.getContentResolver().registerContentObserver( Settings.Global.getUriFor(Settings.Global.MAXIMUM_OBSCURING_OPACITY_FOR_TOUCH), @@ -2854,22 +2821,6 @@ public class InputManagerService extends IInputManager.Stub mWindowManagerCallbacks.notifyDropWindow(token, x, y); } - // Native callback - @SuppressWarnings("unused") - private void notifyUntrustedTouch(String packageName) { - // TODO(b/169067926): Remove toast after gathering feedback on dogfood. - if (!UNTRUSTED_TOUCHES_TOAST || ArrayUtils.contains( - PACKAGE_BLOCKLIST_FOR_UNTRUSTED_TOUCHES_TOAST, packageName)) { - Log.i(TAG, "Suppressing untrusted touch toast for " + packageName); - return; - } - DisplayThread.getHandler().post(() -> - Toast.makeText(mContext, - "Touch obscured by " + packageName - + " will be blocked. Check go/untrusted-touches", - Toast.LENGTH_SHORT).show()); - } - // Native callback. @SuppressWarnings("unused") private void notifyNoFocusedWindowAnr(InputApplicationHandle inputApplicationHandle) { diff --git a/services/core/java/com/android/server/input/NativeInputManagerService.java b/services/core/java/com/android/server/input/NativeInputManagerService.java index 2169155343cd4..b29619eac2ed6 100644 --- a/services/core/java/com/android/server/input/NativeInputManagerService.java +++ b/services/core/java/com/android/server/input/NativeInputManagerService.java @@ -68,8 +68,6 @@ public interface NativeInputManagerService { void setMaximumObscuringOpacityForTouch(float opacity); - void setBlockUntrustedTouchesMode(int mode); - int injectInputEvent(InputEvent event, int pid, int uid, int syncMode, int timeoutMillis, int policyFlags); @@ -233,9 +231,6 @@ public interface NativeInputManagerService { @Override public native void setMaximumObscuringOpacityForTouch(float opacity); - @Override - public native void setBlockUntrustedTouchesMode(int mode); - @Override public native int injectInputEvent(InputEvent event, int pid, int uid, int syncMode, int timeoutMillis, int policyFlags); diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp index ffda8be56b3f8..d551944a745a5 100644 --- a/services/core/jni/com_android_server_input_InputManagerService.cpp +++ b/services/core/jni/com_android_server_input_InputManagerService.cpp @@ -71,7 +71,6 @@ using android::base::ParseUint; using android::base::StringPrintf; -using android::os::BlockUntrustedTouchesMode; using android::os::InputEventInjectionResult; using android::os::InputEventInjectionSync; @@ -108,7 +107,6 @@ static struct { jmethodID notifySensorEvent; jmethodID notifySensorAccuracy; jmethodID notifyVibratorState; - jmethodID notifyUntrustedTouch; jmethodID filterInputEvent; jmethodID interceptKeyBeforeQueueing; jmethodID interceptMotionBeforeQueueingNonInteractive; @@ -330,7 +328,6 @@ public: void notifySensorAccuracy(int32_t deviceId, InputDeviceSensorType sensorType, InputDeviceSensorAccuracy accuracy) override; void notifyVibratorState(int32_t deviceId, bool isOn) override; - void notifyUntrustedTouch(const std::string& obscuringPackage) override; bool filterInputEvent(const InputEvent* inputEvent, uint32_t policyFlags) override; void getDispatcherConfiguration(InputDispatcherConfiguration* outConfig) override; void interceptKeyBeforeQueueing(const KeyEvent* keyEvent, uint32_t& policyFlags) override; @@ -898,17 +895,6 @@ void NativeInputManager::notifyInputChannelBroken(const sp& token) { } } -void NativeInputManager::notifyUntrustedTouch(const std::string& obscuringPackage) { -#if DEBUG_INPUT_DISPATCHER_POLICY - ALOGD("notifyUntrustedTouch - obscuringPackage=%s", obscuringPackage.c_str()); -#endif - ATRACE_CALL(); - JNIEnv* env = jniEnv(); - jstring jPackage = env->NewStringUTF(obscuringPackage.c_str()); - env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifyUntrustedTouch, jPackage); - checkAndClearExceptionFromCallback(env, "notifyUntrustedTouch"); -} - void NativeInputManager::notifyFocusChanged(const sp& oldToken, const sp& newToken) { #if DEBUG_INPUT_DISPATCHER_POLICY @@ -1712,13 +1698,6 @@ static void nativeSetMaximumObscuringOpacityForTouch(JNIEnv* env, jobject native im->getInputManager()->getDispatcher().setMaximumObscuringOpacityForTouch(opacity); } -static void nativeSetBlockUntrustedTouchesMode(JNIEnv* env, jobject nativeImplObj, jint mode) { - NativeInputManager* im = getNativeInputManager(env, nativeImplObj); - - im->getInputManager()->getDispatcher().setBlockUntrustedTouchesMode( - static_cast(mode)); -} - static jint nativeInjectInputEvent(JNIEnv* env, jobject nativeImplObj, jobject inputEventObj, jint injectorPid, jint injectorUid, jint syncMode, jint timeoutMillis, jint policyFlags) { @@ -2357,7 +2336,6 @@ static const JNINativeMethod gInputManagerMethods[] = { {"setInTouchMode", "(ZIIZ)Z", (void*)nativeSetInTouchMode}, {"setMaximumObscuringOpacityForTouch", "(F)V", (void*)nativeSetMaximumObscuringOpacityForTouch}, - {"setBlockUntrustedTouchesMode", "(I)V", (void*)nativeSetBlockUntrustedTouchesMode}, {"injectInputEvent", "(Landroid/view/InputEvent;IIIII)I", (void*)nativeInjectInputEvent}, {"verifyInputEvent", "(Landroid/view/InputEvent;)Landroid/view/VerifiedInputEvent;", (void*)nativeVerifyInputEvent}, @@ -2476,9 +2454,6 @@ int register_android_server_InputManager(JNIEnv* env) { GET_METHOD_ID(gServiceClassInfo.notifyVibratorState, clazz, "notifyVibratorState", "(IZ)V"); - GET_METHOD_ID(gServiceClassInfo.notifyUntrustedTouch, clazz, "notifyUntrustedTouch", - "(Ljava/lang/String;)V"); - GET_METHOD_ID(gServiceClassInfo.notifyNoFocusedWindowAnr, clazz, "notifyNoFocusedWindowAnr", "(Landroid/view/InputApplicationHandle;)V");