Merge "Open IM.getMaximumObscuringOpacityForTouch() and update docs."
This commit is contained in:
committed by
Android (Google) Code Review
commit
0702b2fa10
@@ -18512,6 +18512,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);
|
||||
|
||||
@@ -931,9 +931,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
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
* <p>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);
|
||||
}
|
||||
|
||||
@@ -14730,9 +14730,8 @@ public final class Settings {
|
||||
* touch, allow the UID to propagate the touch.
|
||||
* </ul>
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
@@ -1555,17 +1555,26 @@ public interface WindowManager extends ViewManager {
|
||||
* <li><b>Fully transparent windows</b>: This window has {@link LayoutParams#alpha} equal
|
||||
* to 0.
|
||||
* <li><b>One SAW window with enough transparency</b>: This window is of type {@link
|
||||
* #TYPE_APPLICATION_OVERLAY}, has {@link LayoutParams#alpha} below or equal to <b>0.8</b>
|
||||
* and it's the <b>only</b> window of type {@link #TYPE_APPLICATION_OVERLAY} from this UID
|
||||
* in the touch path.
|
||||
* #TYPE_APPLICATION_OVERLAY}, has {@link LayoutParams#alpha} below or equal to the
|
||||
* <a href="#MaximumOpacity">maximum obscuring opacity</a> (see below) and it's the
|
||||
* <b>only</b> window of type {@link #TYPE_APPLICATION_OVERLAY} from this UID in the touch
|
||||
* path.
|
||||
* <li><b>Multiple SAW windows with enough transparency</b>: The multiple overlapping
|
||||
* {@link #TYPE_APPLICATION_OVERLAY} windows in the
|
||||
* touch path from this UID have a <b>combined obscuring opacity</b> below or equal to
|
||||
* <b>0.8</b>. See section below on how to compute this value.
|
||||
* the <a href="#MaximumOpacity">maximum obscuring opacity</a>. See section
|
||||
* <a href="#ObscuringOpacity">Combined obscuring opacity</a> below on how to compute this
|
||||
* value.
|
||||
* </ol>
|
||||
* <p>If none of these cases hold, the touch will not be delivered and a message will be
|
||||
* logged to logcat.</p>
|
||||
*
|
||||
* <a name="MaximumOpacity"></a>
|
||||
* <h3>Maximum obscuring opacity</h3>
|
||||
* <p>This value is <b>0.8</b>. 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()}.</p>
|
||||
*
|
||||
* <a name="ObscuringOpacity"></a>
|
||||
* <h3>Combined obscuring opacity</h3>
|
||||
*
|
||||
|
||||
@@ -1820,8 +1820,7 @@ public class InputManagerService extends IInputManager.Stub
|
||||
}
|
||||
|
||||
private void updateMaximumObscuringOpacityForTouchFromSettings() {
|
||||
final float opacity = InputManager.getInstance().getMaximumObscuringOpacityForTouch(
|
||||
mContext);
|
||||
final float opacity = InputManager.getInstance().getMaximumObscuringOpacityForTouch();
|
||||
if (opacity < 0 || opacity > 1) {
|
||||
Log.e(TAG, "Invalid maximum obscuring opacity " + opacity
|
||||
+ ", it should be >= 0 and <= 1, rejecting update.");
|
||||
|
||||
Reference in New Issue
Block a user