Add one-time flag to permission if group is currently one-time

There is currently an issue where apps can get permission-B granted
permanently if the user has granted permission-A in same the group as
one-time. The app can then further use that permanent grant on
permission-B to get the permission-A permanently granted without user
interaction.

This change marks permission-B as one-time if permission-A in
the group is currently granted as one-time; this will cause the
permission to be revoked with the other permission.

An alternative would be to prompt the user for permission-B, but this
isn't consistent since 1. Permission prompts are presented as groups, so
it will look like repeated UI 2. Might be considered a behavior change.

Test: Manual
Bug: 237405974
Change-Id: I421d28a491ff5506d0bbd1118ea915e8a6753903
Merged-In: I421d28a491ff5506d0bbd1118ea915e8a6753903
(cherry picked from commit d72688263a1924f859689b789732b608ef1d35f8)
Merged-In: I421d28a491ff5506d0bbd1118ea915e8a6753903
(cherry picked from commit 2ea35d7b208c381005cb4772faea5b5f068edd77)
diff --git a/PermissionController/src/com/android/permissioncontroller/permission/ui/model/GrantPermissionsViewModel.kt b/PermissionController/src/com/android/permissioncontroller/permission/ui/model/GrantPermissionsViewModel.kt
index 23cce17..93f0f74 100644
--- a/PermissionController/src/com/android/permissioncontroller/permission/ui/model/GrantPermissionsViewModel.kt
+++ b/PermissionController/src/com/android/permissioncontroller/permission/ui/model/GrantPermissionsViewModel.kt
@@ -674,7 +674,7 @@
                 if (isBackground) {
                     KotlinUtils.grantBackgroundRuntimePermissions(app, group, listOf(perm))
                 } else {
-                    KotlinUtils.grantForegroundRuntimePermissions(app, group, listOf(perm))
+                    KotlinUtils.grantForegroundRuntimePermissions(app, group, listOf(perm), group.isOneTime)
                 }
                 KotlinUtils.setGroupFlags(app, group, FLAG_PERMISSION_USER_SET to false,
                     FLAG_PERMISSION_USER_FIXED to false, filterPermissions = listOf(perm))