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 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(); } } }