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

Commit 3138b12f authored by Prabir Pradhan's avatar Prabir Pradhan Committed by Android (Google) Code Review
Browse files

Revert "Bind an input device via descriptor"

Revert submission 26153841-bind_via_descriptor

Reason for revert: b/335777956
Reverted changes: /q/submissionid:26153841-bind_via_descriptor

Change-Id: I1fd8c73f6700b1992a43e8b2f43d4df4b8f9f05e
parent b12a749f
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -135,11 +135,5 @@ flag {
  description: "Enable prediction pruning based on jerk thresholds."
  bug: "266747654"
  is_fixed_read_only: true
}

flag {
  name: "device_associations"
  namespace: "input"
  description: "Binds InputDevice name and InputDevice description against display unique id."
  bug: "324075859"
}
+2 −6
Original line number Diff line number Diff line
@@ -111,13 +111,9 @@ struct InputReaderConfiguration {
    // Used to determine which DisplayViewport should be tied to which InputDevice.
    std::unordered_map<std::string, uint8_t> portAssociations;

    // The associations between input device ports and display unique ids.
    // The associations between input device physical port locations and display unique ids.
    // Used to determine which DisplayViewport should be tied to which InputDevice.
    std::unordered_map<std::string, std::string> uniqueIdAssociationsByPort;

    // The associations between input device descriptor and display unique ids.
    // Used to determine which DisplayViewport should be tied to which InputDevice.
    std::unordered_map<std::string, std::string> uniqueIdAssociationsByDescriptor;
    std::unordered_map<std::string, std::string> uniqueIdAssociations;

    // The associations between input device ports device types.
    // This is used to determine which device type and source should be tied to which InputDevice.
+15 −49
Original line number Diff line number Diff line
@@ -77,11 +77,11 @@ std::list<NotifyArgs> InputDevice::updateEnableState(nsecs_t when,

        // If a device is associated with a specific display but there is no
        // associated DisplayViewport, don't enable the device.
        if (enable && (mAssociatedDisplayPort || mAssociatedDisplayUniqueIdByPort) &&
        if (enable && (mAssociatedDisplayPort || mAssociatedDisplayUniqueId) &&
            !mAssociatedViewport) {
            const std::string desc = mAssociatedDisplayPort
                    ? "port " + std::to_string(*mAssociatedDisplayPort)
                    : "uniqueId " + *mAssociatedDisplayUniqueIdByPort;
                    : "uniqueId " + *mAssociatedDisplayUniqueId;
            ALOGW("Cannot enable input device %s because it is associated "
                  "with %s, but the corresponding viewport is not found",
                  getName().c_str(), desc.c_str());
@@ -124,15 +124,9 @@ void InputDevice::dump(std::string& dump, const std::string& eventHubDevStr) {
    } else {
        dump += "<none>\n";
    }
    dump += StringPrintf(INDENT2 "AssociatedDisplayUniqueIdByPort: ");
    if (mAssociatedDisplayUniqueIdByPort) {
        dump += StringPrintf("%s\n", mAssociatedDisplayUniqueIdByPort->c_str());
    } else {
        dump += "<none>\n";
    }
    dump += StringPrintf(INDENT2 "AssociatedDisplayUniqueIdByDescriptor: ");
    if (mAssociatedDisplayUniqueIdByDescriptor) {
        dump += StringPrintf("%s\n", mAssociatedDisplayUniqueIdByDescriptor->c_str());
    dump += StringPrintf(INDENT2 "AssociatedDisplayUniqueId: ");
    if (mAssociatedDisplayUniqueId) {
        dump += StringPrintf("%s\n", mAssociatedDisplayUniqueId->c_str());
    } else {
        dump += "<none>\n";
    }
@@ -275,28 +269,8 @@ std::list<NotifyArgs> InputDevice::configureInternal(nsecs_t when,

            // In most situations, no port or name will be specified.
            mAssociatedDisplayPort = std::nullopt;
            mAssociatedDisplayUniqueIdByPort = std::nullopt;
            mAssociatedDisplayUniqueId = std::nullopt;
            mAssociatedViewport = std::nullopt;
            // Find the display port that corresponds to the current input device descriptor
            const std::string& inputDeviceDescriptor = mIdentifier.descriptor;
            if (!inputDeviceDescriptor.empty()) {
                const std::unordered_map<std::string, uint8_t>& ports =
                        readerConfig.portAssociations;
                const auto& displayPort = ports.find(inputDeviceDescriptor);
                if (displayPort != ports.end()) {
                    mAssociatedDisplayPort = std::make_optional(displayPort->second);
                } else {
                    const std::unordered_map<std::string, std::string>&
                            displayUniqueIdsByDescriptor =
                                    readerConfig.uniqueIdAssociationsByDescriptor;
                    const auto& displayUniqueIdByDescriptor =
                            displayUniqueIdsByDescriptor.find(inputDeviceDescriptor);
                    if (displayUniqueIdByDescriptor != displayUniqueIdsByDescriptor.end()) {
                        mAssociatedDisplayUniqueIdByDescriptor =
                                displayUniqueIdByDescriptor->second;
                    }
                }
            }
            // Find the display port that corresponds to the current input port.
            const std::string& inputPort = mIdentifier.location;
            if (!inputPort.empty()) {
@@ -306,11 +280,11 @@ std::list<NotifyArgs> InputDevice::configureInternal(nsecs_t when,
                if (displayPort != ports.end()) {
                    mAssociatedDisplayPort = std::make_optional(displayPort->second);
                } else {
                    const std::unordered_map<std::string, std::string>& displayUniqueIdsByPort =
                            readerConfig.uniqueIdAssociationsByPort;
                    const auto& displayUniqueIdByPort = displayUniqueIdsByPort.find(inputPort);
                    if (displayUniqueIdByPort != displayUniqueIdsByPort.end()) {
                        mAssociatedDisplayUniqueIdByPort = displayUniqueIdByPort->second;
                    const std::unordered_map<std::string, std::string>& displayUniqueIds =
                            readerConfig.uniqueIdAssociations;
                    const auto& displayUniqueId = displayUniqueIds.find(inputPort);
                    if (displayUniqueId != displayUniqueIds.end()) {
                        mAssociatedDisplayUniqueId = displayUniqueId->second;
                    }
                }
            }
@@ -325,21 +299,13 @@ std::list<NotifyArgs> InputDevice::configureInternal(nsecs_t when,
                          "but the corresponding viewport is not found.",
                          getName().c_str(), *mAssociatedDisplayPort);
                }
            } else if (mAssociatedDisplayUniqueIdByDescriptor != std::nullopt) {
                mAssociatedViewport = readerConfig.getDisplayViewportByUniqueId(
                        *mAssociatedDisplayUniqueIdByDescriptor);
                if (!mAssociatedViewport) {
                    ALOGW("Input device %s should be associated with display %s but the "
                          "corresponding viewport cannot be found",
                          getName().c_str(), mAssociatedDisplayUniqueIdByDescriptor->c_str());
                }
            } else if (mAssociatedDisplayUniqueIdByPort != std::nullopt) {
                mAssociatedViewport = readerConfig.getDisplayViewportByUniqueId(
                        *mAssociatedDisplayUniqueIdByPort);
            } else if (mAssociatedDisplayUniqueId != std::nullopt) {
                mAssociatedViewport =
                        readerConfig.getDisplayViewportByUniqueId(*mAssociatedDisplayUniqueId);
                if (!mAssociatedViewport) {
                    ALOGW("Input device %s should be associated with display %s but the "
                          "corresponding viewport cannot be found",
                          getName().c_str(), mAssociatedDisplayUniqueIdByPort->c_str());
                          getName().c_str(), mAssociatedDisplayUniqueId->c_str());
                }
            }

+5 −12
Original line number Diff line number Diff line
@@ -63,11 +63,8 @@ public:
    inline std::optional<uint8_t> getAssociatedDisplayPort() const {
        return mAssociatedDisplayPort;
    }
    inline std::optional<std::string> getAssociatedDisplayUniqueIdByPort() const {
        return mAssociatedDisplayUniqueIdByPort;
    }
    inline std::optional<std::string> getAssociatedDisplayUniqueIdByDescriptor() const {
        return mAssociatedDisplayUniqueIdByDescriptor;
    inline std::optional<std::string> getAssociatedDisplayUniqueId() const {
        return mAssociatedDisplayUniqueId;
    }
    inline std::optional<std::string> getDeviceTypeAssociation() const {
        return mAssociatedDeviceType;
@@ -197,8 +194,7 @@ private:
    bool mIsWaking;
    bool mIsExternal;
    std::optional<uint8_t> mAssociatedDisplayPort;
    std::optional<std::string> mAssociatedDisplayUniqueIdByPort;
    std::optional<std::string> mAssociatedDisplayUniqueIdByDescriptor;
    std::optional<std::string> mAssociatedDisplayUniqueId;
    std::optional<std::string> mAssociatedDeviceType;
    std::optional<DisplayViewport> mAssociatedViewport;
    bool mHasMic;
@@ -453,11 +449,8 @@ public:
    inline std::optional<uint8_t> getAssociatedDisplayPort() const {
        return mDevice.getAssociatedDisplayPort();
    }
    inline std::optional<std::string> getAssociatedDisplayUniqueIdByPort() const {
        return mDevice.getAssociatedDisplayUniqueIdByPort();
    }
    inline std::optional<std::string> getAssociatedDisplayUniqueIdByDescriptor() const {
        return mDevice.getAssociatedDisplayUniqueIdByDescriptor();
    inline std::optional<std::string> getAssociatedDisplayUniqueId() const {
        return mDevice.getAssociatedDisplayUniqueId();
    }
    inline std::optional<std::string> getDeviceTypeAssociation() const {
        return mDevice.getDeviceTypeAssociation();
+3 −9
Original line number Diff line number Diff line
@@ -536,15 +536,9 @@ std::optional<DisplayViewport> TouchInputMapper::findViewport() {
            return getDeviceContext().getAssociatedViewport();
        }

        const std::optional<std::string> associatedDisplayUniqueIdByDescriptor =
                getDeviceContext().getAssociatedDisplayUniqueIdByDescriptor();
        if (associatedDisplayUniqueIdByDescriptor) {
            return getDeviceContext().getAssociatedViewport();
        }

        const std::optional<std::string> associatedDisplayUniqueIdByPort =
                getDeviceContext().getAssociatedDisplayUniqueIdByPort();
        if (associatedDisplayUniqueIdByPort) {
        const std::optional<std::string> associatedDisplayUniqueId =
                getDeviceContext().getAssociatedDisplayUniqueId();
        if (associatedDisplayUniqueId) {
            return getDeviceContext().getAssociatedViewport();
        }

Loading