コード例 #1
0
        /// <summary>
        /// Get the set of available SDK packages and whether they're installed.
        /// </summary>
        /// <param name="androidTool">Path to the Android SDK manager tool.</param>
        /// <param name="svcSupport">PlayServicesSupport instance used to retrieve the SDK
        /// path.</param>
        /// <param name="packages">Delegate called with a dictionary of package names and whether
        /// they're installed or null if the Android SDK isn't configured correctly.</param>
        internal static void GetAvailablePackages(
            string androidTool, PlayServicesSupport svcSupport,
            GetAvailablePackagesComplete complete)
        {
            CommandLineDialog window = CommandLineDialog.CreateCommandLineDialog(
                "Get Installed Android SDK packages.");

            window.modal              = false;
            window.summaryText        = "Getting list of installed Android packages.";
            window.progressTitle      = window.summaryText;
            window.autoScrollToBottom = true;
            window.RunAsync(
                androidTool, "list sdk -u -e -a",
                (result) => {
                window.Close();
                if (result.exitCode != 0)
                {
                    Debug.LogError("Unable to determine which Android packages are " +
                                   "installed.  Failed to run " + androidTool + ".  " +
                                   result.stderr + " (" + result.exitCode.ToString() + ")");
                    complete(null);
                    return;
                }
                Dictionary <string, bool> packages = new Dictionary <string, bool>();
                string[] lines           = Regex.Split(result.stdout, "\r\n|\r|\n");
                string packageIdentifier = null;
                foreach (string line in lines)
                {
                    // Find the start of a package description.
                    Match match = Regex.Match(line, "^id:\\W+\\d+\\W+or\\W+\"([^\"]+)\"");
                    if (match.Success)
                    {
                        packageIdentifier           = match.Groups[1].Value;
                        packages[packageIdentifier] = false;
                        continue;
                    }
                    if (packageIdentifier == null)
                    {
                        continue;
                    }
                    // Parse the install path and record whether the package is installed.
                    match = Regex.Match(line, "^\\W+Install[^:]+:\\W+([^ ]+)");
                    if (match.Success)
                    {
                        packages[packageIdentifier] = File.Exists(
                            Path.Combine(Path.Combine(svcSupport.SDK, match.Groups[1].Value),
                                         "source.properties"));
                        packageIdentifier = null;
                    }
                }
                complete(packages);
            },
                maxProgressLines: 50);
            window.Show();
        }
コード例 #2
0
 /// <summary>
 /// Get the set of available SDK packages and whether they're installed.
 /// </summary>
 /// <param name="androidTool">Path to the Android SDK manager tool.</param>
 /// <param name="svcSupport">PlayServicesSupport instance used to retrieve the SDK
 /// path.</param>
 /// <param name="packages">Delegate called with a dictionary of package names and whether
 /// they're installed or null if the Android SDK isn't configured correctly.</param>
 internal static void GetAvailablePackages(
     string androidTool, PlayServicesSupport svcSupport,
     GetAvailablePackagesComplete complete)
 {
     CommandLineDialog window = CommandLineDialog.CreateCommandLineDialog(
         "Get Installed Android SDK packages.");
     window.modal = false;
     window.summaryText = "Getting list of installed Android packages.";
     window.progressTitle = window.summaryText;
     window.autoScrollToBottom = true;
     window.RunAsync(
         androidTool, "list sdk -u -e -a",
         (result) => {
             window.Close();
             if (result.exitCode != 0)
             {
                 Debug.LogError("Unable to determine which Android packages are " +
                                "installed.  Failed to run " + androidTool + ".  " +
                                result.stderr + " (" + result.exitCode.ToString() + ")");
                 complete(null);
                 return;
             }
             Dictionary<string, bool> packages = new Dictionary<string, bool>();
             string[] lines = Regex.Split(result.stdout, "\r\n|\r|\n");
             string packageIdentifier = null;
             foreach (string line in lines)
             {
                 // Find the start of a package description.
                 Match match = Regex.Match(line, "^id:\\W+\\d+\\W+or\\W+\"([^\"]+)\"");
                 if (match.Success)
                 {
                     packageIdentifier = match.Groups[1].Value;
                     packages[packageIdentifier] = false;
                     continue;
                 }
                 if (packageIdentifier == null)
                 {
                     continue;
                 }
                 // Parse the install path and record whether the package is installed.
                 match = Regex.Match(line, "^\\W+Install[^:]+:\\W+([^ ]+)");
                 if (match.Success)
                 {
                     packages[packageIdentifier] = File.Exists(
                         Path.Combine(Path.Combine(svcSupport.SDK, match.Groups[1].Value),
                             "source.properties"));
                     packageIdentifier = null;
                 }
             }
             complete(packages);
         },
         maxProgressLines: 50);
     window.Show();
 }