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

Commit 51e7db07 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

WindowInfo: Merge InputConfig and Feature flags

Merge the two flags in native code. We move the InputConfig flag
defintions to AIDL since we will be using the flags in Java as part of
the InputWindowHandle API next.

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: I82d6de35b30d9cd4bcaf61499216c8faf407e885
parent 1077ad7f
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -51,11 +51,11 @@ bool WindowInfo::supportsSplitTouch() const {
}

bool WindowInfo::isSpy() const {
    return inputFeatures.test(Feature::SPY);
    return inputConfig.test(InputConfig::SPY);
}

bool WindowInfo::interceptsStylus() const {
    return inputFeatures.test(Feature::INTERCEPTS_STYLUS);
    return inputConfig.test(InputConfig::INTERCEPTS_STYLUS);
}

bool WindowInfo::overlaps(const WindowInfo* other) const {
@@ -73,8 +73,7 @@ bool WindowInfo::operator==(const WindowInfo& info) const {
            info.touchableRegion.hasSameRects(touchableRegion) &&
            info.touchOcclusionMode == touchOcclusionMode && info.ownerPid == ownerPid &&
            info.ownerUid == ownerUid && info.packageName == packageName &&
            info.inputFeatures == inputFeatures && info.inputConfig == inputConfig &&
            info.displayId == displayId &&
            info.inputConfig == inputConfig && info.displayId == displayId &&
            info.replaceTouchableRegionWithCrop == replaceTouchableRegionWithCrop &&
            info.applicationInfo == applicationInfo && info.layoutParamsType == layoutParamsType &&
            info.layoutParamsFlags == layoutParamsFlags;
@@ -92,7 +91,6 @@ status_t WindowInfo::writeToParcel(android::Parcel* parcel) const {
    parcel->writeInt32(1);

    // Ensure that the size of the flags that we use is 32 bits for writing into the parcel.
    static_assert(sizeof(inputFeatures) == 4u);
    static_assert(sizeof(inputConfig) == 4u);

    // clang-format off
@@ -120,7 +118,6 @@ status_t WindowInfo::writeToParcel(android::Parcel* parcel) const {
        parcel->writeInt32(ownerPid) ?:
        parcel->writeInt32(ownerUid) ?:
        parcel->writeUtf8AsUtf16(packageName) ?:
        parcel->writeInt32(inputFeatures.get()) ?:
        parcel->writeInt32(inputConfig.get()) ?:
        parcel->writeInt32(displayId) ?:
        applicationInfo.writeToParcel(parcel) ?:
@@ -178,7 +175,6 @@ status_t WindowInfo::readFromParcel(const android::Parcel* parcel) {

    touchOcclusionMode = static_cast<TouchOcclusionMode>(touchOcclusionModeInt);

    inputFeatures = Flags<Feature>(parcel->readInt32());
    inputConfig = Flags<InputConfig>(parcel->readInt32());
    // clang-format off
    status = parcel->readInt32(&displayId) ?:
+32 −37
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
#pragma once

#include <android/gui/TouchOcclusionMode.h>
#include <android/os/IInputConstants.h>
#include <android/os/InputConfig.h>
#include <binder/Parcel.h>
#include <binder/Parcelable.h>
#include <ftl/Flags.h>
@@ -132,49 +132,45 @@ struct WindowInfo : public Parcelable {
        ftl_last = FIRST_SYSTEM_WINDOW + 15
    };

    // This is a conversion of os::IInputConstants::InputFeature to an enum backed by an unsigned
    // Flags used to determine configuration of this input window.
    // This is a conversion of os::InputConfig to an enum backed by an unsigned
    // type. This indicates that they are flags, so it can be used with ftl/enum.h.
    enum class Feature : uint32_t {
    enum class InputConfig : uint32_t {
        // clang-format off
        DEFAULT =
                static_cast<uint32_t>(os::InputConfig::DEFAULT),
        NO_INPUT_CHANNEL =
                static_cast<uint32_t>(os::IInputConstants::InputFeature::NO_INPUT_CHANNEL),
                static_cast<uint32_t>(os::InputConfig::NO_INPUT_CHANNEL),
        NOT_VISIBLE =
                static_cast<uint32_t>(os::InputConfig::NOT_VISIBLE),
        NOT_FOCUSABLE =
                static_cast<uint32_t>(os::InputConfig::NOT_FOCUSABLE),
        NOT_TOUCHABLE =
                static_cast<uint32_t>(os::InputConfig::NOT_TOUCHABLE),
        PREVENT_SPLITTING =
                static_cast<uint32_t>(os::InputConfig::PREVENT_SPLITTING),
        DUPLICATE_TOUCH_TO_WALLPAPER =
                static_cast<uint32_t>(os::InputConfig::DUPLICATE_TOUCH_TO_WALLPAPER),
        IS_WALLPAPER =
                static_cast<uint32_t>(os::InputConfig::IS_WALLPAPER),
        PAUSE_DISPATCHING =
                static_cast<uint32_t>(os::InputConfig::PAUSE_DISPATCHING),
        TRUSTED_OVERLAY =
                static_cast<uint32_t>(os::InputConfig::TRUSTED_OVERLAY),
        WATCH_OUTSIDE_TOUCH =
                static_cast<uint32_t>(os::InputConfig::WATCH_OUTSIDE_TOUCH),
        SLIPPERY =
                static_cast<uint32_t>(os::InputConfig::SLIPPERY),
        DISABLE_USER_ACTIVITY =
                static_cast<uint32_t>(os::IInputConstants::InputFeature::DISABLE_USER_ACTIVITY),
                static_cast<uint32_t>(os::InputConfig::DISABLE_USER_ACTIVITY),
        DROP_INPUT =
                static_cast<uint32_t>(os::IInputConstants::InputFeature::DROP_INPUT),
                static_cast<uint32_t>(os::InputConfig::DROP_INPUT),
        DROP_INPUT_IF_OBSCURED =
                static_cast<uint32_t>(os::IInputConstants::InputFeature::DROP_INPUT_IF_OBSCURED),
                static_cast<uint32_t>(os::InputConfig::DROP_INPUT_IF_OBSCURED),
        SPY =
                static_cast<uint32_t>(os::IInputConstants::InputFeature::SPY),
                static_cast<uint32_t>(os::InputConfig::SPY),
        INTERCEPTS_STYLUS =
                static_cast<uint32_t>(os::IInputConstants::InputFeature::INTERCEPTS_STYLUS),
        // clang-format on
    };

    // Flags used to determine configuration of this input window.
    // Input windows can be configured with two sets of flags: InputFeature (WindowInfo::Feature
    // defined above), and InputConfig. When adding a new configuration for an input window:
    //   - If you are adding a new flag that's visible and accessible to apps, it should be added
    //   as an InputFeature.
    //   - If you are adding an internal behaviour that is used within the system or shell and is
    //   not exposed to apps, it should be added as an InputConfig.
    enum class InputConfig : uint32_t {
        // clang-format off
        NONE                         = 0,
        NOT_VISIBLE                  = 1 << 0,
        NOT_FOCUSABLE                = 1 << 1,
        NOT_TOUCHABLE                = 1 << 2,
        PREVENT_SPLITTING            = 1 << 3,
        DUPLICATE_TOUCH_TO_WALLPAPER = 1 << 4,
        IS_WALLPAPER                 = 1 << 5,
        PAUSE_DISPATCHING            = 1 << 6,
        // This flag is set when the window is of a trusted type that is allowed to silently
        // overlay other windows for the purpose of implementing the secure views feature.
        // Trusted overlays, such as IME windows, can partly obscure other windows without causing
        // motion events to be delivered to them with AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED.
        TRUSTED_OVERLAY              = 1 << 7,
        WATCH_OUTSIDE_TOUCH          = 1 << 8,
        SLIPPERY                     = 1 << 9,
                static_cast<uint32_t>(os::InputConfig::INTERCEPTS_STYLUS),
        // clang-format on
    };

@@ -228,7 +224,6 @@ struct WindowInfo : public Parcelable {
    int32_t ownerPid = -1;
    int32_t ownerUid = -1;
    std::string packageName;
    Flags<Feature> inputFeatures;
    Flags<InputConfig> inputConfig;
    int32_t displayId = ADISPLAY_ID_NONE;
    InputApplicationInfo applicationInfo;
+0 −2
Original line number Diff line number Diff line
@@ -64,7 +64,6 @@ TEST(WindowInfo, Parcelling) {
    i.ownerPid = 19;
    i.ownerUid = 24;
    i.packageName = "com.example.package";
    i.inputFeatures = WindowInfo::Feature::DISABLE_USER_ACTIVITY;
    i.inputConfig = WindowInfo::InputConfig::NOT_FOCUSABLE;
    i.displayId = 34;
    i.replaceTouchableRegionWithCrop = true;
@@ -97,7 +96,6 @@ TEST(WindowInfo, Parcelling) {
    ASSERT_EQ(i.ownerPid, i2.ownerPid);
    ASSERT_EQ(i.ownerUid, i2.ownerUid);
    ASSERT_EQ(i.packageName, i2.packageName);
    ASSERT_EQ(i.inputFeatures, i2.inputFeatures);
    ASSERT_EQ(i.inputConfig, i2.inputConfig);
    ASSERT_EQ(i.displayId, i2.displayId);
    ASSERT_EQ(i.replaceTouchableRegionWithCrop, i2.replaceTouchableRegionWithCrop);
+3 −4
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ filegroup {
        "android/os/IInputConstants.aidl",
        "android/os/InputEventInjectionResult.aidl",
        "android/os/InputEventInjectionSync.aidl",
        "android/os/InputConfig.aidl",
    ],
}

@@ -79,11 +80,8 @@ cc_library {
        android: {
            srcs: [
                "InputTransport.cpp",
                "android/os/BlockUntrustedTouchesMode.aidl",
                "android/os/IInputConstants.aidl",
                "android/os/IInputFlinger.aidl",
                "android/os/InputEventInjectionResult.aidl",
                "android/os/InputEventInjectionSync.aidl",
                ":inputconstants_aidl",
            ],

            export_shared_lib_headers: ["libbinder"],
@@ -119,6 +117,7 @@ cc_library {
                "InputTransport.cpp",
                "android/os/IInputConstants.aidl",
                "android/os/IInputFlinger.aidl",
                "android/os/InputConfig.aidl",
            ],
            static_libs: [
                "libhostgraphics",
+0 −49
Original line number Diff line number Diff line
@@ -47,55 +47,6 @@ interface IInputConstants
     */
    const int INPUT_EVENT_FLAG_IS_ACCESSIBILITY_EVENT = 0x800;

    @Backing(type="int")
    enum InputFeature {
        /**
         * Does not construct an input channel for this window.  The channel will therefore
         * be incapable of receiving input.
         */
        NO_INPUT_CHANNEL = 0x00000002,

        /**
         * When this window has focus, does not call user activity for all input events so
         * the application will have to do it itself.  Should only be used by
         * the keyguard and phone app.
         *
         * Should only be used by the keyguard and phone app.
         */
        DISABLE_USER_ACTIVITY = 0x00000004,

        /**
         * Internal flag used to indicate that input should be dropped on this window.
         */
        DROP_INPUT = 0x00000008,

        /**
         * Internal flag used to indicate that input should be dropped on this window if this window
         * is obscured.
         */
        DROP_INPUT_IF_OBSCURED = 0x00000010,

        /**
         * 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.
         * An input event will be dispatched to all spy windows above the top non-spy window at the
         * event's coordinates.
         */
        SPY = 0x00000020,

        /**
         * When used with the window flag {@link #FLAG_NOT_TOUCHABLE}, this window will continue
         * to receive events from a stylus device within its touchable region. All other pointer
         * events, such as from a mouse or touchscreen, will be dispatched to the windows behind it.
         *
         * This input feature has no effect when the window flag {@link #FLAG_NOT_TOUCHABLE} is
         * not set.
         *
         * The window must be a trusted overlay to use this input feature.
         */
        INTERCEPTS_STYLUS = 0x00000040,
    }

    /* The default pointer acceleration value. */
    const int DEFAULT_POINTER_ACCELERATION = 3;
}
Loading