diff --git a/core/api/current.txt b/core/api/current.txt index e0e2762cdd569..b3cb0bedd279c 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -18443,6 +18443,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 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 d6abbeca44808..11168e4f8d4e9 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -922,9 +922,8 @@ package android.hardware.input { public final class InputManager { method public int getBlockUntrustedTouchesMode(@NonNull android.content.Context); - method public float getMaximumObscuringOpacityForTouch(@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(@NonNull android.content.Context, float); + method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void setMaximumObscuringOpacityForTouch(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 6ab11068aac7c..e63dc112233f8 100644 --- a/core/java/android/hardware/input/InputManager.java +++ b/core/java/android/hardware/input/InputManager.java @@ -25,6 +25,7 @@ import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SystemService; import android.annotation.TestApi; +import android.app.ActivityThread; import android.compat.annotation.ChangeId; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; @@ -909,18 +910,17 @@ public final class InputManager { } /** - * Returns the maximum allowed obscuring opacity by UID to propagate touches. + * Returns the maximum allowed obscuring opacity per UID to propagate touches. * - * 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 certain window types (eg. {@link LayoutParams#TYPE_APPLICATION_OVERLAY}), 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, per UID. Check documentation of + * {@link LayoutParams#FLAG_NOT_TOUCHABLE} for more details. * - * @see #setMaximumObscuringOpacityForTouch(Context, float) - * - * @hide + * @see LayoutParams#FLAG_NOT_TOUCHABLE */ - @TestApi - public float getMaximumObscuringOpacityForTouch(@NonNull Context context) { + public float getMaximumObscuringOpacityForTouch() { + Context context = ActivityThread.currentApplication(); return Settings.Global.getFloat(context.getContentResolver(), Settings.Global.MAXIMUM_OBSCURING_OPACITY_FOR_TOUCH, DEFAULT_MAXIMUM_OBSCURING_OPACITY_FOR_TOUCH); @@ -946,17 +946,18 @@ public final class InputManager { * * This value should be between 0 (inclusive) and 1 (inclusive). * - * @see #getMaximumObscuringOpacityForTouch(Context) + * @see #getMaximumObscuringOpacityForTouch() * * @hide */ @TestApi @RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS) - public void setMaximumObscuringOpacityForTouch(@NonNull Context context, float opacity) { + public void setMaximumObscuringOpacityForTouch(float opacity) { if (opacity < 0 || opacity > 1) { throw new IllegalArgumentException( "Maximum obscuring opacity for touch should be >= 0 and <= 1"); } + Context context = ActivityThread.currentApplication(); Settings.Global.putFloat(context.getContentResolver(), Settings.Global.MAXIMUM_OBSCURING_OPACITY_FOR_TOUCH, opacity); } diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 743713c096be9..7e6267e8cce7d 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -15766,9 +15766,8 @@ public final class Settings { * touch, allow the UID to propagate the touch. * * - * @see android.hardware.input.InputManager#getMaximumObscuringOpacityForTouch(Context) - * @see android.hardware.input.InputManager#setMaximumObscuringOpacityForTouch(Context, - * float) + * @see android.hardware.input.InputManager#getMaximumObscuringOpacityForTouch() + * @see android.hardware.input.InputManager#setMaximumObscuringOpacityForTouch(float) * * @hide */ diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index 1327f9c6e8270..6edae93c35428 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -1555,17 +1555,26 @@ public interface WindowManager extends ViewManager { *
If none of these cases hold, the touch will not be delivered and a message will be * logged to logcat.
* + * + *This value is 0.8. Apps that want to gather this value from the system rather + * than hard-coding it might want to use {@link + * android.hardware.input.InputManager#getMaximumObscuringOpacityForTouch()}.
+ * * *