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

Commit 9fbfdaf5 authored by Hasib Prince's avatar Hasib Prince
Browse files

fixed: updating update cache after the app is installed

parent 249d585d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.os.IBinder
import androidx.annotation.RequiresApi
import dagger.hilt.android.AndroidEntryPoint
import foundation.e.apps.api.faultyApps.FaultyAppRepository
import foundation.e.apps.api.fused.UpdatesDao
import foundation.e.apps.manager.fused.FusedManagerRepository
import foundation.e.apps.utils.enums.Status
import foundation.e.apps.utils.eventBus.AppEvent
@@ -75,6 +76,7 @@ class InstallerService : Service() {
    private fun postStatus(status: Int, packageName: String?, extra: String?) {
        Timber.d("postStatus: $status $packageName $extra")
        if (status == PackageInstaller.STATUS_SUCCESS) {
            UpdatesDao.removeUpdateIfExists(packageName ?: "")
            return
        }

+6 −12
Original line number Diff line number Diff line
@@ -128,8 +128,7 @@ class InstallAppWorker @AssistedInject constructor(
            .onEach {
                val download = databaseRepository.getDownloadById(fusedDownload.id)
                if (download == null) {
                    isDownloading = false
                    unlockMutex()
                    finishInstallation()
                } else {
                    handleFusedDownloadStatusCheckingException(download)
                    if (isAppDownloading(download)) {
@@ -151,8 +150,7 @@ class InstallAppWorker @AssistedInject constructor(
            handleFusedDownloadStatus(download)
        } catch (e: Exception) {
            Log.e(TAG, "observeDownload: ", e)
            isDownloading = false
            unlockMutex()
            finishInstallation()
        }
    }

@@ -193,11 +191,11 @@ class InstallAppWorker @AssistedInject constructor(
                Timber.d("===> doWork: Installing ${fusedDownload.name} ${fusedDownload.status}")
            }
            Status.INSTALLED, Status.INSTALLATION_ISSUE -> {
                finishInstallation(fusedDownload, fusedDownload.status)
                finishInstallation()
                Timber.d("===> doWork: Installed/Failed: ${fusedDownload.name} ${fusedDownload.status}")
            }
            else -> {
                isDownloading = false
                unlockMutex()
                finishInstallation()
                Log.wtf(
                    TAG,
                    "===> ${fusedDownload.name} is in wrong state ${fusedDownload.status}"
@@ -206,13 +204,9 @@ class InstallAppWorker @AssistedInject constructor(
        }
    }

    private fun finishInstallation(fusedDownload: FusedDownload, status: Status) {
        if (status == Status.INSTALLED) {
            UpdatesDao.removeUpdateIfExists(fusedDownload.packageName)
        }
    private fun finishInstallation() {
        isDownloading = false
        unlockMutex()
        Timber.d("===> doWork: Installed/Failed: ${fusedDownload.name} ${fusedDownload.status}")
    }

    private fun unlockMutex() {
+2 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import com.aurora.gplayapi.data.models.AuthData
import foundation.e.apps.api.fused.UpdatesDao
import foundation.e.apps.api.fused.data.FusedApp
import foundation.e.apps.utils.enums.ResultStatus
import timber.log.Timber
import javax.inject.Inject

class UpdatesManagerRepository @Inject constructor(
@@ -29,6 +30,7 @@ class UpdatesManagerRepository @Inject constructor(
) {

    suspend fun getUpdates(authData: AuthData): Pair<List<FusedApp>, ResultStatus> {
        Timber.d("===> getUpdates: ${UpdatesDao.hasAnyAppsForUpdate()}")
        if (UpdatesDao.hasAnyAppsForUpdate()) {
            return Pair(UpdatesDao.appsAwaitingForUpdate, ResultStatus.OK)
        }