/// <summary>
        /// 主方法
        /// </summary>
        /// <param name="toolKit"></param>
        /// <returns></returns>
        protected override Output MainMethod(ToolKit <FlowArgs> toolKit)
        {
            var result = new NetDebuggingOpener().Run(new NetDebuggingOpenerArgs()
            {
                Port         = 5555,
                DevBasicInfo = toolKit.Args.DevBasicInfo
            });

            return(result.OutputData);
        }
Пример #2
0
        /// <summary>
        /// 尝试开启网络调试
        /// </summary>
        protected async virtual void TryFixAndroidAdb()
        {
            try
            {
                await Task.Run(() =>
                {
                    uint port = 5555;
                    Thread.Sleep(3000);

                    var opener = new NetDebuggingOpener();
                    opener.Init(new NetDebuggingOpenerArgs()
                    {
                        DevBasicInfo = _tooKit.Args.DevBasicInfo, Port = port
                    });
                    var openerResult = opener.Run();


                    if (openerResult.ExitCode == 0)                                                       //如果开启成功
                    {
                        Thread.Sleep(2000);                                                               //稍等一会儿
                        IPAddress ip = new DeviceSoftwareInfoGetter(_tooKit.Args.Serial).GetLocationIP(); //获取设备IP

                        //连接到该设备
                        var connecter = new NetDeviceConnecter();
                        connecter.Init(new NetDeviceConnecterArgs()
                        {
                            IPEndPoint = new IPEndPoint(ip, (int)port)
                        });
                        connecter.Run();
                    }

                    Logger.Info(this, "Fix android o adb successful....");
                });
            }
            catch (Exception e)
            {
                FixFailed(this, e);
                Logger.Warn(this, "Fix android o adb failed....", e);
            }
        }