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

Commit 20f36f34 authored by Matheo Levallois's avatar Matheo Levallois
Browse files

fix: deactivation of applications that do not have content rating

parent e11bb56e
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
package foundation.e.apps.domain

import com.aurora.gplayapi.data.models.ContentRating
import com.aurora.gplayapi.exceptions.InternalException
import foundation.e.apps.contract.ParentalControlContract.Age
import foundation.e.apps.data.ResultSupreme
import foundation.e.apps.data.application.apps.AppsApi
@@ -77,7 +78,9 @@ class ValidateAppAgeLimitUseCase @Inject constructor(
                data = ContentRatingValidity(true)
            )

            hasNoContentRatingOnGPlay(app) -> ResultSupreme.Error()
            hasNoContentRatingOnGPlay(app) -> ResultSupreme.Success(
                data = ContentRatingValidity(false, requestPin = true)
            )

            isParentalGuidance(app) -> ResultSupreme.Success(
                data = ContentRatingValidity(false, requestPin = true)
@@ -158,9 +161,14 @@ class ValidateAppAgeLimitUseCase @Inject constructor(

    private suspend fun verifyContentRatingExists(app: AppInstall): Boolean {
        if (app.contentRating.id.isEmpty()) {
            val fetchedContentRating =
            var fetchedContentRating : ContentRating? = null
            try {
                fetchedContentRating =
                    gPlayContentRatingRepository.getEnglishContentRating(app.packageName)

            } catch(exception: InternalException.AppNotFound){
                Timber.d("Error fetching age ratings for the package : ${app.packageName}" )
                return false
            }
            Timber.d("Fetched content rating - ${app.packageName} - ${fetchedContentRating?.id}")

            app.contentRating = if (fetchedContentRating == null) {