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

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

refactor: modify classes to use AppInstallationManager abstraction

parent da79130b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ interface AppInstallationModule {

    @Binds
    @Singleton
    fun bindInstallationAppManager(appManagerWrapper: AppInstallationManagerImpl): AppInstallationManager
    fun bindAppInstallationManager(appInstallationManagerImpl: AppInstallationManagerImpl): AppInstallationManager

    @Binds
    @Singleton
+13 −13
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ class AppInstallationManagerImpl @Inject constructor(
    private val fDroidRepository: FDroidRepository
) : AppInstallationManager {

    fun createNotificationChannels() {
    override fun createNotificationChannels() {
        return appManager.createNotificationChannels()
    }

@@ -51,11 +51,11 @@ class AppInstallationManagerImpl @Inject constructor(
        return appManager.downloadApp(appInstall, isUpdate)
    }

    fun moveOBBFileToOBBDirectory(appInstall: AppInstall) {
    override fun moveOBBFileToOBBDirectory(appInstall: AppInstall) {
        return appManager.moveOBBFilesToOBBDirectory(appInstall)
    }

    suspend fun addDownload(appInstall: AppInstall): Boolean {
    override suspend fun addDownload(appInstall: AppInstall): Boolean {
        val existingFusedDownload = appManager.getDownloadById(appInstall)
        val canAddDownload = when {
            isInstallWorkRunning(existingFusedDownload, appInstall) -> false
@@ -87,19 +87,19 @@ class AppInstallationManagerImpl @Inject constructor(
            appInstall.id
        )

    suspend fun addFusedDownloadPurchaseNeeded(appInstall: AppInstall) {
    override suspend fun addFusedDownloadPurchaseNeeded(appInstall: AppInstall) {
        appManager.insertAppInstallPurchaseNeeded(appInstall)
    }

    suspend fun getDownloadList(): List<AppInstall> {
    override suspend fun getDownloadList(): List<AppInstall> {
        return appManager.getDownloadList()
    }

    fun getDownloadLiveList(): LiveData<List<AppInstall>> {
    override fun getDownloadLiveList(): LiveData<List<AppInstall>> {
        return appManager.getDownloadLiveList()
    }

    suspend fun getFusedDownload(downloadId: Long = 0, packageName: String = ""): AppInstall {
    override suspend fun getFusedDownload(downloadId: Long, packageName: String): AppInstall {
        return appManager.getFusedDownload(downloadId, packageName)
    }

@@ -111,7 +111,7 @@ class AppInstallationManagerImpl @Inject constructor(
        return appManager.cancelDownload(appInstall, "")
    }

    suspend fun cancelDownload(appInstall: AppInstall, packageName: String = "") {
    override suspend fun cancelDownload(appInstall: AppInstall, packageName: String) {
        return appManager.cancelDownload(appInstall, packageName)
    }

@@ -119,15 +119,15 @@ class AppInstallationManagerImpl @Inject constructor(
        return appManager.reportInstallationIssue(appInstall)
    }

    suspend fun updateAwaiting(appInstall: AppInstall) {
    override suspend fun updateAwaiting(appInstall: AppInstall) {
        appManager.updateAwaiting(appInstall)
    }

    suspend fun updateUnavailable(appInstall: AppInstall) {
    override suspend fun updateUnavailable(appInstall: AppInstall) {
        appManager.updateUnavailable(appInstall)
    }

    suspend fun updateFusedDownload(appInstall: AppInstall) {
    override suspend fun updateFusedDownload(appInstall: AppInstall) {
        appManager.updateAppInstall(appInstall)
    }

@@ -209,7 +209,7 @@ class AppInstallationManagerImpl @Inject constructor(
        return null
    }

    suspend fun isFDroidApplicationSigned(context: Context, appInstall: AppInstall): Boolean {
    override suspend fun isFDroidApplicationSigned(context: Context, appInstall: AppInstall): Boolean {
        val apkFilePath = appManager.getBaseApkPath(appInstall)
        return fDroidRepository.isFDroidApplicationSigned(
            context,
@@ -223,7 +223,7 @@ class AppInstallationManagerImpl @Inject constructor(
        return appManager.isAppInstalled(appInstall)
    }

    fun getFusedDownloadPackageStatus(appInstall: AppInstall): Status {
    override fun getFusedDownloadPackageStatus(appInstall: AppInstall): Status {
        return appManager.getInstallationStatus(appInstall)
    }
}
+3 −3
Original line number Diff line number Diff line
@@ -22,15 +22,15 @@ import foundation.e.apps.data.application.ApplicationRepository
import foundation.e.apps.data.application.data.Application
import foundation.e.apps.data.enums.ResultStatus
import foundation.e.apps.data.enums.Source
import foundation.e.apps.data.install.AppInstallationManagerImpl
import foundation.e.apps.data.installation.core.InstallationProcessor
import foundation.e.apps.data.installation.model.AppInstall
import foundation.e.apps.data.installation.model.InstallationResult
import foundation.e.apps.data.installation.port.AppInstallationManager
import foundation.e.apps.domain.model.install.Status
import javax.inject.Inject

class AppInstallationFacade @Inject constructor(
    private val appManagerWrapper: AppInstallationManagerImpl,
    private val appInstallationManager: AppInstallationManager,
    private val installationEnqueuer: InstallationEnqueuer,
    private val installationProcessor: InstallationProcessor,
    private val installationRequest: InstallationRequest,
@@ -68,7 +68,7 @@ class AppInstallationFacade @Inject constructor(

        val isUpdate = isAnUpdate ||
            application.status == Status.UPDATABLE ||
            appManagerWrapper.isFusedDownloadInstalled(appInstall)
            appInstallationManager.isFusedDownloadInstalled(appInstall)

        return enqueueFusedDownload(appInstall, isUpdate, application.isSystemApp)
    }
+2 −2
Original line number Diff line number Diff line
@@ -22,11 +22,11 @@ import android.content.Context
import dagger.hilt.android.qualifiers.ApplicationContext
import foundation.e.apps.R
import foundation.e.apps.data.event.AppEvent
import foundation.e.apps.data.install.AppInstallationManagerImpl
import foundation.e.apps.data.install.core.helper.PreEnqueueChecker
import foundation.e.apps.data.install.workmanager.InstallWorkManager
import foundation.e.apps.data.install.wrapper.AppEventDispatcher
import foundation.e.apps.data.installation.model.AppInstall
import foundation.e.apps.data.installation.port.AppInstallationManager
import foundation.e.apps.data.preference.PlayStoreAuthStore
import foundation.e.apps.domain.model.User
import foundation.e.apps.domain.preferences.SessionRepository
@@ -36,7 +36,7 @@ import javax.inject.Inject
class InstallationEnqueuer @Inject constructor(
    @ApplicationContext private val context: Context,
    private val preEnqueueChecker: PreEnqueueChecker,
    private val appManagerWrapper: AppInstallationManagerImpl,
    private val appManagerWrapper: AppInstallationManager,
    private val sessionRepository: SessionRepository,
    private val playStoreAuthStore: PlayStoreAuthStore,
    private val appEventDispatcher: AppEventDispatcher,
+3 −3
Original line number Diff line number Diff line
@@ -21,9 +21,9 @@ package foundation.e.apps.data.install.core.helper
import foundation.e.apps.R
import foundation.e.apps.data.ResultSupreme
import foundation.e.apps.data.event.AppEvent
import foundation.e.apps.data.install.AppInstallationManagerImpl
import foundation.e.apps.data.install.wrapper.AppEventDispatcher
import foundation.e.apps.data.installation.model.AppInstall
import foundation.e.apps.data.installation.port.AppInstallationManager
import foundation.e.apps.data.installation.port.ParentalControlAuthGateway
import foundation.e.apps.domain.ValidateAppAgeLimitUseCase
import foundation.e.apps.domain.model.ContentRatingValidity
@@ -31,7 +31,7 @@ import kotlinx.coroutines.CompletableDeferred
import javax.inject.Inject
class AgeLimiter @Inject constructor(
    private val validateAppAgeLimitUseCase: ValidateAppAgeLimitUseCase,
    private val appManagerWrapper: AppInstallationManagerImpl,
    private val appInstallationManager: AppInstallationManager,
    private val appEventDispatcher: AppEventDispatcher,
    private val parentalControlAuthGateway: ParentalControlAuthGateway,
) {
@@ -51,7 +51,7 @@ class AgeLimiter @Inject constructor(
        }

        if (!isAllowed) {
            appManagerWrapper.cancelDownload(appInstall)
            appInstallationManager.cancelDownload(appInstall)
        }

        return isAllowed
Loading