load modules from vendor_boot ramdisk in TWRP instead of depending on init

Use 'TW_LOAD_VENDOR_BOOT_MODULES := true'
to use TWRP module loader code for vendor_boot module loading.

Some devices need this for successful kernel module loading.

* See
https://twrp.zulipchat.com/#narrow/stream/290975-development-device/topic/Moto.20G52.20.28rhode.29/near/403681268

Change-Id: Ic772b59f612ceec836cf0ca38369a40936932307
diff --git a/Android.mk b/Android.mk
index a939c87..a2088d7 100644
--- a/Android.mk
+++ b/Android.mk
@@ -317,6 +317,9 @@
     ifeq ($(TW_LOAD_VENDOR_MODULES_EXCLUDE_GKI),true)
         LOCAL_CFLAGS += -DTW_LOAD_VENDOR_MODULES_EXCLUDE_GKI
     endif
+    ifeq ($(TW_LOAD_VENDOR_BOOT_MODULES),true)
+        LOCAL_CFLAGS += -DTW_LOAD_VENDOR_BOOT_MODULES
+    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 292d18f..47ca4a3 100644
--- a/kernel_module_loader.cpp
+++ b/kernel_module_loader.cpp
@@ -73,6 +73,12 @@
 
 		case FASTBOOTD_MODE:
 		case RECOVERY_IN_BOOT_MODE:
+#ifdef TW_LOAD_VENDOR_BOOT_MODULES
+			for (auto&& module_dir:module_dirs) {
+				modules_loaded += Try_And_Load_Modules(module_dir, false);
+				if (modules_loaded >= expected_module_count) goto exit;
+			}
+#endif
 			/* In both mode vendor_boot or vendor modules are used
 			 * Because Ramdisk is flashed in both.
 			 */