From 2ce8b611b1718060121a8ed871d4b242ea96e7c5 Mon Sep 17 00:00:00 2001 From: Bernardo Rufino Date: Tue, 9 Mar 2021 09:58:23 +0000 Subject: [PATCH] Annotate obscuring opacity getter/setter w/ @FloatRange And document accordingly. Bug: 182215611 Test: Builds Change-Id: I7727abfba0611e3b56d83d29927ba7052ecb9489 --- core/api/current.txt | 2 +- core/api/test-current.txt | 2 +- core/java/android/hardware/input/InputManager.java | 12 ++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index db5d143662e47..c5e318dd066b5 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -18643,7 +18643,7 @@ package android.hardware.input { public final class InputManager { method public android.view.InputDevice getInputDevice(int); method public int[] getInputDeviceIds(); - method public float getMaximumObscuringOpacityForTouch(); + method @FloatRange(from=0, to=1) public float getMaximumObscuringOpacityForTouch(); method public void registerInputDeviceListener(android.hardware.input.InputManager.InputDeviceListener, android.os.Handler); method public void unregisterInputDeviceListener(android.hardware.input.InputManager.InputDeviceListener); method @Nullable public android.view.VerifiedInputEvent verifyInputEvent(@NonNull android.view.InputEvent); diff --git a/core/api/test-current.txt b/core/api/test-current.txt index fc1edf1156250..9b1cb36fceef6 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -995,7 +995,7 @@ package android.hardware.input { public final class InputManager { method public int getBlockUntrustedTouchesMode(@NonNull android.content.Context); method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void setBlockUntrustedTouchesMode(@NonNull android.content.Context, int); - method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void setMaximumObscuringOpacityForTouch(float); + 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 e15d6298d63dd..01fd3964df1d2 100644 --- a/core/java/android/hardware/input/InputManager.java +++ b/core/java/android/hardware/input/InputManager.java @@ -17,6 +17,7 @@ package android.hardware.input; import android.Manifest; +import android.annotation.FloatRange; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; @@ -922,8 +923,11 @@ public final class InputManager { * opacity of the windows above the touch-consuming window, per UID. Check documentation of * {@link LayoutParams#FLAG_NOT_TOUCHABLE} for more details. * + *

The value returned is between 0 (inclusive) and 1 (inclusive). + * * @see LayoutParams#FLAG_NOT_TOUCHABLE */ + @FloatRange(from = 0, to = 1) public float getMaximumObscuringOpacityForTouch() { Context context = ActivityThread.currentApplication(); return Settings.Global.getFloat(context.getContentResolver(), @@ -934,11 +938,11 @@ public final class InputManager { /** * Sets the maximum allowed obscuring opacity by UID to propagate touches. * - * For certain window types (eg. SAWs), the decision of honoring {@link LayoutParams + *

For certain window types (eg. SAWs), the decision of honoring {@link LayoutParams * #FLAG_NOT_TOUCHABLE} or not depends on the combined obscuring opacity of the windows * above the touch-consuming window. * - * For a certain UID: + *

For a certain UID: *

* - * This value should be between 0 (inclusive) and 1 (inclusive). + *

This value should be between 0 (inclusive) and 1 (inclusive). * * @see #getMaximumObscuringOpacityForTouch() * @@ -957,7 +961,7 @@ public final class InputManager { */ @TestApi @RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS) - public void setMaximumObscuringOpacityForTouch(float opacity) { + public void setMaximumObscuringOpacityForTouch(@FloatRange(from = 0, to = 1) float opacity) { if (opacity < 0 || opacity > 1) { throw new IllegalArgumentException( "Maximum obscuring opacity for touch should be >= 0 and <= 1");