Skip to content

Commit 0a545fe

Browse files
committed
Update method to fetch OS version for Macs with full detail
1 parent 5eae522 commit 0a545fe

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

OpenBCI_GUI/Extras.pde

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ private boolean isMac() {
3232
return !isWindows() && !isLinux();
3333
}
3434

35+
private void checkIsMacFullDetail() {
36+
StringBuilder response = new StringBuilder("MacOS Details: ");
37+
if (isMacOsLowerThanCatalina()) {
38+
response.append("MacOS Mojave or earlier");
39+
} else if (isMacOsBigSur()) {
40+
response.append("MacOS Big Sur");
41+
} else if (isMacOsMonterey()) {
42+
response.append("MacOS Monterey");
43+
} else {
44+
response.append("MacOS Catalina");
45+
}
46+
println(response);
47+
}
48+
3549
// For a full list of modern Mac OS versions, visit https://en.wikipedia.org/wiki/MacOS_version_history
3650
private boolean isMacOsLowerThanCatalina() {
3751
int[] versionInfo = fetchAndParseMacOsVersion();
@@ -40,7 +54,14 @@ private boolean isMacOsLowerThanCatalina() {
4054

4155
private boolean isMacOsBigSur() {
4256
int[] versionInfo = fetchAndParseMacOsVersion();
43-
return versionInfo[0] == 11;
57+
//This should return 11, but there was a recently discovered bug in Java 8 -- https://bugs.openjdk.java.net/browse/JDK-8274907
58+
int[] javaInfo = fetchAndParseJavaVersion();
59+
boolean usingJava8_202 = javaInfo[0] == 1 && javaInfo[1] == 8 && javaInfo[2] == 202;
60+
if (usingJava8_202) {
61+
return versionInfo[0] == 10 && versionInfo[1] == 16;
62+
} else {
63+
return versionInfo[0] == 11;
64+
}
4465
}
4566

4667
private boolean isMacOsMonterey() {
@@ -57,7 +78,6 @@ private int[] fetchAndParseMacOsVersion() {
5778
println("Oops! Please only call this method on MacOS");
5879
return null;
5980
}
60-
6181
final String version = getOperatingSystemVersion();
6282
final String[] splitStrings = split(version, '.');
6383
int[] versionVals = new int[splitStrings.length];
@@ -67,6 +87,17 @@ private int[] fetchAndParseMacOsVersion() {
6787
return versionVals;
6888
}
6989

90+
private int[] fetchAndParseJavaVersion() {
91+
final String version = System.getProperty("java.version");
92+
final String[] splitStrings = split(version, '.');
93+
int[] versionVals = new int[splitStrings.length];
94+
versionVals[0] = Integer.valueOf(splitStrings[0]);
95+
versionVals[1] = Integer.valueOf(splitStrings[1]);
96+
final String[] minorVersion = split(splitStrings[2], "_");
97+
versionVals[2] = Integer.valueOf(minorVersion[minorVersion.length - 1]);
98+
return versionVals;
99+
}
100+
70101
//BrainFlow only supports Windows 8 and 10. This will help with OpenBCI support tickets. #964
71102
private void checkIsOldVersionOfWindowsOS() {
72103
boolean isOld = SystemUtils.IS_OS_WINDOWS_7 || SystemUtils.IS_OS_WINDOWS_VISTA || SystemUtils.IS_OS_WINDOWS_XP;

OpenBCI_GUI/OpenBCI_GUI.pde

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,9 @@ void setup() {
416416
println(globalScreenResolution.toString());
417417
println(globalScreenDPI.toString());
418418
println(osName.toString());
419+
if (isMac()) {
420+
checkIsMacFullDetail();
421+
}
419422
println("Welcome to the Processing-based OpenBCI GUI!"); //Welcome line.
420423
println("For more information, please visit: https://docs.openbci.com/Software/OpenBCISoftware/GUIDocs/");
421424

0 commit comments

Comments
 (0)