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
This commit is contained in:
Prabir Pradhan
2021-12-22 00:32:14 -08:00
parent d4e6b2aad7
commit 6288496385

View File

@@ -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<String> 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);
}
/**