@@ -208,9 +208,18 @@ std::string GetModuleLoadList(BootMode boot_mode, const std::string& dir_path) {
208208}
209209
210210#define MODULE_BASE_DIR " /lib/modules"
211+ <<<<<<< HEAD
211212bool LoadKernelModules (BootMode boot_mode, bool want_console, bool want_parallel,
212213 int & modules_loaded) {
213214 struct utsname uts {};
215+ ||||||| parent of d05f06828 (don' t auto-enable USB port during normal boot on Tensor Pixel devices)
216+ bool LoadKernelModules(bool recovery, bool want_console, bool want_parallel, int& modules_loaded) {
217+ struct utsname uts;
218+ =======
219+ bool LoadKernelModules(bool recovery, bool want_console, bool want_parallel, bool disable_usb_port,
220+ int& modules_loaded) {
221+ struct utsname uts;
222+ >>>>>>> d05f06828 (don' t auto -enable USB port during normal boot on Tensor Pixel devices)
214223 if (uname (&uts)) {
215224 LOG (FATAL) << " Failed to get kernel version." ;
216225 }
@@ -266,7 +275,13 @@ bool LoadKernelModules(BootMode boot_mode, bool want_console, bool want_parallel
266275 for (const auto & module_dir : module_dirs) {
267276 std::string dir_path = MODULE_BASE_DIR " /" ;
268277 dir_path.append (module_dir);
278+ <<<<<<< HEAD
269279 Modprobe m ({dir_path}, GetModuleLoadList (boot_mode, dir_path));
280+ ||||||| parent of d05f06828 (don' t auto-enable USB port during normal boot on Tensor Pixel devices)
281+ Modprobe m({dir_path}, GetModuleLoadList(recovery, dir_path));
282+ =======
283+ Modprobe m({dir_path}, GetModuleLoadList(recovery, dir_path), true, disable_usb_port);
284+ >>>>>>> d05f06828 (don' t auto -enable USB port during normal boot on Tensor Pixel devices)
270285 bool retval = m.LoadListedModules (!want_console);
271286 modules_loaded = m.GetModuleCount ();
272287 if (modules_loaded > 0 ) {
@@ -275,7 +290,13 @@ bool LoadKernelModules(BootMode boot_mode, bool want_console, bool want_parallel
275290 }
276291 }
277292
293+ <<<<<<< HEAD
278294 Modprobe m ({MODULE_BASE_DIR}, GetModuleLoadList (boot_mode, MODULE_BASE_DIR));
295+ ||||||| parent of d05f06828 (don' t auto-enable USB port during normal boot on Tensor Pixel devices)
296+ Modprobe m({MODULE_BASE_DIR}, GetModuleLoadList(recovery, MODULE_BASE_DIR));
297+ =======
298+ Modprobe m({MODULE_BASE_DIR}, GetModuleLoadList(recovery, MODULE_BASE_DIR), true, disable_usb_port);
299+ >>>>>>> d05f06828 (don' t auto -enable USB port during normal boot on Tensor Pixel devices)
279300 bool retval = (want_parallel) ? m.LoadModulesParallel (std::thread::hardware_concurrency ())
280301 : m.LoadListedModules (!want_console);
281302 modules_loaded = m.GetModuleCount ();
@@ -430,9 +451,25 @@ int FirstStageMain(int argc, char** argv) {
430451
431452 boot_clock::time_point module_start_time = boot_clock::now ();
432453 int module_count = 0 ;
454+ <<<<<<< HEAD
433455 BootMode boot_mode = GetBootMode (cmdline, bootconfig);
434456 if (!LoadKernelModules (boot_mode, want_console,
435457 want_parallel, module_count)) {
458+ ||||||| parent of d05f06828 (don' t auto-enable USB port during normal boot on Tensor Pixel devices)
459+ if (!LoadKernelModules(IsRecoveryMode() && !ForceNormalBoot(cmdline, bootconfig), want_console,
460+ want_parallel, module_count)) {
461+ =======
462+
463+ const bool recovery = IsRecoveryMode() && !ForceNormalBoot(cmdline, bootconfig);
464+ bool disable_usb_port = false;
465+ if (!recovery) {
466+ bool is_charger = bootconfig.find("androidboot.mode = \" charger\" ") != std::string::npos ||
467+ cmdline.find("androidboot.mode=charger") != std::string::npos;
468+ disable_usb_port = !is_charger;
469+ }
470+
471+ if (!LoadKernelModules(recovery, want_console, want_parallel, disable_usb_port, module_count)) {
472+ >>>>>>> d05f06828 (don' t auto -enable USB port during normal boot on Tensor Pixel devices)
436473 if (want_console != FirstStageConsoleParam::DISABLED) {
437474 LOG (ERROR) << " Failed to load kernel modules, starting console" ;
438475 } else {
0 commit comments