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

Commit 122279f3 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Return a copy of InputDeviceLightInfo instead of pointer" into sc-dev am: 0d1e6c83

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/14847816

Change-Id: Ia17c993a0bce545ca03147a5112b6c3279e886e4
parents 975f0726 0d1e6c83
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -257,13 +257,9 @@ public:
        return mMotionRanges;
    }

    const InputDeviceSensorInfo* getSensorInfo(InputDeviceSensorType type);
    std::vector<InputDeviceSensorInfo> getSensors();

    const std::vector<InputDeviceSensorType> getSensorTypes();

    const std::vector<int32_t> getLightIds();

    const InputDeviceLightInfo* getLightInfo(int32_t id);
    std::vector<InputDeviceLightInfo> getLights();

private:
    int32_t mId;
+10 −24
Original line number Diff line number Diff line
@@ -247,36 +247,22 @@ void InputDeviceInfo::addLightInfo(const InputDeviceLightInfo& info) {
    mLights.insert_or_assign(info.id, info);
}

const std::vector<InputDeviceSensorType> InputDeviceInfo::getSensorTypes() {
    std::vector<InputDeviceSensorType> types;
std::vector<InputDeviceSensorInfo> InputDeviceInfo::getSensors() {
    std::vector<InputDeviceSensorInfo> infos;
    infos.reserve(mSensors.size());
    for (const auto& [type, info] : mSensors) {
        types.push_back(type);
        infos.push_back(info);
    }
    return types;
    return infos;
}

const InputDeviceSensorInfo* InputDeviceInfo::getSensorInfo(InputDeviceSensorType type) {
    auto it = mSensors.find(type);
    if (it == mSensors.end()) {
        return nullptr;
    }
    return &it->second;
}

const std::vector<int32_t> InputDeviceInfo::getLightIds() {
    std::vector<int32_t> ids;
std::vector<InputDeviceLightInfo> InputDeviceInfo::getLights() {
    std::vector<InputDeviceLightInfo> infos;
    infos.reserve(mLights.size());
    for (const auto& [id, info] : mLights) {
        ids.push_back(id);
    }
    return ids;
}

const InputDeviceLightInfo* InputDeviceInfo::getLightInfo(int32_t id) {
    auto it = mLights.find(id);
    if (it == mLights.end()) {
        return nullptr;
        infos.push_back(info);
    }
    return &it->second;
    return infos;
}

} // namespace android
+2 −2
Original line number Diff line number Diff line
@@ -113,9 +113,9 @@ public:
    /* Get battery status of a particular input device. */
    virtual std::optional<int32_t> getBatteryStatus(int32_t deviceId) = 0;

    virtual std::vector<int32_t> getLightIds(int32_t deviceId) = 0;
    virtual std::vector<InputDeviceLightInfo> getLights(int32_t deviceId) = 0;

    virtual const InputDeviceLightInfo* getLightInfo(int32_t deviceId, int32_t lightId) = 0;
    virtual std::vector<InputDeviceSensorInfo> getSensors(int32_t deviceId) = 0;

    /* Return true if the device can send input events to the specified display. */
    virtual bool canDispatchToDisplay(int32_t deviceId, int32_t displayId) = 0;
+8 −7
Original line number Diff line number Diff line
@@ -89,8 +89,7 @@ void InputDevice::setEnabled(bool enabled, nsecs_t when) {
}

void InputDevice::dump(std::string& dump, const std::string& eventHubDevStr) {
    InputDeviceInfo deviceInfo;
    getDeviceInfo(&deviceInfo);
    InputDeviceInfo deviceInfo = getDeviceInfo();

    dump += StringPrintf(INDENT "Device %d: %s\n", deviceInfo.getId(),
                         deviceInfo.getDisplayName().c_str());
@@ -417,15 +416,17 @@ void InputDevice::updateExternalStylusState(const StylusState& state) {
    for_each_mapper([state](InputMapper& mapper) { mapper.updateExternalStylusState(state); });
}

void InputDevice::getDeviceInfo(InputDeviceInfo* outDeviceInfo) {
    outDeviceInfo->initialize(mId, mGeneration, mControllerNumber, mIdentifier, mAlias, mIsExternal,
InputDeviceInfo InputDevice::getDeviceInfo() {
    InputDeviceInfo outDeviceInfo;
    outDeviceInfo.initialize(mId, mGeneration, mControllerNumber, mIdentifier, mAlias, mIsExternal,
                             mHasMic);
    for_each_mapper(
            [outDeviceInfo](InputMapper& mapper) { mapper.populateDeviceInfo(outDeviceInfo); });
            [&outDeviceInfo](InputMapper& mapper) { mapper.populateDeviceInfo(&outDeviceInfo); });

    if (mController) {
        mController->populateDeviceInfo(outDeviceInfo);
        mController->populateDeviceInfo(&outDeviceInfo);
    }
    return outDeviceInfo;
}

int32_t InputDevice::getKeyCodeState(uint32_t sourceMask, int32_t keyCode) {
+12 −18
Original line number Diff line number Diff line
@@ -406,9 +406,7 @@ void InputReader::getExternalStylusDevicesLocked(std::vector<InputDeviceInfo>& o
    for (auto& devicePair : mDevices) {
        std::shared_ptr<InputDevice>& device = devicePair.second;
        if (device->getClasses().test(InputDeviceClass::EXTERNAL_STYLUS) && !device->isIgnored()) {
            InputDeviceInfo info;
            device->getDeviceInfo(&info);
            outDevices.push_back(info);
            outDevices.push_back(device->getDeviceInfo());
        }
    }
}
@@ -498,9 +496,7 @@ std::vector<InputDeviceInfo> InputReader::getInputDevicesLocked() const {

    for (const auto& [device, eventHubIds] : mDeviceToEventHubIdsMap) {
        if (!device->isIgnored()) {
            InputDeviceInfo info;
            device->getDeviceInfo(&info);
            outInputDevices.push_back(info);
            outInputDevices.push_back(device->getDeviceInfo());
        }
    }
    return outInputDevices;
@@ -695,28 +691,26 @@ std::optional<int32_t> InputReader::getBatteryStatus(int32_t deviceId) {
    return std::nullopt;
}

std::vector<int32_t> InputReader::getLightIds(int32_t deviceId) {
std::vector<InputDeviceLightInfo> InputReader::getLights(int32_t deviceId) {
    std::scoped_lock _l(mLock);

    InputDevice* device = findInputDeviceLocked(deviceId);
    if (device) {
        InputDeviceInfo info;
        device->getDeviceInfo(&info);
        return info.getLightIds();
    }
    if (device == nullptr) {
        return {};
    }

const InputDeviceLightInfo* InputReader::getLightInfo(int32_t deviceId, int32_t lightId) {
    return device->getDeviceInfo().getLights();
}

std::vector<InputDeviceSensorInfo> InputReader::getSensors(int32_t deviceId) {
    std::scoped_lock _l(mLock);

    InputDevice* device = findInputDeviceLocked(deviceId);
    if (device) {
        InputDeviceInfo info;
        device->getDeviceInfo(&info);
        return info.getLightInfo(lightId);
    if (device == nullptr) {
        return {};
    }
    return nullptr;

    return device->getDeviceInfo().getSensors();
}

bool InputReader::setLightColor(int32_t deviceId, int32_t lightId, int32_t color) {
Loading