1 /* 2 * Copyright (C) 2020 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.model.livedatatypes 18 19 import android.permission.PermissionControllerManager.HIBERNATION_ELIGIBILITY_ELIGIBLE 20 import android.permission.PermissionControllerManager.HIBERNATION_ELIGIBILITY_EXEMPT_BY_SYSTEM 21 22 /** 23 * Tracks the setting state of hibernation and auto revoke for a package 24 * 25 * @param hibernationEligibility state saying whether the package is eligible for hibernation. See 26 * [HIBERNATION_ELIGIBILITY_ELIGIBLE]. 27 * @param revocableGroupNames A list of which permission groups of this package are eligible for 28 * auto-revoke. A permission group is auto-revocable if it does not contain a default granted 29 * permission. 30 */ 31 data class HibernationSettingState( 32 val hibernationEligibility: Int, 33 val revocableGroupNames: List<String> 34 ) { 35 /** Whether package will hibernate if it is unused. */ isEligibleForHibernationnull36 fun isEligibleForHibernation(): Boolean { 37 return hibernationEligibility == HIBERNATION_ELIGIBILITY_ELIGIBLE 38 } 39 40 /** 41 * Whether the package is exempt from hibernation by the system. This means the app can never be 42 * hibernated, and the user setting to exempt it is disabled. 43 */ isExemptBySystemnull44 fun isExemptBySystem(): Boolean { 45 return hibernationEligibility == HIBERNATION_ELIGIBILITY_EXEMPT_BY_SYSTEM 46 } 47 } 48