Exemplo n.º 1
0
        private async void RunRestore(object obj)
        {
            string restoreBackupPath = BackupLocation;

            if (string.IsNullOrWhiteSpace(restoreBackupPath))
            {
                restoreBackupPath = await HostViewWindow.ShowInputAsync("Select backup", "Enter the full file path to a backup to restore to your device");

                if (string.IsNullOrWhiteSpace(restoreBackupPath))
                {
                    await HostViewWindow.ShowMessageAsync("Invalid parameters", "The existing backup path is invalid.");

                    return;
                }
            }
            var dialogResult = await HostViewWindow.ShowMessageAsync("Confirm action", "You are about to begin a restore. Are you absolutely sure you want to proceed?", MessageDialogStyle.AffirmativeAndNegative);

            if (dialogResult == MessageDialogResult.Affirmative)
            {
                //Run restore operation
                var progressController = await HostViewWindow.ShowProgressAsync("Restoring Backup", "Please wait while the backup is being restored to your device.");

                progressController.SetIndeterminate();
                //Start restore process
                string[] restoreCommandArguments = { restoreBackupPath };
                var      backupProcess           = new CommandLineAdbExecutor(Properties.Settings.Default.adbExecutablePath);
                var      processController       = backupProcess.ExecuteCommand("restore", restoreCommandArguments);
                int      exitCode = await processController.WaitForCompletion();

                await progressController.CloseAsync();

                if (exitCode == 0)
                {
                    await HostViewWindow.ShowMessageAsync("Success", "The operation completed successfully.");
                }
                else
                {
                    await HostViewWindow.ShowMessageAsync("Error", $"The process exited with error code {exitCode}.");
                }
            }
        }
Exemplo n.º 2
0
        private async void RunBackup(object obj)
        {
            if (string.IsNullOrWhiteSpace(BackupLocation))
            {
                await HostViewWindow.ShowMessageAsync("Invalid parameters", "The backup output path is invalid.");

                return;
            }
            var dialogResult = await HostViewWindow.ShowMessageAsync("Confirm action", "You are about to begin a backup. Are you sure you want to proceed?", MessageDialogStyle.AffirmativeAndNegative);

            if (dialogResult == MessageDialogResult.Affirmative)
            {
                //Create arguments for backup
                List <string> backupArguments = new List <string>();
                if (BackupIncludeApk)
                {
                    backupArguments.Add("-apk");
                }
                else
                {
                    backupArguments.Add("-noapk");
                }
                if (BackupIncludeShared)
                {
                    backupArguments.Add("-shared");
                }
                else
                {
                    backupArguments.Add("-noshared");
                }
                if (BackupIncludeSystem)
                {
                    backupArguments.Add("-system");
                }
                else
                {
                    backupArguments.Add("-nosystem");
                }
                backupArguments.Add("-all");
                backupArguments.Add("-f");
                backupArguments.Add(BackupLocation);
                //Run backup operation
                var progressController = await HostViewWindow.ShowProgressAsync("Creating Backup", "Please wait while your device is being 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 HostViewWindow.ShowMessageAsync("Success", "The operation completed successfully.");
                }
                else
                {
                    await HostViewWindow.ShowMessageAsync("Error", $"The process exited with error code {exitCode}.");
                }
            }
        }