Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ea99f7fa authored by Abhishek Aggarwal's avatar Abhishek Aggarwal
Browse files

Applounge: Properly Inject broadcast reciever

parent 160d1678
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -77,6 +77,9 @@ class AppLoungeApplication : Application(), Configuration.Provider {
    @IoCoroutineScope
    lateinit var coroutineScope: CoroutineScope

    @Inject
    lateinit var pkgManagerBR: PkgManagerBR

    @RequiresApi(Build.VERSION_CODES.TIRAMISU)
    override fun onCreate() {
        super.onCreate()
@@ -85,7 +88,6 @@ class AppLoungeApplication : Application(), Configuration.Provider {

        InstallWorkManager.context = this
        // Register broadcast receiver for package manager
        val pkgManagerBR = object : PkgManagerBR() {}
        registerReceiver(pkgManagerBR, appLoungePackageManager.getFilter(), RECEIVER_EXPORTED)

        val currentVersion = runBlocking { appLoungeDataStore.tosVersion.first() }
+25 −35
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.pm.PackageInstaller
import dagger.hilt.android.AndroidEntryPoint
import foundation.e.apps.data.enums.Status
import foundation.e.apps.data.faultyApps.FaultyAppRepository
import foundation.e.apps.data.install.AppManagerWrapper
@@ -32,26 +31,17 @@ import kotlinx.coroutines.launch
import timber.log.Timber
import javax.inject.Inject

@AndroidEntryPoint
open class PkgManagerBR : BroadcastReceiver() {
class PkgManagerBR @Inject constructor(
    private val appManagerWrapper: AppManagerWrapper,
    private val appLoungePackageManager: AppLoungePackageManager,
    private val faultyAppRepository: FaultyAppRepository,
    @IoCoroutineScope private val coroutineScope: CoroutineScope
) : BroadcastReceiver() {

    companion object {
        private const val DEFAULT_INSTALL_STATUS = -69
    }

    @Inject
    lateinit var appManagerWrapper: AppManagerWrapper

    @Inject
    lateinit var appLoungePackageManager: AppLoungePackageManager

    @Inject
    lateinit var faultyAppRepository: FaultyAppRepository

    @Inject
    @IoCoroutineScope
    lateinit var coroutineScope: CoroutineScope

    override fun onReceive(context: Context?, intent: Intent?) {
        val action = intent?.action
        if (context != null && action != null) {