Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions feature/orchestrator/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application>

<activity
Expand Down Expand Up @@ -80,6 +81,14 @@
</intent-filter>
</activity>

<receiver
android:name=".receivers.CacheResetReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.ACTION_MY_PACKAGE_REPLACED" />
</intent-filter>
</receiver>

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.simprints.feature.orchestrator.receivers

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.simprints.core.ExcludedFromGeneratedTestCoverageReports
import com.simprints.core.SessionCoroutineScope
import com.simprints.feature.orchestrator.cache.OrchestratorCache
import com.simprints.infra.events.session.SessionEventRepository
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import javax.inject.Inject

/**
* Cached step structure might change between SID versions therefore caches should be cleared to avoid unmarshalling exceptions.
* Since we do not support cross-version sessions, any ongoing scopes should be closed as well.
*/
@ExcludedFromGeneratedTestCoverageReports("Platform glue code")
@AndroidEntryPoint
internal class CacheResetReceiver : BroadcastReceiver() {
@Inject
@SessionCoroutineScope
lateinit var externalScope: CoroutineScope

@Inject
lateinit var sessionEventRepository: SessionEventRepository

@Inject
lateinit var orchestratorCache: OrchestratorCache

override fun onReceive(
context: Context,
intent: Intent,
) {
if (Intent.ACTION_MY_PACKAGE_REPLACED == intent.action) {
orchestratorCache.clearCache()
externalScope.launch { sessionEventRepository.closeCurrentSession() }
}
}
}