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

Commit 5f54283e authored by Hasib Prince's avatar Hasib Prince
Browse files

Merge branch '1218-refactor_init_install' into 'main'

refactor: initiating install process

See merge request !333
parents f20ce143 d1df329f
Loading
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -20,6 +20,5 @@ package foundation.e.apps.data.enums

enum class Origin {
    CLEANAPK,
    GITLAB,
    GPLAY
}
+0 −1
Original line number Diff line number Diff line
@@ -76,7 +76,6 @@ class FusedAPIRepository @Inject constructor(private val fusedAPIImpl: FusedApi)
    }

    suspend fun updateFusedDownloadWithDownloadingInfo(
        authData: AuthData,
        origin: Origin,
        fusedDownload: FusedDownload
    ) {
+0 −3
Original line number Diff line number Diff line
@@ -537,9 +537,6 @@ class FusedApiImpl @Inject constructor(
                fusedDownload.files = downloadList
                list.addAll(downloadList.map { it.url })
            }

            Origin.GITLAB -> {
            }
        }
        fusedDownload.downloadURLList = list
    }
+1 −6
Original line number Diff line number Diff line
@@ -85,11 +85,6 @@ class FusedManagerImpl @Inject constructor(
        return fusedDownloadRepository.getDownloadLiveList()
    }

    override suspend fun clearInstallationIssue(fusedDownload: FusedDownload) {
        flushOldDownload(fusedDownload.packageName)
        fusedDownloadRepository.deleteDownload(fusedDownload)
    }

    @OptIn(DelicateCoroutinesApi::class)
    override suspend fun updateDownloadStatus(fusedDownload: FusedDownload, status: Status) {
        if (status == Status.INSTALLED) {
@@ -258,9 +253,9 @@ class FusedManagerImpl @Inject constructor(
        "$cacheDir/${fusedDownload.packageName}/${fusedDownload.packageName}_1.apk"

    override suspend fun installationIssue(fusedDownload: FusedDownload) {
        flushOldDownload(fusedDownload.packageName)
        fusedDownload.status = Status.INSTALLATION_ISSUE
        fusedDownloadRepository.updateDownload(fusedDownload)
        flushOldDownload(fusedDownload.packageName)
    }

    override suspend fun updateAwaiting(fusedDownload: FusedDownload) {
+8 −5
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ class FusedManagerRepository @Inject constructor(
        }

        // We don't want to add any thing, if it already exists without INSTALLATION_ISSUE
        if (existingFusedDownload != null && existingFusedDownload.status != Status.INSTALLATION_ISSUE) {
        if (existingFusedDownload != null && !isStatusEligibleToInstall(existingFusedDownload)) {
            return false
        }

@@ -49,6 +49,13 @@ class FusedManagerRepository @Inject constructor(
        return true
    }

    private fun isStatusEligibleToInstall(existingFusedDownload: FusedDownload) =
        listOf(
            Status.UNAVAILABLE,
            Status.INSTALLATION_ISSUE,
            Status.PURCHASE_NEEDED
        ).contains(existingFusedDownload.status)

    private fun isInstallWorkRunning(
        existingFusedDownload: FusedDownload?,
        fusedDownload: FusedDownload
@@ -61,10 +68,6 @@ class FusedManagerRepository @Inject constructor(
        fusedManagerImpl.insertFusedDownloadPurchaseNeeded(fusedDownload)
    }

    suspend fun clearInstallationIssue(fusedDownload: FusedDownload) {
        return fusedManagerImpl.clearInstallationIssue(fusedDownload)
    }

    suspend fun getDownloadList(): List<FusedDownload> {
        return fusedManagerImpl.getDownloadList()
    }
Loading