Skip to content

Commit

Permalink
Merge pull request #553 from SM2A/v3.x
Browse files Browse the repository at this point in the history
Fix android 14 implicit intent for not exported broadcast receivers
  • Loading branch information
hannesa2 authored Jan 18, 2024
2 parents a80aaef + 89dd3e4 commit b48ef71
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class MqttAndroidClient @JvmOverloads constructor(
val filter = IntentFilter()
filter.addAction(MqttServiceConstants.CALLBACK_TO_ACTIVITY)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU)
context.registerReceiver(receiver, filter, Context.RECEIVER_EXPORTED)
context.registerReceiver(receiver, filter, Context.RECEIVER_NOT_EXPORTED)
else
context.registerReceiver(receiver, filter)
receiverRegistered = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ class MqttService : Service(), MqttTraceHandler {
*/
fun callbackToActivity(clientHandle: String, status: Status, dataBundle: Bundle) {
// Don't call traceDebug, as it will try to callbackToActivity leading to recursion.
val callbackIntent = Intent(MqttServiceConstants.CALLBACK_TO_ACTIVITY)
val callbackIntent = Intent(MqttServiceConstants.CALLBACK_TO_ACTIVITY).apply {
setPackage(applicationContext.packageName)
}
clientHandle.let {
callbackIntent.putExtra(MqttServiceConstants.CALLBACK_CLIENT_HANDLE, it)
}
Expand Down

0 comments on commit b48ef71

Please sign in to comment.