/// <summary>
        /// Install a set of packages.
        /// </summary>
        /// <param name="packages">List of package versions to install / upgrade.</param>
        /// <param name="complete">Called when installation is complete.</param>
        public void InstallPackages(HashSet <AndroidSdkPackageNameVersion> packages,
                                    Action <bool> complete)
        {
            var packagesString = AndroidSdkPackageNameVersion.ListToString(packages);
            // TODO: Remove this dialog when the package manager provides feedback while
            // downloading.
            bool installPackage = UnityEditor.EditorUtility.DisplayDialog(
                "Missing Android SDK packages",
                String.Format(
                    "Android SDK packages need to be installed:\n" +
                    "{0}\n" +
                    "\n" +
                    "The install process can be *slow* and does not provide any feedback " +
                    "which may lead you to think Unity has hung / crashed.  Would you like " +
                    "to wait for these package to be installed?",
                    packagesString),
                "Yes", cancel: "No");

            if (!installPackage)
            {
                PlayServicesSupport.Log("User cancelled installation of Android SDK tools package.",
                                        level: PlayServicesSupport.LogLevel.Warning);
                complete(false);
                return;
            }
            var packageNames = new List <string>();

            foreach (var pkg in packages)
            {
                packageNames.Add(pkg.Name);
            }
            SdkManagerUtil.InstallPackages(toolPath, String.Join(" ", packageNames.ToArray()),
                                           packages, "Accept? (y/N):", "y", "N",
                                           new Regex("^License\\W+[^ ]+:"), complete);
        }
Esempio n. 2
0
 /// <summary>
 /// Use the package manager to retrieve the set of installed and available packages.
 /// </summary>
 /// <param name="complete">Called when the query is complete.</param>
 public void QueryPackages(Action <AndroidSdkPackageCollection> complete)
 {
     SdkManagerUtil.QueryPackages(
         toolPath, "list sdk -u -e -a",
         (CommandLine.Result result) => {
         complete(result.exitCode == 0 ?
                  ParseAndroidListSdkOutput(result.stdout) : null);
     });
 }
Esempio n. 3
0
        /// <summary>
        /// Use the package manager to retrieve the set of installed and available packages.
        /// </summary>
        /// <param name="complete">Called when the query is complete.</param>
        public void QueryPackages(Action <AndroidSdkPackageCollection> complete)
        {
            bool useVerbose = Package != null &&
                              Package.Version >= MINIMUM_VERSION_FOR_VERBOSE_OUTPUT;

            SdkManagerUtil.QueryPackages(
                toolPath, "--list" + (useVerbose ? " --verbose" : ""),
                (CommandLine.Result result) => {
                complete(result.exitCode == 0 ?
                         useVerbose ? ParseListVerboseOutput(result.stdout) :
                         ParseListOutput(result.stdout) :
                         null);
            });
        }
Esempio n. 4
0
        /// <summary>
        /// Install a set of packages.
        /// </summary>
        /// <param name="packages">List of package versions to install / upgrade.</param>
        /// <param name="complete">Called when installation is complete.</param>
        public void InstallPackages(HashSet <AndroidSdkPackageNameVersion> packages,
                                    Action <bool> complete)
        {
            var packageNames = new List <string>();

            foreach (var pkg in packages)
            {
                packageNames.Add(pkg.LegacyName);
            }
            SdkManagerUtil.InstallPackages(
                toolPath, String.Format(
                    "update sdk -a -u -t {0}", String.Join(",", packageNames.ToArray())),
                packages, "Do you accept the license", "yes", "no",
                new Regex("^--------"), complete);
        }