mirror of
https://github.com/vector-im/riotX-android
synced 2025-10-05 15:52:47 +02:00
Use ContextCompat.registerReceiver with explicit RECEIVER_EXPORTED to fix crash on API 34.
java.lang.SecurityException: im.vector.app.debug: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
This commit is contained in:
@@ -21,6 +21,7 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.SharedPreferences
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.edit
|
||||
import im.vector.app.core.debug.DebugReceiver
|
||||
import im.vector.app.core.di.DefaultPreferences
|
||||
@@ -37,7 +38,12 @@ class VectorDebugReceiver @Inject constructor(
|
||||
) : BroadcastReceiver(), DebugReceiver {
|
||||
|
||||
override fun register(context: Context) {
|
||||
context.registerReceiver(this, getIntentFilter(context))
|
||||
ContextCompat.registerReceiver(
|
||||
context,
|
||||
this,
|
||||
getIntentFilter(context),
|
||||
ContextCompat.RECEIVER_NOT_EXPORTED,
|
||||
)
|
||||
}
|
||||
|
||||
override fun unregister(context: Context) {
|
||||
|
@@ -27,6 +27,7 @@ import android.os.HandlerThread
|
||||
import android.os.StrictMode
|
||||
import android.util.Log
|
||||
import android.view.Gravity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.provider.FontRequest
|
||||
import androidx.core.provider.FontsContractCompat
|
||||
import androidx.lifecycle.DefaultLifecycleObserver
|
||||
@@ -217,13 +218,16 @@ class VectorApplication :
|
||||
ProcessLifecycleOwner.get().lifecycle.addObserver(callManager)
|
||||
// This should be done as early as possible
|
||||
// initKnownEmojiHashSet(appContext)
|
||||
|
||||
applicationContext.registerReceiver(powerKeyReceiver, IntentFilter().apply {
|
||||
// Looks like i cannot receive OFF, if i don't have both ON and OFF
|
||||
addAction(Intent.ACTION_SCREEN_OFF)
|
||||
addAction(Intent.ACTION_SCREEN_ON)
|
||||
})
|
||||
|
||||
ContextCompat.registerReceiver(
|
||||
applicationContext,
|
||||
powerKeyReceiver,
|
||||
IntentFilter().apply {
|
||||
// Looks like i cannot receive OFF, if i don't have both ON and OFF
|
||||
addAction(Intent.ACTION_SCREEN_OFF)
|
||||
addAction(Intent.ACTION_SCREEN_ON)
|
||||
},
|
||||
ContextCompat.RECEIVER_NOT_EXPORTED,
|
||||
)
|
||||
EmojiManager.install(GoogleEmojiProvider())
|
||||
|
||||
// Initialize Mapbox before inflating mapViews
|
||||
|
Reference in New Issue
Block a user