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

Commit c4b300ae authored by Matheo Levallois's avatar Matheo Levallois
Browse files

Merge branch '3350-apps-outside-the-child-age-group-are-not-toggled-off' into 'main'

fix: deactivation of applications that do not have content rating

See merge request !690
parents e11bb56e 8eebe03f
Loading
Loading
Loading
Loading
Loading
+8 −6
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,10 +78,8 @@ class ValidateAppAgeLimitUseCase @Inject constructor(
                data = ContentRatingValidity(true)
            )

            hasNoContentRatingOnGPlay(app) -> ResultSupreme.Error()

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

            else -> validateAgeLimit(ageGroup, app)
@@ -158,9 +157,12 @@ class ValidateAppAgeLimitUseCase @Inject constructor(

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

            } catch (exception: InternalException.AppNotFound) {
                Timber.w(exception, "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) {
+1 −1
Original line number Diff line number Diff line
@@ -135,7 +135,7 @@ class ValidateAppAgeLimitUseCaseTest {
            )
        )

        assertThat(result).isInstanceOf(ResultSupreme.Error::class.java)
        assertThat(result).isInstanceOf(ResultSupreme.Success::class.java)
    }

    private fun appInstall(