Пример #1
0
        private async void InstallApplicationFromFile(object obj)
        {
            var apkFile = FileDialogUtil.BrowseForOpenFile("Android Applications (*.apk)|*.apk|All Files (*.*)|*.*", "Select an APK");

            if (apkFile != null)
            {
                var progressController = await HostWindow.ShowProgressAsync("Installing", "Installing application");

                progressController.SetIndeterminate();
                Tuple <bool, string> installResult = await _pageState.InstallApplicationFromFileAsync(apkFile);

                var success = installResult.Item1;
                if (!success)
                {
                    await progressController.CloseAsync();

                    await HostWindow.ShowMessageAsync("Error", $"Application install failed with error: {installResult.Item2}");

                    return;
                }

                await progressController.CloseAsync();

                RefreshApplications(null);
            }
        }
Пример #2
0
        private async void RunBackupRestore(string backupFile)
        {
            List <string> restoreArguments = new List <string>();

            restoreArguments.Add(backupFile);

            var progressController = await HostWindow.ShowProgressAsync("Restoring Backup", $"Please wait while the backup is restored.");

            progressController.SetIndeterminate();

            //Start backup process
            var restoreProcess = new CommandLineAdbExecutor(Properties.Settings.Default.adbExecutablePath);

            var processController = restoreProcess.ExecuteCommand("restore", restoreArguments.ToArray());
            int exitCode          = await processController.WaitForCompletion();

            await progressController.CloseAsync();

            if (exitCode == 0)
            {
                await HostWindow.ShowMessageAsync("Success", "The operation completed successfully.");
            }
            else
            {
                await HostWindow.ShowMessageAsync("Error", $"The process exited with error code {exitCode}.");
            }
        }
Пример #3
0
        private async void RunApplicationBackup(bool apk, bool obb, string outputFile)
        {
            //Create arguments for backup
            List <string> backupArguments = new List <string>();

            if (apk)
            {
                backupArguments.Add("-apk");
            }
            else
            {
                backupArguments.Add("-noapk");
            }
            if (obb)
            {
                backupArguments.Add("-obb");
            }
            else
            {
                backupArguments.Add("-noobb");
            }
            backupArguments.Add("-f");
            backupArguments.Add(outputFile);
            backupArguments.Add(SelectedPackageId);

            var progressController = await HostWindow.ShowProgressAsync("Creating Backup", $"Please wait while {SelectedPackageId} is backed up.");

            progressController.SetIndeterminate();

            //Start backup process
            var backupProcess = new CommandLineAdbExecutor(Properties.Settings.Default.adbExecutablePath);

            var processController = backupProcess.ExecuteCommand("backup", backupArguments.ToArray());
            int exitCode          = await processController.WaitForCompletion();

            await progressController.CloseAsync();

            if (exitCode == 0)
            {
                await HostWindow.ShowMessageAsync("Success", "The operation completed successfully.");
            }
            else
            {
                await HostWindow.ShowMessageAsync("Error", $"The process exited with error code {exitCode}.");
            }
        }