//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); }
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() || !MonoDroidFramework.CheckTrial()) { return; } 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); } }
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(); } } }