Loading src/com/android/permissioncontroller/permission/model/livedatatypes/LightAppPermGroup.kt +45 −53 Original line number Diff line number Diff line Loading @@ -60,81 +60,73 @@ data class LightAppPermGroup( if (!backgroundPermNames.contains(it.key)) it.key else null } val foreground = AppPermSubGroup(permissions.filter { it.key in foregroundPermNames }, specialLocationGrant) val background = AppPermSubGroup(permissions.filter { it.key in backgroundPermNames }, specialLocationGrant) /** * Whether or not this App Permission Group has a permission which has a background mode */ val hasPermWithBackground = backgroundPermNames.isNotEmpty() val hasPermWithBackgroundMode = backgroundPermNames.isNotEmpty() /** * Whether or not this App Permission Group requests a background permission */ val hasBackgroundPerms = backgroundPermNames.any { permissions.contains(it) } val hasBackgroundGroup = backgroundPermNames.any { permissions.contains(it) } /** * Whether any of this App Permission Group's foreground permissions are fixed by policy * Whether this App Permission Group's background and foreground permissions are fixed by policy */ val isForegroundPolicyFixed = permissions.any { !backgroundPermNames.contains(it.key) && it.value.isPolicyFixed } val isPolicyFullyFixed = foreground.isPolicyFixed && (!hasBackgroundGroup || background.isPolicyFixed) /** * Whether any of this App Permission Group's background permissions are fixed by policy * Whether or not this group supports runtime permissions */ val isBackgroundPolicyFixed = permissions.any { backgroundPermNames.contains(it.key) && it.value.isPolicyFixed } val supportsRuntimePerms = packageInfo.targetSdkVersion >= Build.VERSION_CODES.M /** * Whether this App Permission Group's background and foreground permissions are fixed by policy * Whether this App Permission Group contains any one-time permission */ val isPolicyFullyFixed = isForegroundPolicyFixed && (!hasBackgroundPerms || isBackgroundPolicyFixed) val isOneTime = permissions.any { it.value.isOneTime } /** * Whether this App Permission Group's foreground permissions are fixed by the system * Whether this App Permission Subgroup's permissions are fixed by the user */ val isForegroundSystemFixed = permissions.any { !backgroundPermNames.contains(it.key) && it.value.isSystemFixed } val isUserFixed = permissions.any { it.value.isUserFixed } /** * Whether this App Permission Group's background permissions are fixed by the system * A subset of the AppPermssionGroup, representing either the background or foreground permissions * of the full group. * * @param permissions The permissions contained within this subgroup, a subset of those contained * in the full group * @param specialLocationGrant Whether this is a special location package */ val isBackgroundSystemFixed = permissions.any { backgroundPermNames.contains(it.key) && it.value.isSystemFixed } data class AppPermSubGroup internal constructor( private val permissions: Map<String, LightPermission>, private val specialLocationGrant: Boolean? ) { /** * Whether any of this App Permission Group's foreground permissions are granted * Whether any of this App Permission Group's foreground permissions are fixed by policy */ val isForegroundGranted = specialLocationGrant ?: permissions.any { !backgroundPermNames.contains(it.key) && it.value.isGrantedIncludingAppOp } val isPolicyFixed = permissions.any { it.value.isPolicyFixed } /** * Whether any of this App Permission Group's background permissions are granted * Whether this App Permission Group's permissions are fixed by the system */ val isBackgroundGranted = specialLocationGrant ?: permissions.any { backgroundPermNames.contains(it.key) && it.value.isGrantedIncludingAppOp } val isForegroundGrantedByDefault = permissions.any { !backgroundPermNames.contains(it.key) && it.value.isGrantedByDefault } val isBackgroundGrantedByDefault = permissions.any { backgroundPermNames.contains(it.key) && it.value.isGrantedByDefault } val supportsRuntimePerms = packageInfo.targetSdkVersion >= Build.VERSION_CODES.M val isSystemFixed = permissions.any { it.value.isSystemFixed } /** * Whether this App Permission Group's permissions are fixed by the user * Whether any of this App Permission SubGroup's permissions are granted */ val isUserFixed = permissions.any { it.value.isUserFixed } val isGranted = specialLocationGrant ?: permissions.any { it.value.isGrantedIncludingAppOp } /** * Whether this App Permission Group contains any one-time permission * Whether any of this App Permission SubGroup's permissions are granted by default */ val isOneTime = permissions.any { it.value.isOneTime } val isGrantedByDefault = permissions.any { it.value.isGrantedByDefault } } } No newline at end of file src/com/android/permissioncontroller/permission/ui/handheld/AppPermissionViewModel.kt +40 −40 Original line number Diff line number Diff line Loading @@ -164,26 +164,26 @@ class AppPermissionViewModel( askOneTimeState.isChecked = group.isOneTime if (group.hasPermWithBackground) { if (group.hasPermWithBackgroundMode) { // Background / Foreground / Deny case allowedForegroundState.isShown = true if (group.hasBackgroundPerms) { if (group.hasBackgroundGroup) { allowedAlwaysState.isShown = true } allowedAlwaysState.isChecked = group.isBackgroundGranted && group.isForegroundGranted allowedForegroundState.isChecked = group.isForegroundGranted && !group.isBackgroundGranted && !group.isOneTime askState.isChecked = !group.isForegroundGranted && !group.isUserFixed deniedState.isChecked = !group.isForegroundGranted && group.isUserFixed allowedAlwaysState.isChecked = group.background.isGranted && group.foreground.isGranted allowedForegroundState.isChecked = group.foreground.isGranted && !group.background.isGranted && !group.isOneTime askState.isChecked = !group.foreground.isGranted && !group.isUserFixed deniedState.isChecked = !group.foreground.isGranted && group.isUserFixed if (applyFixToForegroundBackground(group, group.isForegroundSystemFixed, group.isBackgroundSystemFixed, allowedAlwaysState, if (applyFixToForegroundBackground(group, group.foreground.isSystemFixed, group.background.isSystemFixed, allowedAlwaysState, allowedForegroundState, askState, deniedState, deniedForegroundState) || applyFixToForegroundBackground(group, group.isForegroundPolicyFixed, group.isBackgroundPolicyFixed, allowedAlwaysState, applyFixToForegroundBackground(group, group.foreground.isPolicyFixed, group.background.isPolicyFixed, allowedAlwaysState, allowedForegroundState, askState, deniedState, deniedForegroundState)) { showAdminSupportLiveData.value = admin Loading @@ -200,11 +200,11 @@ class AppPermissionViewModel( // Allow / Deny case allowedState.isShown = true allowedState.isChecked = group.isForegroundGranted askState.isChecked = !group.isForegroundGranted && !group.isUserFixed deniedState.isChecked = !group.isForegroundGranted && group.isUserFixed allowedState.isChecked = group.foreground.isGranted askState.isChecked = !group.foreground.isGranted && !group.isUserFixed deniedState.isChecked = !group.foreground.isGranted && group.isUserFixed if (group.isForegroundPolicyFixed || group.isForegroundSystemFixed) { if (group.foreground.isPolicyFixed || group.foreground.isSystemFixed) { allowedState.isEnabled = false askState.isEnabled = false deniedState.isEnabled = false Loading Loading @@ -259,7 +259,7 @@ class AppPermissionViewModel( deniedState.isChecked = true } } else if (isBackgroundFixed && !isForegroundFixed) { if (group.isBackgroundGranted) { if (group.background.isGranted) { // Background policy fixed as granted, foreground flexible. Granting // foreground implies background comes with it in this case. // Only allow user to grant background or deny (which only toggles fg) Loading @@ -278,7 +278,7 @@ class AppPermissionViewModel( allowedAlwaysState.isEnabled = false } } else if (!isBackgroundFixed && isForegroundFixed) { if (group.isForegroundGranted) { if (group.foreground.isGranted) { // Foreground is fixed as granted, background flexible. // Allow switching between foreground and background. No denying askState.isEnabled = false Loading Loading @@ -356,8 +356,8 @@ class AppPermissionViewModel( ) { val context = fragment.context ?: return val group = lightAppPermGroup ?: return val wasForegroundGranted = group.isForegroundGranted val wasBackgroundGranted = group.isBackgroundGranted val wasForegroundGranted = group.foreground.isGranted val wasBackgroundGranted = group.background.isGranted if (LocationUtils.isLocationGroupAndProvider(context, permGroupName, packageName)) { val packageLabel = KotlinUtils.getPackageLabel(app, packageName, user) Loading @@ -376,7 +376,7 @@ class AppPermissionViewModel( SafetyNetLogger.logPermissionToggled(newGroup) } } if (shouldChangeBackground && group.hasBackgroundPerms) { if (shouldChangeBackground && group.hasBackgroundGroup) { val newGroup = KotlinUtils.grantBackgroundRuntimePermissions(app, group) if (!wasBackgroundGranted) { Loading @@ -389,20 +389,20 @@ class AppPermissionViewModel( var showGrantedByDefaultWarning = false if (shouldChangeForeground && wasForegroundGranted) { showDefaultDenyDialog = (group.isForegroundGrantedByDefault || showDefaultDenyDialog = (group.foreground.isGrantedByDefault || !group.supportsRuntimePerms || group.hasInstallToRuntimeSplit) showGrantedByDefaultWarning = showGrantedByDefaultWarning || group.isForegroundGrantedByDefault group.foreground.isGrantedByDefault } if (shouldChangeBackground && wasBackgroundGranted) { showDefaultDenyDialog = showDefaultDenyDialog || group.isBackgroundGrantedByDefault || group.background.isGrantedByDefault || !group.supportsRuntimePerms || group.hasInstallToRuntimeSplit showGrantedByDefaultWarning = showGrantedByDefaultWarning || group.isBackgroundGrantedByDefault group.background.isGrantedByDefault } if (showDefaultDenyDialog && !hasConfirmedRevoke && showGrantedByDefaultWarning) { Loading @@ -425,7 +425,7 @@ class AppPermissionViewModel( SafetyNetLogger.logPermissionToggled(newGroup) } } if (shouldChangeBackground && group.hasBackgroundPerms && if (shouldChangeBackground && group.hasBackgroundGroup && (wasBackgroundGranted || userFixed != group.isUserFixed)) { val newGroup = KotlinUtils.revokeBackgroundRuntimePermissions(app, group, userFixed) Loading @@ -452,8 +452,8 @@ class AppPermissionViewModel( */ fun onDenyAnyWay(changeTarget: ChangeTarget, userFixed: Boolean) { val group = lightAppPermGroup ?: return val wasForegroundGranted = group.isForegroundGranted val wasBackgroundGranted = group.isBackgroundGranted val wasForegroundGranted = group.foreground.isGranted val wasBackgroundGranted = group.background.isGranted var hasDefaultPermissions = false val stateBefore = createPermissionSnapshot() Loading @@ -462,16 +462,16 @@ class AppPermissionViewModel( if (wasForegroundGranted) { SafetyNetLogger.logPermissionToggled(newGroup) } hasDefaultPermissions = group.isForegroundGrantedByDefault hasDefaultPermissions = group.foreground.isGrantedByDefault } if (changeTarget andValue ChangeTarget.CHANGE_BACKGROUND != 0 && group.hasBackgroundPerms) { if (changeTarget andValue ChangeTarget.CHANGE_BACKGROUND != 0 && group.hasBackgroundGroup) { val newGroup = KotlinUtils.revokeBackgroundRuntimePermissions(app, group, userFixed) if (wasBackgroundGranted) { SafetyNetLogger.logPermissionToggled(newGroup) } hasDefaultPermissions = hasDefaultPermissions || group.isBackgroundGrantedByDefault group.background.isGrantedByDefault } logPermissionChanges(stateBefore!!) Loading Loading @@ -517,10 +517,10 @@ class AppPermissionViewModel( group: LightAppPermGroup, hasAdmin: Boolean ): Int { val isForegroundPolicyDenied = group.isForegroundPolicyFixed && !group.isForegroundGranted val isForegroundPolicyDenied = group.foreground.isPolicyFixed && !group.foreground.isGranted val isPolicyFullyFixedWithGrantedOrNoBkg = group.isPolicyFullyFixed && (group.isBackgroundGranted || !group.hasBackgroundPerms) if (group.isForegroundSystemFixed || group.isBackgroundSystemFixed) { (group.background.isGranted || !group.hasBackgroundGroup) if (group.foreground.isSystemFixed || group.background.isSystemFixed) { return R.string.permission_summary_enabled_system_fixed } else if (hasAdmin) { // Permission is fully controlled by policy and cannot be switched Loading @@ -533,11 +533,11 @@ class AppPermissionViewModel( } // Part of the permission group can still be switched if (group.isBackgroundPolicyFixed && group.isBackgroundGranted) { if (group.background.isPolicyFixed && group.background.isGranted) { return R.string.permission_summary_enabled_by_admin_background_only } else if (group.isBackgroundPolicyFixed) { } else if (group.background.isPolicyFixed) { return R.string.permission_summary_disabled_by_admin_background_only } else if (group.isForegroundPolicyFixed) { } else if (group.foreground.isPolicyFixed) { return R.string.permission_summary_enabled_by_admin_foreground_only } } else { Loading @@ -551,11 +551,11 @@ class AppPermissionViewModel( } // Part of the permission group can still be switched if (group.isBackgroundPolicyFixed && group.isBackgroundGranted) { if (group.background.isPolicyFixed && group.background.isGranted) { return R.string.permission_summary_enabled_by_policy_background_only } else if (group.isBackgroundPolicyFixed) { } else if (group.background.isPolicyFixed) { return R.string.permission_summary_disabled_by_policy_background_only } else if (group.isForegroundPolicyFixed) { } else if (group.foreground.isPolicyFixed) { return R.string.permission_summary_enabled_by_policy_foreground_only } } Loading Loading
src/com/android/permissioncontroller/permission/model/livedatatypes/LightAppPermGroup.kt +45 −53 Original line number Diff line number Diff line Loading @@ -60,81 +60,73 @@ data class LightAppPermGroup( if (!backgroundPermNames.contains(it.key)) it.key else null } val foreground = AppPermSubGroup(permissions.filter { it.key in foregroundPermNames }, specialLocationGrant) val background = AppPermSubGroup(permissions.filter { it.key in backgroundPermNames }, specialLocationGrant) /** * Whether or not this App Permission Group has a permission which has a background mode */ val hasPermWithBackground = backgroundPermNames.isNotEmpty() val hasPermWithBackgroundMode = backgroundPermNames.isNotEmpty() /** * Whether or not this App Permission Group requests a background permission */ val hasBackgroundPerms = backgroundPermNames.any { permissions.contains(it) } val hasBackgroundGroup = backgroundPermNames.any { permissions.contains(it) } /** * Whether any of this App Permission Group's foreground permissions are fixed by policy * Whether this App Permission Group's background and foreground permissions are fixed by policy */ val isForegroundPolicyFixed = permissions.any { !backgroundPermNames.contains(it.key) && it.value.isPolicyFixed } val isPolicyFullyFixed = foreground.isPolicyFixed && (!hasBackgroundGroup || background.isPolicyFixed) /** * Whether any of this App Permission Group's background permissions are fixed by policy * Whether or not this group supports runtime permissions */ val isBackgroundPolicyFixed = permissions.any { backgroundPermNames.contains(it.key) && it.value.isPolicyFixed } val supportsRuntimePerms = packageInfo.targetSdkVersion >= Build.VERSION_CODES.M /** * Whether this App Permission Group's background and foreground permissions are fixed by policy * Whether this App Permission Group contains any one-time permission */ val isPolicyFullyFixed = isForegroundPolicyFixed && (!hasBackgroundPerms || isBackgroundPolicyFixed) val isOneTime = permissions.any { it.value.isOneTime } /** * Whether this App Permission Group's foreground permissions are fixed by the system * Whether this App Permission Subgroup's permissions are fixed by the user */ val isForegroundSystemFixed = permissions.any { !backgroundPermNames.contains(it.key) && it.value.isSystemFixed } val isUserFixed = permissions.any { it.value.isUserFixed } /** * Whether this App Permission Group's background permissions are fixed by the system * A subset of the AppPermssionGroup, representing either the background or foreground permissions * of the full group. * * @param permissions The permissions contained within this subgroup, a subset of those contained * in the full group * @param specialLocationGrant Whether this is a special location package */ val isBackgroundSystemFixed = permissions.any { backgroundPermNames.contains(it.key) && it.value.isSystemFixed } data class AppPermSubGroup internal constructor( private val permissions: Map<String, LightPermission>, private val specialLocationGrant: Boolean? ) { /** * Whether any of this App Permission Group's foreground permissions are granted * Whether any of this App Permission Group's foreground permissions are fixed by policy */ val isForegroundGranted = specialLocationGrant ?: permissions.any { !backgroundPermNames.contains(it.key) && it.value.isGrantedIncludingAppOp } val isPolicyFixed = permissions.any { it.value.isPolicyFixed } /** * Whether any of this App Permission Group's background permissions are granted * Whether this App Permission Group's permissions are fixed by the system */ val isBackgroundGranted = specialLocationGrant ?: permissions.any { backgroundPermNames.contains(it.key) && it.value.isGrantedIncludingAppOp } val isForegroundGrantedByDefault = permissions.any { !backgroundPermNames.contains(it.key) && it.value.isGrantedByDefault } val isBackgroundGrantedByDefault = permissions.any { backgroundPermNames.contains(it.key) && it.value.isGrantedByDefault } val supportsRuntimePerms = packageInfo.targetSdkVersion >= Build.VERSION_CODES.M val isSystemFixed = permissions.any { it.value.isSystemFixed } /** * Whether this App Permission Group's permissions are fixed by the user * Whether any of this App Permission SubGroup's permissions are granted */ val isUserFixed = permissions.any { it.value.isUserFixed } val isGranted = specialLocationGrant ?: permissions.any { it.value.isGrantedIncludingAppOp } /** * Whether this App Permission Group contains any one-time permission * Whether any of this App Permission SubGroup's permissions are granted by default */ val isOneTime = permissions.any { it.value.isOneTime } val isGrantedByDefault = permissions.any { it.value.isGrantedByDefault } } } No newline at end of file
src/com/android/permissioncontroller/permission/ui/handheld/AppPermissionViewModel.kt +40 −40 Original line number Diff line number Diff line Loading @@ -164,26 +164,26 @@ class AppPermissionViewModel( askOneTimeState.isChecked = group.isOneTime if (group.hasPermWithBackground) { if (group.hasPermWithBackgroundMode) { // Background / Foreground / Deny case allowedForegroundState.isShown = true if (group.hasBackgroundPerms) { if (group.hasBackgroundGroup) { allowedAlwaysState.isShown = true } allowedAlwaysState.isChecked = group.isBackgroundGranted && group.isForegroundGranted allowedForegroundState.isChecked = group.isForegroundGranted && !group.isBackgroundGranted && !group.isOneTime askState.isChecked = !group.isForegroundGranted && !group.isUserFixed deniedState.isChecked = !group.isForegroundGranted && group.isUserFixed allowedAlwaysState.isChecked = group.background.isGranted && group.foreground.isGranted allowedForegroundState.isChecked = group.foreground.isGranted && !group.background.isGranted && !group.isOneTime askState.isChecked = !group.foreground.isGranted && !group.isUserFixed deniedState.isChecked = !group.foreground.isGranted && group.isUserFixed if (applyFixToForegroundBackground(group, group.isForegroundSystemFixed, group.isBackgroundSystemFixed, allowedAlwaysState, if (applyFixToForegroundBackground(group, group.foreground.isSystemFixed, group.background.isSystemFixed, allowedAlwaysState, allowedForegroundState, askState, deniedState, deniedForegroundState) || applyFixToForegroundBackground(group, group.isForegroundPolicyFixed, group.isBackgroundPolicyFixed, allowedAlwaysState, applyFixToForegroundBackground(group, group.foreground.isPolicyFixed, group.background.isPolicyFixed, allowedAlwaysState, allowedForegroundState, askState, deniedState, deniedForegroundState)) { showAdminSupportLiveData.value = admin Loading @@ -200,11 +200,11 @@ class AppPermissionViewModel( // Allow / Deny case allowedState.isShown = true allowedState.isChecked = group.isForegroundGranted askState.isChecked = !group.isForegroundGranted && !group.isUserFixed deniedState.isChecked = !group.isForegroundGranted && group.isUserFixed allowedState.isChecked = group.foreground.isGranted askState.isChecked = !group.foreground.isGranted && !group.isUserFixed deniedState.isChecked = !group.foreground.isGranted && group.isUserFixed if (group.isForegroundPolicyFixed || group.isForegroundSystemFixed) { if (group.foreground.isPolicyFixed || group.foreground.isSystemFixed) { allowedState.isEnabled = false askState.isEnabled = false deniedState.isEnabled = false Loading Loading @@ -259,7 +259,7 @@ class AppPermissionViewModel( deniedState.isChecked = true } } else if (isBackgroundFixed && !isForegroundFixed) { if (group.isBackgroundGranted) { if (group.background.isGranted) { // Background policy fixed as granted, foreground flexible. Granting // foreground implies background comes with it in this case. // Only allow user to grant background or deny (which only toggles fg) Loading @@ -278,7 +278,7 @@ class AppPermissionViewModel( allowedAlwaysState.isEnabled = false } } else if (!isBackgroundFixed && isForegroundFixed) { if (group.isForegroundGranted) { if (group.foreground.isGranted) { // Foreground is fixed as granted, background flexible. // Allow switching between foreground and background. No denying askState.isEnabled = false Loading Loading @@ -356,8 +356,8 @@ class AppPermissionViewModel( ) { val context = fragment.context ?: return val group = lightAppPermGroup ?: return val wasForegroundGranted = group.isForegroundGranted val wasBackgroundGranted = group.isBackgroundGranted val wasForegroundGranted = group.foreground.isGranted val wasBackgroundGranted = group.background.isGranted if (LocationUtils.isLocationGroupAndProvider(context, permGroupName, packageName)) { val packageLabel = KotlinUtils.getPackageLabel(app, packageName, user) Loading @@ -376,7 +376,7 @@ class AppPermissionViewModel( SafetyNetLogger.logPermissionToggled(newGroup) } } if (shouldChangeBackground && group.hasBackgroundPerms) { if (shouldChangeBackground && group.hasBackgroundGroup) { val newGroup = KotlinUtils.grantBackgroundRuntimePermissions(app, group) if (!wasBackgroundGranted) { Loading @@ -389,20 +389,20 @@ class AppPermissionViewModel( var showGrantedByDefaultWarning = false if (shouldChangeForeground && wasForegroundGranted) { showDefaultDenyDialog = (group.isForegroundGrantedByDefault || showDefaultDenyDialog = (group.foreground.isGrantedByDefault || !group.supportsRuntimePerms || group.hasInstallToRuntimeSplit) showGrantedByDefaultWarning = showGrantedByDefaultWarning || group.isForegroundGrantedByDefault group.foreground.isGrantedByDefault } if (shouldChangeBackground && wasBackgroundGranted) { showDefaultDenyDialog = showDefaultDenyDialog || group.isBackgroundGrantedByDefault || group.background.isGrantedByDefault || !group.supportsRuntimePerms || group.hasInstallToRuntimeSplit showGrantedByDefaultWarning = showGrantedByDefaultWarning || group.isBackgroundGrantedByDefault group.background.isGrantedByDefault } if (showDefaultDenyDialog && !hasConfirmedRevoke && showGrantedByDefaultWarning) { Loading @@ -425,7 +425,7 @@ class AppPermissionViewModel( SafetyNetLogger.logPermissionToggled(newGroup) } } if (shouldChangeBackground && group.hasBackgroundPerms && if (shouldChangeBackground && group.hasBackgroundGroup && (wasBackgroundGranted || userFixed != group.isUserFixed)) { val newGroup = KotlinUtils.revokeBackgroundRuntimePermissions(app, group, userFixed) Loading @@ -452,8 +452,8 @@ class AppPermissionViewModel( */ fun onDenyAnyWay(changeTarget: ChangeTarget, userFixed: Boolean) { val group = lightAppPermGroup ?: return val wasForegroundGranted = group.isForegroundGranted val wasBackgroundGranted = group.isBackgroundGranted val wasForegroundGranted = group.foreground.isGranted val wasBackgroundGranted = group.background.isGranted var hasDefaultPermissions = false val stateBefore = createPermissionSnapshot() Loading @@ -462,16 +462,16 @@ class AppPermissionViewModel( if (wasForegroundGranted) { SafetyNetLogger.logPermissionToggled(newGroup) } hasDefaultPermissions = group.isForegroundGrantedByDefault hasDefaultPermissions = group.foreground.isGrantedByDefault } if (changeTarget andValue ChangeTarget.CHANGE_BACKGROUND != 0 && group.hasBackgroundPerms) { if (changeTarget andValue ChangeTarget.CHANGE_BACKGROUND != 0 && group.hasBackgroundGroup) { val newGroup = KotlinUtils.revokeBackgroundRuntimePermissions(app, group, userFixed) if (wasBackgroundGranted) { SafetyNetLogger.logPermissionToggled(newGroup) } hasDefaultPermissions = hasDefaultPermissions || group.isBackgroundGrantedByDefault group.background.isGrantedByDefault } logPermissionChanges(stateBefore!!) Loading Loading @@ -517,10 +517,10 @@ class AppPermissionViewModel( group: LightAppPermGroup, hasAdmin: Boolean ): Int { val isForegroundPolicyDenied = group.isForegroundPolicyFixed && !group.isForegroundGranted val isForegroundPolicyDenied = group.foreground.isPolicyFixed && !group.foreground.isGranted val isPolicyFullyFixedWithGrantedOrNoBkg = group.isPolicyFullyFixed && (group.isBackgroundGranted || !group.hasBackgroundPerms) if (group.isForegroundSystemFixed || group.isBackgroundSystemFixed) { (group.background.isGranted || !group.hasBackgroundGroup) if (group.foreground.isSystemFixed || group.background.isSystemFixed) { return R.string.permission_summary_enabled_system_fixed } else if (hasAdmin) { // Permission is fully controlled by policy and cannot be switched Loading @@ -533,11 +533,11 @@ class AppPermissionViewModel( } // Part of the permission group can still be switched if (group.isBackgroundPolicyFixed && group.isBackgroundGranted) { if (group.background.isPolicyFixed && group.background.isGranted) { return R.string.permission_summary_enabled_by_admin_background_only } else if (group.isBackgroundPolicyFixed) { } else if (group.background.isPolicyFixed) { return R.string.permission_summary_disabled_by_admin_background_only } else if (group.isForegroundPolicyFixed) { } else if (group.foreground.isPolicyFixed) { return R.string.permission_summary_enabled_by_admin_foreground_only } } else { Loading @@ -551,11 +551,11 @@ class AppPermissionViewModel( } // Part of the permission group can still be switched if (group.isBackgroundPolicyFixed && group.isBackgroundGranted) { if (group.background.isPolicyFixed && group.background.isGranted) { return R.string.permission_summary_enabled_by_policy_background_only } else if (group.isBackgroundPolicyFixed) { } else if (group.background.isPolicyFixed) { return R.string.permission_summary_disabled_by_policy_background_only } else if (group.isForegroundPolicyFixed) { } else if (group.foreground.isPolicyFixed) { return R.string.permission_summary_enabled_by_policy_foreground_only } } Loading