public static void ExecutePrepare(object parameter)
 {
     Context = (TextBlock)parameter;
     BackgroundWorker worker = new BackgroundWorker();
     worker.DoWork += async (sender, args) =>
     {
         await Context.Dispatcher.InvokeAsync(() => { _adb = new AdbTools(Context); });
         await Task.Run(async () => await _adb.Prepare());
     };
     worker.RunWorkerCompleted += (sender, args) => worker.Dispose();
     worker.RunWorkerAsync();
 }
 public static void ExecuteListDevices(object parameter)
 {
     UIParameters parameters = (UIParameters)parameter;
     if (parameters != null)
     {
         Context = parameters.Context;
         BackgroundWorker worker = new BackgroundWorker();
         worker.DoWork += async (sender, args) =>
         {
             await Context.Dispatcher.InvokeAsync(async () =>
             {
                 _adb = new AdbTools(Context);
                 await _adb.ListDevices(parameters.Context2, parameters.Bool);
             });
         };
         worker.RunWorkerCompleted += (sender, args) => worker.Dispose();
         worker.RunWorkerAsync();
     }
 }
 public static void ExecuteReboot(object parameter)
 {
     SingleCommandParameters parameters = (SingleCommandParameters)parameter;
     Context = parameters.Context;
     BackgroundWorker worker = new BackgroundWorker();
     worker.DoWork += async (sender, args) =>
     {
         await Context.Dispatcher.InvokeAsync(() => { _adb = new AdbTools(Context); });
         await Task.Run(async () => await _adb.Reboot(parameters.Bool, parameters.Target));
     };
     worker.RunWorkerCompleted += (sender, args) => worker.Dispose();
     worker.RunWorkerAsync();
 }
 public static void ExecuteRemoteDisconnect(object parameter)
 {
     SingleCommandParameters parameters = parameter as SingleCommandParameters;
     if (parameters != null)
     {
         Context = parameters.Context;
         BackgroundWorker worker = new BackgroundWorker();
         worker.DoWork += async (sender, args) =>
         {
             await Context.Dispatcher.InvokeAsync(async () =>
             {
                 _adb = new AdbTools(Context);
                 await _adb.RemoteDisconnect(parameters.Bool);
             });
         };
         worker.RunWorkerCompleted += (sender, args) => worker.Dispose();
         worker.RunWorkerAsync();
     }
 }
 public static void ExecuteBackup(object parameter)
 {
     BackupParameters parameters = parameter as BackupParameters;
     if (parameters != null)
     {
         Context = parameters.Context;
         BackgroundWorker worker = new BackgroundWorker();
         worker.DoWork += async (sender, args) =>
         {
             await Context.Dispatcher.InvokeAsync(async () =>
             {
                 _adb = new AdbTools(Context);
                 if (parameters.Context2.SelectedIndex == 0)
                 {
                     await _adb.Backup(parameters.Text, parameters.Text2, AdbBackupMode.All, parameters.Bool, parameters.Target);
                 }
                 if (parameters.Context2.SelectedIndex == 1)
                 {
                     await _adb.Backup(parameters.Text, parameters.Text2, AdbBackupMode.Apps, parameters.Bool, parameters.Target);
                 }
                 if (parameters.Context2.SelectedIndex == 2)
                 {
                     await _adb.Backup(parameters.Text, parameters.Text2, AdbBackupMode.SystemApps, parameters.Bool, parameters.Target);
                 }
                 if (parameters.Context2.SelectedIndex == 3)
                 {
                     await _adb.Backup(parameters.Text, parameters.Text2, AdbBackupMode.AppsWithoutSystemApps, parameters.Bool, parameters.Target);
                 }
                 if (parameters.Context2.SelectedIndex == 4)
                 {
                     await _adb.Backup(parameters.Text, parameters.Text2, AdbBackupMode.SDCard, parameters.Bool, parameters.Target);
                 }
             });
         };
         worker.RunWorkerCompleted += (sender, args) => worker.Dispose();
         worker.RunWorkerAsync();
     }
 }
 public static void ExecuteSingleCommand(object parameter)
 {
     TwoCommandParameters parameters = parameter as TwoCommandParameters;
     if (parameters != null)
     {
         Context = parameters.Context;
         BackgroundWorker worker = new BackgroundWorker();
         worker.DoWork += async (sender, args) =>
         {
             await Context.Dispatcher.InvokeAsync(async () =>
             {
                 _adb = new AdbTools(Context);
                 var cmds = new string[1];
                 cmds[0] = parameters.Text;
                 await _adb.Execute(cmds, parameters.Bool, parameters.Target);
             });
         };
         worker.RunWorkerCompleted += (sender, args) => worker.Dispose();
         worker.RunWorkerAsync();
     }
 }
        public static void Execute(object parameter)
        {
            ExecuteCommandParameters parameters = parameter as ExecuteCommandParameters;
            if (parameters != null)
            {
                Context = parameters.Context;
                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += async (sender, args) =>
                {
                    await Context.Dispatcher.InvokeAsync(async () =>
                    {
                        _adb = new AdbTools(Context);
                        var cmds = new List<string>
                        {
                            parameters.Text,
                            parameters.Text2,
                            parameters.Text3,
                            parameters.Text4,
                            parameters.Text5,
                            parameters.Text6,
                            parameters.Text7,
                            parameters.Text8,
                            parameters.Text9,
                            parameters.Text10
                        };
                        await _adb.Execute(cmds.ToArray<string>(), parameters.Bool, parameters.Target);
                    });
                };
                worker.RunWorkerCompleted += (sender, args) => worker.Dispose();
                worker.RunWorkerAsync();
            }

        }
 public static void ExecutePull(object parameter)
 {
     FiveTextCommandParameters parameters = (FiveTextCommandParameters)parameter;
     Context = parameters.Context;
     BackgroundWorker worker = new BackgroundWorker();
     worker.DoWork += async (sender, args) =>
     {
         await Context.Dispatcher.InvokeAsync(async () =>
         {
             _adb = new AdbTools(Context);
             String[] paths = new string[4];
             if (!string.IsNullOrEmpty(parameters.Text2)) paths[0] = parameters.Text2;
             if (!string.IsNullOrEmpty(parameters.Text3)) paths[1] = parameters.Text3;
             if (!string.IsNullOrEmpty(parameters.Text4)) paths[2] = parameters.Text4;
             if (!string.IsNullOrEmpty(parameters.Text5)) paths[3] = parameters.Text5;
             await _adb.Pull(parameters.Text, parameters.Bool, paths, parameters.Target);
         });
     };
     worker.RunWorkerCompleted += (sender, args) => worker.Dispose();
     worker.RunWorkerAsync();
 }
        public static void ExecuteRoot(object parameter)
        {
            var parameters = (RootParameters)parameter;
            Context = parameters.Context;
            AdbTools adb = new AdbTools(Context);
            BackgroundWorker worker = new BackgroundWorker();
            worker.DoWork += async (sender, args) =>
            {
                await parameters.Window.Dispatcher.InvokeAsync(async () =>
                {
                    if (parameters.SuperSU || parameters.SuperUser)
                    {
                        if (ConnectionChecker.IsConnectedToInternet)
                        {
                            var controller = await parameters.Window.ShowProgressAsync("Please wait", "Downloading...", false, new MetroDialogSettings() { AnimateShow = true, AnimateHide = true, ColorScheme = MetroDialogColorScheme.Theme });
                            if (parameters.SuperUser)
                            {
                                await DownloadFile("http://www.file.appsapk.com/download/Superuser.apk", "Superuser.apk", parameters.Window, controller);
                                if (File.Exists("Superuser.apk"))
                                {
                                    await adb.Root(parameters.CreateNoWindow, parameters.Target);
                                }
                                else
                                {
                                    await parameters.Window.ShowMessageAsync("Unknown error", null);
                                }

                            }
                            if (parameters.SuperSU)
                            {
                                await DownloadFile("http://www.file.appsapk.com/download/SuperSU.apk", "Superuser.apk", parameters.Window, controller);
                                if (File.Exists("Superuser.apk"))
                                {
                                    await adb.Root(parameters.CreateNoWindow, parameters.Target);
                                }
                                else
                                {
                                    await parameters.Window.ShowMessageAsync("Unknown error", null);
                                }

                            }
                        }
                        else
                        {
                            await parameters.Window.ShowMessageAsync("Error", "You must have an internet connection.");
                        }
                    }
                    else
                    {
                        await parameters.Window.ShowMessageAsync("Error", "You must select app");
                    }
                });
            };
            worker.RunWorkerCompleted += (sender, args) => worker.Dispose();
            worker.RunWorkerAsync();
        }