Exemplo n.º 1
0
        private static string GetWindowsJavaSdkLocation(TaskLoggingHelper log)
        {
            string subkey = @"SOFTWARE\JavaSoft\Java Development Kit";

            log.LogMessage("Looking for Java SDK..");

            foreach (var wow64 in new[] { RegistryEx.Wow64.Key32, RegistryEx.Wow64.Key64 })
            {
                string key_name       = string.Format(@"{0}\{1}\{2}", "HKLM", subkey, "CurrentVersion");
                var    currentVersion = RegistryEx.GetValueString(RegistryEx.LocalMachine, subkey, "CurrentVersion", wow64);

                if (!string.IsNullOrEmpty(currentVersion))
                {
                    log.LogMessage("  Key {0} found: {1}.", key_name, currentVersion);

                    if (CheckRegistryKeyForExecutable(RegistryEx.LocalMachine, subkey + "\\" + currentVersion, "JavaHome", wow64, "bin", JarSignerTool, log))
                    {
                        return(RegistryEx.GetValueString(RegistryEx.LocalMachine, subkey + "\\" + currentVersion, "JavaHome", wow64));
                    }
                }

                log.LogMessage("  Key {0} not found.", key_name);
            }

            // We ran out of things to check..
            return(null);
        }
Exemplo n.º 2
0
        static void SetWindowsConfiguredSdkLocations(string androidSdk, string javaSdk)
        {
            var wow = RegistryEx.Wow64.Key32;

            RegistryEx.SetValueString(RegistryEx.CurrentUser, MDREG_KEY, MDREG_ANDROID, androidSdk ?? "", wow);
            RegistryEx.SetValueString(RegistryEx.CurrentUser, MDREG_KEY, MDREG_JAVA, javaSdk ?? "", wow);
        }
Exemplo n.º 3
0
 static string WindowsGetJavaPath()
 {
     foreach (var wow64 in new[] { RegistryEx.Wow64.Key32, RegistryEx.Wow64.Key64 })
     {
         var currentVersion = RegistryEx.GetValueString(RegistryEx.LocalMachine, @"SOFTWARE\JavaSoft\Java Development Kit", "CurrentVersion", wow64);
         if (!string.IsNullOrEmpty(currentVersion))
         {
             string javaPath = RegistryEx.GetValueString(RegistryEx.LocalMachine, @"SOFTWARE\JavaSoft\Java Development Kit\" + currentVersion, "JavaHome", wow64);
             if (!string.IsNullOrEmpty(javaPath))
             {
                 return(javaPath);
             }
         }
     }
     return(null);
 }
Exemplo n.º 4
0
        private static string GetWindowsAndroidSdkLocation(TaskLoggingHelper log)
        {
            var roots = new[] { RegistryEx.CurrentUser, RegistryEx.LocalMachine };
            var wow   = RegistryEx.Wow64.Key32;

            log.LogMessage("Looking for Android SDK..");

            // Check for the key written by the Android SDK installer first
            foreach (var root in roots)
            {
                if (CheckRegistryKeyForExecutable(root, ANDROID_INSTALLER_PATH, ANDROID_INSTALLER_KEY, wow, "platform-tools", AdbTool, log))
                {
                    return(RegistryEx.GetValueString(root, ANDROID_INSTALLER_PATH, ANDROID_INSTALLER_KEY, wow));
                }
            }

            // Check for the key the user gave us in the VS options
            foreach (var root in roots)
            {
                if (CheckRegistryKeyForExecutable(root, MDREG_KEY, MDREG_ANDROID, wow, "platform-tools", AdbTool, log))
                {
                    return(RegistryEx.GetValueString(root, MDREG_KEY, MDREG_ANDROID, wow));
                }
            }

            // Check 2 default locations
            var program_files = GetProgramFilesX86();
            var installerLoc  = Path.Combine(program_files, @"\Android\android-sdk-windows");
            var unzipLoc      = Path.Combine(program_files, @"C:\android-sdk-windows");

            if (ValidateAndroidSdkLocation(installerLoc))
            {
                log.LogMessage("  adb.exe found in {0}", installerLoc);
                return(installerLoc);
            }

            if (ValidateAndroidSdkLocation(unzipLoc))
            {
                log.LogMessage("  adb.exe found in {0}", unzipLoc);
                return(unzipLoc);
            }

            // We ran out of things to check..
            return(null);
        }
Exemplo n.º 5
0
        static void GetWindowsConfiguredSdkLocations(out string androidSdk, out string javaSdk)
        {
            var roots = new [] { RegistryEx.CurrentUser, RegistryEx.LocalMachine };
            var wow   = RegistryEx.Wow64.Key32;

            androidSdk = null;
            javaSdk    = null;

            // Check for the key written by the Android SDK installer first
            foreach (var root in roots)
            {
                androidSdk = NullIfEmpty(RegistryEx.GetValueString(root, ANDROID_INSTALLER_PATH, ANDROID_INSTALLER_KEY, wow));
                if (androidSdk != null)
                {
                    break;
                }
            }

            // Check for the key the user gave us in the VS options
            if (androidSdk == null)
            {
                foreach (var root in roots)
                {
                    androidSdk = NullIfEmpty(RegistryEx.GetValueString(root, MDREG_KEY, MDREG_ANDROID, wow));
                    if (androidSdk != null)
                    {
                        break;
                    }
                }
            }

            // Find the Java SDK
            foreach (var root in roots)
            {
                javaSdk = NullIfEmpty(RegistryEx.GetValueString(root, MDREG_KEY, MDREG_JAVA, wow));
                if (javaSdk != null)
                {
                    break;
                }
            }
        }
Exemplo n.º 6
0
        private static bool CheckRegistryKeyForExecutable(UIntPtr key, string subkey, string valueName, MonoDroid.RegistryEx.Wow64 wow64, string subdir, string exe, TaskLoggingHelper log)
        {
            string key_name = string.Format(@"{0}\{1}\{2}", key == RegistryEx.CurrentUser ? "HKCU" : "HKLM", subkey, valueName);

            var path = NullIfEmpty(RegistryEx.GetValueString(key, subkey, valueName, wow64));

            if (path == null)
            {
                log.LogMessage("  Key {0} not found.", key_name);
                return(false);
            }

            if (!File.Exists(Path.Combine(path, subdir, exe)))
            {
                log.LogMessage("  Key {0} found:\n    Path does not contain {1} in \\{2} ({3}).", key_name, exe, subdir, path);
                return(false);
            }

            log.LogMessage("  Key {0} found:\n    Path contains {1} in \\{2} ({3}).", key_name, exe, subdir, path);

            return(true);
        }