protected override void Run() { if (!MonoDroidFramework.EnsureSdksInstalled()) { return; } var proj = DefaultUploadToDeviceHandler.GetActiveExecutableMonoDroidProject(); var configSel = IdeApp.Workspace.ActiveConfiguration; OperationHandler createApk = delegate { using (var monitor = new MonoDevelop.Ide.ProgressMonitoring.MessageDialogProgressMonitor()) { MonoDroidUtility.SignAndCopy(monitor, proj, configSel); } }; if (proj.NeedsBuilding(configSel)) { IdeApp.ProjectOperations.Build(proj).Completed += createApk; } else { createApk(null); } }
protected override void Run() { if (!MonoDroidFramework.EnsureSdksInstalled()) { return; } MonoDroidFramework.Toolbox.StartAvdManager(); }
//may block while it's showing a GUI. project MUST be built before calling this public static MonoDroidUploadOperation SignAndUpload(IProgressMonitor monitor, MonoDroidProject project, ConfigurationSelector configSel, bool forceReplace, ref AndroidDevice device) { var conf = project.GetConfiguration(configSel); var opMon = new AggregatedOperationMonitor(monitor); InvokeSynch(() => MonoDroidFramework.EnsureSdksInstalled()); IAsyncOperation signOp = null; if (project.PackageNeedsSigning(configSel)) { ClearUploadFlags(conf); signOp = project.SignPackage(configSel); opMon.AddOperation(signOp); } if (device == null) { device = InvokeSynch(() => ChooseDevice(null)); } if (device == null) { opMon.Dispose(); return(null); } if (!device.IsEmulator && MonoDroidFramework.CheckTrial()) { opMon.Dispose(); return(null); } //copture the device for a later anonymous method AndroidDevice dev = device; bool replaceIfExists = forceReplace || !GetUploadFlag(conf, device); var uploadOp = Upload(device, conf.ApkSignedPath, conf.PackageName, signOp, replaceIfExists); opMon.AddOperation(uploadOp); uploadOp.Completed += delegate(IAsyncOperation op) { if (op.Success) { SetUploadFlag(conf, dev); } opMon.Dispose(); }; return(uploadOp); }
protected override void Run(object dataItem) { if (!MonoDroidFramework.EnsureSdksInstalled()) { return; } var proj = DefaultUploadToDeviceHandler.GetActiveExecutableMonoDroidProject(); var conf = (MonoDroidProjectConfiguration)proj.GetConfiguration(IdeApp.Workspace.ActiveConfiguration); var device = MonoDroidUtility.ChooseDevice(null); if (device != null) { proj.SetDeviceTarget(conf, device.ID); } }
public static IAsyncOperation Sign(IProgressMonitor monitor, MonoDroidProject project, ConfigurationSelector configSel) { var conf = project.GetConfiguration(configSel); var opMon = new AggregatedOperationMonitor(monitor); InvokeSynch(() => MonoDroidFramework.EnsureSdksInstalled()); IAsyncOperation signOp = null; if (project.PackageNeedsSigning(configSel)) { ClearUploadFlags(conf); signOp = project.SignPackage(configSel); signOp.Completed += delegate { opMon.Dispose(); }; return(signOp); } return(Core.Execution.NullProcessAsyncOperation.Success); }
public static IAsyncOperation SignAndCopy(IProgressMonitor monitor, MonoDroidProject project, ConfigurationSelector configSel) { var conf = project.GetConfiguration(configSel); var opMon = new AggregatedOperationMonitor(monitor); IAsyncOperation signOp = null; if (project.PackageNeedsSigning(configSel)) { ClearUploadFlags(conf); signOp = project.SignPackage(configSel); opMon.AddOperation(signOp); } string packageName = project.GetPackageName(conf); string targetFile = InvokeSynch(() => ChooseApkLocation(null, project.BaseDirectory, packageName)); if (String.IsNullOrEmpty(targetFile)) { opMon.Dispose(); return(null); } if (MonoDroidFramework.CheckTrial()) { opMon.Dispose(); return(null); } var copy = CopyApk(signOp, conf.ApkSignedPath, targetFile); copy.Completed += delegate { opMon.Dispose(); }; return(copy); }
protected override void Run() { if (!MonoDroidFramework.EnsureSdksInstalled()) { return; } var configSel = IdeApp.Workspace.ActiveConfiguration; var proj = GetActiveExecutableMonoDroidProject(); OperationHandler upload = delegate { using (var monitor = new MonoDevelop.Ide.ProgressMonitoring.MessageDialogProgressMonitor()) { AndroidDevice device = null; var conf = (MonoDroidProjectConfiguration)proj.GetConfiguration(configSel); var deviceId = proj.GetDeviceTarget(conf); if (deviceId != null) { device = MonoDroidFramework.DeviceManager.GetDevice(deviceId); } if (device == null) { proj.SetDeviceTarget(conf, null); } MonoDroidUtility.SignAndUpload(monitor, proj, configSel, true, ref device); } }; if (proj.NeedsBuilding(configSel)) { IdeApp.ProjectOperations.Build(proj).Completed += upload; } else { upload(null); } }
protected override void Run() { if (!MonoDroidFramework.EnsureSdksInstalled()) { return; } // TODO: We may should check the current build profile and // show a warning if we are in a debug mode. var configSel = IdeApp.Workspace.ActiveConfiguration; var proj = DefaultUploadToDeviceHandler.GetActiveExecutableMonoDroidProject(); var conf = proj.GetConfiguration(configSel); OperationHandler signOp = delegate { using (var monitor = new MonoDevelop.Ide.ProgressMonitoring.MessageDialogProgressMonitor()) { var dlg = new MonoDevelop.MonoDroid.Gui.MonoDroidPublishDialog() { ApkPath = conf.ApkPath, BaseDirectory = proj.BaseDirectory }; if (MessageService.ShowCustomDialog(dlg) == (int)Gtk.ResponseType.Ok) { MonoDroidUtility.PublishPackage(monitor, proj, configSel, dlg.SigningOptions, conf.ApkPath, dlg.DestinationApkPath, dlg.CreateNewKey, dlg.DName, dlg.KeyValidity * 365); } }; }; if (proj.NeedsBuilding(configSel)) { IdeApp.ProjectOperations.Build(proj).Completed += signOp; } else { signOp(null); } }
public MonoDroidUploadOperation(IProgressMonitor monitor, AndroidDevice device, FilePath packageFile, string packageName, IAsyncOperation signingOperation, bool replaceIfExists) { var toolbox = MonoDroidFramework.Toolbox; var project = DefaultUploadToDeviceHandler.GetActiveExecutableMonoDroidProject(); var conf = (MonoDroidProjectConfiguration)project.GetConfiguration(IdeApp.Workspace.ActiveConfiguration); int apiLevel = MonoDroidFramework.FrameworkVersionToApiLevel(project.TargetFramework.Id.Version); int runtimeVersion = MonoDroidFramework.GetRuntimeVersion(); string packagesListLocation = null; PackageList list = null; replaceIfExists = replaceIfExists || signingOperation != null; chop = new ChainedAsyncOperationSequence(monitor, new ChainedAsyncOperation() { Skip = () => MonoDroidFramework.DeviceManager.GetDeviceIsOnline(device.ID) ? "" : null, TaskName = GettextCatalog.GetString("Waiting for device"), Create = () => toolbox.WaitForDevice(device, monitor.Log, monitor.Log), Completed = op => { DeviceNotFound = !op.Success; }, ErrorMessage = GettextCatalog.GetString("Failed to get device") }, new ChainedAsyncOperation <AdbShellOperation> () { TaskName = GettextCatalog.GetString("Getting the package list location from device"), Create = () => new AdbShellOperation(device, "ls /data/system/packages.xml"), Completed = op => { string output = op.Output.Trim(new char [] { '\n', '\r' }); if (output == "/data/system/packages.xml") { packagesListLocation = output; } else { packagesListLocation = "/dbdata/system/packages.xml"; } } }, new ChainedAsyncOperation <AdbGetPackagesOperation> () { TaskName = GettextCatalog.GetString("Getting package list from device"), Create = () => new AdbGetPackagesOperation(device, packagesListLocation), Completed = op => list = op.PackageList, ErrorMessage = GettextCatalog.GetString("Failed to get package list") }, new ChainedAsyncOperation() { TaskName = GettextCatalog.GetString("Uninstalling old version of shared runtime package"), Skip = () => !conf.AndroidUseSharedRuntime || list.GetOldRuntimesAndPlatforms(apiLevel, runtimeVersion).Count() == 0 ? "" : null, Create = () => { // Cleanup task, no need to wait for it foreach (InstalledPackage oldPackage in list.GetOldRuntimesAndPlatforms(apiLevel, runtimeVersion)) { toolbox.Uninstall(device, oldPackage.Name, monitor.Log, monitor.Log); } return(Core.Execution.NullProcessAsyncOperation.Success); }, ErrorMessage = GettextCatalog.GetString("Failed to uninstall package") }, new ChainedAsyncOperation() { TaskName = GettextCatalog.GetString("Installing shared runtime package on device"), Skip = () => !conf.AndroidUseSharedRuntime || list.IsCurrentRuntimeInstalled(runtimeVersion) ? "" : null, Create = () => { var pkg = MonoDroidFramework.SharedRuntimePackage; if (!File.Exists(pkg)) { var msg = GettextCatalog.GetString("Could not find shared runtime package file"); monitor.ReportError(msg, null); LoggingService.LogError("{0} '{1}'", msg, pkg); return(null); } return(toolbox.Install(device, pkg, monitor.Log, monitor.Log)); }, ErrorMessage = GettextCatalog.GetString("Failed to install shared runtime package") }, new ChainedAsyncOperation() { TaskName = GettextCatalog.GetString("Installing the platform framework"), Skip = () => !conf.AndroidUseSharedRuntime || list.IsCurrentPlatformInstalled(apiLevel, runtimeVersion) ? "" : null, Create = () => { var platformApk = MonoDroidFramework.GetPlatformPackage(apiLevel); if (!File.Exists(platformApk)) { var msg = GettextCatalog.GetString("Could not find platform package file"); monitor.ReportError(msg, null); LoggingService.LogError("{0} '{1}'", msg, platformApk); return(null); } return(toolbox.Install(device, platformApk, monitor.Log, monitor.Log)); }, ErrorMessage = GettextCatalog.GetString("Failed to install the platform framework") }, new ChainedAsyncOperation() { TaskName = GettextCatalog.GetString("Uninstalling old version of package"), Skip = () => (!replaceIfExists || !list.ContainsPackage(packageName))? "" : null, Create = () => toolbox.Uninstall(device, packageName, monitor.Log, monitor.Log), ErrorMessage = GettextCatalog.GetString("Failed to uninstall package") }, new ChainedAsyncOperation() { TaskName = GettextCatalog.GetString("Waiting for packaging signing to complete"), Skip = () => (signingOperation == null || signingOperation.IsCompleted) ? "" : null, Create = () => signingOperation, ErrorMessage = GettextCatalog.GetString("Package signing failed"), }, new ChainedAsyncOperation() { Skip = () => (list.ContainsPackage(packageName) && !replaceIfExists) ? GettextCatalog.GetString("Package is already up to date") : null, TaskName = GettextCatalog.GetString("Installing package"), Create = () => toolbox.Install(device, packageFile, monitor.Log, monitor.Log), ErrorMessage = GettextCatalog.GetString("Failed to install package") } ); }
protected override void OnExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configSel) { var conf = (MonoDroidProjectConfiguration)GetConfiguration(configSel); IConsole console = null; var opMon = new AggregatedOperationMonitor(monitor); try { var handler = context.ExecutionHandler as MonoDroidExecutionHandler; bool useHandlerDevice = handler != null && handler.DeviceTarget != null; AndroidDevice device = null; if (useHandlerDevice) { device = handler.DeviceTarget; } else { var deviceId = GetDeviceTarget(conf); if (deviceId != null) { device = MonoDroidFramework.DeviceManager.GetDevice(deviceId); } if (device == null) { SetDeviceTarget(conf, null); } } var uploadOp = MonoDroidUtility.SignAndUpload(monitor, this, configSel, false, ref device); //user cancelled device selection if (device == null) { return; } if (!device.IsEmulator && MonoDroidFramework.CheckTrial()) { return; } opMon.AddOperation(uploadOp); uploadOp.WaitForCompleted(); if (!uploadOp.Success || monitor.IsCancelRequested) { return; } //get the activity name after signing produced the final manifest string activity; if (!GetActivityNameFromManifest(monitor, conf, out activity)) { return; } //successful, persist the device choice if (!useHandlerDevice) { SetDeviceTarget(conf, device.ID); } var command = (MonoDroidExecutionCommand)CreateExecutionCommand(configSel, conf); command.Device = device; command.Activity = activity; //FIXME: would be nice to skip this if it's a debug handler, which will set another value later var propOp = MonoDroidFramework.Toolbox.SetProperty(device, "debug.mono.extra", string.Empty); opMon.AddOperation(propOp); propOp.WaitForCompleted(); if (!propOp.Success) { monitor.ReportError(GettextCatalog.GetString("Could not clear debug settings on device"), propOp.Error); return; } console = context.ConsoleFactory.CreateConsole(false); var executeOp = context.ExecutionHandler.Execute(command, console); opMon.AddOperation(executeOp); executeOp.WaitForCompleted(); } finally { opMon.Dispose(); if (console != null) { console.Dispose(); } } }
public override IEnumerable <string> GetToolsPaths() { return(MonoDroidFramework.GetToolsPaths().Concat(base.GetToolsPaths())); }