1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.permissioncontroller.permission.ui.model.grantPermissions
18 
19 import com.android.permissioncontroller.permission.model.livedatatypes.LightAppPermGroup
20 import com.android.permissioncontroller.permission.ui.model.DenyButton
21 import com.android.permissioncontroller.permission.ui.model.Prompt
22 
23 /** A basic group. Shows "allow" and "deny", does not allow fixed permissions to be re-requested */
24 object BasicGrantBehavior : GrantBehavior() {
25 
getPromptnull26     override fun getPrompt(
27         group: LightAppPermGroup,
28         requestedPerms: Set<String>,
29         isSystemTriggeredPrompt: Boolean
30     ): Prompt {
31         return Prompt.BASIC
32     }
33 
getDenyButtonnull34     override fun getDenyButton(
35         group: LightAppPermGroup,
36         requestedPerms: Set<String>,
37         prompt: Prompt
38     ): DenyButton {
39         if (prompt in noDenyButtonPrompts) {
40             return DenyButton.NONE
41         }
42         if (group.isUserSet) {
43             return DenyButton.DENY_DONT_ASK_AGAIN
44         }
45         return DenyButton.DENY
46     }
47 
48     // A list of prompts without any deny behavior
49     private val noDenyButtonPrompts =
50         listOf(
51             Prompt.NO_UI_SETTINGS_REDIRECT,
52             Prompt.NO_UI_PHOTO_PICKER_REDIRECT,
53             Prompt.NO_UI_HEALTH_REDIRECT,
54             Prompt.NO_UI_REJECT_THIS_GROUP,
55             Prompt.NO_UI_REJECT_ALL_GROUPS,
56             Prompt.NO_UI_FILTER_THIS_GROUP
57         )
58 }
59