android: Fix version string on older Android releases
authorTobias Brunner <tobias@strongswan.org>
Tue, 4 Jul 2017 09:10:45 +0000 (11:10 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 4 Jul 2017 09:54:57 +0000 (11:54 +0200)
SECURITY_PATCH is apparently only available since Android 6.

src/frontends/android/app/src/main/java/org/strongswan/android/logic/CharonVpnService.java

index 5ef5e87..d8e07a8 100644 (file)
@@ -1031,8 +1031,12 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
         */
        private static String getAndroidVersion()
        {
-               return "Android " + Build.VERSION.RELEASE + " - " + Build.DISPLAY +
-                          "/" + Build.VERSION.SECURITY_PATCH;
+               String version = "Android " + Build.VERSION.RELEASE + " - " + Build.DISPLAY;
+               if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
+               {
+                       version += "/" + Build.VERSION.SECURITY_PATCH;
+               }
+               return version;
        }
 
        /**