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

Commit 2c23a2ee authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Do not load keylayout if required kernel module is missing" into tm-qpr-dev

parents edd11926 0ac62eb4
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -300,6 +300,8 @@ enum class InputDeviceConfigurationFileType : int32_t {
/*
 * Gets the path of an input device configuration file, if one is available.
 * Considers both system provided and user installed configuration files.
 * The optional suffix is appended to the end of the file name (before the
 * extension).
 *
 * The device identifier is used to construct several default configuration file
 * names to try based on the device name, vendor, product, and version.
@@ -307,8 +309,8 @@ enum class InputDeviceConfigurationFileType : int32_t {
 * Returns an empty string if not found.
 */
extern std::string getInputDeviceConfigurationFilePathByDeviceIdentifier(
        const InputDeviceIdentifier& deviceIdentifier,
        InputDeviceConfigurationFileType type);
        const InputDeviceIdentifier& deviceIdentifier, InputDeviceConfigurationFileType type,
        const char* suffix = "");

/*
 * Gets the path of an input device configuration file, if one is available.
+5 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <utils/Errors.h>
#include <utils/KeyedVector.h>
#include <utils/Tokenizer.h>
#include <set>

#include <input/InputDevice.h>

@@ -64,7 +65,8 @@ struct AxisInfo {
 */
class KeyLayoutMap {
public:
    static base::Result<std::shared_ptr<KeyLayoutMap>> load(const std::string& filename);
    static base::Result<std::shared_ptr<KeyLayoutMap>> load(const std::string& filename,
                                                            const char* contents = nullptr);
    static base::Result<std::shared_ptr<KeyLayoutMap>> loadContents(const std::string& filename,
                                                                    const char* contents);

@@ -104,6 +106,7 @@ private:
    KeyedVector<int32_t, Led> mLedsByScanCode;
    KeyedVector<int32_t, Led> mLedsByUsageCode;
    std::unordered_map<int32_t, Sensor> mSensorsByAbsCode;
    std::set<std::string> mRequiredKernelConfigs;
    std::string mLoadFileName;

    KeyLayoutMap();
@@ -124,6 +127,7 @@ private:
        status_t parseAxis();
        status_t parseLed();
        status_t parseSensor();
        status_t parseRequiredKernelConfig();
    };
};

+1 −3
Original line number Diff line number Diff line
@@ -62,8 +62,6 @@ private:
    status_t loadKeyLayout(const InputDeviceIdentifier& deviceIdentifier, const std::string& name);
    status_t loadKeyCharacterMap(const InputDeviceIdentifier& deviceIdentifier,
                                 const std::string& name);
    std::string getPath(const InputDeviceIdentifier& deviceIdentifier,
            const std::string& name, InputDeviceConfigurationFileType type);
};

/**
+1 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ cc_library {
        "libbase",
        "liblog",
        "libcutils",
        "libvintf",
    ],

    static_libs: [
+18 −12
Original line number Diff line number Diff line
@@ -53,15 +53,18 @@ static void appendInputDeviceConfigurationFileRelativePath(std::string& path,
}

std::string getInputDeviceConfigurationFilePathByDeviceIdentifier(
        const InputDeviceIdentifier& deviceIdentifier,
        InputDeviceConfigurationFileType type) {
        const InputDeviceIdentifier& deviceIdentifier, InputDeviceConfigurationFileType type,
        const char* suffix) {
    if (deviceIdentifier.vendor !=0 && deviceIdentifier.product != 0) {
        if (deviceIdentifier.version != 0) {
            // Try vendor product version.
            std::string versionPath = getInputDeviceConfigurationFilePathByName(
                    StringPrintf("Vendor_%04x_Product_%04x_Version_%04x",
                            deviceIdentifier.vendor, deviceIdentifier.product,
                            deviceIdentifier.version),
            std::string versionPath =
                    getInputDeviceConfigurationFilePathByName(StringPrintf("Vendor_%04x_Product_%"
                                                                           "04x_Version_%04x%s",
                                                                           deviceIdentifier.vendor,
                                                                           deviceIdentifier.product,
                                                                           deviceIdentifier.version,
                                                                           suffix),
                                                              type);
            if (!versionPath.empty()) {
                return versionPath;
@@ -69,9 +72,11 @@ std::string getInputDeviceConfigurationFilePathByDeviceIdentifier(
        }

        // Try vendor product.
        std::string productPath = getInputDeviceConfigurationFilePathByName(
                StringPrintf("Vendor_%04x_Product_%04x",
                        deviceIdentifier.vendor, deviceIdentifier.product),
        std::string productPath =
                getInputDeviceConfigurationFilePathByName(StringPrintf("Vendor_%04x_Product_%04x%s",
                                                                       deviceIdentifier.vendor,
                                                                       deviceIdentifier.product,
                                                                       suffix),
                                                          type);
        if (!productPath.empty()) {
            return productPath;
@@ -79,7 +84,8 @@ std::string getInputDeviceConfigurationFilePathByDeviceIdentifier(
    }

    // Try device name.
    return getInputDeviceConfigurationFilePathByName(deviceIdentifier.getCanonicalName(), type);
    return getInputDeviceConfigurationFilePathByName(deviceIdentifier.getCanonicalName() + suffix,
                                                     type);
}

std::string getInputDeviceConfigurationFilePathByName(
Loading