Example #1
0
        public static void myRename(int index, string name, string dizhi)
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            myldcmd.SimulatorPath = ld.SimulatorPath;
            myldcmd.rename(index, name);
        }
Example #2
0
        public static void myBackup(int index, string path, string dizhi)
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            myldcmd.SimulatorPath = ld.SimulatorPath;
            myldcmd.backUp(index, path);
        }
Example #3
0
        /// <summary>
        /// 新建模拟器并得到新建模拟器的index
        /// </summary>
        public static int addSimulator()
        {
            int     res     = -1;
            MyLdcmd myldcmd = MyLdcmd.GetObject();

            lock (obj)
            {
                int[] dq = getDqmoniqiIndex();
                foreach (int a in dq)
                {
                    //WriteLog.WriteLogFile("", a+"号模拟器");
                }
                ld.AddSimulator();
                int[] dq2 = getDqmoniqiIndex();
                foreach (int a in dq2)
                {
                    //WriteLog.WriteLogFile("", "新增后,"+a + "号模拟器");
                }
                foreach (int a in dq2)
                {
                    if (!dq.Contains <int>(a))
                    {
                        res = a;
                        modifySimulator(res);
                        WriteLog.WriteLogFile("", res + "号模拟器是新增的");
                    }
                }
            }
            return(res);
        }
Example #4
0
        public static void myQuitAll(string dizhi)
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            MyFuncUtil.killProcess("dnplayer");
            Thread.Sleep(10000);
            int[] abcd = getDqmoniqiHuodongIndex(dizhi);
            foreach (var a in abcd)
            {
                if (a == -1)
                {
                    continue;
                }
                while (true)
                {
                    int[]     abc = getDqmoniqiHuodongIndex(dizhi);
                    ArrayList ar  = new ArrayList(); //实例化一个ArrayList
                    ar.AddRange(abc);                //把数组赋到Arraylist对象
                    if (ar.Contains(a))
                    {
                        MyFuncUtil.mylogandxianshi("关闭模拟器" + a);
                        ld.Quit(a);
                    }
                    if (!ar.Contains(a))
                    {
                        MyFuncUtil.mylogandxianshi("模拟器" + a + ",关闭成功");
                        break;
                    }
                }
            }
        }
Example #5
0
        public static void ClearAndCopySimulator(string a_b)
        {
            MyFuncUtil.mylogandxianshi("关闭全部模拟器");
            string dizhi = null;
            string path  = null;
            string seed  = null;

            MyFuncUtil.myqiehuancd(a_b, out dizhi, out path, out seed);
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            myQuitAll(dizhi);
            Thread.Sleep(20000);
            MyFuncUtil.mylogandxianshi("删除全部模拟器");
            myRemoveAll(dizhi);
            Thread.Sleep(20000);
            MyFuncUtil.mylogandxianshi("模拟器0复原");
            myRestore(0, seed, dizhi);
            Thread.Sleep(30000);
            MyFuncUtil.mylogandxianshi("开始模拟器复制");
            int sl = 0;

            if (a_b.ToLower().Equals("c"))
            {
                sl = 19;
            }
            if (a_b.ToLower().Equals("d"))
            {
                sl = 21;
            }
            myCopySimulator(sl, dizhi);
            Thread.Sleep(20000);
        }
Example #6
0
        public static void myCopySimulator(int shuliang, string dizhi)
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);
            int     i       = 0;

            while (true)
            {
                MyFuncUtil.mylogandxianshi((i++) + "个模拟器开始复制");
                int[] moniqiIndex = getDqmoniqiIndex(dizhi);
                try
                {
                    LogWriteLock.EnterWriteLock();
                    ld.CopySimulator(0);
                }
                catch { }
                finally
                {
                    LogWriteLock.ExitWriteLock();
                }
                Thread.Sleep(40000);
                if (moniqiIndex.Length >= shuliang)
                {
                    break;
                }
            }
        }
Example #7
0
        /// <summary>
        /// 启动应用
        /// </summary>
        /// <param name="index">模拟器序号</param>
        /// <param name="value">包名/Activity类名</param>
        /// <returns></returns>
        public static string StartApp(int index, string value)
        {
            MyLdcmd md = MyLdcmd.GetObject();
            string  a  = md.ImplementCmd(string.Format("{0}ld -s {1} am start -n {2}", md.SimulatorPath, index, value));

            WriteLog.WriteLogFile(index + "", string.Format("{0}ld -s {1} am start -n {2}", md.SimulatorPath, index, value));
            return(a);
        }
Example #8
0
        public static void myScreencapLuneng(int index, string path, string sdcardpath = "Pictures")
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject();
            string  zd      = "/sdcard/" + sdcardpath;

            myldcmd.SimulatorPath = ld.SimulatorPath;
            myldcmd.pullFile(index, path, zd);
        }
Example #9
0
        public static void myReboot(int index, string dizhi = @"d:\ChangZhi\dnplayer2\")
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            myldcmd.SimulatorPath = ld.SimulatorPath;

            myldcmd.reboot(index);
        }
Example #10
0
        public static void myClearAppData(string dizhi, int dqinx, string apkname)
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            myldcmd.SimulatorPath = ld.SimulatorPath;
            string a = ld.ClearAppData(dqinx, apkname);

            WriteLog.WriteLogFile("", a);
        }
Example #11
0
        public static void myLaunch(string dizhi, int dqinx, string apkname)
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            myldcmd.SimulatorPath = ld.SimulatorPath;
            string a = myldcmd.Launch(dqinx);

            WriteLog.WriteLogFile("", a);
        }
Example #12
0
        /// <summary>
        /// 修改模拟器默认属性设置
        /// </summary>
        public static void modifySimulator(int index)
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject();

            lock (obj)
            {
                myldcmd.ImplementCmd(string.Format("{0}dnconsole modify --index {1} --resolution 540,960,240 --cpu 1 --memory 1024 --imei auto", myldcmd.SimulatorPath, index));
                WriteLog.WriteLogFile(index + "", string.Format("{0}dnconsole modify --index {1} --resolution 540,960,240 --cpu 1 --memory 1024 --imei auto", myldcmd.SimulatorPath, index));
            }
        }
Example #13
0
        public static void myRestore(int index, string seed, string dizhi)
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            myldcmd.SimulatorPath = ld.SimulatorPath;
            lock (obj){
                myldcmd.restore(index, seed);
                Thread.Sleep(1000 * 20);
            }
        }
Example #14
0
        public static void myScreencap(int index, string path, string dizhi = @"d:\ChangZhi\dnplayer2\")
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);
            string  zd      = "/sdcard/screencap.png";
            string  a       = ld.Screencap(index, zd);

            WriteLog.WriteLogFile(index + "", a);
            Thread.Sleep(3000);
            myldcmd.SimulatorPath = ld.SimulatorPath;
            myldcmd.pullFile(index, path, zd);
        }
Example #15
0
        /// <summary>
        /// 查看已创建的模拟器状态 PS:依次是:索引,标题,顶层窗口句柄,绑定窗口句柄,是否进入android,进程PID,VBox进程PID
        /// </summary>
        /// <returns>直接返回List集合</returns>
        public static List <String> GetListSimulator(string dizhi)
        {
            MyLdcmd       myldcmd = MyLdcmd.GetObject(dizhi);
            List <string> slist   = ld.ListSimulator();

            if ((slist.Count > 0))
            {
                return(slist);
            }
            myldcmd.SimulatorPath = ld.SimulatorPath;
            slist = myldcmd.ListSimulator();
            return(slist);
        }
Example #16
0
        public static void myDownCpu(int index, int rate, string dizhi = @"d:\ChangZhi\dnplayer2\")
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            myldcmd.SimulatorPath = ld.SimulatorPath;
            string a = "";

            lock (obj)
            {
                a = ld.Downcpu(index, rate);
            }
            WriteLog.WriteLogFile(index + "", a);
        }
Example #17
0
        public static string IsRunning(int index, string path, string dizhi)
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            myldcmd.SimulatorPath = ld.SimulatorPath;
            string a = myldcmd.isrunning(index, path);

            string[] str = Regex.Split(a, "\r\n", RegexOptions.IgnoreCase);
            foreach (string ab in str)
            {
                //WriteLog.WriteLogFile("", a);
            }
            return(str[4]);
        }
Example #18
0
        public static void myRemove(int dqinx, string dizhi = @"d:\ChangZhi\dnplayer2\")
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            int[] moniqiIndex = getDqmoniqiIndex(dizhi);
            lock (obj)
            {
                if (moniqiIndex.Contains(dqinx))
                {
                    ld.RemoveSimulator(dqinx);
                }
            }
            WriteLog.WriteLogFile(dqinx + "", dqinx + "号模拟器已经移除");
        }
Example #19
0
        public static void mySort(string a_b)
        {
            string dizhi = null;

            if (a_b.ToLower().Equals("c"))
            {
                dizhi = @"C:\ChangZhi\dnplayer2\";
            }
            if (a_b.ToLower().Equals("d"))
            {
                dizhi = @"D:\ChangZhi\dnplayer2\";
            }
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            myldcmd.SimulatorPath = ld.SimulatorPath;
            string a = ld.SortWnd();

            WriteLog.WriteLogFile("", a);
        }
Example #20
0
        public static void myLaunch1(int index, string dizhi)
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);
            Int64   kstime  = MyFuncUtil.GetTimestamp();

            while (true)
            {
                ld.Launch(index);
                Thread.Sleep(20000);
                int[] abc = getDqmoniqiHuodongIndex(dizhi);
                if (abc.Contains(index))
                {
                    break;
                }
                Int64 jstime = MyFuncUtil.GetTimestamp();
                if ((jstime - kstime) > 1000 * 60 * 5)
                {
                    MyFuncUtil.mylogandxianshi("打开很久5分钟也没打开" + index);
                    break;
                }
            }
        }
Example #21
0
        public static void myRemoveAll(string dizhi)
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            while (true)
            {
                int[] moniqiIndex = getDqmoniqiIndex(dizhi);
                foreach (int i in moniqiIndex)
                {
                    if (i == 0)
                    {
                        continue;
                    }
                    ld.RemoveSimulator(i);
                    MyFuncUtil.mylogandxianshi(i + "个模拟器开始移除");
                    Thread.Sleep(10000);
                }
                if (moniqiIndex.Length == 1)
                {
                    break;
                }
            }
        }
Example #22
0
        private static bool myQuit(int index, string dizhi)
        {
            var res = false;

            lock (obj)
            {
                int    jubing = MyLdcmd.getDqmoniqiWaiCengJuBingByIndex(index, dizhi);
                IntPtr p      = new IntPtr(jubing);
                PostMessage(p, WM_CLOSE, 0, 0);
                Thread.Sleep(5000);
                MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);
                long    kstime  = GetTimestamp();
                long    kstime2 = GetTimestamp();
                int[]   abc     = MyLdcmd.getDqmoniqiHuodongIndex(dizhi);
                if (abc.Contains(index))
                {
                    MyLdcmd.getLdCmd().Quit(index);
                    Thread.Sleep(5000);
                    zaiciguanbi();
                }
                abc = MyLdcmd.getDqmoniqiHuodongIndex(dizhi);
                if (!abc.Contains(index))
                {
                    return(true);
                }
                int shi = 0;
                while (true)
                {
                    long jstime = GetTimestamp();
                    if ((jstime - kstime2) > 1000 * 30)
                    {
                        abc     = MyLdcmd.getDqmoniqiHuodongIndex(dizhi);
                        kstime2 = GetTimestamp();
                    }
                    if (shi == 0 && abc.Contains(index))
                    {
                        MyLdcmd.getLdCmd().Quit(index);
                        Thread.Sleep(5000);
                        zaiciguanbi();
                        shi = 1;
                    }
                    if (shi == 1 && abc.Contains(index))
                    {
                        PostMessage(p, WM_CLOSE, 0, 0);
                        Thread.Sleep(5000);
                        shi = 0;
                    }
                    if (!abc.Contains(index))
                    {
                        res = true;
                        break;
                    }
                    if ((jstime - kstime) > 1000 * 60 * 5)
                    {
                        mylogandxianshi("循环很久5分钟也没有关闭" + index);
                        break;
                    }
                }
            }
            return(res);
        }
Example #23
0
        public bool myQuit(int index, string dizhi, int jubing)
        {
            var res = false;

            if (jubing <= 0)
            {
                WriteLog.WriteLogFile(index + "", "准备获取句柄,在myquit处");
                jubing = MyLdcmd.getDqmoniqiWaiCengJuBingByIndex(index, dizhi);
            }
            IntPtr p = new IntPtr(jubing);

            PostMessage(p, WM_CLOSE, 0, 0);
            Thread.Sleep(5000);
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);
            long    kstime  = MyFuncUtil.GetTimestamp();
            long    kstime2 = MyFuncUtil.GetTimestamp();

            int[] abc = MyLdcmd.getDqmoniqiHuodongIndex(dizhi);
            if (abc.Contains(index))
            {
                MyLdcmd.getLdCmd().Quit(index);
                Thread.Sleep(5000);
                MyFuncUtil.zaiciguanbi();
            }
            abc = MyLdcmd.getDqmoniqiHuodongIndex(dizhi);
            if (!abc.Contains(index))
            {
                return(true);
            }
            int shi = 0;

            while (true)
            {
                long jstime = MyFuncUtil.GetTimestamp();
                if ((jstime - kstime2) > 1000 * 30)
                {
                    abc     = MyLdcmd.getDqmoniqiHuodongIndex(dizhi);
                    kstime2 = MyFuncUtil.GetTimestamp();
                }
                if (shi == 0 && abc.Contains(index))
                {
                    MyLdcmd.getLdCmd().Quit(index);
                    Thread.Sleep(5000);
                    MyFuncUtil.zaiciguanbi();
                    shi = 1;
                }
                if (shi == 1 && abc.Contains(index))
                {
                    PostMessage(p, WM_CLOSE, 0, 0);
                    Thread.Sleep(5000);
                    shi = 0;
                }
                if (!abc.Contains(index))
                {
                    res = true;
                    break;
                }
                if ((jstime - kstime) > 1000 * 60 * 5)
                {
                    MyFuncUtil.mylogandxianshi("循环很久5分钟也没有关闭" + index);
                    break;
                }
            }

            return(res);
        }