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

Commit f57f9af6 authored by Sayantan Roychowdhury's avatar Sayantan Roychowdhury
Browse files

remove unnecessary onlySelf option

parent 4691df22
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ class UpdatesManagerRepository @Inject constructor(
        return updatesManagerImpl.getApplicationCategoryPreference()
    }

    suspend fun getSystemUpdates(onlySelf: Boolean = false): List<Application> {
    suspend fun getSystemUpdates(): List<Application> {
        return updatesManagerImpl.getSystemUpdates()
    }
}
+1 −10
Original line number Diff line number Diff line
@@ -35,14 +35,6 @@ object UpdatesWorkManager {
    const val TAG = "UpdatesWorkTag"
    const val USER_TAG = "UpdatesWorkUserTag"

    fun startAppLoungeUpdateWork(context: Context) {
        WorkManager.getInstance(context).enqueueUniqueWork(
            UPDATES_WORK_USER_NAME,
            ExistingWorkPolicy.APPEND_OR_REPLACE,
            buildOneTimeWorkRequest(selfUpdate = true)
        )
    }

    fun startUpdateAllWork(context: Context) {
        WorkManager.getInstance(context).enqueueUniqueWork(
            UPDATES_WORK_USER_NAME,
@@ -51,14 +43,13 @@ object UpdatesWorkManager {
        )
    }

    private fun buildOneTimeWorkRequest(selfUpdate: Boolean = false): OneTimeWorkRequest {
    private fun buildOneTimeWorkRequest(): OneTimeWorkRequest {
        return OneTimeWorkRequest.Builder(UpdatesWorker::class.java).apply {
            setConstraints(buildWorkerConstraints())
            addTag(USER_TAG)
        }.setInputData(
            Data.Builder()
                .putBoolean(UpdatesWorker.IS_AUTO_UPDATE, false)
                .putBoolean(UpdatesWorker.IS_SELF_UPDATE, selfUpdate)
                .build()
        ).build()
    }
+3 −11
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ class UpdatesWorker @AssistedInject constructor(

    companion object {
        const val IS_AUTO_UPDATE = "IS_AUTO_UPDATE"
        const val IS_SELF_UPDATE = "IS_SELF_UPDATE"
        private const val MAX_RETRY_COUNT = 10
        private const val DELAY_FOR_RETRY = 3000L
    }
@@ -53,13 +52,11 @@ class UpdatesWorker @AssistedInject constructor(
    private var automaticInstallEnabled = true
    private var onlyOnUnmeteredNetwork = false
    private var isAutoUpdate = true // indicates it is auto update or user initiated update
    private var isSelfUpdate = false
    private var retryCount = 0

    override suspend fun doWork(): Result {
        return try {
            isAutoUpdate = params.inputData.getBoolean(IS_AUTO_UPDATE, true)
            isSelfUpdate = params.inputData.getBoolean(IS_SELF_UPDATE, false)
            if (isAutoUpdate && checkManualUpdateRunning()) {
                return Result.success()
            }
@@ -112,12 +109,7 @@ class UpdatesWorker @AssistedInject constructor(
        val authData = authenticatorRepository.getValidatedAuthData().data
        val resultStatus: ResultStatus

        if (isSelfUpdate) {
            val list = updatesManagerRepository.getSystemUpdates(onlySelf = true)
            appsNeededToUpdate.addAll(list)
            resultStatus = ResultStatus.OK

        } else if (user in listOf(User.ANONYMOUS, User.GOOGLE) && authData != null) {
        if (user in listOf(User.ANONYMOUS, User.GOOGLE) && authData != null) {
            /*
             * Signifies valid Google user and valid auth data to update
             * apps from Google Play store.
@@ -141,7 +133,7 @@ class UpdatesWorker @AssistedInject constructor(
            return
        }
        Timber.i("Updates found: ${appsNeededToUpdate.size}; $resultStatus")
        if (isSelfUpdate || (isAutoUpdate && shouldShowNotification)) {
        if (isAutoUpdate && shouldShowNotification) {
            handleNotification(appsNeededToUpdate.size, isConnectedToUnMeteredNetwork)
        }

@@ -153,7 +145,7 @@ class UpdatesWorker @AssistedInject constructor(
             * Issue: https://gitlab.e.foundation/e/backlog/-/issues/5376
             */
            retryCount = 0
            if (isSelfUpdate || (isAutoUpdate && shouldShowNotification)) {
            if (isAutoUpdate && shouldShowNotification) {
                handleNotification(appsNeededToUpdate.size, isConnectedToUnMeteredNetwork)
            }