From 6288496385b49246d06bcbfdb5b0aacc3a9aaf1f Mon Sep 17 00:00:00 2001 From: Prabir Pradhan Date: Wed, 22 Dec 2021 00:32:14 -0800 Subject: [PATCH 1/2] Move InputFeature flag definitions to AIDL (2/2) We convert the InputFeatures flags into AIDL enums that will have values generated in both native and java code so that the value only has to be defined once. Bug: 162194035 Test: build, presubmit Change-Id: I8176265079292ee969c409ddd52676a52f208601 --- core/java/android/view/WindowManager.java | 56 ++++++++++++++++------- 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index 32646113fd310..e51a2adc2dd84 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -105,6 +105,7 @@ import android.graphics.Region; import android.os.Build; import android.os.Bundle; import android.os.IBinder; +import android.os.IInputConstants; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; @@ -120,6 +121,7 @@ import android.view.accessibility.AccessibilityNodeInfo; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Objects; @@ -3331,7 +3333,8 @@ public interface WindowManager extends ViewManager { * * @hide */ - public static final int INPUT_FEATURE_DISABLE_POINTER_GESTURES = 0x00000001; + public static final int INPUT_FEATURE_DISABLE_POINTER_GESTURES = + IInputConstants.InputFeature.DISABLE_POINTER_GESTURES; /** * Does not construct an input channel for this window. The channel will therefore @@ -3339,7 +3342,8 @@ public interface WindowManager extends ViewManager { * * @hide */ - public static final int INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002; + public static final int INPUT_FEATURE_NO_INPUT_CHANNEL = + IInputConstants.InputFeature.NO_INPUT_CHANNEL; /** * When this window has focus, does not call user activity for all input events so @@ -3352,7 +3356,8 @@ public interface WindowManager extends ViewManager { * @hide */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) - public static final int INPUT_FEATURE_DISABLE_USER_ACTIVITY = 0x00000004; + public static final int INPUT_FEATURE_DISABLE_USER_ACTIVITY = + IInputConstants.InputFeature.DISABLE_USER_ACTIVITY; /** * An input spy window. This window will receive all pointer events within its touchable @@ -3361,7 +3366,8 @@ public interface WindowManager extends ViewManager { * event's coordinates. * @hide */ - public static final int INPUT_FEATURE_SPY = 0x00000020; + public static final int INPUT_FEATURE_SPY = + IInputConstants.InputFeature.SPY; /** * When used with the window flag {@link #FLAG_NOT_TOUCHABLE}, this window will continue @@ -3377,7 +3383,8 @@ public interface WindowManager extends ViewManager { * * @hide */ - public static final int INPUT_FEATURE_INTERCEPTS_STYLUS = 0x00000040; + public static final int INPUT_FEATURE_INTERCEPTS_STYLUS = + IInputConstants.InputFeature.INTERCEPTS_STYLUS; /** * An internal annotation for flags that can be specified to {@link #inputFeatures}. @@ -3389,6 +3396,7 @@ public interface WindowManager extends ViewManager { INPUT_FEATURE_DISABLE_POINTER_GESTURES, INPUT_FEATURE_NO_INPUT_CHANNEL, INPUT_FEATURE_DISABLE_USER_ACTIVITY, + INPUT_FEATURE_SPY, INPUT_FEATURE_INTERCEPTS_STYLUS, }) public @interface InputFeatureFlags {} @@ -3399,6 +3407,7 @@ public interface WindowManager extends ViewManager { * @see #INPUT_FEATURE_DISABLE_POINTER_GESTURES * @see #INPUT_FEATURE_NO_INPUT_CHANNEL * @see #INPUT_FEATURE_DISABLE_USER_ACTIVITY + * @see #INPUT_FEATURE_SPY * @see #INPUT_FEATURE_INTERCEPTS_STYLUS * @hide */ @@ -4503,7 +4512,7 @@ public interface WindowManager extends ViewManager { sb.append(hasSystemUiListeners); } if (inputFeatures != 0) { - sb.append(" if=").append(inputFeatureToString(inputFeatures)); + sb.append(" if=").append(inputFeaturesToString(inputFeatures)); } if (userActivityTimeout >= 0) { sb.append(" userActivityTimeout=").append(userActivityTimeout); @@ -4805,17 +4814,32 @@ public interface WindowManager extends ViewManager { } } - private static String inputFeatureToString(int inputFeature) { - switch (inputFeature) { - case INPUT_FEATURE_DISABLE_POINTER_GESTURES: - return "DISABLE_POINTER_GESTURES"; - case INPUT_FEATURE_NO_INPUT_CHANNEL: - return "NO_INPUT_CHANNEL"; - case INPUT_FEATURE_DISABLE_USER_ACTIVITY: - return "DISABLE_USER_ACTIVITY"; - default: - return Integer.toString(inputFeature); + private static String inputFeaturesToString(int inputFeatures) { + final List features = new ArrayList<>(); + if ((inputFeatures & INPUT_FEATURE_DISABLE_POINTER_GESTURES) != 0) { + inputFeatures &= ~INPUT_FEATURE_DISABLE_POINTER_GESTURES; + features.add("INPUT_FEATURE_DISABLE_POINTER_GESTURES"); } + if ((inputFeatures & INPUT_FEATURE_NO_INPUT_CHANNEL) != 0) { + inputFeatures &= ~INPUT_FEATURE_NO_INPUT_CHANNEL; + features.add("INPUT_FEATURE_NO_INPUT_CHANNEL"); + } + if ((inputFeatures & INPUT_FEATURE_DISABLE_USER_ACTIVITY) != 0) { + inputFeatures &= ~INPUT_FEATURE_DISABLE_USER_ACTIVITY; + features.add("INPUT_FEATURE_DISABLE_USER_ACTIVITY"); + } + if ((inputFeatures & INPUT_FEATURE_SPY) != 0) { + inputFeatures &= ~INPUT_FEATURE_SPY; + features.add("INPUT_FEATURE_SPY"); + } + if ((inputFeatures & INPUT_FEATURE_INTERCEPTS_STYLUS) != 0) { + inputFeatures &= ~INPUT_FEATURE_INTERCEPTS_STYLUS; + features.add("INPUT_FEATURE_INTERCEPTS_STYLUS"); + } + if (inputFeatures != 0) { + features.add(Integer.toHexString(inputFeatures)); + } + return String.join(" | ", features); } /** From 68dcaf6eba5d74964683c60a3dd8f14a4a151ff3 Mon Sep 17 00:00:00 2001 From: Prabir Pradhan Date: Wed, 22 Dec 2021 23:26:46 -0800 Subject: [PATCH 2/2] Remove unused InputFeature flag DISABLE_POINTER_GESTURES Bug: None Test: build Change-Id: Ic521e47ddbfffcc84d663274281fe8868c01e045 --- core/java/android/view/WindowManager.java | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index e51a2adc2dd84..f94125d2d5db9 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -3326,16 +3326,6 @@ public interface WindowManager extends ViewManager { */ public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS = 3; - /** - * When this window has focus, disable touch pad pointer gesture processing. - * The window will receive raw position updates from the touch pad instead - * of pointer movements and synthetic touch events. - * - * @hide - */ - public static final int INPUT_FEATURE_DISABLE_POINTER_GESTURES = - IInputConstants.InputFeature.DISABLE_POINTER_GESTURES; - /** * Does not construct an input channel for this window. The channel will therefore * be incapable of receiving input. @@ -3393,7 +3383,6 @@ public interface WindowManager extends ViewManager { */ @Retention(RetentionPolicy.SOURCE) @IntDef(flag = true, prefix = { "INPUT_FEATURE_" }, value = { - INPUT_FEATURE_DISABLE_POINTER_GESTURES, INPUT_FEATURE_NO_INPUT_CHANNEL, INPUT_FEATURE_DISABLE_USER_ACTIVITY, INPUT_FEATURE_SPY, @@ -3404,7 +3393,6 @@ public interface WindowManager extends ViewManager { /** * Control special features of the input subsystem. * - * @see #INPUT_FEATURE_DISABLE_POINTER_GESTURES * @see #INPUT_FEATURE_NO_INPUT_CHANNEL * @see #INPUT_FEATURE_DISABLE_USER_ACTIVITY * @see #INPUT_FEATURE_SPY @@ -4816,10 +4804,6 @@ public interface WindowManager extends ViewManager { private static String inputFeaturesToString(int inputFeatures) { final List features = new ArrayList<>(); - if ((inputFeatures & INPUT_FEATURE_DISABLE_POINTER_GESTURES) != 0) { - inputFeatures &= ~INPUT_FEATURE_DISABLE_POINTER_GESTURES; - features.add("INPUT_FEATURE_DISABLE_POINTER_GESTURES"); - } if ((inputFeatures & INPUT_FEATURE_NO_INPUT_CHANNEL) != 0) { inputFeatures &= ~INPUT_FEATURE_NO_INPUT_CHANNEL; features.add("INPUT_FEATURE_NO_INPUT_CHANNEL");