/// <summary>
        /// Return the detail info of the given device.
        /// </summary>
        public static string RetrieveDeviceDetails(AndroidLogcatDevice device, string deviceId)
        {
            if (device == null)
                return deviceId;

            var manufacturer = device.Manufacturer;
            var model = device.Model;
            var release = device.OSVersion;
            var sdkVersion = device.APILevel;
            var abi = device.ABI;

            return string.Format("{0} {1} (version: {2}, abi: {3}, sdk: {4}, id: {5})", manufacturer, model, release, abi, sdkVersion, deviceId);
        }
        private AndroidLogcatDevice GetAndroidDeviceFromCache(ADB adb, string deviceId)
        {
            AndroidLogcatDevice device;
            if (m_CachedDevices.TryGetValue(deviceId, out device))
            {
                return device;
            }

            try
            {
                device = new AndroidLogcatDevice(new AndroidDevice(adb, deviceId));
                m_CachedDevices[deviceId] = device;
            }
            catch (Exception ex)
            {
                AndroidLogcatInternalLog.Log("Exception caugth while trying to retrieve device details for device {0}. This is harmless and device id will be used. Details\r\n:{1}", deviceId, ex);
                // device will be null in this case (and it will not be added to the cache)
            }

            return device;
        }
        /// <summary>
        /// Return the pid of the given package on the given device.
        /// </summary>
        public static int GetPidFromPackageName(ADB adb, AndroidLogcatDevice device, string deviceId, string packageName)
        {
            if (string.IsNullOrEmpty(deviceId))
            {
                return(-1);
            }

            try
            {
                string cmd = null;
                if (device.SupportsFilteringByPid)
                {
                    cmd = string.Format("-s {0} shell pidof -s {1}", deviceId, packageName);
                }
                else
                {
                    cmd = string.Format("-s {0} shell ps", deviceId);
                }

                AndroidLogcatInternalLog.Log("{0} {1}", adb.GetADBPath(), cmd);
                var output = adb.Run(new[] { cmd }, "Unable to get the pid of the given packages.");
                if (string.IsNullOrEmpty(output))
                {
                    return(-1);
                }

                if (device.SupportsFilteringByPid)
                {
                    AndroidLogcatInternalLog.Log(output);
                    return(int.Parse(output));
                }

                return(ParsePidInfo(packageName, output));
            }
            catch (Exception ex)
            {
                AndroidLogcatInternalLog.Log(ex.Message);
                return(-1);
            }
        }