From 6934ab3e5d434144fd9d88a9d94e2d27fe81edf2 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sat, 23 May 2026 14:56:45 +0800 Subject: [PATCH] Bump SDK to 37 Update compileSdk and targetSdk to 37. Adjust AndroidManifest: remove legacy storage read permissions, add tools:ignore for FOREGROUND_SERVICE policy and keep FOREGROUND_SERVICE_SPECIAL_USE with minSdk 34. Wrap ContextCompat.startForegroundService with SecurityException handling and special-case ForegroundServiceStartNotAllowedException (logged and rethrown as IllegalStateException) to surface permission/OS restrictions. Remove the READ_STORAGE PermissionType and related runtime permission request in HelperBaseActivity (file chooser now launches directly). These changes align permissions and service startup behavior with newer Android SDK requirements. --- V2rayNG/app/build.gradle.kts | 4 ++-- V2rayNG/app/src/main/AndroidManifest.xml | 5 ++--- .../java/com/v2ray/ang/core/CoreServiceManager.kt | 15 ++++++++++++++- .../java/com/v2ray/ang/enums/PermissionType.kt | 12 ------------ .../java/com/v2ray/ang/ui/HelperBaseActivity.kt | 4 +--- 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/V2rayNG/app/build.gradle.kts b/V2rayNG/app/build.gradle.kts index bd6d35adc..3ecad0eb8 100644 --- a/V2rayNG/app/build.gradle.kts +++ b/V2rayNG/app/build.gradle.kts @@ -6,12 +6,12 @@ plugins { android { namespace = "com.v2ray.ang" - compileSdk = 36 + compileSdk = 37 defaultConfig { applicationId = "com.v2ray.ang" minSdk = 24 - targetSdk = 36 + targetSdk = 37 versionCode = 728 versionName = "2.1.8" multiDexEnabled = true diff --git a/V2rayNG/app/src/main/AndroidManifest.xml b/V2rayNG/app/src/main/AndroidManifest.xml index 754a8ddf4..4d150c65b 100644 --- a/V2rayNG/app/src/main/AndroidManifest.xml +++ b/V2rayNG/app/src/main/AndroidManifest.xml @@ -30,15 +30,14 @@ - - + - = Build.VERSION_CODES.S && + e.javaClass.name == "android.app.ForegroundServiceStartNotAllowedException" + ) { + LogUtil.e(AppConfig.TAG, "StartCore-Manager: Foreground service start not allowed", e) + throw IllegalStateException(e.message ?: e.javaClass.simpleName, e) + } + throw e + } } /** diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/enums/PermissionType.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/enums/PermissionType.kt index 9defe638e..f57d489df 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/enums/PermissionType.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/enums/PermissionType.kt @@ -13,17 +13,6 @@ enum class PermissionType { override fun getPermission(): String = Manifest.permission.CAMERA }, - /** Read storage / media permission (adapts to Android version) */ - READ_STORAGE { - override fun getPermission(): String { - return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - Manifest.permission.READ_MEDIA_IMAGES - } else { - Manifest.permission.READ_EXTERNAL_STORAGE - } - } - }, - /** Notification permission (Android 13+) */ POST_NOTIFICATIONS { @RequiresApi(Build.VERSION_CODES.TIRAMISU) @@ -37,7 +26,6 @@ enum class PermissionType { fun getLabel(): String { return when (this) { CAMERA -> "Camera" - READ_STORAGE -> "Storage" POST_NOTIFICATIONS -> "Notification" } } diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/HelperBaseActivity.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/HelperBaseActivity.kt index a8bd39587..c8078450f 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/HelperBaseActivity.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/HelperBaseActivity.kt @@ -56,9 +56,7 @@ abstract class HelperBaseActivity : BaseActivity() { mimeType: String = "*/*", onResult: (Uri?) -> Unit ) { - checkAndRequestPermission(PermissionType.READ_STORAGE) { - fileChooser.launch(mimeType, onResult) - } + fileChooser.launch(mimeType, onResult) } /**