示例#1
0
        public void FindEntryTest( )
        {
            Device device = GetFirstDevice( );

            FileEntry fe = FileEntry.Find(device, "/system/");

            fe = FileEntry.Find(device, "/system/bin/");

            fe = FileEntry.Find(device, "/mnt/sdcard/Android/data/com.camalotdesigns.myandroider/Injector.jar");
            // test links
            fe = FileEntry.Find(device, "/sdcard/Android/data/com.camalotdesigns.myandroider/Injector.jar");
        }
示例#2
0
        public static void GetDevicesTest()
        {
            AndroidDebugBridge.Initialize(true);

            List <Device> devices = AdbHelper.Instance.GetDevices(AndroidDebugBridge.SocketAddress);

            foreach (var item in devices)
            {
                //Monitor.
                FileMonitor monitor = new FileMonitor();

                //List of remote files to be downloaded.
                List <FileEntry> files = new List <FileEntry>();

                //First remote file.
                FileEntry file = FileEntry.Find(item, "/data/data/com.netmarble.lin2ws/shared_prefs/NetmarbleNeo_LineageS.xml");

                //Add remote file to list of remote files.
                files.Add(file);

                //Local filename string split character.
                string axe = ":";

                //Local filename.
                string[] f = Regex.Split(item.SerialNumber, axe);

                //Local path + filename.
                string localFilename = "C:\\test\\" + f[f.Length - 1] + ".xml";

                ShellOutputReceiver receiver = new ShellOutputReceiver();

                if (!item.CanSU())
                {
                    MainWindow.main.UpdateLog = "Root Android.";
                }

                try
                {
                    item.ExecuteShellCommand("input mouse tap 640 340", receiver);
                }
                catch (Exception e)
                {
                    MainWindow.main.UpdateLog = e.ToString();
                }



                //Pull file from remote emulator to local folder.
                item.SyncService.Pull(files, "C:\\test\\", monitor);

                //Rename file to adb port number.
                File.Delete(localFilename);
                File.Move("C:\\test\\NetmarbleNeo_LineageS.xml", localFilename);

                //sample code:
                //<string name="LOCAL_PUSH_TARGET">CharacterName</string>
                string text = Xml.FindInnerTextByTagAttribute(localFilename, "string", "name", "LOCAL_PUSH_TARGET");
                MainWindow.main.UpdateLog = text;

                ////testing shell commands
                //ShellOutPRec receiver = new ShellOutPRec( );
                //item.ExecuteShellCommand("ps", receiver);

                ////testing pull command
                //FileMonitor monitor = new FileMonitor();
                //List<FileEntry> files = new List<FileEntry>();
                //FileEntry file = FileEntry.Find(item, "/data/data/com.netmarble.lin2ws/shared_prefs/");
                //files.Add(file);
                //item.SyncService.Pull(files, "shared_prefs", monitor);

                ////testing screencap
                //PixelFormat format = PixelFormat.Format32bppArgb;
                //Image image = item.Screenshot.ToImage(format);

                //MainWindow.main.UpdateLog = item.SerialNumber + ", " + item.State + item.IsEmulator + " - Emulator" + receiver;
            }
        }
示例#3
0
        public void GetCharacterName()
        {
            //List of remote files to be downloaded.
            List <FileEntry> Files = new List <FileEntry>();

            try
            {
                //First remote file.
                FileEntry File = FileEntry.Find(ADBDevice, "/data/data/com.netmarble.lin2ws/shared_prefs/NetmarbleNeo_LineageS.xml");

                //Add remote file to list of remote files.
                Files.Add(File);
            }
            catch (Exception e)
            {
                MainWindow.main.UpdateLog = "Unable to locate player data";
            }

            //Local filename string split character.
            string Axe = ":";

            //Local filename.
            string[] FileName = Regex.Split(ADBDevice.SerialNumber, Axe);

            LocalPath = "C:\\temp\\";

            if (!Directory.Exists(LocalPath))
            {
                Directory.CreateDirectory(LocalPath);
            }

            //Local path + filename.
            string LocalURI = LocalPath + FileName[FileName.Length - 1] + ".xml";


            if (!ADBDevice.CanSU())
            {
                MainWindow.main.UpdateLog = "Android must be Rooted.";
            }

            try
            {
                //Pull file from remote emulator to local folder.
                ADBDevice.SyncService.Pull(Files, LocalPath, Monitor);
            }
            catch (Exception e)
            {
                MainWindow.main.UpdateLog = "Unable to locate player data";
            }

            //Rename file to adb port number.
            System.IO.File.Delete(LocalURI);
            try
            {
                System.IO.File.Move(LocalPath + "NetmarbleNeo_LineageS.xml", LocalURI);
                //sample XML input code:
                //<string name="LOCAL_PUSH_TARGET">CharacterName</string>
                CharacterName = Xml.FindInnerTextByTagAttribute(LocalURI, "string", "name", "LOCAL_PUSH_TARGET");
            }
            catch (Exception e)
            {
                MainWindow.main.UpdateLog = "Unable to rename file, file read/write error.";
            }
            if (CharacterName == null)
            {
                CharacterName = FileName[FileName.Length - 1];
            }

            ////testing shell commands
            //ShellOutPRec receiver = new ShellOutPRec( );
            //item.ExecuteShellCommand("ps", receiver);

            ////testing pull command
            //FileMonitor monitor = new FileMonitor();
            //List<FileEntry> files = new List<FileEntry>();
            //FileEntry file = FileEntry.Find(item, "/data/data/com.netmarble.lin2ws/shared_prefs/");
            //files.Add(file);
            //item.SyncService.Pull(files, "shared_prefs", monitor);

            ////testing screencap
            //PixelFormat format = PixelFormat.Format32bppArgb;
            //Image image = item.Screenshot.ToImage(format);


            ////Local storage path
            //LocalPath = "C:\\test\\";

            ////Monitor.
            //Monitor = new FileMonitor();

            //MainWindow.main.UpdateLog = ADBDevice.SerialNumber;
            ////Root Check
            //if (!ADBDevice.CanSU())
            //{
            //    MainWindow.main.UpdateLog = "Root Android.";
            //}

            ////List of remote files to be downloaded.
            //List<FileEntry> files = new List<FileEntry>();

            ////First remote file.
            //FileEntry file = FileEntry.Find(ADBDevice, "/data/data/com.netmarble.lin2ws/shared_prefs/NetmarbleNeo_LineageS.xml");

            ////Device 'IP:Port'.
            //string DeviceIPPort = ADBDevice.SerialNumber;

            ////String split character.
            //string Axe = ":";

            ////[0]IP
            ////[1]Port
            //string[] FileData = Regex.Split(DeviceIPPort, Axe);

            ////the last index in FileData containing Port.
            //string Port = FileData[FileData.Length - 1];

            ////Local storage path + Port.xml.
            //string LocalFilename = "C:\\test\\" + Port + ".xml";

            ////Delete the old file, if present.
            ////File.Delete(LocalFilename);

            ////Pull file from remote emulator to LocalPath.
            //ADBDevice.SyncService.Pull(files, "C:\\test\\", Monitor);

            //MainWindow.main.UpdateLog = Receiver.ToString();

            //Thread.Sleep(1000);

            ////Rename file to adb port number.
            //File.Move(LocalPath + "NetmarbleNeo_LineageS.xml", LocalFilename);

            ////sample XML to understand usage:
            ////<string name="LOCAL_PUSH_TARGET">CharacterName</string>
            ////<return>CharacterName</return>
            //CharacterName = Xml.FindInnerTextByTagAttribute(LocalFilename, "string", "name", "LOCAL_PUSH_TARGET");

            ////Show CharacterName
            //MainWindow.main.UpdateLog = CharacterName;
        }