Skip to content
Permalink
Browse files

Ensure we send explicit ACTION_SOURCE_CHANGED broadcasts

Avoid cases where background execution is not allowed when sending ACTION_SOURCE_CHANGED broadcasts by sending an explicit Intent to ourselves before sending the Intent to any third party apps who are listening.
  • Loading branch information...
ianhanniballake committed Jun 21, 2019
1 parent 7fc62e4 commit 882c128b087ffe9f80e480272498f2f51108cf10
@@ -76,6 +76,14 @@ abstract class MuzeiDatabase : RoomDatabase() {
override fun onInvalidated(tables: Set<String>) {
applicationContext.contentResolver
.notifyChange(MuzeiContract.Sources.CONTENT_URI, null)
// First send a targeted broadcast just to ourselves
applicationContext.sendBroadcast(
Intent(MuzeiContract.Sources.ACTION_SOURCE_CHANGED).apply {
`package` = applicationContext.packageName
})
// Now send another broadcast to other apps listening
// (it is expected that our own listener filters
// these second calls out)
applicationContext.sendBroadcast(
Intent(MuzeiContract.Sources.ACTION_SOURCE_CHANGED))
}
@@ -67,6 +67,11 @@ class ProviderChangedReceiver : BroadcastReceiver() {
}
}
override fun onReceive(context: Context, intent: Intent) {
if (intent.`package` != context.packageName) {
// Filter out Intents that don't explicitly
// have our package name
return
}
goAsync {
updateBridging(context)
}

0 comments on commit 882c128

Please sign in to comment.
You can’t perform that action at this time.