void OnGotResponse(TextWriter tw) { XDocument doc = XDocument.Parse(tw.ToString()); var list = new PackageList(); foreach (var elem in doc.Element("packages").Elements("package")) { var name = elem.Attribute("name").Value; var apk = elem.Attribute("codePath").Value; var version = int.Parse(elem.Attribute("version").Value); list.Packages.Add(new InstalledPackage(name, apk, version)); } PackageList = list; SetCompleted(true); }
void OnGotResponse (TextWriter tw) { XDocument doc = XDocument.Parse (tw.ToString ()); var list = new PackageList (); foreach (var elem in doc.Element ("packages").Elements ("package")) { var name = elem.Attribute ("name").Value; var apk = elem.Attribute ("codePath").Value; var version = int.Parse (elem.Attribute ("version").Value); list.Packages.Add (new InstalledPackage (name, apk, version)); } PackageList = list; SetCompleted (true); }
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") } ); }
void OnGotResponse (TextWriter tw) { var sr = new StringReader (tw.ToString ()); var list = new PackageList (); string s; while ((s = sr.ReadLine ()) != null) { //"Error: Could not access the Package Manager. Is the system running?" if (s.StartsWith ("Error:")) throw new GetPackageListException (s.Substring ("Error:".Length)); if (!s.StartsWith ("package:")) throw new GetPackageListException ("Unexpected package list output: '" + s + "'"); s = s.Substring ("package:".Length); if (!string.IsNullOrEmpty (s)) list.Packages.Add (new InstalledPackage (s)); } PackageList = list; SetCompleted (true); }