diff --git a/core/api/current.txt b/core/api/current.txt index 6523c2aca92d7..2d1cfe413fc1b 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -18782,7 +18782,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 5f14be22358a0..7b5b1989c1e5a 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -1128,7 +1128,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). * * @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");