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

Verified Commit da79130b authored by Fahim M. Choudhury's avatar Fahim M. Choudhury
Browse files

refactor: resolve detekt issues with AppInstallationManagerImpl

parent 5f39ace8
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@
    <ID>ProtectedMemberInFinalClass:ApplicationListFragment.kt$ApplicationListFragment$// protected to avoid SyntheticAccessor protected val viewModel: ApplicationListViewModel by viewModels()</ID>
    <ID>ProtectedMemberInFinalClass:GoogleSignInFragment.kt$GoogleSignInFragment$// protected to avoid SyntheticAccessor protected val viewModel: LoginViewModel by lazy { ViewModelProvider(requireActivity())[LoginViewModel::class.java] }</ID>
    <ID>ReturnCount:AppInstallProcessor.kt$AppInstallProcessor$private suspend fun updateDownloadUrls(appInstall: AppInstall): Boolean</ID>
    <ID>ReturnCount:AppInstallationManagerImpl.kt$AppInstallationManagerImpl$suspend fun addDownload(appInstall: AppInstall): Boolean</ID>
    <ID>ReturnCount:CleanApkAppsRepository.kt$CleanApkAppsRepository$override suspend fun getAppDetails(packageName: String): Application</ID>
    <ID>ReturnCount:CleanApkPwaRepository.kt$CleanApkPwaRepository$override suspend fun getAppDetails(packageName: String): Application</ID>
    <ID>ReturnCount:DownloadManager.kt$DownloadManager$fun getSizeRequired(downloadId: Long): Long</ID>
@@ -74,7 +73,6 @@
    <ID>TooManyFunctions:AppLoungePackageManager.kt$AppLoungePackageManager</ID>
    <ID>TooManyFunctions:AppManager.kt$AppManager</ID>
    <ID>TooManyFunctions:AppManagerImpl.kt$AppManagerImpl : AppManager</ID>
    <ID>TooManyFunctions:AppInstallationManagerImpl.kt$AppInstallationManagerImpl</ID>
    <ID>TooManyFunctions:ApplicationListFragment.kt$ApplicationListFragment : TimeoutFragmentApplicationInstaller</ID>
    <ID>TooManyFunctions:ApplicationRepository.kt$ApplicationRepository</ID>
    <ID>TooManyFunctions:MainActivityViewModel.kt$MainActivityViewModel : ViewModel</ID>
+8 −7
Original line number Diff line number Diff line
@@ -57,17 +57,18 @@ class AppInstallationManagerImpl @Inject constructor(

    suspend fun addDownload(appInstall: AppInstall): Boolean {
        val existingFusedDownload = appManager.getDownloadById(appInstall)
        if (isInstallWorkRunning(existingFusedDownload, appInstall)) {
            return false
        val canAddDownload = when {
            isInstallWorkRunning(existingFusedDownload, appInstall) -> false
            // We don't want to add anything if it already exists without INSTALLATION_ISSUE
            existingFusedDownload != null && !isStatusEligibleToInstall(existingFusedDownload) -> false
            else -> true
        }

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

        appManager.addDownload(appInstall)
        return true
        return canAddDownload
    }

    private fun isStatusEligibleToInstall(existingAppInstall: AppInstall) =