Add SystemUtils.IS_OS_ANDROID
This commit is contained in:
parent
28e826894c
commit
d0bb31bc10
|
@ -66,6 +66,7 @@ The <action> type attribute can be add,update,fix,remove.
|
|||
<action type="add" dev="ggregory" due-to="Gary Gregory">Add SystemProperties constants and methods for system properties as of Java 22.</action>
|
||||
<action type="add" dev="ggregory" due-to="Gary Gregory">Add MethodUtils.getMethodObject(Class, String, Class...).</action>
|
||||
<action issue="LANG-1733" type="add" dev="ggregory" due-to="Jongjin Bae, Gary Gregory">Add null-safe Consumers.accept() and Functions.apply() #1215.</action>
|
||||
<action type="add" dev="ggregory" due-to="Gary Gregory">Add SystemUtils.IS_OS_ANDROID.</action>
|
||||
<!-- FIX -->
|
||||
<action type="fix" dev="ggregory" due-to="Miklós Karakó, Gary Gregory">Improve Javadoc in ExceptionUtils #1136.</action>
|
||||
<action type="fix" dev="ggregory" due-to="Saiharshith Karuneegar Ramesh, Gary Gregory">Fixed two non-deterministic tests in EnumUtilsTest.java #1131.</action>
|
||||
|
|
|
@ -1144,6 +1144,20 @@ public class SystemUtils {
|
|||
*/
|
||||
public static final boolean IS_OS_AIX = getOsMatchesName("AIX");
|
||||
|
||||
/**
|
||||
* Is {@code true} if this is Android.
|
||||
*
|
||||
* <p>
|
||||
* See https://developer.android.com/reference/java/lang/System#getProperties().
|
||||
* </p>
|
||||
* <p>
|
||||
* This value is initialized when the class is loaded.
|
||||
* </p>
|
||||
*
|
||||
* @since 3.15.0
|
||||
*/
|
||||
public static final boolean IS_OS_ANDROID = SystemProperties.getJavaVendor().contains("Android");
|
||||
|
||||
/**
|
||||
* Is {@code true} if this is HP-UX.
|
||||
*
|
||||
|
|
|
@ -151,11 +151,13 @@ public class SystemUtilsTest extends AbstractLangTest {
|
|||
assertFalse(SystemUtils.IS_OS_LINUX);
|
||||
assertFalse(SystemUtils.IS_OS_MAC_OSX);
|
||||
} else if (osName.startsWith("Windows")) {
|
||||
assertFalse(SystemUtils.IS_OS_UNIX);
|
||||
assertTrue(SystemUtils.IS_OS_WINDOWS);
|
||||
assertFalse(SystemUtils.IS_OS_ANDROID);
|
||||
assertFalse(SystemUtils.IS_OS_UNIX);
|
||||
} else if (osName.startsWith("Solaris")) {
|
||||
assertTrue(SystemUtils.IS_OS_SOLARIS);
|
||||
assertTrue(SystemUtils.IS_OS_UNIX);
|
||||
assertFalse(SystemUtils.IS_OS_ANDROID);
|
||||
assertFalse(SystemUtils.IS_OS_WINDOWS);
|
||||
} else if (osName.toLowerCase(Locale.ENGLISH).startsWith("linux")) {
|
||||
assertTrue(SystemUtils.IS_OS_LINUX);
|
||||
|
@ -164,21 +166,25 @@ public class SystemUtilsTest extends AbstractLangTest {
|
|||
} else if (osName.startsWith("Mac OS X")) {
|
||||
assertTrue(SystemUtils.IS_OS_MAC_OSX);
|
||||
assertTrue(SystemUtils.IS_OS_UNIX);
|
||||
assertFalse(SystemUtils.IS_OS_ANDROID);
|
||||
assertFalse(SystemUtils.IS_OS_WINDOWS);
|
||||
} else if (osName.startsWith("OS/2")) {
|
||||
assertTrue(SystemUtils.IS_OS_OS2);
|
||||
assertFalse(SystemUtils.IS_OS_UNIX);
|
||||
assertFalse(SystemUtils.IS_OS_ANDROID);
|
||||
assertFalse(SystemUtils.IS_OS_WINDOWS);
|
||||
} else if (osName.startsWith("SunOS")) {
|
||||
assertTrue(SystemUtils.IS_OS_SUN_OS);
|
||||
assertTrue(SystemUtils.IS_OS_UNIX);
|
||||
assertFalse(SystemUtils.IS_OS_ANDROID);
|
||||
assertFalse(SystemUtils.IS_OS_WINDOWS);
|
||||
} else if (osName.startsWith("FreeBSD")) {
|
||||
assertTrue(SystemUtils.IS_OS_FREE_BSD);
|
||||
assertTrue(SystemUtils.IS_OS_UNIX);
|
||||
assertFalse(SystemUtils.IS_OS_ANDROID);
|
||||
assertFalse(SystemUtils.IS_OS_WINDOWS);
|
||||
} else {
|
||||
System.out.println("Can't test IS_OS value: " + osName);
|
||||
System.err.println("Can't test IS_OS_ value: " + osName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue