Ejemplo n.º 1
0
        protected override void Run(object dataItem)
        {
            var proj = DefaultUploadToDeviceHandler.GetActiveExecutableMonoDroidProject();
            var conf = (MonoDroidProjectConfiguration)proj.GetConfiguration(IdeApp.Workspace.ActiveConfiguration);

            proj.SetDeviceTarget(conf, ((AndroidDevice)dataItem).ID);
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        protected override void Update(CommandInfo info)
        {
            var proj      = DefaultUploadToDeviceHandler.GetActiveExecutableMonoDroidProject();
            var configSel = IdeApp.Workspace.ActiveConfiguration;
            var conf      = proj.GetConfiguration(configSel);

            info.Visible = proj != null;
            info.Enabled = proj != null && conf.Name.IndexOf("debug", StringComparison.OrdinalIgnoreCase) < 0;
        }
Ejemplo n.º 4
0
        protected override void Run()
        {
            var proj = DefaultUploadToDeviceHandler.GetActiveExecutableMonoDroidProject();
            var conf = (MonoDroidProjectConfiguration)proj.GetConfiguration(IdeApp.Workspace.ActiveConfiguration);
            var dlg  = new MonoDevelop.MonoDroid.Gui.DeviceChooserDialog();

            if (MessageService.ShowCustomDialog(dlg) == (int)Gtk.ResponseType.Ok)
            {
                proj.SetDeviceTarget(conf, dlg.Device.ID);
            }
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        protected override void Update(CommandArrayInfo info)
        {
            var proj = DefaultUploadToDeviceHandler.GetActiveExecutableMonoDroidProject();

            if (proj == null || !MonoDroidFramework.HasAndroidJavaSdks)
            {
                return;
            }

            var conf        = (MonoDroidProjectConfiguration)proj.GetConfiguration(IdeApp.Workspace.ActiveConfiguration);
            var projSetting = proj.GetDeviceTarget(conf);

            foreach (var st in MonoDroidFramework.DeviceManager.Devices)
            {
                var i = info.Add(st.ID, st);
                if (projSetting != null && projSetting.Equals(st))
                {
                    i.Checked = true;
                }
            }
        }
Ejemplo n.º 7
0
        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);
            }
        }
Ejemplo n.º 8
0
        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")
            }
                                                     );
        }
Ejemplo n.º 9
0
        protected override void Update(CommandInfo info)
        {
            var proj = DefaultUploadToDeviceHandler.GetActiveExecutableMonoDroidProject();

            info.Visible = info.Enabled = proj != null;
        }