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 import com.android.permissioncontroller.permission.utils.Utils 23 24 /** Health permissions always redirect to the health connect UI. */ 25 object HealthGrantBehavior : GrantBehavior() { getPromptnull26 override fun getPrompt( 27 group: LightAppPermGroup, 28 requestedPerms: Set<String>, 29 isSystemTriggeredPrompt: Boolean 30 ): Prompt { 31 return if (Utils.isHealthPermissionUiEnabled()) { 32 Prompt.NO_UI_HEALTH_REDIRECT 33 } else { 34 Prompt.NO_UI_REJECT_THIS_GROUP 35 } 36 } 37 getDenyButtonnull38 override fun getDenyButton( 39 group: LightAppPermGroup, 40 requestedPerms: Set<String>, 41 prompt: Prompt 42 ): DenyButton { 43 return DenyButton.NONE 44 } 45 isGroupFullyGrantednull46 override fun isGroupFullyGranted( 47 group: LightAppPermGroup, 48 requestedPerms: Set<String> 49 ): Boolean { 50 return requestedPerms.all { group.permissions[it]?.isGrantedIncludingAppOp != false } 51 } 52 isPermissionFixednull53 override fun isPermissionFixed(group: LightAppPermGroup, perm: String): Boolean { 54 return group.permissions[perm]?.isUserFixed == true 55 } 56 } 57