Merge "Annotate obscuring opacity getter/setter w/ @FloatRange" into sc-dev

This commit is contained in:
Bernardo Rufino
2021-03-09 14:18:28 +00:00
committed by Android (Google) Code Review
3 changed files with 10 additions and 6 deletions

View File

@@ -18782,7 +18782,7 @@ package android.hardware.input {
public final class InputManager { public final class InputManager {
method public android.view.InputDevice getInputDevice(int); method public android.view.InputDevice getInputDevice(int);
method public int[] getInputDeviceIds(); 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 registerInputDeviceListener(android.hardware.input.InputManager.InputDeviceListener, android.os.Handler);
method public void unregisterInputDeviceListener(android.hardware.input.InputManager.InputDeviceListener); method public void unregisterInputDeviceListener(android.hardware.input.InputManager.InputDeviceListener);
method @Nullable public android.view.VerifiedInputEvent verifyInputEvent(@NonNull android.view.InputEvent); method @Nullable public android.view.VerifiedInputEvent verifyInputEvent(@NonNull android.view.InputEvent);

View File

@@ -1128,7 +1128,7 @@ package android.hardware.input {
public final class InputManager { public final class InputManager {
method public int getBlockUntrustedTouchesMode(@NonNull android.content.Context); 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 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 field public static final long BLOCK_UNTRUSTED_TOUCHES = 158002302L; // 0x96aec7eL
} }

View File

@@ -17,6 +17,7 @@
package android.hardware.input; package android.hardware.input;
import android.Manifest; import android.Manifest;
import android.annotation.FloatRange;
import android.annotation.IntDef; import android.annotation.IntDef;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable; 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 * opacity of the windows above the touch-consuming window, per UID. Check documentation of
* {@link LayoutParams#FLAG_NOT_TOUCHABLE} for more details. * {@link LayoutParams#FLAG_NOT_TOUCHABLE} for more details.
* *
* <p>The value returned is between 0 (inclusive) and 1 (inclusive).
*
* @see LayoutParams#FLAG_NOT_TOUCHABLE * @see LayoutParams#FLAG_NOT_TOUCHABLE
*/ */
@FloatRange(from = 0, to = 1)
public float getMaximumObscuringOpacityForTouch() { public float getMaximumObscuringOpacityForTouch() {
Context context = ActivityThread.currentApplication(); Context context = ActivityThread.currentApplication();
return Settings.Global.getFloat(context.getContentResolver(), 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. * Sets the maximum allowed obscuring opacity by UID to propagate touches.
* *
* For certain window types (eg. SAWs), the decision of honoring {@link LayoutParams * <p>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 * #FLAG_NOT_TOUCHABLE} or not depends on the combined obscuring opacity of the windows
* above the touch-consuming window. * above the touch-consuming window.
* *
* For a certain UID: * <p>For a certain UID:
* <ul> * <ul>
* <li>If it's the same as the UID of the touch-consuming window, allow it to propagate * <li>If it's the same as the UID of the touch-consuming window, allow it to propagate
* the touch. * the touch.
@@ -949,7 +953,7 @@ public final class InputManager {
* touch, allow the UID to propagate the touch. * touch, allow the UID to propagate the touch.
* </ul> * </ul>
* *
* This value should be between 0 (inclusive) and 1 (inclusive). * <p>This value should be between 0 (inclusive) and 1 (inclusive).
* *
* @see #getMaximumObscuringOpacityForTouch() * @see #getMaximumObscuringOpacityForTouch()
* *
@@ -957,7 +961,7 @@ public final class InputManager {
*/ */
@TestApi @TestApi
@RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS) @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) { if (opacity < 0 || opacity > 1) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Maximum obscuring opacity for touch should be >= 0 and <= 1"); "Maximum obscuring opacity for touch should be >= 0 and <= 1");