kernel_module_loader: add flag to skip GKI folders
On some devices, parsing all of the GKI folders for modules
to load causes unnecessary delay to the boot process, which
prevents some firmware from loading. The result is that
the battery sysfs entries never get loaded.
Since the modules needed for the device and not typically located
in the GKI folder for the standard kernel, allow skipping these
folders to eliminate the overhead from parsing all of the modules
in these folders.
Usage:
TW_LOAD_VENDOR_MODULES_EXCLUDE_GKI := true
Change-Id: Ia619a5fb0f28ba716bde3972a969c78bfdac1a13
diff --git a/Android.mk b/Android.mk
index 03de408..3bf7968 100755
--- a/Android.mk
+++ b/Android.mk
@@ -316,6 +316,9 @@
LOCAL_C_INCLUDES += system/core/libmodprobe/include
LOCAL_STATIC_LIBRARIES += libmodprobe
LOCAL_CFLAGS += -DTW_LOAD_VENDOR_MODULES=$(TW_LOAD_VENDOR_MODULES)
+ ifeq ($(TW_LOAD_VENDOR_MODULES_EXCLUDE_GKI),true)
+ LOCAL_CFLAGS += -DTW_LOAD_VENDOR_MODULES_EXCLUDE_GKI
+ endif
endif
ifeq ($(TW_INCLUDE_CRYPTO), true)
LOCAL_CFLAGS += -DTW_INCLUDE_CRYPTO -DUSE_FSCRYPT -Wno-macro-redefined
diff --git a/kernel_module_loader.cpp b/kernel_module_loader.cpp
index db5dee8..88f1d78 100644
--- a/kernel_module_loader.cpp
+++ b/kernel_module_loader.cpp
@@ -37,9 +37,11 @@
std::vector<std::string> release = TWFunc::split_string(rls, '.', true);
int expected_module_count = kernel_modules_requested.size();
module_dirs.push_back(base_dir + "/" + release[0] + "." + release[1]);
+#ifndef TW_LOAD_VENDOR_MODULES_EXCLUDE_GKI
std::string gki = "/" + release[0] + "." + release[1] + "-gki";
module_dirs.push_back(base_dir + gki);
vendor_module_dirs.push_back(vendor_base_dir + gki);
+#endif
for (auto&& module_dir:module_dirs) {
modules_loaded += Try_And_Load_Modules(module_dir, false);