/// <summary> /// 主方法 /// </summary> /// <param name="toolKit"></param> /// <returns></returns> protected override Output MainMethod(ToolKit <FlowArgs> toolKit) { var builder = new OutputBuilder(); var shell = new AndroidShellV2(toolKit.Args.Serial); builder.Register(shell); builder.Register(toolKit.Executer); shell.Execute("rm /data/system/gesture.key", AndroidShellV2.LinuxUser.Su); shell.Execute("rm /data/system/password.key", AndroidShellV2.LinuxUser.Su); toolKit.Ae("reboot"); return(builder.Result); }
/// <summary> /// 主方法 /// </summary> /// <param name="toolKit"></param> /// <returns></returns> protected override Output MainMethod(ToolKit <ApkInstallerArgs> toolKit) { Logger.Info(this, $"Install starts....have {toolKit.Args.Files.Count} Apks"); OutputBuilder result = new OutputBuilder(); result.Register(toolKit.Executer); foreach (FileInfo apkFileInfo in toolKit.Args.Files) { Command command = Command.MakeForCmd( $"{AdbConstants.FullAdbFileName} {toolKit.Args.Serial.ToFullSerial()} install -r \"{apkFileInfo.FullName}\""); var installResult = toolKit.Executer.Execute(command); bool currentSuccessful = !installResult.Contains("failure"); if (!currentSuccessful) { errorCount++; } var args = new AApkInstalltionCompleteArgs() { ApkFileInfo = apkFileInfo, IsSuccess = currentSuccessful, Output = installResult, }; if (AApkIstanlltionCompleted?.Invoke(this, args) != true) { break; } } return(result.ToOutput()); }
/// <summary> /// 主方法 /// </summary> /// <param name="toolKit"></param> /// <returns></returns> protected override Output MainMethod(ToolKit <RecoveryFlasherArgs> toolKit) { var builder = new OutputBuilder(); builder.Register(toolKit.Executer); toolKit.Fe($"flash recovery \"{toolKit.Args.RecoveryFilePath}\""); toolKit.Fe($"boot \"{toolKit.Args.RecoveryFilePath}\""); return(builder.Result); }
/// <summary> /// 主方法 /// </summary> /// <param name="toolKit"></param> /// <returns></returns> protected override Output MainMethod(ToolKit <ScreenShoterArgs> toolKit) { string tempFileName = $"{DateTime.Now.ToString("yyyy_MM_dd_hh_MM_ss")}.png"; var outputBuilder = new OutputBuilder(); outputBuilder.Register(toolKit.Executer); toolKit.Ae($"shell /system/bin/screencap -p /sdcard/{tempFileName}"); toolKit.Ae($"pull /sdcard/{tempFileName} {toolKit.Args.SavePath}"); toolKit.Ae($"shell rm -rf /sdcard/{tempFileName}"); return(outputBuilder.Result); }
/// <summary> /// 构造 /// </summary> /// <param name="executableFile"></param> /// <param name="args"></param> public ProcessBasedCommand(string executableFile, string args) { if (string.IsNullOrWhiteSpace(executableFile)) { throw new ArgumentException("message", nameof(executableFile)); } outputBuilder.Register(this); this.executableFile = executableFile; this.args = args; }
/// <summary> /// 主方法 /// </summary> /// <param name="toolKit"></param> /// <returns></returns> protected override Output MainMethod(ToolKit <DpiChangerArgs> toolKit) { var outputBuilder = new OutputBuilder(); outputBuilder.Register(toolKit.Executer); exitCode = toolKit.Executer.QuicklyShell(toolKit.Args.DevBasicInfo.Serial, $"wm density {toolKit.Args.Dpi}").GetExitCode(); if (exitCode == 0) { toolKit.Ae("reboot"); } return(outputBuilder.Result); }
/// <summary> /// 构造 /// </summary> /// <param name="executableFile"></param> /// <param name="args"></param> public ProcessBasedCommand(string executableFile, string args) { processStartInfo = new ProcessStartInfo() { RedirectStandardError = true, RedirectStandardOutput = true, RedirectStandardInput = true, UseShellExecute = false, CreateNoWindow = true, FileName = executableFile, Arguments = args, }; outputBuilder.Register(this); }
public void EntryPoint(ILeafUI _ui, IDevice device, IStorage storage, IEmbeddedFileManager emb, ICommandExecutor _executor) { //确保资源被正确释放 using var ui = _ui; using var executor = _executor; //显示UI后初始化一些细节 ui.Show(); InitUI(ui); //做出一系列警告与提示,只要一个不被同意,立刻再见 if (!(DoAppCheck(ui, device, PackageName) && DoWarn(ui))) { ui.Shutdown(); //直接关闭UI return; //退出函数 } /* 正式开始流程 */ //创建一个OutputBuilder OutputBuilder outputBuilder = new OutputBuilder(); //接收并记录所有executor的输出 outputBuilder.Register(executor); //将命令执行器输出定向到界面 executor.OutputReceived += (s, e) => ui.WriteLineToDetails(e.Text); //构造一个dpmpro的控制器 var dpmpro = new DpmPro(executor, emb, storage, device); //将dpmpro提取到临时目录 SetProgress(ui, "Extract", 0); dpmpro.Extract(); //推送dpmpro到设备 SetProgress(ui, "Push", 20); dpmpro.PushToDevice(); //移除账户 SetProgress(ui, "RMAcc", 40); dpmpro.RemoveAccounts(); //移除用户 SetProgress(ui, "RMUser", 60); dpmpro.RemoveUsers(); //使用可能的方式设置管理员,并记录结果 SetProgress(ui, "SettingDpm", 80); var codeOfSetDeviceOwner = SetDeviceOwner(device, ui, ComponentName, executor, dpmpro).ExitCode; if (codeOfSetDeviceOwner == 0 && //如果设置成功并且 (PackageName == "com.catchingnow.icebox" || //目标包名是冰箱 PackageName == "web1n.stopapp")) //小黑屋 { //给予APPOPS权限 executor.AdbShell(device, $"pm grant {PackageName} android.permission.GET_APP_OPS_STATS"); } //使用输出解析器,对记录的输出进行解析 DpmFailedMessageParser.Parse(codeOfSetDeviceOwner, outputBuilder.ToString(), out string tip, out string message); //在输出框写下简要信息与建议 ui.WriteLineToDetails(message); ui.ShowMessage(message); //去除输出信息事件注册 outputBuilder.Unregister(executor); //ui流程结束 ui.Finish(tip); }
public void EntryPoint() { using (UI) { UI.Show(); //显示ui InitUI(); //初始化ui ////执行前的一些检查与提示 //SetProgress("Checking", 10); //if (!DoAppCheck()) return;//进行APP安装检查 //if (!DoWarn()) return;//进行一系列提示与警告 //做出一系列警告与提示,只要一个不被同意,立刻再见 if (!(DoAppCheck() && DoWarn())) { UI.Shutdown(); //直接关闭UI return; //退出函数 } /* 正式开始流程 */ //构造一个命令执行器 using (CommandExecutor executor = new CommandExecutor()) { //创建一个OutputBuilder OutputBuilder outputBuilder = new OutputBuilder(); //接收并记录所有executor的输出 outputBuilder.Register(executor); //将命令执行器输出定向到界面 executor.To(e => UI.WriteOutput(e.Text)); //构造一个dpmpro的控制器 var dpmpro = new DpmPro(executor, CoreLib.Current, Device); //将dpmpro提取到临时目录 SetProgress("Extract", 0); dpmpro.Extract(); //推送dpmpro到设备 SetProgress("Push", 20); dpmpro.PushToDevice(); //移除账户 SetProgress("RMAcc", 40); dpmpro.RemoveAccounts(); //移除用户 SetProgress("RMUser", 60); dpmpro.RemoveUsers(); //使用可能的方式设置管理员,并记录结果 SetProgress("SettingDpm", 80); var codeOfSetDeviceOwner = SetDeviceOwner(executor, dpmpro).ExitCode; if (codeOfSetDeviceOwner == 0 && //如果设置成功并且 (PackageName == "com.catchingnow.icebox" || //目标包名是冰箱 PackageName == "web1n.stopapp")) //小黑屋 { //给予APPOPS权限 executor.AdbShell(Device, $"pm grant {PackageName} android.permission.GET_APP_OPS_STATS"); } //使用输出解析器,对记录的输出进行解析 DpmFailedMessageParser.Parse(codeOfSetDeviceOwner, outputBuilder.ToString(), out string tip, out string message); //在输出框写下简要信息与建议 UI.WriteLine(message); UI.ShowMessage(message); //去除输出信息事件注册 outputBuilder.Unregister(executor); //ui流程结束 UI.Finish(tip); } } }
/// <summary> /// 构造CommandExecutor /// </summary> public CommandExecutor() { outputBuilder.Register(this); }