From: Tobias Brunner Date: Fri, 7 Mar 2025 09:10:56 +0000 (+0100) Subject: android: Remove special handling of legacy Android versions in native code X-Git-Tag: 6.0.2dr1~32 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=77f99df656f59177e5b1da6fd463120a0ecbdf2e;p=thirdparty%2Fstrongswan.git android: Remove special handling of legacy Android versions in native code Since minSdkVersion has been 21 for a while, we can remove some code that was necessary for older versions. --- diff --git a/src/frontends/android/app/src/main/jni/libandroidbridge/android_jni.h b/src/frontends/android/app/src/main/jni/libandroidbridge/android_jni.h index 85cd54c551..31e97f3275 100644 --- a/src/frontends/android/app/src/main/jni/libandroidbridge/android_jni.h +++ b/src/frontends/android/app/src/main/jni/libandroidbridge/android_jni.h @@ -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; diff --git a/src/frontends/android/app/src/main/jni/libandroidbridge/backend/android_private_key.c b/src/frontends/android/app/src/main/jni/libandroidbridge/backend/android_private_key.c index a03081dc34..f1422f42ba 100644 --- a/src/frontends/android/app/src/main/jni/libandroidbridge/backend/android_private_key.c +++ b/src/frontends/android/app/src/main/jni/libandroidbridge/backend/android_private_key.c @@ -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); diff --git a/src/frontends/android/app/src/main/jni/libandroidbridge/backend/android_service.c b/src/frontends/android/app/src/main/jni/libandroidbridge/backend/android_service.c index 12d2e681be..2ab0af9fd8 100644 --- a/src/frontends/android/app/src/main/jni/libandroidbridge/backend/android_service.c +++ b/src/frontends/android/app/src/main/jni/libandroidbridge/backend/android_service.c @@ -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); diff --git a/src/frontends/android/app/src/main/jni/libandroidbridge/kernel/android_net.c b/src/frontends/android/app/src/main/jni/libandroidbridge/kernel/android_net.c index 2a6d5326e7..7b556b4bb5 100644 --- a/src/frontends/android/app/src/main/jni/libandroidbridge/kernel/android_net.c +++ b/src/frontends/android/app/src/main/jni/libandroidbridge/kernel/android_net.c @@ -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);