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

Commit 332a29a5 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Do not load keylayout if required kernel module is missing"

parents bdaf9ec7 ec70ee2c
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -295,6 +295,8 @@ enum class InputDeviceConfigurationFileType : int32_t {
/*
/*
 * Gets the path of an input device configuration file, if one is available.
 * Gets the path of an input device configuration file, if one is available.
 * Considers both system provided and user installed configuration files.
 * 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
 * The device identifier is used to construct several default configuration file
 * names to try based on the device name, vendor, product, and version.
 * names to try based on the device name, vendor, product, and version.
@@ -302,8 +304,8 @@ enum class InputDeviceConfigurationFileType : int32_t {
 * Returns an empty string if not found.
 * Returns an empty string if not found.
 */
 */
extern std::string getInputDeviceConfigurationFilePathByDeviceIdentifier(
extern std::string getInputDeviceConfigurationFilePathByDeviceIdentifier(
        const InputDeviceIdentifier& deviceIdentifier,
        const InputDeviceIdentifier& deviceIdentifier, InputDeviceConfigurationFileType type,
        InputDeviceConfigurationFileType type);
        const char* suffix = "");


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


#include <input/InputDevice.h>
#include <input/InputDevice.h>


@@ -63,7 +64,8 @@ struct AxisInfo {
 */
 */
class KeyLayoutMap {
class KeyLayoutMap {
public:
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,
    static base::Result<std::shared_ptr<KeyLayoutMap>> loadContents(const std::string& filename,
                                                                    const char* contents);
                                                                    const char* contents);


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


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


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


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


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


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


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


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


std::string getInputDeviceConfigurationFilePathByName(
std::string getInputDeviceConfigurationFilePathByName(
Loading