Loading app/src/main/java/foundation/e/apps/data/install/AppManagerImpl.kt +23 −9 Original line number Diff line number Diff line Loading @@ -152,14 +152,8 @@ class AppManagerImpl @Inject constructor( appInstallRepository.deleteDownload(appInstall) } else if (status == Status.INSTALLING) { appInstall.downloadIdMap.all { true } appInstall.status = status val isSelfUpdate = appInstall.packageName == context.packageName if (isSelfUpdate) { appInstallRepository.deleteDownload(appInstall) } else { appInstall.status = status appInstallRepository.updateDownload(appInstall) } installApp(appInstall) } } Loading Loading @@ -195,7 +189,7 @@ class AppManagerImpl @Inject constructor( list.sort() if (list.isEmpty()) { reportInstallationIssue(appInstall) finalizeUnattendedFailure(appInstall) val errorMessage = "installApp: Downloaded files doesn't exist for package ${appInstall.packageName} " Timber.e(errorMessage) Loading @@ -214,7 +208,7 @@ class AppManagerImpl @Inject constructor( Timber.d("installApp: ENDED ${appInstall.name} ${list.size}") } catch (e: Exception) { Timber.e(">>> installApp app failed ${e.localizedMessage}") reportInstallationIssue(appInstall) finalizeUnattendedFailure(appInstall) throw e } } Loading @@ -238,6 +232,26 @@ class AppManagerImpl @Inject constructor( } } override suspend fun finalizeUnattendedFailure(appInstall: AppInstall) { mutex.withLock { Timber.w( "Finalizing unattended failure for %s (%s) with %d tracked downloads", appInstall.name, appInstall.packageName, appInstall.downloadIdMap.size ) appInstall.downloadIdMap.forEach { (key, _) -> downloadManager.remove(key) } DownloadProgressLD.setDownloadId(-1) appInstall.downloadIdMap = mutableMapOf() appInstall.status = Status.INSTALLATION_ISSUE appInstallRepository.updateDownload(appInstall) flushOldDownload(appInstall.packageName) } } private suspend fun removeFusedDownload(appInstall: AppInstall) { appInstall.downloadIdMap.forEach { (key, _) -> downloadManager.remove(key) Loading app/src/main/java/foundation/e/apps/data/install/core/InstallationEnqueuer.kt +1 −1 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ class InstallationEnqueuer @Inject constructor( "Enqueuing App install work is failed for ${appInstall.packageName} " + "exception: ${throwable.localizedMessage}" ) appManager.reportInstallationIssue(appInstall) appManager.finalizeUnattendedFailure(appInstall) false } else -> throw throwable Loading app/src/main/java/foundation/e/apps/data/install/download/DownloadManagerUtils.kt +1 −2 Original line number Diff line number Diff line Loading @@ -96,8 +96,7 @@ class DownloadManagerUtils @Inject constructor( } private suspend fun handleDownloadFailed(appInstall: AppInstall, downloadId: Long) { appManager.reportInstallationIssue(appInstall) appManager.cancelDownload(appInstall) appManager.finalizeUnattendedFailure(appInstall) Timber.w("===> Download failed: ${appInstall.name} ${appInstall.status}") val hasInsufficientSpace = Loading app/src/main/java/foundation/e/apps/data/install/pkg/InstallerService.kt +6 −1 Original line number Diff line number Diff line Loading @@ -135,10 +135,15 @@ class InstallerService : Service() { private fun updateInstallationIssue(pkgName: String) { if (pkgName.isEmpty()) { Timber.d("updateDownloadStatus: package name should not be empty!") return } coroutineScope.launch { val fusedDownload = appManager.getFusedDownload(packageName = pkgName) appManager.reportInstallationIssue(fusedDownload) if (fusedDownload.id.isEmpty()) { Timber.w("Unable to finalize install failure for unresolved package %s", pkgName) return@launch } appManager.finalizeUnattendedFailure(fusedDownload) } } } app/src/main/java/foundation/e/apps/data/install/pkg/PkgManagerBR.kt +5 −1 Original line number Diff line number Diff line Loading @@ -109,7 +109,11 @@ class PkgManagerBR @Inject constructor( private fun updateInstallationIssue(pkgName: String) { coroutineScope.launch { val fusedDownload = appManager.getFusedDownload(packageName = pkgName) appManager.reportInstallationIssue(fusedDownload) if (fusedDownload.id.isEmpty()) { Timber.w("Unable to finalize broadcast install failure for unresolved package %s", pkgName) return@launch } appManager.finalizeUnattendedFailure(fusedDownload) } } } Loading
app/src/main/java/foundation/e/apps/data/install/AppManagerImpl.kt +23 −9 Original line number Diff line number Diff line Loading @@ -152,14 +152,8 @@ class AppManagerImpl @Inject constructor( appInstallRepository.deleteDownload(appInstall) } else if (status == Status.INSTALLING) { appInstall.downloadIdMap.all { true } appInstall.status = status val isSelfUpdate = appInstall.packageName == context.packageName if (isSelfUpdate) { appInstallRepository.deleteDownload(appInstall) } else { appInstall.status = status appInstallRepository.updateDownload(appInstall) } installApp(appInstall) } } Loading Loading @@ -195,7 +189,7 @@ class AppManagerImpl @Inject constructor( list.sort() if (list.isEmpty()) { reportInstallationIssue(appInstall) finalizeUnattendedFailure(appInstall) val errorMessage = "installApp: Downloaded files doesn't exist for package ${appInstall.packageName} " Timber.e(errorMessage) Loading @@ -214,7 +208,7 @@ class AppManagerImpl @Inject constructor( Timber.d("installApp: ENDED ${appInstall.name} ${list.size}") } catch (e: Exception) { Timber.e(">>> installApp app failed ${e.localizedMessage}") reportInstallationIssue(appInstall) finalizeUnattendedFailure(appInstall) throw e } } Loading @@ -238,6 +232,26 @@ class AppManagerImpl @Inject constructor( } } override suspend fun finalizeUnattendedFailure(appInstall: AppInstall) { mutex.withLock { Timber.w( "Finalizing unattended failure for %s (%s) with %d tracked downloads", appInstall.name, appInstall.packageName, appInstall.downloadIdMap.size ) appInstall.downloadIdMap.forEach { (key, _) -> downloadManager.remove(key) } DownloadProgressLD.setDownloadId(-1) appInstall.downloadIdMap = mutableMapOf() appInstall.status = Status.INSTALLATION_ISSUE appInstallRepository.updateDownload(appInstall) flushOldDownload(appInstall.packageName) } } private suspend fun removeFusedDownload(appInstall: AppInstall) { appInstall.downloadIdMap.forEach { (key, _) -> downloadManager.remove(key) Loading
app/src/main/java/foundation/e/apps/data/install/core/InstallationEnqueuer.kt +1 −1 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ class InstallationEnqueuer @Inject constructor( "Enqueuing App install work is failed for ${appInstall.packageName} " + "exception: ${throwable.localizedMessage}" ) appManager.reportInstallationIssue(appInstall) appManager.finalizeUnattendedFailure(appInstall) false } else -> throw throwable Loading
app/src/main/java/foundation/e/apps/data/install/download/DownloadManagerUtils.kt +1 −2 Original line number Diff line number Diff line Loading @@ -96,8 +96,7 @@ class DownloadManagerUtils @Inject constructor( } private suspend fun handleDownloadFailed(appInstall: AppInstall, downloadId: Long) { appManager.reportInstallationIssue(appInstall) appManager.cancelDownload(appInstall) appManager.finalizeUnattendedFailure(appInstall) Timber.w("===> Download failed: ${appInstall.name} ${appInstall.status}") val hasInsufficientSpace = Loading
app/src/main/java/foundation/e/apps/data/install/pkg/InstallerService.kt +6 −1 Original line number Diff line number Diff line Loading @@ -135,10 +135,15 @@ class InstallerService : Service() { private fun updateInstallationIssue(pkgName: String) { if (pkgName.isEmpty()) { Timber.d("updateDownloadStatus: package name should not be empty!") return } coroutineScope.launch { val fusedDownload = appManager.getFusedDownload(packageName = pkgName) appManager.reportInstallationIssue(fusedDownload) if (fusedDownload.id.isEmpty()) { Timber.w("Unable to finalize install failure for unresolved package %s", pkgName) return@launch } appManager.finalizeUnattendedFailure(fusedDownload) } } }
app/src/main/java/foundation/e/apps/data/install/pkg/PkgManagerBR.kt +5 −1 Original line number Diff line number Diff line Loading @@ -109,7 +109,11 @@ class PkgManagerBR @Inject constructor( private fun updateInstallationIssue(pkgName: String) { coroutineScope.launch { val fusedDownload = appManager.getFusedDownload(packageName = pkgName) appManager.reportInstallationIssue(fusedDownload) if (fusedDownload.id.isEmpty()) { Timber.w("Unable to finalize broadcast install failure for unresolved package %s", pkgName) return@launch } appManager.finalizeUnattendedFailure(fusedDownload) } } }