public async Task <string> GetConnectedDeviceIpAddressAsync(MobileDevice device)
        {
            var data = GetDeviceData(device);
            var recv = new ConsoleOutputReceiver();

            await AdbClient
            .Instance
            .ExecuteRemoteCommandAsync(WiFiAddressCommand, data, recv, CancellationToken.None, LaunchTimeout);

            var output = recv.ToString();

            return(ParseIpAddress(output));
        }
        public async Task <bool> IsDesignerRunning(MobileDevice device)
        {
            await CheckDesignerInstalledAsync(device);

            var data = GetDeviceData(device);
            var recv = new ConsoleOutputReceiver();

            await AdbClient
            .Instance
            .ExecuteRemoteCommandAsync(ProcessRunningCommand, data, recv, CancellationToken.None, LaunchTimeout);

            return(recv.ToString().Contains(PackageName));
        }
        public async Task StopDesignerAsync(MobileDevice device)
        {
            var running = await IsDesignerRunning(device);

            if (!running)
            {
                return;
            }

            var data = GetDeviceData(device);
            var recv = new ConsoleOutputReceiver();

            await AdbClient
            .Instance
            .ExecuteRemoteCommandAsync(DesignerStopCommand, data, recv, CancellationToken.None, LaunchTimeout);
        }
        public async Task <bool> CheckDesignerInstalledAsync(MobileDevice device)
        {
            var data = GetDeviceData(device);
            var recv = new ConsoleOutputReceiver();

            await AdbClient
            .Instance
            .ExecuteRemoteCommandAsync(DesignerInstalledCommand, data, recv, CancellationToken.None, LaunchTimeout);

            var result = recv.ToString();

            if (result.Contains($"package:{PackageName}"))
            {
                return(true);
            }

            return(false);
        }
        public async Task InstallDesignerAsync(MobileDevice device, string localApk)
        {
            await Task.Run(() =>
            {
                var data = GetDeviceData(device);

                using (var service = new SyncService(data))
                {
                    using (Stream stream = File.OpenRead(localApk))
                    {
                        service.Push(stream, TempPackage, 777, DateTime.Now, null, CancellationToken.None);
                    }
                }

                var manager = new PackageManager(data);
                manager.InstallRemotePackage(TempPackage, true);
            });
        }
        public async Task <bool> LegacyCheckVersionInstalledAsync(MobileDevice device, int version)
        {
            var data = GetDeviceData(device);
            var recv = new ConsoleOutputReceiver();

            await AdbClient
            .Instance
            .ExecuteRemoteCommandAsync(VersionCodeCommand, data, recv, CancellationToken.None, LaunchTimeout);

            var result = recv.ToString();

            if (result.Contains($"versionCode={version}"))
            {
                return(true);
            }

            return(false);
        }
        public async Task <bool> IsRecentVersionInstalledAsync(MobileDevice device, int version)
        {
            var data      = GetDeviceData(device);
            var installed = await CheckDesignerInstalledAsync(device);

            if (!installed)
            {
                return(false);
            }

            var manager = new PackageManager(data);
            var info    = manager.GetVersionInfo(PackageName);

            if (info != null)
            {
                return(version == info.VersionCode);
            }

            var legacyCheck = await LegacyCheckVersionInstalledAsync(device, version);

            return(legacyCheck);
        }
Beispiel #8
0
 public DeviceItemView(AndroidDeviceBridge bridge, MobileDevice device)
 {
     Bridge = bridge;
     Device = device;
     CreateLayout();
 }
        public async Task <Image> CaptureScreenAsync(MobileDevice device)
        {
            var data = GetDeviceData(device);

            return(await AdbClient.Instance.GetFrameBufferAsync(data, CancellationToken.None));
        }