Do not load keylayout if required kernel module is missing

Some key layouts require the presence of a specific kernel module. If
the kernel module is not present, the layout should not be loaded.

In this CL, we add an option to specify which kernel modules / configs
are needed inside the kl file.

Bug: 228005926
Test: atest libinput_tests
Change-Id: I0d2ab6298bd41df6dc56120bf0385e10da6c3bfe
Merged-In: I0d2ab6298bd41df6dc56120bf0385e10da6c3bfe
diff --git a/include/input/KeyLayoutMap.h b/include/input/KeyLayoutMap.h
index 006c068..1da78aa 100644
--- a/include/input/KeyLayoutMap.h
+++ b/include/input/KeyLayoutMap.h
@@ -21,6 +21,7 @@
 #include <stdint.h>
 #include <utils/Errors.h>
 #include <utils/Tokenizer.h>
+#include <set>
 
 #include <input/InputDevice.h>
 
@@ -63,7 +64,8 @@
  */
 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);
 
@@ -103,6 +105,7 @@
     std::unordered_map<int32_t, Led> mLedsByScanCode;
     std::unordered_map<int32_t, Led> mLedsByUsageCode;
     std::unordered_map<int32_t, Sensor> mSensorsByAbsCode;
+    std::set<std::string> mRequiredKernelConfigs;
     std::string mLoadFileName;
 
     KeyLayoutMap();
@@ -123,6 +126,7 @@
         status_t parseAxis();
         status_t parseLed();
         status_t parseSensor();
+        status_t parseRequiredKernelConfig();
     };
 };