Example #1
0
        /// <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);
        }
Example #2
0
        /// <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);
        }