]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Remove special handling of legacy Android versions in native code
authorTobias Brunner <tobias@strongswan.org>
Fri, 7 Mar 2025 09:10:56 +0000 (10:10 +0100)
committerTobias Brunner <tobias@strongswan.org>
Mon, 14 Apr 2025 09:54:42 +0000 (11:54 +0200)
Since minSdkVersion has been 21 for a while, we can remove some code
that was necessary for older versions.

src/frontends/android/app/src/main/jni/libandroidbridge/android_jni.h
src/frontends/android/app/src/main/jni/libandroidbridge/backend/android_private_key.c
src/frontends/android/app/src/main/jni/libandroidbridge/backend/android_service.c
src/frontends/android/app/src/main/jni/libandroidbridge/kernel/android_net.c

index 85cd54c5516778b0dd105461767cee6ad3f0462e..31e97f327563caa6b91b55a8b8d4e966ec771f55 100644 (file)
@@ -48,17 +48,11 @@ extern jclass *android_charonvpnservice_builder_class;
 extern jclass *android_simple_fetcher_class;
 
 /**
- * Currently known (supported) SDK versions
+ * SDK versions for which we need some special handling.
  *
  * see android.os.Build.VERSION_CODES for definitions
  */
 typedef enum {
-       ANDROID_ICE_CREAM_SANDWICH = 14,
-       ANDROID_ICE_CREAM_SANDWICH_MR1 = 15,
-       ANDROID_JELLY_BEAN = 16,
-       ANDROID_JELLY_BEAN_MR1 = 17,
-       ANDROID_JELLY_BEAN_MR2 = 18,
-       ANDROID_LOLLIPOP = 21,
        ANDROID_MARSHMALLOW = 23,
 } android_sdk_version_t;
 
index a03081dc34f443955b7a8287bd5ab8a121052160..f1422f42ba6dff92709086d5f085d7bc226c5fd4 100644 (file)
@@ -435,16 +435,7 @@ METHOD(private_key_t, destroy, void,
                JNIEnv *env;
 
                androidjni_attach_thread(&env);
-               if (android_sdk_version == ANDROID_JELLY_BEAN)
-               {       /* there is a bug in JB that causes a SIGSEGV if the key object is
-                        * garbage collected so we intentionally leak the reference to it */
-                       DBG1(DBG_LIB, "intentionally leaking private key reference due to "
-                                "a bug in the framework");
-               }
-               else
-               {
-                       (*env)->DeleteGlobalRef(env, this->key);
-               }
+               (*env)->DeleteGlobalRef(env, this->key);
                (*env)->DeleteGlobalRef(env, this->signature_class);
                androidjni_detach_thread();
                this->pubkey->destroy(this->pubkey);
index 12d2e681becc36658679719452acff82c563e4eb..2ab0af9fd852ff32bfeafd3ec295d060f6bfcf37 100644 (file)
@@ -792,10 +792,9 @@ static job_requeue_t initiate(private_android_service_t *this)
        };
        char *type, *remote_id;
 
-       if (android_sdk_version >= ANDROID_LOLLIPOP)
-       {   /* only try once and notify the GUI on Android 5+ where we have a blocking TUN device */
-               peer.keyingtries = 1;
-       }
+       /* only try once and notify the GUI since Android 5+ where we have a
+        * blocking TUN device */
+       peer.keyingtries = 1;
 
        ike.remote = this->settings->get_str(this->settings, "connection.server",
                                                                                 NULL);
index 2a6d5326e7344f67070b25ec90f5a490374acc8f..7b556b4bb508577e1e42d8fe9e1700d83c953c9e 100644 (file)
@@ -124,11 +124,6 @@ METHOD(kernel_net_t, get_source_addr, host_t*,
        }
        charonservice->bypass_socket(charonservice, skt, dst->get_family(dst));
 
-       if (android_sdk_version <= ANDROID_JELLY_BEAN_MR2)
-       {       /* this seems to help avoiding the VIP, unless there is no connectivity
-                * at all */
-               charonservice->bypass_socket(charonservice, -1, 0);
-       }
        if (connect(skt, dst->get_sockaddr(dst), addrlen) < 0)
        {
                /* don't report an error if we are not connected (ENETUNREACH) */
@@ -179,28 +174,6 @@ CALLBACK(vip_equals, bool,
        return host->ip_equals(host, vip);
 }
 
-METHOD(kernel_net_t, get_source_addr_old, host_t*,
-       private_android_net_t *this, host_t *dest, host_t *src)
-{
-       host_t *host;
-
-       /* on older Android versions we might get the virtual IP back because
-        * the protect() implementation there and connect() don't properly work
-        * together, on newer releases (using fwmarks) that's not a problem */
-       host = get_source_addr(this, dest, src);
-       if (host)
-       {
-               this->mutex->lock(this->mutex);
-               if (this->vips->find_first(this->vips, vip_equals, NULL, host))
-               {
-                       host->destroy(host);
-                       host = NULL;
-               }
-               this->mutex->unlock(this->mutex);
-       }
-       return host;
-}
-
 METHOD(kernel_net_t, get_nexthop, host_t*,
        private_android_net_t *this, host_t *dest, int prefix, host_t *src,
        char **iface)
@@ -303,11 +276,6 @@ kernel_net_t *kernel_android_net_create()
        );
        timerclear(&this->next_roam);
 
-       if (android_sdk_version <= ANDROID_JELLY_BEAN_MR2)
-       {
-               this->public.get_source_addr = _get_source_addr_old;
-       }
-
        this->mutex->lock(this->mutex);
        this->network_manager->add_connectivity_cb(
                                                this->network_manager, (void*)connectivity_cb, this);