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

Commit e25a06f1 authored by dev-12's avatar dev-12
Browse files

Merge branch '1737-fix-stuck-on-installation' into 'main'

throw error if downloaded file doesn't exist before installing

See merge request !651
parents 340b6133 9cc30ae4
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ interface AppManager {
    fun moveOBBFilesToOBBDirectory(appInstall: AppInstall)
    fun getBaseApkPath(appInstall: AppInstall): String

    suspend fun installationIssue(appInstall: AppInstall)
    suspend fun reportInstallationIssue(appInstall: AppInstall)

    suspend fun updateAwaiting(appInstall: AppInstall)

+17 −11
Original line number Diff line number Diff line
@@ -136,18 +136,24 @@ class AppManagerImpl @Inject constructor(
                parentPathFile.listFiles()?.let { list.addAll(it) }
                list.sort()

                if (list.size != 0) {
                if (list.isEmpty()) {
                    reportInstallationIssue(appInstall)
                    val errorMessage =
                        "installApp: Downloaded files doesn't exist for package ${appInstall.packageName} "
                    Timber.e(errorMessage)
                    throw IllegalStateException(errorMessage)
                }

                try {
                        Timber.i("installApp: STARTED ${appInstall.name} ${list.size}")
                    Timber.d("installApp: STARTED ${appInstall.name} ${list.size}")
                    appLoungePackageManager.installApplication(list, appInstall.packageName)
                        Timber.i("installApp: ENDED ${appInstall.name} ${list.size}")
                    Timber.d("installApp: ENDED ${appInstall.name} ${list.size}")
                } catch (e: Exception) {
                        Timber.i(">>> installApp app failed ")
                        installationIssue(appInstall)
                    Timber.e(">>> installApp app failed ${e.localizedMessage}")
                    reportInstallationIssue(appInstall)
                    throw e
                }
            }
            }
            else -> {
                Timber.d("Unsupported application type!")
                appInstall.status = Status.INSTALLATION_ISSUE
@@ -273,7 +279,7 @@ class AppManagerImpl @Inject constructor(
    override fun getBaseApkPath(appInstall: AppInstall) =
        "$cacheDir/${appInstall.packageName}/${appInstall.packageName}_1.apk"

    override suspend fun installationIssue(appInstall: AppInstall) {
    override suspend fun reportInstallationIssue(appInstall: AppInstall) {
        appInstall.status = Status.INSTALLATION_ISSUE
        appInstallRepository.updateDownload(appInstall)
        flushOldDownload(appInstall.packageName)
+1 −1
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ class AppManagerWrapper @Inject constructor(
    }

    suspend fun installationIssue(appInstall: AppInstall) {
        return appManager.installationIssue(appInstall)
        return appManager.reportInstallationIssue(appInstall)
    }

    suspend fun updateAwaiting(appInstall: AppInstall) {
+1 −1
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ class FakeAppManager(private val appInstallDAO: AppInstallDAO) : AppManager {
        return "root/data/apps/${appInstall.packageName}/${appInstall.packageName}_1.apk"
    }

    override suspend fun installationIssue(appInstall: AppInstall) {
    override suspend fun reportInstallationIssue(appInstall: AppInstall) {
        TODO("Not yet implemented")
    }