From f1971c08a6774d4e90d5fa5880fff631b3a2a916 Mon Sep 17 00:00:00 2001 From: aderan Date: Wed, 18 Sep 2024 16:35:57 +0800 Subject: [PATCH] update target sdk to 34 --- app/build.gradle | 5 ++--- .../io/agora/flat/common/android/AndroidDownloader.kt | 8 +++++++- .../java/io/agora/flat/common/login/LoginManager.kt | 11 ++++++++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 5b36aa7f..0e211850 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,13 +11,12 @@ plugins { } android { - compileSdk 33 - buildToolsVersion "33.0.0" + compileSdk 34 defaultConfig { applicationId "io.agora.flat" minSdkVersion 21 - targetSdkVersion 33 + targetSdk 34 versionCode 58 versionName "2.10.1" diff --git a/app/src/main/java/io/agora/flat/common/android/AndroidDownloader.kt b/app/src/main/java/io/agora/flat/common/android/AndroidDownloader.kt index 3d33401c..0318e513 100644 --- a/app/src/main/java/io/agora/flat/common/android/AndroidDownloader.kt +++ b/app/src/main/java/io/agora/flat/common/android/AndroidDownloader.kt @@ -5,9 +5,11 @@ import android.app.DownloadManager.Request import android.app.DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED import android.content.BroadcastReceiver import android.content.Context +import android.content.Context.RECEIVER_EXPORTED import android.content.Intent import android.content.IntentFilter import android.net.Uri +import android.os.Build import android.os.Environment import dagger.hilt.android.qualifiers.ApplicationContext import java.io.File @@ -26,7 +28,11 @@ class AndroidDownloader @Inject constructor(@ApplicationContext val context: Con value?.run { cont.resume(desUri) } } } - context.registerReceiver(receiver, filter) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + context.registerReceiver(receiver, filter, RECEIVER_EXPORTED) + } else { + context.registerReceiver(receiver, filter) + } } private val downloadManager: DownloadManager by lazy { diff --git a/app/src/main/java/io/agora/flat/common/login/LoginManager.kt b/app/src/main/java/io/agora/flat/common/login/LoginManager.kt index de4a18d6..bea1f1a4 100644 --- a/app/src/main/java/io/agora/flat/common/login/LoginManager.kt +++ b/app/src/main/java/io/agora/flat/common/login/LoginManager.kt @@ -4,8 +4,10 @@ import android.app.Activity import android.content.BroadcastReceiver import android.content.ComponentName import android.content.Context +import android.content.Context.RECEIVER_EXPORTED import android.content.Intent import android.content.IntentFilter +import android.os.Build import com.tencent.mm.opensdk.constants.ConstantsAPI import com.tencent.mm.opensdk.modelmsg.SendAuth import com.tencent.mm.opensdk.openapi.IWXAPI @@ -18,8 +20,7 @@ import javax.inject.Singleton @Singleton class LoginManager @Inject constructor( - @ApplicationContext val context: Context, - val appEnv: AppEnv + @ApplicationContext val context: Context, val appEnv: AppEnv ) { private var api: IWXAPI? = null private var wechatReceiver: BroadcastReceiver? = null @@ -44,7 +45,11 @@ class LoginManager @Inject constructor( } } } - context.registerReceiver(wechatReceiver, IntentFilter(ConstantsAPI.ACTION_REFRESH_WXAPP)) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + context.registerReceiver(wechatReceiver, IntentFilter(ConstantsAPI.ACTION_REFRESH_WXAPP), RECEIVER_EXPORTED) + } else { + context.registerReceiver(wechatReceiver, IntentFilter(ConstantsAPI.ACTION_REFRESH_WXAPP)) + } } fun unregisterReceiver(context: Context) {