Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ed142dca authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

WindowInfo: Merge InputConfig and Feature flags

InputFeatureFlags are now a WM-only flag, but is temporarily used by
InputWindowHandle until the cleanup is completed.

Bug: 216806304
Test: atest libgui_test
Test: atest inputflinger_tests
Change-Id: I1260431e99d2c50261dc8b0356dc3e21ba76d39f
parent 5546ba69
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -106,6 +106,7 @@ public final class InputWindowHandle {
    public String packageName;

    // Window input features.
    @WindowManager.LayoutParams.InputFeatureFlags
    public int inputFeatures;

    // Display this input is on.
+5 −10
Original line number Diff line number Diff line
@@ -106,7 +106,6 @@ 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;
@@ -3360,8 +3359,7 @@ public interface WindowManager extends ViewManager {
         *
         * @hide
         */
        public static final int INPUT_FEATURE_NO_INPUT_CHANNEL =
                IInputConstants.InputFeature.NO_INPUT_CHANNEL;
        public static final int INPUT_FEATURE_NO_INPUT_CHANNEL = 1 << 0;

        /**
         * When this window has focus, does not call user activity for all input events so
@@ -3374,18 +3372,16 @@ public interface WindowManager extends ViewManager {
         * @hide
         */
        @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
        public static final int INPUT_FEATURE_DISABLE_USER_ACTIVITY =
                IInputConstants.InputFeature.DISABLE_USER_ACTIVITY;
        public static final int INPUT_FEATURE_DISABLE_USER_ACTIVITY = 1 << 1;

        /**
         * An input spy window. This window will receive all pointer events within its touchable
         * area, but will will not stop events from being sent to other windows below it in z-order.
         * area, but will not stop events from being sent to other windows below it in z-order.
         * An input event will be dispatched to all spy windows above the top non-spy window at the
         * event's coordinates.
         * @hide
         */
        public static final int INPUT_FEATURE_SPY =
                IInputConstants.InputFeature.SPY;
        public static final int INPUT_FEATURE_SPY = 1 << 2;

        /**
         * When used with the window flag {@link #FLAG_NOT_TOUCHABLE}, this window will continue
@@ -3401,8 +3397,7 @@ public interface WindowManager extends ViewManager {
         *
         * @hide
         */
        public static final int INPUT_FEATURE_INTERCEPTS_STYLUS =
                IInputConstants.InputFeature.INTERCEPTS_STYLUS;
        public static final int INPUT_FEATURE_INTERCEPTS_STYLUS = 1 << 3;

        /**
         * An internal annotation for flags that can be specified to {@link #inputFeatures}.
+36 −7
Original line number Diff line number Diff line
@@ -162,13 +162,23 @@ bool NativeInputWindowHandle::updateInfo() {
    mInfo.layoutParamsFlags = flags;
    mInfo.layoutParamsType = type;

    // TODO(b/216806304): Expose InputConfig as InputWindowHandle API so we don't have to use
    //  WindowManager.LayoutParams.InputFeatureFlags here.
    const auto inputFeatures =
            static_cast<uint32_t>(env->GetIntField(obj, gInputWindowHandleClassInfo.inputFeatures));

    using InputConfig = gui::WindowInfo::InputConfig;
    // Determine the value for each of the InputConfig flags. We rely on a switch statement and
    // -Wswitch-enum to give us a build error if we forget to explicitly handle an InputConfig flag.
    mInfo.inputConfig = InputConfig::NONE;
    InputConfig enumerationStart = InputConfig::NONE;
    mInfo.inputConfig = InputConfig::DEFAULT;
    InputConfig enumerationStart = InputConfig::DEFAULT;
    switch (enumerationStart) {
        case InputConfig::NONE:
        case InputConfig::DEFAULT:
            FALLTHROUGH_INTENDED;
        case InputConfig::NO_INPUT_CHANNEL:
            if ((inputFeatures & 0x00000001) != 0) {
                mInfo.inputConfig |= InputConfig::NO_INPUT_CHANNEL;
            }
            FALLTHROUGH_INTENDED;
        case InputConfig::NOT_VISIBLE:
            if (env->GetBooleanField(obj, gInputWindowHandleClassInfo.visible) == JNI_FALSE) {
@@ -219,6 +229,27 @@ bool NativeInputWindowHandle::updateInfo() {
            if (flags.test(WindowInfo::Flag::SLIPPERY)) {
                mInfo.inputConfig |= InputConfig::SLIPPERY;
            }
            FALLTHROUGH_INTENDED;
        case InputConfig::DISABLE_USER_ACTIVITY:
            if ((inputFeatures & 0x00000002) != 0) {
                mInfo.inputConfig |= InputConfig::DISABLE_USER_ACTIVITY;
            }
            FALLTHROUGH_INTENDED;
        case InputConfig::DROP_INPUT:
            // This flag cannot be set from Java.
            FALLTHROUGH_INTENDED;
        case InputConfig::DROP_INPUT_IF_OBSCURED:
            // This flag cannot be set from Java.
            FALLTHROUGH_INTENDED;
        case InputConfig::SPY:
            if ((inputFeatures & 0x00000004) != 0) {
                mInfo.inputConfig |= InputConfig::SPY;
            }
            FALLTHROUGH_INTENDED;
        case InputConfig::INTERCEPTS_STYLUS:
            if ((inputFeatures & 0x00000008) != 0) {
                mInfo.inputConfig |= InputConfig::INTERCEPTS_STYLUS;
            }
    }

    mInfo.touchOcclusionMode = static_cast<TouchOcclusionMode>(
@@ -228,8 +259,6 @@ bool NativeInputWindowHandle::updateInfo() {
    mInfo.ownerUid = env->GetIntField(obj,
            gInputWindowHandleClassInfo.ownerUid);
    mInfo.packageName = getStringField(env, obj, gInputWindowHandleClassInfo.packageName, "<null>");
    mInfo.inputFeatures = static_cast<WindowInfo::Feature>(
            env->GetIntField(obj, gInputWindowHandleClassInfo.inputFeatures));
    mInfo.displayId = env->GetIntField(obj,
            gInputWindowHandleClassInfo.displayId);

@@ -377,8 +406,8 @@ jobject android_view_InputWindowHandle_fromWindowInfo(JNIEnv* env, gui::WindowIn
    ScopedLocalRef<jstring> packageName(env, env->NewStringUTF(windowInfo.packageName.data()));
    env->SetObjectField(inputWindowHandle, gInputWindowHandleClassInfo.packageName,
                        packageName.get());
    env->SetIntField(inputWindowHandle, gInputWindowHandleClassInfo.inputFeatures,
                     static_cast<int32_t>(windowInfo.inputFeatures.get()));
    // TODO(b/216806304): Write InputConfig flag to Java once it's exposed as an InputWindowHandle
    //  API.

    float transformVals[9];
    for (int i = 0; i < 9; i++) {