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

Commit 44dabbde authored by Sayantan Roychowdhury's avatar Sayantan Roychowdhury
Browse files

Merge branch '5174-restricted_apps_update' into 'main'

Issue 5174: Filter out restricted apps from updates list

See merge request !111
parents d4c08cb9 b27e8bb9
Loading
Loading
Loading
Loading
Loading
+22 −4
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ package foundation.e.apps.api.fused

import android.content.Context
import android.text.format.Formatter
import com.aurora.gplayapi.Constants
import com.aurora.gplayapi.SearchSuggestEntry
import com.aurora.gplayapi.data.models.App
import com.aurora.gplayapi.data.models.Artwork
@@ -261,14 +262,31 @@ class FusedAPIImpl @Inject constructor(
            pkgList
        } else {
            gPlayAPIRepository.getAppDetails(packageNameList, authData).map { app ->
                /*
                 * Some apps are restricted to locations. Example "com.skype.m2".
                 * For restricted apps, check if it is possible to get their specific app info.
                 *
                 * Issue: https://gitlab.e.foundation/e/backlog/-/issues/5174
                 */
                if (app.restriction != Constants.Restriction.NOT_RESTRICTED) {
                    try {
                        gPlayAPIRepository.getAppDetails(app.packageName, authData)
                            ?.transformToFusedApp() ?: FusedApp()
                    } catch (e: Exception) {
                        FusedApp()
                    }
                } else {
                    app.transformToFusedApp()
                }
            }
        }
        response.forEach {
            if (it.package_name.isNotBlank()) {
                it.updateStatus()
                it.updateType()
                list.add(it)
            }
        }
        return list
    }