Example #1
0
        private static void Main(string[] args)
        {
            Console.BufferWidth = Math.Min(Console.LargestWindowWidth, 150);
            Console.WindowWidth = Math.Min(Console.LargestWindowWidth, 150);

            ProcessFactory.SetBasePath(args.Length > 0 ? args[0] : string.Empty);
            Console.WriteLine("Utility is using '" + ProcessFactory.BasePath + "' as the path to your scrcpy-installation.");

            // preset the scrcpy arguments with some default values
            ScrcpyArguments.Global.NoControl     = false;
            ScrcpyArguments.Global.TurnScreenOff = true;
            ScrcpyArguments.Global.MaxSize       = 1280;
            // prefills the list of devices available on this machine
            Commands.RunGetAvailableDevices();
            ADBDevice.SelectDevice("", true);

            do
            {
                Console.WriteLine("Please enter your command (type 'quit' to terminate the application).");
                Console.Write("> ");

                _command = Console.ReadLine();
                Program.ProcessCommand(_command);
            }while (!_command.Equals(Commands.CMD_Quit));

            // terminate all scrcpy processes running for available devices
            foreach (ADBDevice device in ADBDevice.AllDevicesCollection)
            {
                if (device.IsConnected)
                {
                    device.Process.CloseMainWindow();
                    device.Process.Kill();
                }
            }
        }
Example #2
0
        public override bool Remount()
        {
            ValidateState();

            ADBDevice.RemountMountPoint("/system", false);

            return(true);
        }
Example #3
0
        public override bool Install(string packagePath)
        {
            ValidateState();

            mEventProvider.OnActivityProgressUpdated(new ActivityProgressUpdatedEventArgs(string.Format(Resources.LblActivityInstallPackage, packagePath), 0, -1));

            try
            {
                ADBDevice.InstallPackage(packagePath, false);
            }
            finally
            {
                mEventProvider.OnActivityProgressUpdated(new ActivityProgressUpdatedEventArgs(Resources.LblActivityInstallFinished, 1, 1));
            }

            return(true);
        }
Example #4
0
        protected override string ExecuteShellCommand(string command, bool reportOutput)
        {
            MultilineShellOutputReceiver outputReceiver = new MultilineShellOutputReceiver(this, reportOutput);

            try
            {
                ADBDevice.ExecuteRootShellCommand(command, outputReceiver);
            }
            catch (OperationCanceledException)
            {
                HandleAbort();

                return(null);
            }

            return(outputReceiver.CombinedOutput);
        }
Example #5
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;
        }
Example #6
0
        //logic

        public void Click(Point GamePoint)
        {
            ADBDevice.ExecuteShellCommand("input mouse tap " + GamePoint.X + " " + GamePoint.Y, Receiver);
        }
Example #7
0
 protected override bool InstalldirEntry(string packagePath)
 {
     ADBDevice.InstallPackage(packagePath, false);
     return(true);
 }