diff --git a/app/src/main/java/foundation/e/apps/data/install/AppManager.kt b/app/src/main/java/foundation/e/apps/data/install/AppManager.kt index a37de7778ad1a7a05306eb6c69d88e194f06c519..d299b4227f2755f3b406ece4b7950abab0556f90 100644 --- a/app/src/main/java/foundation/e/apps/data/install/AppManager.kt +++ b/app/src/main/java/foundation/e/apps/data/install/AppManager.kt @@ -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) diff --git a/app/src/main/java/foundation/e/apps/data/install/AppManagerImpl.kt b/app/src/main/java/foundation/e/apps/data/install/AppManagerImpl.kt index 5bfb81e8b39d187d8d0331aaaa042a9aff5e5165..3e4475293346485bbfc99961105f1af302b5f742 100644 --- a/app/src/main/java/foundation/e/apps/data/install/AppManagerImpl.kt +++ b/app/src/main/java/foundation/e/apps/data/install/AppManagerImpl.kt @@ -136,16 +136,22 @@ class AppManagerImpl @Inject constructor( parentPathFile.listFiles()?.let { list.addAll(it) } list.sort() - if (list.size != 0) { - try { - Timber.i("installApp: STARTED ${appInstall.name} ${list.size}") - appLoungePackageManager.installApplication(list, appInstall.packageName) - Timber.i("installApp: ENDED ${appInstall.name} ${list.size}") - } catch (e: Exception) { - Timber.i(">>> installApp app failed ") - installationIssue(appInstall) - throw e - } + 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.d("installApp: STARTED ${appInstall.name} ${list.size}") + appLoungePackageManager.installApplication(list, appInstall.packageName) + Timber.d("installApp: ENDED ${appInstall.name} ${list.size}") + } catch (e: Exception) { + Timber.e(">>> installApp app failed ${e.localizedMessage}") + reportInstallationIssue(appInstall) + throw e } } else -> { @@ -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) diff --git a/app/src/main/java/foundation/e/apps/data/install/AppManagerWrapper.kt b/app/src/main/java/foundation/e/apps/data/install/AppManagerWrapper.kt index fd82ddfd4655c85d0fc45236ac3af8b5289487ac..44b8f90dae6246121d0c94250391fe7701f77be9 100644 --- a/app/src/main/java/foundation/e/apps/data/install/AppManagerWrapper.kt +++ b/app/src/main/java/foundation/e/apps/data/install/AppManagerWrapper.kt @@ -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) { diff --git a/app/src/test/java/foundation/e/apps/fusedManager/FakeAppManager.kt b/app/src/test/java/foundation/e/apps/fusedManager/FakeAppManager.kt index 20abb9f03a489bcc4c0a07ae309a09cc2e5e5728..c2613295bd8f120bdbb93a37f7dcf8d256479a23 100644 --- a/app/src/test/java/foundation/e/apps/fusedManager/FakeAppManager.kt +++ b/app/src/test/java/foundation/e/apps/fusedManager/FakeAppManager.kt @@ -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") }