private void Main(ILeafUI ui, IDevice device) { //# Script to start "web1n's demon" on the device, which has a very rudimentary //# shell. //# //base=/system //path=`pm path web1n.stopapp` //path=${path:8} //export CLASSPATH=$path //exec app_process $base/bin com.web1n.stopapp.app_process.DemonStart "$@" using (ui) { ui.Show(); using var shell = new AndroidShell(device); shell.To(e => ui.WriteLineToDetails(e.Text)); shell.Open(); shell.WriteLine("base=/system"); shell.WriteLine("path=`pm path web1n.stopapp`"); shell.WriteLine("path=${path:8}"); shell.WriteLine("export CLASSPATH=$path"); shell.WriteLine("exec app_process $base/bin com.web1n.stopapp.app_process.DemonStart \"$@\""); shell.WriteLine("exit $?"); shell.WaitForExit(); ui.WriteLineToDetails("exit code:" + shell.ExitCode); ui.Finish(shell.ExitCode == 0 ? StatusMessages.Success : StatusMessages.Failed); } }
private void Main(ILeafUI ui, IDevice device) { // # Script to start "web1n's demon" on the device, which has a very rudimentary //# shell. //# //base=/system //path=`pm path web1n.stopapp` //path=${path:8} //export CLASSPATH=$path //exec app_process $base/bin com.web1n.stopapp.app_process.DemonStart "$@" using (ui) { var info = this.GetInformations(); ui.Icon = info.Icon; ui.Title = info.Name; ui.Show(); using (var shell = new AndroidShell(device)) { shell.To(e => ui.WriteOutput(e.Text)); shell.Open(); shell.WriteLine("base=/system"); shell.WriteLine("path=`pm path web1n.stopapp`"); shell.WriteLine("path=${path:8}"); shell.WriteLine("export CLASSPATH=$path"); shell.WriteLine("exec app_process $base/bin com.web1n.stopapp.app_process.DemonStart \"$@\""); shell.WriteLine("exit $?"); shell.WaitForExit(); ui.WriteOutput("exit code:" + shell.ExitCode); ui.Finish(shell.ExitCode == 0 ? AutumnBoxExtension.OK : AutumnBoxExtension.ERR); } } }
/// <summary> /// 主函数 /// </summary> /// <param name="toolKit"></param> /// <returns></returns> protected override Output MainMethod(ToolKit <DeviceImageFlasherArgs> toolKit) { var outputBuilder = new AdvanceOutputBuilder(); /*push image file to sdcard*/ var pushArgs = new FilePusherArgs() { DevBasicInfo = toolKit.Args.DevBasicInfo, SavePath = _savePath, SourceFile = toolKit.Args.SourceFile, }; var pushResult = new FilePusher().Run(pushArgs); outputBuilder.Append(pushResult.OutputData); /*move file to img path*/ string path = DeviceImageFinder.PathOf(toolKit.Args.DevBasicInfo.Serial, toolKit.Args.ImageType); using (AndroidShell shell = new AndroidShell(toolKit.Args.DevBasicInfo.Serial)) { shell.Connect(); shell.Switch2Su(); moveResult = shell.SafetyInput($"mv {_savePath} {path}"); outputBuilder.Append(moveResult); } return(outputBuilder.Result); }
/// <summary> /// 主函数 /// </summary> /// <param name="toolKit"></param> /// <returns></returns> protected override Output MainMethod(ToolKit <DeviceImageExtractorArgs> toolKit) { var outBuilder = new AdvanceOutputBuilder(); string path = DeviceImageFinder.PathOf(toolKit.Args.DevBasicInfo.Serial, toolKit.Args.ImageType); if (path == null) { return(null); } _getPathSuccessful = true; using (AndroidShell shell = new AndroidShell(toolKit.Args.DevBasicInfo.Serial)) { shell.Connect(); shell.Switch2Su(); //复制到程序根目录 string copyPath = $"/sdcard/{tempFileName}"; var copyResult = shell.SafetyInput($"cp {path} {copyPath}"); outBuilder.Append(copyResult); if (copyResult.IsSuccessful) { _copySuccessful = copyResult.IsSuccessful; var filePullerArgs = new FilePullerArgs() { DevBasicInfo = toolKit.Args.DevBasicInfo, SavePath = toolKit.Args.SavePath + $"\\{toolKit.Args.ImageType.ToString().ToLower()}.img", FilePathOnDevice = copyPath, }; var pullResult = new FilePuller().Run(filePullerArgs); _pullSuccessful = (pullResult.ExitCode == 0); toolKit.Ae("rm -rf " + copyPath); outBuilder.Append(pullResult.OutputData); } } return(outBuilder.Result); }
public DeviceBuildPropSetter(DeviceSerialNumber serial) { this.DeviceSerial = serial; shellAsSu = new AndroidShell(serial); shellAsSu.Connect(); if (!shellAsSu.Switch2Su()) { throw new DeviceHaveNoRootException(); } ReloadFromDevice(); }
/// <summary> /// 主方法 /// </summary> /// <param name="toolKit"></param> /// <returns></returns> protected override Output MainMethod(ToolKit <ShScriptExecuterArgs> toolKit) { _tooKit = toolKit; var ob = new AdvanceOutputBuilder(); if (AppPackageName != null && AppActivity != null) { Logger.Info(this, Activity.Start(toolKit.Args.Serial, AppPackageName, AppActivity)); Thread.Sleep(Delay); } int retCode = 0; using (AndroidShell shell = new AndroidShell(toolKit.Args.DevBasicInfo.Serial)) { shell.Connect(); ob.Register(shell); retCode = shell.SafetyInput($"sh {ScriptPath}").GetExitCode(); } ob.ExitCode = retCode; _result = ob.Result; return(_result); }