Пример #1
0
        public bool excuteCmdGetFastState()
        {
            bool      state       = false;
            CmdResult result      = excuteCmd(Enums.CmdType.CMD_FASTBOOT, "devices", false);
            String    s           = result.output;
            Regex     regFastboot = new Regex(@"\d{1,8}");
            Match     match       = regFastboot.Match(s);

            if (match.Length > 0)
            {
                state = true;
            }
            else
            {
                state = false;
            }
            //   Log("fast:" + state);
            return(state);
        }
Пример #2
0
        public bool excuteCmdGetAdbState()
        {
            bool      state  = false;
            CmdResult result = excuteCmd(Enums.CmdType.CMD_ADB, "devices", false);
            String    s      = result.output;

            Regex regAdb = new Regex(@"\d{1,8}");
            Match match  = regAdb.Match(s);

            if (match.Length > 0)
            {
                state = true;
            }
            else
            {
                state = false;
            }
            //  Log(Enums.CmdType.CMD_ADB + state);
            return(state);
        }
Пример #3
0
        public bool excuteCmdFlashBoot(String s)
        {
            CmdResult result = new CmdResult();
            bool      exist  = File.Exists(s);

            if (exist)
            {
                result = excuteCmd(Enums.CmdType.CMD_FASTBOOT, "flash boot " + s, true);
            }
            else
            {
                s += " is not exist";
                s += "\r\n";
                if ((mIntfShow != null))
                {
                    mIntfShow.showText(s);
                }
            }
            return(exist & result.getResult());
        }
Пример #4
0
        public CmdResult excuteCmd(String cmd, String para, bool show)
        {
            CmdResult result  = new CmdResult();
            Process   process = new Process();

            if (show)
            {
                mIntfShow.showText("$:" + cmd + " " + para + "\r\n");
            }
            process.StartInfo.FileName        = cmd;
            process.StartInfo.Arguments       = para;
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.CreateNoWindow  = true;
            //process.StartInfo.RedirectStandardInput = true;  // 重定向输入流
            process.StartInfo.RedirectStandardOutput = true; //重定向输出流
            process.StartInfo.RedirectStandardError  = true; //重定向错误流

            process.Start();


            Thread errorThreadReader = new Thread(new ParameterizedThreadStart(writeErrorThread));

            //adb start-server has bug block
            if (para.Equals("start-server") == false)
            {
                errorThreadReader.Start(process.StandardError);
            }

            String       output     = "";
            StreamReader readStream = process.StandardOutput;

            while (!readStream.EndOfStream)
            {
                String s = readStream.ReadLine();
                s += "\r\n";
                if ((mIntfShow != null) && (show == true))
                {
                    mIntfShow.showText(s);
                }
                output += s;
                //adb start-server has bug block
                if (para.Equals("start-server"))
                {
                    Regex regx  = new Regex("starting it now on port");
                    Match match = regx.Match(s);
                    if (match.Length > 0)
                    {
                        Console.WriteLine(" exit start-server process");
                        break;
                    }
                }
            }
            readStream.Close();
            process.WaitForExit();
            result.ret    = process.ExitCode;
            result.output = output;

            process.Close();

            return(result);
        }
Пример #5
0
 public void excuteCmdForward(String src, String to)
 {
     CmdResult result = excuteCmd(Enums.CmdType.CMD_ADB, " forward tcp:" + src + " tcp:" + to, true);
 }
Пример #6
0
        public bool excuteCmdPull(String file)
        {
            CmdResult result = excuteCmd(Enums.CmdType.CMD_ADB, " pull " + file + " " + Enums.Path.CACHE, true);

            return(result.getResult());
        }
Пример #7
0
        public bool excuteCmdSearch(String file)
        {
            CmdResult result = excuteCmd(Enums.CmdType.CMD_ADB, " shell busybox find . -name " + file, true);

            return(result.getResult());
        }
Пример #8
0
        public String excuteCmdCmdline()
        {
            CmdResult result = excuteCmd(Enums.CmdType.CMD_ADB, "shell cat /proc/cmdline", true);

            return(result.output);
        }
Пример #9
0
 public void excuteCmdHome()
 {
     CmdResult result = excuteCmd(Enums.CmdType.CMD_ADB, "shell input keyevent 3", true);
 }
Пример #10
0
        ///
        ///
        public bool excuteCmdExistFile(String s)
        {
            CmdResult res = excuteCmd(Enums.CmdType.CMD_ADB, " shell ls " + s, true);

            return(res.getResult());
        }