Beispiel #1
0
        public SDBAppCmd(SDBDeviceInfo device, params string[] args)
        {
            List <string> rawItemList = SDBLib.RequestToTargetSync(device.Serial, SDBProtocol.appcmd, CombineArgs(args));

            ConsoleOutput = new List <string>();

            IsTargetFound = (rawItemList != null);
            RetrunString  = string.Empty;
            ExitCode      = SDBReqExitCode.EXIT_DEFAULT_FAILURE;

            if (IsTargetFound)
            {
                foreach (string item in rawItemList)
                {
                    if (HasPrefix(item, SDBProtocol.appcmd_returnstr))
                    {
                        RetrunString = GetPureValue(item);
                    }
                    else if (HasPrefix(item, SDBProtocol.appcmd_exitcode))
                    {
                        ExitCode = ParseInt(item);
                    }
                    else if (!string.IsNullOrWhiteSpace(item))
                    {
                        ConsoleOutput.Add(item.Replace("\r\n\0", string.Empty));
                    }
                }
            }
        }
Beispiel #2
0
        public SDBCapability(SDBDeviceInfo device)
        {
            string[] args = { "-s", device.Serial, SDBProtocol.capability };

            string returnValue;

            using (ProcessProxy p = new ProcessProxy())
            {
                p.StartInfo.FileName               = SDBLib.GetSdbFilePath();
                p.StartInfo.UseShellExecute        = false;
                p.StartInfo.CreateNoWindow         = true;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.Arguments              = string.Join(" ", args);
                Debug.WriteLine("{0} SDBCapability command '{1}'", DateTime.Now, p.StartInfo.Arguments);
                p.Start();

                returnValue = p.StandardOutput.ReadToEnd().Replace("\r", string.Empty);
                p.WaitForExit();
            }

            IsSupported = !string.IsNullOrEmpty(returnValue);
            if (IsSupported)
            {
                GenCapDic(returnValue);
            }
        }
Beispiel #3
0
 public ProfileSession(SDBDeviceInfo device, ProfileSessionConfiguration sessionConfiguration, bool isLiveProfiling)
     : base(device, sessionConfiguration)
 {
     SetState(ProfileSessionState.Initial);
     _isLiveProfiling             = isLiveProfiling;
     _targetInstallationDirectory = _targetShareDirectory = $"{_sdkToolPath}/coreprofiler";
 }
Beispiel #4
0
        protected async Task ProjectRuleBlock_ChangedAsync(IProjectVersionedValue <IProjectSubscriptionUpdate> projectSubscriptionUpdate)
        {
            if (projectSubscriptionUpdate.Value.CurrentState.TryGetValue(ProjectDebugger.SchemaName, out IProjectRuleSnapshot ruleSnapshot))
            {
                await Task.Run(() =>
                {
                    SDBDeviceInfo selectedDevice = null;

                    if (isProjectLoadingTime)
                    {
                        selectedDevice = DeviceManager.DeviceInfoList?.FindLast(_ => true);

                        isProjectLoadingTime = false;
                    }
                    else
                    {
                        ruleSnapshot.Properties.TryGetValue(ProjectDebugger.ActiveDebugProfileProperty, out string activeProfile);

                        selectedDevice = DeviceManager.DeviceInfoList.Find(device => activeProfile.Split('#')[0].Equals(device.Serial));
                    }

                    if (selectedDevice != null)
                    {
                        DeviceManager.SelectDevice(selectedDevice);

                        DeviceManager.UpdateDebugTargetList(false);
                    }
                });
            }
        }
Beispiel #5
0
        public static bool InstallRpmPackage(SDBDeviceInfo device, string rpmFileName, out string errorMessage,
                                             TimeSpan?timeout = null)
        {
            string command          = $"rpm -U --force {rpmFileName}";
            string lastNonEmptyLine = "";
            bool   success          = SDBLib.RunSdbShellCommandAndCheckExitStatus(device, command,
                                                                                  (bool isStdOut, string line) =>
            {
                if (line != "")
                {
                    lastNonEmptyLine = line;
                }
                return(false);    // continue processing
            },
                                                                                  out errorMessage, timeout);

            if (!success)
            {
                if (!(errorMessage.Contains(rpmFileName) || lastNonEmptyLine.Contains(rpmFileName)))
                {
                    errorMessage = StringHelper.CombineMessages(errorMessage, $"Package: \"{rpmFileName}\"");
                }
                errorMessage = StringHelper.CombineMessages(errorMessage, lastNonEmptyLine);
            }
            return(success);
        }
Beispiel #6
0
        protected AbstractSession(SDBDeviceInfo device, TSessionConfiguration sessionConfiguration)
        {
            _selectedDevice = device;
            var cap = new SDBCapability(_selectedDevice);

            _tizenVersion = cap.GetValueByKey("platform_version");
            if (!ProfilerPlugin.IsTizenVersionSupported(_tizenVersion, false))
            {
                throw new Exception($"Target platform version {_tizenVersion} is not supported");
            }
            _sdkToolPath          = cap.GetValueByKey("sdk_toolpath");
            _isSecureProtocol     = cap.GetAvailabilityByKey("secure_protocol");
            _sessionConfiguration = sessionConfiguration;
            ProjectDirectory      = _sessionConfiguration.ProjectHostPath;
            DeviceName            = _selectedDevice.Name;
            _asyncErrorTask       = Task.Run(() =>
            {
                try
                {
                    _asyncErrorEvent.WaitOne();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }
                DisposeHelper.SafeDispose(ref _asyncErrorEvent);
            });
        }
Beispiel #7
0
        public HeaptrackSession CreateSession(SDBDeviceInfo device, HeaptrackSessionConfiguration sessionConfiguration)
        {
            string details;

            if (ProfilerPlugin.Instance.BuildSolution())
            {
                try
                {
                    return(new HeaptrackSession(device, sessionConfiguration));
                }
                catch (Exception ex)
                {
                    details = ex.Message;
                }
            }
            else
            {
                details = "Solution build failed";
            }
            string errMsg = $"Cannot start memory profiling session. {details}";

            ProfilerPlugin.Instance.WriteToOutput(errMsg);
            ProfilerPlugin.Instance.ShowError(errMsg);
            return(null);
        }
Beispiel #8
0
        /// <summary>
        /// Start a memory profiling (heaptrack) session.
        /// </summary>
        public void StartHeaptrack()
        {
            Project project;

            if (!CanStartProfiler(out project) || (project == null))
            {
                return;
            }

            var sessionConfiguration = new HeaptrackSessionConfiguration(project, HeaptrackOptions);

            SDBDeviceInfo device = GetAndCheckSelectedDevice(RunMode.MemoryProfiler);

            if (device == null)
            {
                return;
            }

            HeaptrackSession session = HeaptrackLauncher.CreateSession(device, sessionConfiguration);

            if (session == null)
            {
                return;
            }
            HeaptrackLauncher.StartSession(session);
        }
Beispiel #9
0
        public static bool PushFile(SDBDeviceInfo device, string sourceFileName, string destinationFileName,
                                    Func <bool, string, bool> onLineRead, out string errorMessage, TimeSpan?timeout = null)
        {
            if (!File.Exists(sourceFileName))
            {
                errorMessage = $"File \"{sourceFileName}\" not found";
                return(false);
            }
            string sdbErr     = null;
            string sdbOutput  = null;
            int    exitResult = 0;

            SDBLib.SdbRunResult sdbResult = SDBLib.RunSdbCommand(device,
                                                                 $"push \"{sourceFileName}\" \"{destinationFileName}\"",
                                                                 (bool isStdOut, string line) =>
            {
                bool stop = false;
                if (onLineRead != null)
                {
                    stop = onLineRead(isStdOut, line);
                }
                if (line.Contains("1 file(s) pushed"))
                {
                    stop = true;
                }
                if (line.StartsWith("error:"))
                {
                    sdbErr = line;
                    stop   = true;
                }
                sdbOutput += line;
                return(stop);
            },
                                                                 out exitResult,
                                                                 timeout ?? DefaultTimeout);
            if (sdbResult == SDBLib.SdbRunResult.Success && exitResult == 0)
            {
                if (sdbErr == null)
                {
                    errorMessage = "";
                    return(true);
                }
            }
            errorMessage = $"Cannot push \"{sourceFileName}\" to \"{destinationFileName}\"";
            if (sdbResult != SDBLib.SdbRunResult.Success)
            {
                errorMessage = StringHelper.CombineMessages(errorMessage, SDBLib.FormatSdbRunResult(sdbResult));
            }
            if (sdbOutput != null)
            {
                errorMessage = StringHelper.CombineMessages(errorMessage, sdbOutput);
            }
            return(false);
            //if (sdbErr != null)
            //{
            //    errorMessage = StringHelper.CombineMessages(errorMessage, sdbErr);
            //}
            //return false;
        }
Beispiel #10
0
        public static bool EnsureRootOff(SDBDeviceInfo device, RunMode runMode)
        {
            bool   isRoot;
            string errorMessage;

            bool isSecureProtocol = (new SDBCapability(DeviceManager.SelectedDevice)).GetAvailabilityByKey("secure_protocol");

            if (isSecureProtocol)
            {
                return(true);
            }

            if (!SDBLib.CheckIsRoot(device, out isRoot, out errorMessage))
            {
                Instance.ShowError(StringHelper.CombineMessages("Cannot check if \"root off\" mode set", errorMessage));
                return(false);
            }

            if (isRoot)
            {
                string msg = $"Currently \"root on\" mode is used on the \"{device.Name}\" device.\n";
                switch (runMode)
                {
                case RunMode.Debug:
                    msg +=
                        "Debugging cannot be started until switching the device to \"root off\".\n\n" +
                        "Do you want the plugin to switch the device to \"root off\" for you and continue?\n\n" +
                        "Note: please don't switch to \"root on\" mode manually while debugging.";
                    break;

                case RunMode.CoreProfiler:
                case RunMode.LiveProfiler:
                case RunMode.MemoryProfiler:
                    msg +=
                        "Profiling cannot be started until switching the device to \"root off\".\n\n" +
                        "Do you want the plugin to switch the device to \"root off\" for you and continue?\n\n" +
                        "Note: please don't switch to \"root on\" mode manually while profiling.";
                    break;

                default:
                    msg +=
                        "An application cannot be started until switching the device to \"root off\".\n\n" +
                        "Do you want the plugin to switch the device to \"root off\" for you and continue?";
                    break;
                }
                if (System.Windows.MessageBox.Show(msg, "Tizen Plugin", MessageBoxButton.YesNoCancel,
                                                   MessageBoxImage.Question) != MessageBoxResult.Yes)
                {
                    return(false);
                }
                if (!SDBLib.SwitchToRoot(device, false))
                {
                    ProfilerPlugin.Instance.ShowError($"Cannot switch \"{device.Name}\" to \"root off\" mode");
                    return(false);
                }
            }

            return(true);
        }
Beispiel #11
0
 public PreviewerTool()
 {
     _selectedDevice = DeviceManager.SelectedDevice;
     if (_selectedDevice == null)
     {
         throw new Exception("Target device not selected");
     }
 }
Beispiel #12
0
 public OnDemandInstaller(SDBDeviceInfo device, bool supportRpms, bool supportTarGz, Action <string> onMessage)
 {
     if (!(supportRpms || supportTarGz))
     {
         throw new ArgumentException($"At least one of {nameof(supportRpms)} or {nameof(supportTarGz)} parameters must be true");
     }
     _device       = device;
     _supportRpms  = supportRpms;
     _supportTarGz = supportTarGz;
     _onMessage    = onMessage;
 }
        private bool IsNetCoreDbgSupported()
        {
            SDBDeviceInfo device = DeviceManager.SelectedDevice;
            bool          is_netcoredbg_support = false;

            if (device != null)
            {
                var cap = new SDBCapability(device);
                is_netcoredbg_support =
                    cap.GetAvailabilityByKey("netcoredbg_support");
            }
            return(is_netcoredbg_support);
        }
Beispiel #14
0
        public static bool InstallTpk(SDBDeviceInfo device, string tpkFileName,
                                      Func <bool, string, bool> onLineRead, out string errorMessage, TimeSpan?timeout = null)
        {
            if (!File.Exists(tpkFileName))
            {
                errorMessage = $"File \"{tpkFileName}\" not found";
                return(false);
            }
            string sdbErr = null;
            int    exitCode;

            SDBLib.SdbRunResult sdbResult = SDBLib.RunSdbCommand(device,
                                                                 $"install \"{tpkFileName}\"",
                                                                 (bool isStdOut, string line) =>
            {
                bool stop = false;
                if (onLineRead != null)
                {
                    stop = onLineRead(isStdOut, line);
                }
                if (line.StartsWith("spend time for pkgcmd is"))
                {
                    stop = true;
                }
                if (line.StartsWith("error:"))
                {
                    sdbErr = line;
                    stop   = true;
                }
                return(stop);
            },
                                                                 out exitCode, timeout ?? DefaultTimeout);
            if (sdbResult == SDBLib.SdbRunResult.Success)
            {
                if (sdbErr == null)
                {
                    errorMessage = "";
                    return(true);
                }
            }
            errorMessage = StringHelper.CombineMessages($"Cannot install TPK", SDBLib.FormatSdbRunResult(sdbResult, exitCode));
            if (sdbErr != null)
            {
                if (!sdbErr.Contains(tpkFileName))
                {
                    errorMessage = StringHelper.CombineMessages(errorMessage, $"Package: \"{tpkFileName}\"");
                }
                errorMessage = StringHelper.CombineMessages(errorMessage, sdbErr);
            }
            return(false);
        }
Beispiel #15
0
        public static bool FileExists(SDBDeviceInfo device, string fullFileName, out string errorMessage)
        {
            string firstLine;
            bool   result = ListAndGetFirstLine(device, fullFileName, out firstLine, out errorMessage);

            if (result)
            {
                if (fullFileName != firstLine)
                {
                    errorMessage = $"Unexpected line received: \"{firstLine}\"";
                    result       = false;
                }
            }
            return(result);
        }
Beispiel #16
0
 private void CreateLogTabDispatcher(SDBDeviceInfo device)
 {
     try
     {
         LogTabControl?.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Input,
                                          new Action(delegate()
         {
             LogTabControl.Items.Clear();
             LogTabControl.Items.Add(new LogTab(device, staticLogViewerControl));
         }));
     }
     catch
     {
     }
 }
        public static Version RunGetVersionCommand(SDBDeviceInfo device, string command, out string errorMessage)
        {
            string outputLine = "";

            if (!RunCommand(device, command, out outputLine, out errorMessage))
            {
                return(null);
            }
            Version result = null;

            if ((outputLine != "") && !Version.TryParse(outputLine, out result))
            {
                errorMessage = $"Cannot parse package version \"{outputLine}\"";
            }
            return(result);
        }
Beispiel #18
0
        private bool TargetHasTizenDotNET(SDBDeviceInfo device, out string lastErrorMessage)
        {
            bool isDotnetSupported = false;

            try
            {
                var cap = new SDBCapability(device);
                isDotnetSupported = DeployHelper.IsTizenVersionSupported(cap.GetValueByKey("platform_version"));
            }
            catch
            {
            }
            lastErrorMessage = isDotnetSupported ? string.Empty
                : "Failed to identify the .NET support on current platform version. Tizen .NET is supported on Tizen 4.0 or higher.";
            return(isDotnetSupported);
        }
Beispiel #19
0
        public static bool IsRmpPackageInstalled(SDBDeviceInfo device, string packageName,
                                                 out string installedPackageName, out string errorMessage, TimeSpan?timeout = null)
        {
            string command = $"rpm -q {packageName}";

            installedPackageName = "";
            string lastNonEmptyLine = "";
            bool   success          = SDBLib.RunSdbShellCommandAndCheckExitStatus(device, command,
                                                                                  (bool isStdOut, string line) =>
            {
                if (line != "")
                {
                    lastNonEmptyLine = line;
                }
                return(false);    // continue processing
            },
                                                                                  out errorMessage, timeout);

            if (success)
            {
                if (!String.IsNullOrEmpty(lastNonEmptyLine))
                {
                    installedPackageName = lastNonEmptyLine;
                }
                else
                {
                    errorMessage = $"Cannot check RPM package \"{packageName}\"";
                    success      = false;
                }
            }
            else
            {
                if (lastNonEmptyLine.EndsWith("is not installed"))
                {
                    errorMessage = ""; // no error, package just not installed
                }
                else
                {
                    if (!(errorMessage.Contains(packageName) || lastNonEmptyLine.Contains(packageName)))
                    {
                        errorMessage = StringHelper.CombineMessages(errorMessage, $"Package: \"{packageName}\"");
                    }
                    errorMessage = StringHelper.CombineMessages(errorMessage, lastNonEmptyLine);
                }
            }
            return(success);
        }
Beispiel #20
0
        private static SDBDeviceInfo GetAndCheckSelectedDevice(RunMode runMode)
        {
            SDBDeviceInfo device = DeviceManager.SelectedDevice;

            if (device != null)
            {
                if (!EnsureRootOff(device, runMode))
                {
                    device = null;
                }
            }
            else
            {
                Instance.ShowMessage(MessageDialogType.Warning, "Target device not selected");
            }
            return(device);
        }
Beispiel #21
0
        public static bool ListAndGetFirstLine(SDBDeviceInfo device, string pathName, out string firstLine, out string errorMessage)
        {
            string s      = null;
            bool   result = (SDBLib.RunSdbShellCommandAndCheckExitStatus(device, $"ls -U {pathName}", // "-U" is for speed
                                                                         (bool isStdOut, string line) =>
            {
                if ((s == null) && isStdOut && (line != ""))
                {
                    s = line;
                }
                return(false);    // we want to get the exit status so nether return true
            },
                                                                         out errorMessage));

            firstLine = s;
            return(result && (firstLine != null));
        }
        private bool InstallTizenPackage(SDBDeviceInfo device, TizenDebugLaunchOptions tDebugLaunchOptions)
        {
            SDBLauncher.Create(VsPackage.outputPaneTizen).TerminateApplication(device, tDebugLaunchOptions.AppId);

            InstallResult installResult = Launcher.Create().InstallTizenPackage(device, tDebugLaunchOptions.TpkPath,
                                                                                null, VsPackage.dialogFactory, false, out lastErrorMessage);

            bool isInstallSucceeded = (installResult == InstallResult.OK);

            if (!isInstallSucceeded)
            {
                OutputDebugLaunchMessage(lastErrorMessage);
                ShowInstallError(installResult);
                TizenPackageTracer.CleanTpiFiles();
            }

            return(isInstallSucceeded);
        }
Beispiel #23
0
        /// <summary>
        /// Start a profiling session.
        /// </summary>
        /// <remarks>
        /// A run profiler dialog is shown (if not starting a live profiling session). The dialog allows a user to edit
        /// different profiling options.
        /// </remarks>
        /// <param name="isLiveProfiling">
        /// true in case of live profiling (i.e. combined debugging and profiling), false otherwise
        /// </param>
        /// <returns>true if profiling has been started successfully, false otherwise</returns>
        public bool StartProfiler(bool isLiveProfiling)
        {
            Project project;

            if (!CanStartProfiler(out project) || (project == null))
            {
                return(false);
            }

            var sessionConfiguration = new ProfileSessionConfiguration(project, GeneralOptions);

            if (isLiveProfiling)
            {
                var preset = ProfilingPreset.CpuSampling;
                preset.ProfilingSettings.TraceSourceLines = false; // TODO!! example
                sessionConfiguration.ProfilingPreset      = preset;
            }
            else
            {
                var dlg = new RunProfilerDialog(sessionConfiguration);
                dlg.ShowDialog();
                if (!(dlg.DialogResult ?? false))
                {
                    return(false);
                }
            }

            SDBDeviceInfo device = GetAndCheckSelectedDevice(isLiveProfiling ? RunMode.LiveProfiler : RunMode.CoreProfiler);

            if (device == null)
            {
                return(false);
            }

            ProfileSession session = ProfileLauncher.CreateSession(device, sessionConfiguration, isLiveProfiling);

            if (session == null)
            {
                return(false);
            }
            ProfilingProgressWindow.SetSession(session);
            ProfileLauncher.StartSession(session);
            return(true);
        }
            public TizenDebugLaunchOptions(SDBDeviceInfo device, bool isDebugMode, Project proj, string extraArgs)
            {
                _device = device;

                IsDebugMode = isDebugMode;

                AppId   = projHelper.GetAppId(proj);      //projHelper.GetManifestApplicationId(proj);
                AppType = projHelper.GetAppType(proj);
                TpkPath = GetDebugeeTpkPath(AppId, proj); //pkgTracer.GetTpkPathByAppId(AppId) ?? projHelper.GetTizenPackagePath(proj);
                string     debugLaunchPadArgs          = string.Empty;
                string     launchCommand               = string.Empty;
                Parameters debugEngineLaunchParameters = GetDebugEngineLaunchParameters();

                if (IsDebugMode)
                {
                    DebugEngineOptions =
                        "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<PipeLaunchOptions PipePath=\"" +
                        debugEngineLaunchParameters.PipePath +
                        "\" PipeArguments=\"" +
                        debugEngineLaunchParameters.PipeArguments +
                        "\" PipeCwd=\"" +
                        projHelper.GetValidRootPath() +
                        "\" ExePath=\"" +
                        DebugLaunchDataStore.DotNetLauncher +
                        "\" MIMode=\"" + debugEngineLaunchParameters.MiMode + "\" TargetArchitecture=\"" +
                        GetTargetArch() +
                        "\" WorkingDirectory=\"" +
                        DebugLaunchDataStore.AppInstallPath + "/" + projHelper.GetPackageId(TpkPath) + "/bin" +
                        "\" AdditionalSOLibSearchPath=\"\" xmlns=\"http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014\" >" +
                        debugEngineLaunchParameters.AdditionalOptions +
                        "</PipeLaunchOptions>";

                    launchCommand      = debugEngineLaunchParameters.LaunchCommand;
                    debugLaunchPadArgs = debugEngineLaunchParameters.LaunchpadArgs;
                }
                else
                {
                    DebugEngineOptions = string.Empty;
                    launchCommand      = debugEngineLaunchParameters.LaunchCommand;
                    debugLaunchPadArgs = " __AUL_SDK__ dotnet-launcher ";
                }
                LaunchSequence = GetLaunchSequence(AppId, proj, extraArgs, launchCommand, debugLaunchPadArgs);
            }
        public static bool RunCommand(SDBDeviceInfo device, string command, out string outputLine, out string errorMessage)
        {
            string s          = "";
            int    exitResult = 0;

            SDBLib.SdbRunResult sdbResult = SDBLib.RunSdbCommand(device, command,
                                                                 (bool isStdOut, string line) =>
            {
                if (line != "")
                {
                    s = line;
                    return(true);    // TODO!! check if it is valid to return 'true' here
                }
                return(false);
            },
                                                                 out exitResult,
                                                                 TimeSpan.FromSeconds(60));
            outputLine = s;
            if (sdbResult != SDBLib.SdbRunResult.Success)
            {
                errorMessage = $"Cannot run \"{command}\". {SDBLib.FormatSdbRunResult(sdbResult)}";
                return(false);
            }
            // TODO!! shell command might fail even if sdbResult is Success - check the output
            // (support different commands - vs_sdkinstall, vs_sdkremove, etc.!)
            if (outputLine.StartsWith("/bin/sh:")) // error
            {
                errorMessage = outputLine;
                return(false);
            }
            else if (outputLine.EndsWith("is not installed")) // vs_sdkinstall error
            {
                errorMessage = outputLine;
                return(false);
            }
            if (exitResult != 0)
            {
                errorMessage = outputLine;
                return(false);
            }
            errorMessage = "";
            return(true);
        }
Beispiel #26
0
        public static bool ExtractTarGzip(SDBDeviceInfo device, string tarGzipFileName, string destinationPath,
                                          out string errorMessage, TimeSpan?timeout = null)
        {
            string command          = $"mkdir -p {destinationPath} && tar -xvf \"{tarGzipFileName}\" -C {destinationPath}";
            string tarError         = null;
            string lastNonEmptyLine = "";
            bool   success          = SDBLib.RunSdbShellCommandAndCheckExitStatus(device, command,
                                                                                  (bool isStdOut, string line) =>
            {
                if ((tarError == null) && line.StartsWith("tar: ") && line.Contains("Cannot"))
                {
                    tarError = line;
                }
                if (line != "")
                {
                    lastNonEmptyLine = line;
                }
                return(false);    // continue processing
            },
                                                                                  out errorMessage, timeout);

            if (!success)
            {
                if (String.IsNullOrEmpty(tarError))
                {
                    tarError = lastNonEmptyLine;
                }
                if (!String.IsNullOrEmpty(tarError))
                {
                    if (!(errorMessage.Contains(tarGzipFileName) || tarError.Contains(tarGzipFileName)))
                    {
                        errorMessage = StringHelper.CombineMessages(errorMessage, $"Package: \"{tarGzipFileName}\"");
                    }
                    errorMessage = StringHelper.CombineMessages(errorMessage, tarError);
                }
                if (String.IsNullOrEmpty(errorMessage))
                {
                    errorMessage = $"Cannot extract \"{tarGzipFileName}\" to {destinationPath}";
                }
            }
            return(success);
        }
Beispiel #27
0
        public LogTab(SDBDeviceInfo device, LogViewerControl parent)
        {
            this.parentControl = parent;

            logDataGrid             = CreateLogDataGrid();
            logDataGrid.LoadingRow += LogDataGrid_LoadingRow;

            ConnectLogObserver();

            ExcuteLogProcess(device?.Serial);

            viewSource.Filter += ViewSource_Filter;

            this.AddChild(logDataGrid);
            this.Loaded   += LogTab_Loaded;
            this.Unloaded += LogTab_Unloaded;

            SetViewFont(logDataGrid);
            SetDataGridUpdateTimer();
        }
Beispiel #28
0
        private InstallResult DoInstallTizenPackage(SDBDeviceInfo device, string tpkPath, out string lastErrorMessage)
        {
            var waiter = new InstallWaiter(this);

/*!!
 *          DeployHelper.InstallTpk(device, tpkPath,
 *              (bool isStdOut, string line) => waiter.IsWaiterSet(line),
 *              out lastErrorMessage, TimeSpan.FromMinutes(5));
 */
            InstallResult result;
            int           exitCode = 0;

            switch (SDBLib.RunSdbCommand(device, "install \"" + tpkPath + "\"",
                                         (bool isStdOut, string line) => waiter.IsWaiterSet(line),
                                         out exitCode,
                                         TimeSpan.FromMinutes(5))) // 5 minutes will be enough?
            {
            case SDBLib.SdbRunResult.Success:
                lastErrorMessage = waiter.LastErrorMessage;
                result           = (exitCode == 0 ? InstallResult.OK : GetInstallResultFromMsg(lastErrorMessage));
                break;

            case SDBLib.SdbRunResult.CreateProcessError:
                lastErrorMessage = "Failed to get sdb.exe program";
                result           = InstallResult.INSTALL_NOT_TRIED;
                break;

            case SDBLib.SdbRunResult.Timeout:
                lastErrorMessage = "Installation timeout";
                result           = InstallResult.TIMEOUT;
                break;

            default:
                lastErrorMessage = "Installation error";
                lastErrorMessage = (string.IsNullOrEmpty(waiter.LastErrorMessage) ? waiter.LastErrorMessage : "Installation error");
                result           = (exitCode == 0 ? InstallResult.OK : InstallResult.GENERAL_ERROR);
                break;
            }

            return(result);
        }
Beispiel #29
0
        public static Version GetInstalledPackageVersion(SDBDeviceInfo device, string versionFileMask, out string errorMessage)
        {
            Version result = null;
            string  firstLine;

            if (ListAndGetFirstLine(device, versionFileMask, out firstLine, out errorMessage))
            {
                if (firstLine != null)
                {
                    int i = firstLine.LastIndexOf('/');
                    if (i > 0)
                    {
                        result = ParsePackageVersion(firstLine.Substring(i + 1));
                    }
                }
            }
            else if (firstLine != null)
            {
                errorMessage = firstLine;
            }
            return(result);
        }
Beispiel #30
0
        public InstallResult InstallTizenPackage(SDBDeviceInfo device, string tpkPath,
                                                 IVsOutputWindowPane outputPane,
                                                 IVsThreadedWaitDialogFactory dlgFactory,
                                                 bool forceInstall,
                                                 out string lastErrorMessage)
        {
            this.outputPane = outputPane;
            this.outputPane?.Activate();

            if (!TargetHasTizenDotNET(device, out lastErrorMessage))
            {
                return(InstallResult.INSTALL_NOT_TRIED);
            }

            if (!NeedToInstall(device, tpkPath, forceInstall))
            {
                lastErrorMessage = string.Format("  Skip install ({0})", tpkPath);
                return(InstallResult.OK);
            }

            dlgFactory?.CreateInstance(out this.waitDialog);//waitDialog can be null and dialog can not be displayed by VS without some reasons.
            this.waitDialog?.StartWaitDialog(
                "Install Tizen Application",
                "Please wait while the new application is being installed...",
                "Preparing...",
                null,
                "Tizen application install in progress...",
                0, false, true);

            int userCancel;

            var           appUninstallCmd = new SDBAppCmd(device, SDBProtocol.uninstall, VsProjectHelper.GetInstance.GetPackageId(tpkPath));
            InstallResult result          = DoInstallTizenPackage(device, tpkPath, out lastErrorMessage);

            this.waitDialog?.EndWaitDialog(out userCancel);

            return(result);
        }