public MembootTasks(MembootTaskType type, string[] hmodsInstall = null, string[] hmodsUninstall = null, string dumpPath = null) { fel = new Fel(); List <TaskFunc> taskList = new List <TaskFunc>(); if (!hakchi.MinimalMemboot) { taskList.Add(WaitForFelOrMembootableShell); taskList.Add(Memboot); taskList.Add(WaitForShellCycle); taskList.Add(ShellTasks.ShowSplashScreen); } switch (type) { case MembootTaskType.InstallHakchi: taskList.AddRange(new TaskFunc[] { HandleHakchi(HakchiTasks.Install), ModTasks.TransferBaseHmods("/hakchi/transfer"), BootHakchi }); break; case MembootTaskType.ResetHakchi: taskList.AddRange(new TaskFunc[] { HandleHakchi(HakchiTasks.Reset), ModTasks.TransferBaseHmods("/hakchi/transfer"), BootHakchi }); break; case MembootTaskType.UninstallHakchi: taskList.AddRange(new TaskFunc[] { GetStockKernel, FlashStockKernel, HandleHakchi(HakchiTasks.Uninstall), ShellTasks.Reboot }); break; case MembootTaskType.FactoryReset: taskList.AddRange(new TaskFunc[] { GetStockKernel, FlashStockKernel, ProcessNand(null, NandTasks.FormatNandC), ShellTasks.Reboot }); break; case MembootTaskType.DumpNand: taskList.AddRange(new TaskFunc[] { ProcessNand(dumpPath, NandTasks.DumpNand), ShellTasks.Reboot }); break; case MembootTaskType.DumpNandB: taskList.AddRange(new TaskFunc[] { ProcessNand(dumpPath, NandTasks.DumpNandB), ShellTasks.Reboot }); break; case MembootTaskType.DumpNandC: taskList.AddRange(new TaskFunc[] { ProcessNand(dumpPath, NandTasks.DumpNandC), ShellTasks.Reboot }); break; case MembootTaskType.FlashNandB: taskList.AddRange(new TaskFunc[] { ProcessNand(dumpPath, NandTasks.FlashNandB), ShellTasks.Reboot }); break; case MembootTaskType.FlashNandC: taskList.AddRange(new TaskFunc[] { ProcessNand(dumpPath, NandTasks.FlashNandC), ShellTasks.Reboot }); break; case MembootTaskType.FormatNandC: taskList.AddRange(new TaskFunc[] { ProcessNand(dumpPath, NandTasks.FormatNandC), HandleHakchi(HakchiTasks.Install), ModTasks.TransferBaseHmods("/hakchi/transfer"), BootHakchi }); break; case MembootTaskType.ProcessMods: taskList.AddRange(new ModTasks(hmodsInstall, hmodsUninstall).Tasks); break; case MembootTaskType.FlashNormalUboot: taskList.AddRange(new TaskFunc[] { FlashUboot(Fel.UbootType.Normal), ShellTasks.Reboot }); break; case MembootTaskType.FlashSDUboot: taskList.AddRange(new TaskFunc[] { FlashUboot(Fel.UbootType.SD), ShellTasks.Reboot }); break; case MembootTaskType.Memboot: taskList.Add(BootHakchi); break; case MembootTaskType.MembootOriginal: taskList.Add(BootBackup2); break; case MembootTaskType.MembootRecovery: break; case MembootTaskType.DumpStockKernel: taskList.AddRange(new TaskFunc[] { DumpStockKernel(dumpPath), ShellTasks.Reboot }); break; } Tasks = taskList.ToArray(); }
public MembootTasks(MembootTaskType type, string[] hmodsInstall = null, string[] hmodsUninstall = null, string dumpPath = null, bool forceRecoveryReload = false, bool ignoreBackupKernel = false, bool requireSD = false) { this.ignoreBackupKernel = ignoreBackupKernel; userRecovery = (hakchi.Shell.IsOnline && hakchi.MinimalMemboot && hakchi.UserMinimalMemboot); fel = new Fel(); List <TaskFunc> taskList = new List <TaskFunc>(); if (!hakchi.MinimalMemboot || forceRecoveryReload) { taskList.Add(WaitForFelOrMembootableShell(requireSD)); taskList.Add(TaskIf(() => { return(hakchi.Shell.IsOnline); }, Memboot, MembootFel)); taskList.Add(WaitForShellCycle(-1)); taskList.Add(ShellTasks.ShowSplashScreen); } switch (type) { case MembootTaskType.InstallHakchi: taskList.Add(CheckMdRootfs); taskList.AddRange(new GrowTask(true, true).Tasks); taskList.AddRange(new TaskFunc[] { HandleHakchi(HakchiTasks.Install), ModTasks.TransferBaseHmods("/hakchi/transfer"), ModTasks.TransferHakchiHmod("/hakchi/transfer") }); if (!userRecovery) { taskList.Add(BootHakchi); taskList.Add(WaitForShellCycle(-1)); } break; case MembootTaskType.ResetHakchi: taskList.Add(CheckMdRootfs); taskList.AddRange(new GrowTask(true, true).Tasks); taskList.AddRange(new TaskFunc[] { HandleHakchi(HakchiTasks.Reset), ModTasks.TransferBaseHmods("/hakchi/transfer"), ModTasks.TransferHakchiHmod("/hakchi/transfer") }); if (!userRecovery) { taskList.Add(BootHakchi); taskList.Add(WaitForShellCycle(-1)); } break; case MembootTaskType.UninstallHakchi: case MembootTaskType.FormatUserPartition: case MembootTaskType.FactoryReset: var reinstallHakchi = false; if (type == MembootTaskType.UninstallHakchi || type == MembootTaskType.FactoryReset) { taskList.Add(TaskIf(() => hakchi.IsMdPartitioning, SuccessTask, GetStockKernel)); if (ignoreBackupKernel) { taskList.Add(TaskIf(() => hakchi.IsMdPartitioning, SuccessTask, EraseBackupKernel)); } taskList.AddRange(new TaskFunc[] { TaskIf(() => hakchi.IsMdPartitioning, SuccessTask, FlashKernel), HandleHakchi(HakchiTasks.Uninstall) }); } if (type == MembootTaskType.FormatUserPartition || type == MembootTaskType.FactoryReset) { if (type == MembootTaskType.FormatUserPartition) { taskList.AddRange(new TaskFunc[] { (Tasker tasker, object SyncObject) => { hakchi.Shell.Execute("hakchi mount_base"); reinstallHakchi = hakchi.Shell.Execute("hakchi eval '[ -e \"$mountpoint/var/lib/hakchi/\" ]'") == 0; hakchi.Shell.Execute("hakchi umount_base"); return(Conclusion.Success); }, }); } taskList.AddRange(new TaskFunc[] { ShellTasks.UnmountBase, (Tasker tasker, Object syncObject) => ShellTasks.FormatDevice($"/dev/{Sunxi.NandInfo.GetNandInfo().GetDataPartition().Device}")(tasker, syncObject) }); if (type == MembootTaskType.FormatUserPartition) { taskList.AddRange(new TaskFunc[] { TaskIf(() => reinstallHakchi, HandleHakchi(HakchiTasks.Install), SuccessTask), TaskIf(() => reinstallHakchi, ModTasks.TransferBaseHmods("/hakchi/transfer"), SuccessTask), TaskIf(() => reinstallHakchi, ModTasks.TransferHakchiHmod("/hakchi/transfer"), SuccessTask) }); } } if (!userRecovery) { taskList.Add(TaskIf(() => reinstallHakchi, BootHakchi, ShellTasks.Reboot)); } break; case MembootTaskType.DumpNand: taskList.AddRange(new TaskFunc[] { ProcessNand(dumpPath, NandTasks.DumpNand) }); if (!userRecovery) { taskList.Add(ShellTasks.Reboot); } break; case MembootTaskType.DumpSystemPartition: taskList.AddRange(new TaskFunc[] { ProcessNand(dumpPath, NandTasks.DumpSystemPartition) }); if (!userRecovery) { taskList.Add(ShellTasks.Reboot); } break; case MembootTaskType.DumpUserPartition: taskList.AddRange(new TaskFunc[] { ProcessNand(dumpPath, NandTasks.DumpUserPartition) }); if (!userRecovery) { taskList.Add(ShellTasks.Reboot); } break; case MembootTaskType.FlashSystemPartition: taskList.AddRange(new TaskFunc[] { ProcessNand(dumpPath, NandTasks.FlashSystemPartition) }); if (!userRecovery) { taskList.Add(ShellTasks.Reboot); } break; case MembootTaskType.FlashUserPartition: taskList.AddRange(new TaskFunc[] { ProcessNand(dumpPath, NandTasks.FlashUserPartition) }); if (!userRecovery) { taskList.Add(ShellTasks.Reboot); } break; case MembootTaskType.ProcessMods: bool unmountAfter = userRecovery && hakchi.Shell.Execute("hakchi eval 'mountpoint -q \"$mountpoint/var/lib/\"'") == 0; taskList.Add(ShellTasks.MountBase); taskList.AddRange(new ModTasks(hmodsInstall, hmodsUninstall).Tasks); if (!userRecovery) { taskList.Add(BootHakchi); } if (unmountAfter) { taskList.Add(ShellTasks.UnmountBase); } break; case MembootTaskType.FlashNormalUboot: taskList.AddRange(new TaskFunc[] { FlashUboot(UbootType.Normal) }); if (!userRecovery) { taskList.Add(ShellTasks.Reboot); } break; case MembootTaskType.FlashSDUboot: taskList.AddRange(new TaskFunc[] { FlashUboot(UbootType.SD) }); if (!userRecovery) { taskList.Add(ShellTasks.Reboot); } break; case MembootTaskType.Memboot: taskList.Add(BootHakchi); break; case MembootTaskType.MembootOriginal: taskList.Add(TaskIf(() => hakchi.IsMdPartitioning, ErrorTask(Resources.NotSupportedOnThisPlatform), SuccessTask)); taskList.Add(BootBackup2); break; case MembootTaskType.MembootRecovery: break; case MembootTaskType.DumpStockKernel: taskList.AddRange(new TaskFunc[] { TaskIf(() => hakchi.IsMdPartitioning, ErrorTask(Resources.NotSupportedOnThisPlatform), SuccessTask), DumpStockKernel(dumpPath) }); if (!userRecovery) { taskList.Add(ShellTasks.Reboot); } break; } Tasks = taskList.ToArray(); }
public MembootTasks(MembootTaskType type, string[] hmodsInstall = null, string[] hmodsUninstall = null, string dumpPath = null, bool forceRecoveryReload = false, bool ignoreBackupKernel = false) { this.ignoreBackupKernel = ignoreBackupKernel; userRecovery = (hakchi.Shell.IsOnline && hakchi.MinimalMemboot && hakchi.UserMinimalMemboot); fel = new Fel(); List <TaskFunc> taskList = new List <TaskFunc>(); if (!hakchi.MinimalMemboot || forceRecoveryReload) { taskList.Add(WaitForFelOrMembootableShell); taskList.Add(TaskIf(() => { return(hakchi.Shell.IsOnline); }, Memboot, MembootFel)); taskList.Add(WaitForShellCycle); taskList.Add(ShellTasks.ShowSplashScreen); } switch (type) { case MembootTaskType.InstallHakchi: taskList.AddRange(new TaskFunc[] { HandleHakchi(HakchiTasks.Install), ModTasks.TransferBaseHmods("/hakchi/transfer") }); if (!userRecovery) { taskList.Add(BootHakchi); } break; case MembootTaskType.ResetHakchi: taskList.AddRange(new TaskFunc[] { HandleHakchi(HakchiTasks.Reset), ModTasks.TransferBaseHmods("/hakchi/transfer") }); if (!userRecovery) { taskList.Add(BootHakchi); } break; case MembootTaskType.UninstallHakchi: taskList.Add(GetStockKernel); if (ignoreBackupKernel) { taskList.Add(EraseBackupKernel); } taskList.AddRange(new TaskFunc[] { FlashKernel, HandleHakchi(HakchiTasks.Uninstall) }); if (!userRecovery) { taskList.Add(ShellTasks.Reboot); } break; case MembootTaskType.FactoryReset: taskList.Add(GetStockKernel); if (ignoreBackupKernel) { taskList.Add(EraseBackupKernel); } taskList.AddRange(new TaskFunc[] { FlashKernel, ProcessNand(null, NandTasks.FormatNandC) }); if (!userRecovery) { taskList.Add(ShellTasks.Reboot); } break; case MembootTaskType.DumpNand: taskList.AddRange(new TaskFunc[] { ProcessNand(dumpPath, NandTasks.DumpNand) }); if (!userRecovery) { taskList.Add(ShellTasks.Reboot); } break; case MembootTaskType.DumpNandB: taskList.AddRange(new TaskFunc[] { ProcessNand(dumpPath, NandTasks.DumpNandB) }); if (!userRecovery) { taskList.Add(ShellTasks.Reboot); } break; case MembootTaskType.DumpNandC: taskList.AddRange(new TaskFunc[] { ProcessNand(dumpPath, NandTasks.DumpNandC) }); if (!userRecovery) { taskList.Add(ShellTasks.Reboot); } break; case MembootTaskType.FlashNandB: taskList.AddRange(new TaskFunc[] { ProcessNand(dumpPath, NandTasks.FlashNandB) }); if (!userRecovery) { taskList.Add(ShellTasks.Reboot); } break; case MembootTaskType.FlashNandC: taskList.AddRange(new TaskFunc[] { ProcessNand(dumpPath, NandTasks.FlashNandC) }); if (!userRecovery) { taskList.Add(ShellTasks.Reboot); } break; case MembootTaskType.FormatNandC: taskList.AddRange(new TaskFunc[] { ProcessNand(dumpPath, NandTasks.FormatNandC), HandleHakchi(HakchiTasks.Install), ModTasks.TransferBaseHmods("/hakchi/transfer") }); if (!userRecovery) { taskList.Add(BootHakchi); } break; case MembootTaskType.ProcessMods: bool unmountAfter = userRecovery && hakchi.Shell.Execute("hakchi eval 'mountpoint -q \"$mountpoint/var/lib/\"'") == 0; taskList.Add(ShellTasks.MountBase); taskList.AddRange(new ModTasks(hmodsInstall, hmodsUninstall).Tasks); if (!userRecovery) { taskList.Add(BootHakchi); } if (unmountAfter) { taskList.Add(ShellTasks.UnmountBase); } break; case MembootTaskType.FlashNormalUboot: taskList.AddRange(new TaskFunc[] { FlashUboot(Fel.UbootType.Normal) }); if (!userRecovery) { taskList.Add(ShellTasks.Reboot); } break; case MembootTaskType.FlashSDUboot: taskList.AddRange(new TaskFunc[] { FlashUboot(Fel.UbootType.SD) }); if (!userRecovery) { taskList.Add(ShellTasks.Reboot); } break; case MembootTaskType.Memboot: taskList.Add(BootHakchi); break; case MembootTaskType.MembootOriginal: taskList.Add(BootBackup2); break; case MembootTaskType.MembootRecovery: break; case MembootTaskType.DumpStockKernel: taskList.AddRange(new TaskFunc[] { DumpStockKernel(dumpPath) }); if (!userRecovery) { taskList.Add(ShellTasks.Reboot); } break; } Tasks = taskList.ToArray(); }