Exemplo n.º 1
0
        /// <summary>
        /// Downloads and launches the Log file for the target application on the target device.
        /// </summary>
        /// <param name="packageFamilyName"></param>
        /// <param name="targetDevice"></param>
        /// <returns>True, if download success.</returns>
        public static bool DeviceLogFile_View(string packageFamilyName, ConnectInfo targetDevice)
        {
            EditorUtility.DisplayProgressBar("Download Log", "Downloading Log File for " + packageFamilyName, 0.25f);

            AppDetails appDetails = QueryAppDetails(packageFamilyName, targetDevice);

            if (appDetails == null)
            {
                Debug.LogWarningFormat("{0} not installed on target device", packageFamilyName);
                EditorUtility.ClearProgressBar();
                return(false);
            }

            string logFile = string.Format("{0}/{1}_{2}{3}{4}{5}{6}{7}_deviceLog.txt",
                                           Application.temporaryCachePath,
                                           targetDevice.MachineName,
                                           DateTime.Now.Year,
                                           DateTime.Now.Month,
                                           DateTime.Now.Day,
                                           DateTime.Now.Hour,
                                           DateTime.Now.Minute,
                                           DateTime.Now.Second);

            string response = WebRequestGet(string.Format(API_FileQuery, FinalizeUrl(targetDevice.IP), appDetails.PackageFullName), GetBasicAuthHeader(targetDevice, true));
            bool   success  = !string.IsNullOrEmpty(response);

            if (success)
            {
                File.WriteAllText(logFile, response);
                Process.Start(logFile);
            }

            EditorUtility.ClearProgressBar();

            return(success);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Kills the target application on the target device.
        /// </summary>
        /// <param Name="packageFamilyName"></param>
        /// <param Name="targetDevice"></param>
        /// <param Name="showDialog"></param>
        /// <returns>true, if application was successfully stopped.</returns>
        public static bool KillApp(string packageFamilyName, ConnectInfo targetDevice, bool showDialog = true)
        {
            AppDetails appDetails = QueryAppDetails(packageFamilyName, targetDevice);

            if (appDetails == null)
            {
                Debug.LogError("Application not found");
                return(false);
            }

            string query = string.Format("{0}?package={1}",
                                         string.Format(API_AppQuery, FinalizeUrl(targetDevice.IP)),
                                         WWW.EscapeURL(EncodeTo64(appDetails.PackageFullName)));

            bool        success       = WebRequestDelete(query, GetBasicAuthHeader(targetDevice), showDialog);
            MachineName targetMachine = GetMachineName(targetDevice);

            if (success)
            {
                Debug.LogFormat("Successfully stopped {0} on {1}.", packageFamilyName, targetMachine.ComputerName);
            }

            return(success);
        }