diff options
author | Stas Negara <snegara@google.com> | 2015-08-03 16:07:31 -0700 |
---|---|---|
committer | Stas Negara <snegara@google.com> | 2015-08-03 16:07:31 -0700 |
commit | 0f7e1c61fdcf450d75419644e1402cf8a6a73dee (patch) | |
tree | 1ea1df5c24bfb7402a9d84d258b1f6061927e5d7 | |
parent | 5ada7137abdea5c5e659f613078ee38dfa315a03 (diff) | |
download | testing-0f7e1c61fdcf450d75419644e1402cf8a6a73dee.tar.gz |
Change-Id: I7eca1804b7cc3ece81101b71fe45bc3e95663a08
-rw-r--r-- | src/com/google/gct/testing/CloudConfigurationProviderImpl.java | 4 | ||||
-rw-r--r-- | src/com/google/gct/testing/CloudTestingUtils.java | 24 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/com/google/gct/testing/CloudConfigurationProviderImpl.java b/src/com/google/gct/testing/CloudConfigurationProviderImpl.java index 4b4cfb1..747d683 100644 --- a/src/com/google/gct/testing/CloudConfigurationProviderImpl.java +++ b/src/com/google/gct/testing/CloudConfigurationProviderImpl.java @@ -74,6 +74,7 @@ import java.util.*; import static com.android.tools.idea.run.CloudConfiguration.Kind.MATRIX; import static com.android.tools.idea.run.CloudConfiguration.Kind.SINGLE_DEVICE; +import static com.google.gct.testing.CloudTestingUtils.checkJavaVersion; import static com.google.gct.testing.launcher.CloudAuthenticator.getTest; public class CloudConfigurationProviderImpl extends CloudConfigurationProvider { @@ -314,6 +315,9 @@ public class CloudConfigurationProviderImpl extends CloudConfigurationProvider { } public void launchCloudDevice(String configurationInstance) { + if (!checkJavaVersion()) { + return; + } final String cloudProjectId = lastCloudProjectId; String[] dimensionValues = configurationInstance.split("-"); Device device = new Device().setAndroidDevice( diff --git a/src/com/google/gct/testing/CloudTestingUtils.java b/src/com/google/gct/testing/CloudTestingUtils.java index 6b6abc3..4a1d054 100644 --- a/src/com/google/gct/testing/CloudTestingUtils.java +++ b/src/com/google/gct/testing/CloudTestingUtils.java @@ -109,6 +109,30 @@ public class CloudTestingUtils { } } + /** + * Returns {@code false} iff the Java version is too old for launching cloud devices (i.e., < 1.8). + * + */ + public static boolean checkJavaVersion() { + String javaVersion = System.getProperty("java.version"); + String[] versionParts = javaVersion.split("\\."); + if (Double.parseDouble(versionParts[0] + "." + versionParts[1]) < 1.8) { + final String message = "<html>You are using Java <b>" + javaVersion + "</b>.<br>" + + "Due to security reasons, to launch cloud devices, you need to upgrade to Java <b>1.8</b> or higher.<br>" + + "You can download the latest Java release from <a href='https://java.com'>here</a>.</html>"; + final Project project = null; + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + Messages + .showDialog(project, message, "Your Java is too old for launching cloud devices!", new String[]{Messages.CANCEL_BUTTON}, 0, null); + } + }); + return false; + } + return true; + } + public static void showBalloonMessage(final Project project, final String message, final MessageType type, final int delaySeconds) { SwingUtilities.invokeLater(new Runnable() { @Override |