diff --git a/app/src/main/java/foundation/e/apps/data/parentalcontrol/ParentalControlRepository.kt b/app/src/main/java/foundation/e/apps/data/parentalcontrol/ParentalControlRepository.kt index 21dfc69e1fc34dfb91be1ef8d2dd51f0285b3e68..02f5e49c46d98376a993376612fe6f2e764a9dbc 100644 --- a/app/src/main/java/foundation/e/apps/data/parentalcontrol/ParentalControlRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/parentalcontrol/ParentalControlRepository.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 MURENA SAS + * Copyright (C) 2025 MURENA SAS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,10 +19,11 @@ package foundation.e.apps.data.parentalcontrol import android.content.Context +import androidx.core.net.toUri import dagger.hilt.android.qualifiers.ApplicationContext +import org.e.parentalcontrol.data.model.TypeAppManagement import javax.inject.Inject import javax.inject.Singleton -import androidx.core.net.toUri @Singleton class ParentalControlRepository @Inject constructor( @@ -51,18 +52,18 @@ class ParentalControlRepository @Inject constructor( return Age.PARENTAL_CONTROL_DISABLED } - fun getSelectedProtectionMode(): ProtectionMode { + fun getSelectedTypeAppManagement(): TypeAppManagement { val uri = URI_PARENTAL_CONTROL_INSTALL_TYPE_APP_MANAGEMENT.toUri() val cursor = context.contentResolver.query(uri, null, null, null, null) cursor?.use { if (it.moveToFirst()) { val protectionMode = it.getInt(it.getColumnIndexOrThrow("protectionmode")) - return ProtectionMode.entries[protectionMode] + return TypeAppManagement.entries[protectionMode] } } - return ProtectionMode.DISABLED_MODE + return TypeAppManagement.DISABLED_MODE } } @@ -74,9 +75,3 @@ enum class Age { SEVENTEEN, PARENTAL_CONTROL_DISABLED } - -enum class ProtectionMode { - REGULAR_MODE, - REQUEST_PIN_MODE, - DISABLED_MODE -} diff --git a/app/src/main/java/foundation/e/apps/domain/ValidateAppAgeLimitUseCase.kt b/app/src/main/java/foundation/e/apps/domain/ValidateAppAgeLimitUseCase.kt index e51d4198bb70abca4d91cf05f01550ffe07fff89..17ded119608f812c9009f2ccf7a29479b75cff06 100644 --- a/app/src/main/java/foundation/e/apps/domain/ValidateAppAgeLimitUseCase.kt +++ b/app/src/main/java/foundation/e/apps/domain/ValidateAppAgeLimitUseCase.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 MURENA SAS + * Copyright (C) 2025 MURENA SAS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,11 +29,11 @@ import foundation.e.apps.data.parentalcontrol.Age import foundation.e.apps.data.parentalcontrol.ContentRatingDao import foundation.e.apps.data.parentalcontrol.ParentalControlRepository import foundation.e.apps.data.parentalcontrol.ParentalControlRepository.Companion.KEY_PARENTAL_GUIDANCE -import foundation.e.apps.data.parentalcontrol.ProtectionMode import foundation.e.apps.data.parentalcontrol.fdroid.FDroidAntiFeatureRepository import foundation.e.apps.data.parentalcontrol.googleplay.GPlayContentRatingGroup import foundation.e.apps.data.parentalcontrol.googleplay.GPlayContentRatingRepository import foundation.e.apps.domain.model.ContentRatingValidity +import org.e.parentalcontrol.data.model.TypeAppManagement import timber.log.Timber import javax.inject.Inject @@ -53,8 +53,8 @@ class ValidateAppAgeLimitUseCase @Inject constructor( private val ageGroup: Age get() = parentalControlRepository.getSelectedAgeGroup() - private val protectionMode: ProtectionMode - get() = parentalControlRepository.getSelectedProtectionMode() + private val typeAppManagement: TypeAppManagement + get() = parentalControlRepository.getSelectedTypeAppManagement() suspend operator fun invoke(app: AppInstall): ResultSupreme { @@ -123,7 +123,7 @@ class ValidateAppAgeLimitUseCase @Inject constructor( ageGroup: Age, app: AppInstall ): ResultSupreme { - if (protectionMode == ProtectionMode.REGULAR_MODE) { + if (typeAppManagement == TypeAppManagement.CONTENT_RATING) { val allowedContentRating = gPlayContentRatingRepository.contentRatingGroups.find { it.id == ageGroup.toString() } @@ -181,7 +181,7 @@ class ValidateAppAgeLimitUseCase @Inject constructor( } private suspend fun isParentalGuidance(app: AppInstall): Boolean { - if (protectionMode == ProtectionMode.REGULAR_MODE) { + if (typeAppManagement == TypeAppManagement.CONTENT_RATING) { val fetchedContentRating = gPlayContentRatingRepository.getEnglishContentRating(app.packageName) return fetchedContentRating?.id == KEY_PARENTAL_GUIDANCE diff --git a/parental-control-data/README.md b/parental-control-data/README.md new file mode 100644 index 0000000000000000000000000000000000000000..5a08135e7150fdac6194ea7c2159f5f4aab02127 --- /dev/null +++ b/parental-control-data/README.md @@ -0,0 +1,18 @@ +# App Lounge library + +This document describes the library used for sharing information between applications: +- AppLounge +- ParentalControl + +# Versions + +## 1.0.0 + +Initial version : ParentalControlContract + +## 1.1.0 + +TypeAppManagement: +- CONTENT_RATING Legacy mode validation based on age +- SECURITY_CODE Security code request by the Parental Controls application +- DISABLED_MODE No restriction \ No newline at end of file diff --git a/parental-control-data/build.gradle b/parental-control-data/build.gradle index 2b15ab8e7914fd024e2d88bc2b57bb401722ffba..a4c8651069572788805f31335b668dfa2006e575 100644 --- a/parental-control-data/build.gradle +++ b/parental-control-data/build.gradle @@ -14,7 +14,7 @@ publishing { jar(MavenPublication) { groupId = 'foundation.e.apps' artifactId = 'ParentalControlData' - version = '1.0.0' + version = '1.1.0' artifact("$buildDir/libs/${project.name}.jar") diff --git a/parental-control-data/src/main/java/org/e/parentalcontrol/data/model/TypeAppManagement.kt b/parental-control-data/src/main/java/org/e/parentalcontrol/data/model/TypeAppManagement.kt new file mode 100644 index 0000000000000000000000000000000000000000..269078a60127755f4f59c4415c20cf38c8bbd9b2 --- /dev/null +++ b/parental-control-data/src/main/java/org/e/parentalcontrol/data/model/TypeAppManagement.kt @@ -0,0 +1,25 @@ +/* + * Copyright MURENA SAS 2025 + * Apps Quickly and easily install Android apps onto your device! + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +package org.e.parentalcontrol.data.model + +enum class TypeAppManagement { + CONTENT_RATING, // Legacy mode validation based on age + SECURITY_CODE, // Security code request by the Parental Controls application + DISABLED_MODE // No restriction +} \ No newline at end of file