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

Commit 4aeb67df authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Introduce InputConfig::SENSITIVE_FOR_TRACING" into main

parents 06bf5557 cf35919a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -178,6 +178,8 @@ struct WindowInfo : public Parcelable {
                static_cast<uint32_t>(os::InputConfig::CLONE),
        GLOBAL_STYLUS_BLOCKS_TOUCH =
                static_cast<uint32_t>(os::InputConfig::GLOBAL_STYLUS_BLOCKS_TOUCH),
        SENSITIVE_FOR_TRACING =
                static_cast<uint32_t>(os::InputConfig::SENSITIVE_FOR_TRACING),
        // clang-format on
    };

+8 −0
Original line number Diff line number Diff line
@@ -157,4 +157,12 @@ enum InputConfig {
     * like StatusBar and TaskBar.
     */
    GLOBAL_STYLUS_BLOCKS_TOUCH   = 1 << 17,

    /**
     * InputConfig used to indicate that this window is sensitive for tracing.
     * This must be set on windows that use {@link WindowManager.LayoutParams#FLAG_SECURE},
     * but it may also be set without setting FLAG_SECURE. The tracing configuration will
     * determine how these sensitive events are eventually traced.
     */
     SENSITIVE_FOR_TRACING       = 1 << 18,
}
+7 −0
Original line number Diff line number Diff line
@@ -838,6 +838,13 @@ Result<void> validateWindowInfosUpdate(const gui::WindowInfosUpdate& update) {
        if (!inserted) {
            return Error() << "Duplicate entry for " << info;
        }
        if (info.layoutParamsFlags.test(WindowInfo::Flag::SECURE) &&
            !info.inputConfig.test(WindowInfo::InputConfig::NOT_VISIBLE) &&
            !info.inputConfig.test(WindowInfo::InputConfig::SENSITIVE_FOR_TRACING)) {
            return Error()
                    << "Window with FLAG_SECURE does not set InputConfig::SENSITIVE_FOR_TRACING: "
                    << info;
        }
    }
    return {};
}
+3 −2
Original line number Diff line number Diff line
@@ -86,8 +86,9 @@ InputTargetInfo getTargetInfo(const InputTarget& target) {
        // This is a global monitor, assume its target is the system.
        return {.uid = gui::Uid{AID_SYSTEM}, .isSecureWindow = false};
    }
    return {target.windowHandle->getInfo()->ownerUid,
            target.windowHandle->getInfo()->layoutParamsFlags.test(gui::WindowInfo::Flag::SECURE)};
    const bool isSensitiveTarget = target.windowHandle->getInfo()->inputConfig.test(
            gui::WindowInfo::InputConfig::SENSITIVE_FOR_TRACING);
    return {target.windowHandle->getInfo()->ownerUid, isSensitiveTarget};
}

} // namespace
+13 −6
Original line number Diff line number Diff line
@@ -1028,6 +1028,8 @@ void LayerSnapshotBuilder::updateInput(LayerSnapshot& snapshot,
                                       const LayerSnapshot& parentSnapshot,
                                       const LayerHierarchy::TraversalPath& path,
                                       const Args& args) {
    using InputConfig = gui::WindowInfo::InputConfig;

    if (requested.windowInfoHandle) {
        snapshot.inputInfo = *requested.windowInfoHandle->getInfo();
    } else {
@@ -1056,6 +1058,11 @@ void LayerSnapshotBuilder::updateInput(LayerSnapshot& snapshot,
        snapshot.dropInputMode = gui::DropInputMode::NONE;
    }

    if (snapshot.isSecure ||
        parentSnapshot.inputInfo.inputConfig.test(InputConfig::SENSITIVE_FOR_TRACING)) {
        snapshot.inputInfo.inputConfig |= InputConfig::SENSITIVE_FOR_TRACING;
    }

    updateVisibility(snapshot, snapshot.isVisible);
    if (!needsInputInfo(snapshot, requested)) {
        return;
@@ -1068,14 +1075,14 @@ void LayerSnapshotBuilder::updateInput(LayerSnapshot& snapshot,
    auto displayInfo = displayInfoOpt.value_or(sDefaultInfo);

    if (!requested.windowInfoHandle) {
        snapshot.inputInfo.inputConfig = gui::WindowInfo::InputConfig::NO_INPUT_CHANNEL;
        snapshot.inputInfo.inputConfig = InputConfig::NO_INPUT_CHANNEL;
    }
    fillInputFrameInfo(snapshot.inputInfo, displayInfo.transform, snapshot);

    if (noValidDisplay) {
        // Do not let the window receive touches if it is not associated with a valid display
        // transform. We still allow the window to receive keys and prevent ANRs.
        snapshot.inputInfo.inputConfig |= gui::WindowInfo::InputConfig::NOT_TOUCHABLE;
        snapshot.inputInfo.inputConfig |= InputConfig::NOT_TOUCHABLE;
    }

    snapshot.inputInfo.alpha = snapshot.color.a;
@@ -1085,7 +1092,7 @@ void LayerSnapshotBuilder::updateInput(LayerSnapshot& snapshot,
    // If the window will be blacked out on a display because the display does not have the secure
    // flag and the layer has the secure flag set, then drop input.
    if (!displayInfo.isSecure && snapshot.isSecure) {
        snapshot.inputInfo.inputConfig |= gui::WindowInfo::InputConfig::DROP_INPUT;
        snapshot.inputInfo.inputConfig |= InputConfig::DROP_INPUT;
    }

    if (requested.touchCropId != UNASSIGNED_LAYER_ID || path.isClone()) {
@@ -1102,7 +1109,7 @@ void LayerSnapshotBuilder::updateInput(LayerSnapshot& snapshot,
    // Inherit the trusted state from the parent hierarchy, but don't clobber the trusted state
    // if it was set by WM for a known system overlay
    if (snapshot.isTrustedOverlay) {
        snapshot.inputInfo.inputConfig |= gui::WindowInfo::InputConfig::TRUSTED_OVERLAY;
        snapshot.inputInfo.inputConfig |= InputConfig::TRUSTED_OVERLAY;
    }

    snapshot.inputInfo.contentSize = snapshot.croppedBufferSize.getSize();
@@ -1110,10 +1117,10 @@ void LayerSnapshotBuilder::updateInput(LayerSnapshot& snapshot,
    // If the layer is a clone, we need to crop the input region to cloned root to prevent
    // touches from going outside the cloned area.
    if (path.isClone()) {
        snapshot.inputInfo.inputConfig |= gui::WindowInfo::InputConfig::CLONE;
        snapshot.inputInfo.inputConfig |= InputConfig::CLONE;
        // Cloned layers shouldn't handle watch outside since their z order is not determined by
        // WM or the client.
        snapshot.inputInfo.inputConfig.clear(gui::WindowInfo::InputConfig::WATCH_OUTSIDE_TOUCH);
        snapshot.inputInfo.inputConfig.clear(InputConfig::WATCH_OUTSIDE_TOUCH);
    }
}

Loading