private EmulatorPlatformType GetPlatform() { EmulatorPlatformType result = EmulatorPlatformType.Mobile; int exitCode; SDBLib.SdbRunResult sdbResult = SDBLib.RunSdbCommand(_selectedDevice, "shell grep TZ_BUILD_PROFILE /etc/tizen-build.conf", (bool isStdOut, string line) => { if (line.StartsWith("TZ_BUILD_PROFILE")) { if (line.EndsWith("=tv")) { result = EmulatorPlatformType.TV; } return(true); } return(false); }, out exitCode, SdbCommandTimeout); if (sdbResult != SDBLib.SdbRunResult.Success) { ShowWarning("Failed to determine the target platform type. " + SDBLib.FormatSdbRunResult(sdbResult, exitCode)); } return(result); }
private bool IsPreviewerInstalled(EmulatorPlatformType platformType) { bool isPreviewerInstalled = false; int exitCode; SDBLib.SdbRunResult sdbResult = SDBLib.RunSdbCommand(_selectedDevice, String.Format( "shell [ -f /opt/usr/home/owner/apps_rw/{0}/tizen-manifest.xml ] && echo 1 || echo 0", (platformType == EmulatorPlatformType.TV) ? AppIdTV : AppIdMobile), (bool isStdOut, string line) => { if (line.StartsWith("1")) { isPreviewerInstalled = true; } return(true); // only one line is needed }, out exitCode, SdbCommandTimeout); if (sdbResult != SDBLib.SdbRunResult.Success) { ShowError("Failed to detect the XAML previewer application. " + SDBLib.FormatSdbRunResult(sdbResult, exitCode)); } return(isPreviewerInstalled); }
private bool InstallTpk(EmulatorPlatformType platformType) { string packagePath = (platformType == EmulatorPlatformType.TV) ? ToolsPathInfo.XamlPreviewerTVPath : ToolsPathInfo.XamlPreviewerMobilePath; string lastErrorMessage; InstallResult installResult = Launcher.Create().InstallTizenPackage(_selectedDevice, packagePath, null, VsPackage.dialogFactory, false, out lastErrorMessage); return(String.IsNullOrEmpty(lastErrorMessage)); }
private bool RunTpk(EmulatorPlatformType platformType) { string errorMessage; bool result = SDBLib.RunSdbShellCommandAndCheckExitStatus(_selectedDevice, $"launch_app {((platformType == EmulatorPlatformType.TV) ? AppIdTV : AppIdMobile)} " + "__AUL_SDK__ dotnet-launcher", null, out errorMessage); if (!result) { ShowError(errorMessage); } return(result); }
public bool Preview(IServiceProvider serviceProvider) { DTE dte = (DTE)serviceProvider.GetService(typeof(SDTE)); var doc = dte.ActiveDocument; if ((doc == null) || !doc.Name.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase)) { ShowWarning("Please open a XAML document to preview"); return(false); } EmulatorPlatformType platformType = EmulatorPlatformType.Mobile; string temp = ""; try { try { temp = Path.GetTempFileName(); FileHelper.CopyToUnixText(doc.FullName, temp); } catch (Exception ex) { ShowError($"Cannot create temporary XAML file. {ex.Message}"); return(false); } const string ErrMsg = "Cannot deploy XAML previewer utility"; try { platformType = GetPlatform(); if (!IsPreviewerInstalled(platformType)) { if (!InstallTpk(platformType)) { ShowError(ErrMsg); return(false); } } } catch (Exception ex) { ShowError($"{ErrMsg}. {ex.Message}"); return(false); } try { string targetXamlFile = String.Format("/opt/usr/home/owner/apps_rw/{0}/data/preview_data.txt", (platformType == EmulatorPlatformType.TV) ? AppIdTV : AppIdMobile); if (!PushXaml(temp, targetXamlFile)) { return(false); // PushXaml shows error messages } } catch (Exception ex) { ShowError($"Cannot push XAML file to the target system. {ex.Message}"); return(false); } } finally { if (temp != "") { try { File.Delete(temp); } catch { } } } try { if (!RunTpk(platformType)) { return(false); // RunTpk shows error messages } } catch (Exception ex) { ShowError($"Cannot run XAML previewer utility on the target system. {ex.Message}"); return(false); } return(true); }