From c5a0fb3b33b41649c813a1b21d464640a053c485 Mon Sep 17 00:00:00 2001 From: jyyi1 Date: Wed, 2 Apr 2025 16:12:17 -0400 Subject: [PATCH] build: update target SDK to 34 and declare foreground service type --- Android/app/src/main/AndroidManifest.xml | 5 +++- .../java/app/intra/sys/IntraVpnService.java | 9 ++++++- Android/gradle.properties | 6 ++--- Android/gradle/verification-metadata.xml | 27 +++++++++++++++++++ 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/Android/app/src/main/AndroidManifest.xml b/Android/app/src/main/AndroidManifest.xml index 82d25892..3dcd5518 100644 --- a/Android/app/src/main/AndroidManifest.xml +++ b/Android/app/src/main/AndroidManifest.xml @@ -3,8 +3,10 @@ + + @@ -30,7 +32,8 @@ android:name="app.intra.sys.IntraVpnService" android:exported="false" android:label="@string/app_name" - android:permission="android.permission.BIND_VPN_SERVICE" > + android:permission="android.permission.BIND_VPN_SERVICE" + android:foregroundServiceType="connectedDevice"> diff --git a/Android/app/src/main/java/app/intra/sys/IntraVpnService.java b/Android/app/src/main/java/app/intra/sys/IntraVpnService.java index 976165f6..255e068a 100644 --- a/Android/app/src/main/java/app/intra/sys/IntraVpnService.java +++ b/Android/app/src/main/java/app/intra/sys/IntraVpnService.java @@ -24,6 +24,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; +import android.content.pm.ServiceInfo; import android.net.ConnectivityManager; import android.net.Network; import android.net.NetworkInfo; @@ -190,7 +191,13 @@ public int onStartCommand(Intent intent, int flags, int startId) { builder = builder.setVisibility(Notification.VISIBILITY_SECRET); } - startForeground(SERVICE_ID, builder.getNotification()); + if (Build.VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) { + // https://developer.android.com/about/versions/14/changes/fgs-types-required + startForeground(SERVICE_ID, builder.build(), + ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE); + } else { + startForeground(SERVICE_ID, builder.build()); + } updateQuickSettingsTile(); diff --git a/Android/gradle.properties b/Android/gradle.properties index 65b52bc7..f6c1ede0 100644 --- a/Android/gradle.properties +++ b/Android/gradle.properties @@ -27,8 +27,8 @@ android.defaults.buildfeatures.buildconfig=true android.nonTransitiveRClass=false android.nonFinalResIds=false -ANDROID_COMPILE_SDK_VERSION=33 -ANDROID_BUILD_TOOLS_VERSION=33.0.0 +ANDROID_COMPILE_SDK_VERSION=34 +ANDROID_BUILD_TOOLS_VERSION=34.0.0 ANDROID_MIN_SDK_VERSION=16 -ANDROID_TARGET_SDK_VERSION=33 +ANDROID_TARGET_SDK_VERSION=34 diff --git a/Android/gradle/verification-metadata.xml b/Android/gradle/verification-metadata.xml index 39000817..3cd57ea5 100644 --- a/Android/gradle/verification-metadata.xml +++ b/Android/gradle/verification-metadata.xml @@ -64,6 +64,9 @@ + + + @@ -239,6 +242,9 @@ + + + @@ -281,6 +287,9 @@ + + + @@ -1764,16 +1773,25 @@ + + + + + + + + + @@ -2120,6 +2138,9 @@ + + + @@ -2133,11 +2154,17 @@ + + + + + +