From 0b2f036a22c5389c9c9e77a57edf9369ce67a327 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Mon, 4 Dec 2023 10:55:26 +0800 Subject: [PATCH] Up targetSdkVersion 34 --- V2rayNG/app/src/main/AndroidManifest.xml | 8 +++++++- .../com/v2ray/ang/service/V2RayServiceManager.kt | 6 +++++- .../main/kotlin/com/v2ray/ang/ui/MainActivity.kt | 2 +- .../com/v2ray/ang/viewmodel/MainViewModel.kt | 14 +++++++++++++- V2rayNG/gradle.properties | 6 +++--- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/V2rayNG/app/src/main/AndroidManifest.xml b/V2rayNG/app/src/main/AndroidManifest.xml index 24d7d2bd4..97456d6c8 100644 --- a/V2rayNG/app/src/main/AndroidManifest.xml +++ b/V2rayNG/app/src/main/AndroidManifest.xml @@ -1,6 +1,7 @@ + xmlns:tools="http://schemas.android.com/tools" + tools:ignore="MissingLeanbackLauncher"> --> + @@ -127,6 +131,7 @@ android:exported="false" android:label="@string/app_name" android:permission="android.permission.BIND_VPN_SERVICE" + android:foregroundServiceType="dataSync" android:process=":RunSoLibV2RayDaemon"> @@ -139,6 +144,7 @@ diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayServiceManager.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayServiceManager.kt index 15f4a1e83..e3b885391 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayServiceManager.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayServiceManager.kt @@ -133,7 +133,11 @@ object V2RayServiceManager { mFilter.addAction(Intent.ACTION_SCREEN_ON) mFilter.addAction(Intent.ACTION_SCREEN_OFF) mFilter.addAction(Intent.ACTION_USER_PRESENT) - service.registerReceiver(mMsgReceive, mFilter) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + service.registerReceiver(mMsgReceive, mFilter, Context.RECEIVER_EXPORTED) + } else { + service.registerReceiver(mMsgReceive, mFilter) + } } catch (e: Exception) { Log.d(ANG_PACKAGE, e.toString()) } diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/MainActivity.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/MainActivity.kt index f2de9bde1..201599b6f 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/MainActivity.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/MainActivity.kt @@ -103,7 +103,7 @@ class MainActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedList binding.drawerLayout.addDrawerListener(toggle) toggle.syncState() binding.navView.setNavigationItemSelectedListener(this) - binding.version.text = "v${BuildConfig.VERSION_NAME} (${SpeedtestUtil.getLibVersion()})" + "v${BuildConfig.VERSION_NAME} (${SpeedtestUtil.getLibVersion()})".also { binding.version.text = it } setupViewModel() copyAssets() diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/MainViewModel.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/MainViewModel.kt index d1cf5db26..eeae055fc 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/MainViewModel.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/MainViewModel.kt @@ -2,6 +2,7 @@ package com.v2ray.ang.viewmodel import android.app.Application import android.content.* +import android.os.Build import android.util.Log import android.view.LayoutInflater import android.widget.ArrayAdapter @@ -40,7 +41,18 @@ class MainViewModel(application: Application) : AndroidViewModel(application) { fun startListenBroadcast() { isRunning.value = false - getApplication().registerReceiver(mMsgReceiver, IntentFilter(AppConfig.BROADCAST_ACTION_ACTIVITY)) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + getApplication().registerReceiver( + mMsgReceiver, + IntentFilter(AppConfig.BROADCAST_ACTION_ACTIVITY), + Context.RECEIVER_EXPORTED + ) + } else { + getApplication().registerReceiver( + mMsgReceiver, + IntentFilter(AppConfig.BROADCAST_ACTION_ACTIVITY) + ) + } MessageUtil.sendMsg2Service(getApplication(), AppConfig.MSG_REGISTER_CLIENT, "") } diff --git a/V2rayNG/gradle.properties b/V2rayNG/gradle.properties index 2fbe9156a..bce82af5f 100644 --- a/V2rayNG/gradle.properties +++ b/V2rayNG/gradle.properties @@ -1,7 +1,7 @@ -buildToolsVer=33.0.2 -compileSdkVer=33 -targetSdkVer=33 +buildToolsVer=34.0.0 +compileSdkVer=34 +targetSdkVer=34 kotlin.incremental=true android.useAndroidX=true android.enableJetifier=true