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

Commit abbe8ecb authored by Hasib Prince's avatar Hasib Prince
Browse files

Removed uncessary delays of install process

parent 94cb7858
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -381,7 +381,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) {
                        appSize
                    )
                    Status.UNAVAILABLE -> handleUnavaiable(installButton, fusedApp, downloadPB, appSize)
                    Status.QUEUED, Status.AWAITING -> handleQueued(
                    Status.QUEUED, Status.AWAITING, Status.DOWNLOADED -> handleQueued(
                        installButton,
                        fusedApp,
                        downloadPB,
+1 −1
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ class ApplicationListRVAdapter(
            Status.UNAVAILABLE -> {
                handleUnavailable(view, searchApp, holder)
            }
            Status.QUEUED, Status.AWAITING, Status.DOWNLOADING -> {
            Status.QUEUED, Status.AWAITING, Status.DOWNLOADING, Status.DOWNLOADED -> {
                handleDownloading(view, searchApp)
            }
            Status.INSTALLING, Status.UNINSTALLING -> {
+2 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import foundation.e.apps.home.HomeFragmentDirections
import foundation.e.apps.utils.enums.Origin
import foundation.e.apps.utils.enums.Status
import foundation.e.apps.utils.enums.User
import timber.log.Timber

class HomeChildRVAdapter(
    private var fusedAPIInterface: FusedAPIInterface?,
@@ -110,7 +111,7 @@ class HomeChildRVAdapter(
                Status.UNAVAILABLE -> {
                    handleUnavailable(homeApp, holder, view)
                }
                Status.QUEUED, Status.AWAITING, Status.DOWNLOADING -> {
                Status.QUEUED, Status.AWAITING, Status.DOWNLOADING, Status.DOWNLOADED -> {
                    handleQueued(view, homeApp)
                }
                Status.INSTALLING, Status.UNINSTALLING -> {
+19 −5
Original line number Diff line number Diff line
@@ -6,6 +6,8 @@ import foundation.e.apps.OpenForTesting
import foundation.e.apps.manager.database.fusedDownload.FusedDownload
import foundation.e.apps.manager.database.fusedDownload.FusedDownloadDAO
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import javax.inject.Inject
import javax.inject.Singleton

@@ -15,29 +17,41 @@ class DatabaseRepository @Inject constructor(
    private val fusedDownloadDAO: FusedDownloadDAO
) {

    private val mutex = Mutex()

    suspend fun addDownload(fusedDownload: FusedDownload) {
        mutex.withLock {
            return fusedDownloadDAO.addDownload(fusedDownload)
        }
    }

    suspend fun getDownloadList(): List<FusedDownload> {
        mutex.withLock {
            return fusedDownloadDAO.getDownloadList()
        }
    }

    fun getDownloadLiveList(): LiveData<List<FusedDownload>> {
        return fusedDownloadDAO.getDownloadLiveList()
    }

    suspend fun updateDownload(fusedDownload: FusedDownload) {
        mutex.withLock {
            fusedDownloadDAO.updateDownload(fusedDownload)
        }
    }

    suspend fun deleteDownload(fusedDownload: FusedDownload) {
        mutex.withLock {
            return fusedDownloadDAO.deleteDownload(fusedDownload)
        }
    }

    suspend fun getDownloadById(id: String): FusedDownload? {
        mutex.withLock {
            return fusedDownloadDAO.getDownloadById(id)
        }
    }

    fun getDownloadFlowById(id: String): Flow<FusedDownload> {
        return fusedDownloadDAO.getDownloadFlowById(id).asFlow()
+1 −7
Original line number Diff line number Diff line
@@ -92,18 +92,15 @@ class FusedManagerImpl @Inject constructor(
    suspend fun updateDownloadStatus(fusedDownload: FusedDownload, status: Status) {
        if (status == Status.INSTALLED) {
            fusedDownload.status = status
            databaseRepository.updateDownload(fusedDownload)
//            databaseRepository.updateDownload(fusedDownload)
            DownloadManagerBR.downloadedList.clear()
            delay(100)
            flushOldDownload(fusedDownload.packageName)
            databaseRepository.deleteDownload(fusedDownload)
        } else if (status == Status.INSTALLING) {
            fusedDownload.downloadIdMap.all { true }
            fusedDownload.status = status
            databaseRepository.updateDownload(fusedDownload)
            delay(100)
            installApp(fusedDownload)
            delay(100)
        }
    }

@@ -141,7 +138,6 @@ class FusedManagerImpl @Inject constructor(
                Timber.d("Unsupported application type!")
                fusedDownload.status = Status.INSTALLATION_ISSUE
                databaseRepository.updateDownload(fusedDownload)
                delay(100)
            }
        }
    }
@@ -157,7 +153,6 @@ class FusedManagerImpl @Inject constructor(

            // Reset the status before deleting download
            updateDownloadStatus(fusedDownload, fusedDownload.orgStatus)
            delay(100)

            databaseRepository.deleteDownload(fusedDownload)
            flushOldDownload(fusedDownload.packageName)
@@ -199,7 +194,6 @@ class FusedManagerImpl @Inject constructor(
        fusedDownload.status = Status.DOWNLOADING
        databaseRepository.updateDownload(fusedDownload)
        DownloadProgressLD.setDownloadId(-1)
        delay(100)
        fusedDownload.downloadURLList.forEach {
            count += 1
            val packagePath: File = if (fusedDownload.files.isNotEmpty()) {