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

Commit 9eed431f authored by Nate Myren's avatar Nate Myren Committed by Android (Google) Code Review
Browse files

Merge "Granted, ECM restricted settings should not be labeled as restricted" into main

parents d501cec0 e49a1452
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import kotlinx.coroutines.flow.flowOn
data class EnhancedConfirmation(
    val key: String,
    val packageName: String,
    val isRestrictedSettingAllowed: Boolean?
)
data class Restrictions(
    val userId: Int = UserHandle.myUserId(),
@@ -92,6 +93,9 @@ internal class RestrictionsProviderImpl(
        }

        restrictions.enhancedConfirmation?.let { ec ->
            if (ec.isRestrictedSettingAllowed == true) {
                return NoRestricted
            }
            RestrictedLockUtilsInternal
                    .checkIfRequiresEnhancedConfirmation(context, ec.key,
                        ec.packageName)
+1 −1
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ internal fun <T : AppRecord> TogglePermissionAppListModel<T>.TogglePermissionApp
        }
        RestrictedSwitchPreference(
            model = switchModel,
            restrictions = getRestrictions(userId, packageName),
            restrictions = getRestrictions(userId, packageName, isAllowed()),
            ifBlockedByAdminOverrideCheckedValueTo = switchifBlockedByAdminOverrideCheckedValueTo,
            restrictionsProviderFactory = restrictionsProviderFactory,
        )
+4 −1
Original line number Diff line number Diff line
@@ -116,12 +116,15 @@ fun <T : AppRecord> TogglePermissionAppListModel<T>.isChangeableWithSystemUidChe
fun <T : AppRecord> TogglePermissionAppListModel<T>.getRestrictions(
    userId: Int,
    packageName: String,
    isRestrictedSettingAllowed: Boolean?
) =
    Restrictions(
        userId = userId,
        keys = switchRestrictionKeys,
        enhancedConfirmation =
            enhancedConfirmationKey?.let { key -> EnhancedConfirmation(key, packageName) },
            enhancedConfirmationKey?.let {
                key -> EnhancedConfirmation(key, packageName, isRestrictedSettingAllowed)
                                         },
    )

interface TogglePermissionAppListProvider {
+2 −1
Original line number Diff line number Diff line
@@ -149,13 +149,14 @@ internal class TogglePermissionInternalAppListModel<T : AppRecord>(

    @Composable
    fun getSummary(record: T): () -> String {
        val allowed = listModel.isAllowed(record)
        val restrictions =
            listModel.getRestrictions(
                userId = record.app.userId,
                packageName = record.app.packageName,
                allowed()
            )
        val restrictedMode by restrictionsProviderFactory.rememberRestrictedMode(restrictions)
        val allowed = listModel.isAllowed(record)
        return RestrictedSwitchPreferenceModel.getSummary(
            context = context,
            summaryIfNoRestricted = { getSummaryIfNoRestricted(allowed()) },