1 /* 2 * Copyright (C) 2024 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.intentresolver.shared.model 18 19 import com.android.intentresolver.shared.model.Profile.Type 20 21 /** 22 * Associates [users][User] into a [Type] instance. 23 * 24 * This is a simple abstraction which combines a primary [user][User] with an optional 25 * [cloned apps][User.Role.CLONE] user. This encapsulates the cloned app user id, while still being 26 * available where needed. 27 */ 28 data class Profile( 29 val type: Type, 30 val primary: User, 31 /** 32 * An optional [User] of which contains second instances of some applications installed for the 33 * personal user. This value may only be supplied when creating the PERSONAL profile. 34 */ 35 val clone: User? = null 36 ) { 37 38 init { <lambda>null39 clone?.apply { 40 require(primary.role == User.Role.PERSONAL) { 41 "clone is not supported for profile=${this@Profile.type} / primary=$primary" 42 } 43 require(role == User.Role.CLONE) { "clone is not a clone user ($this)" } 44 } 45 } 46 47 enum class Type { 48 PERSONAL, 49 WORK, 50 PRIVATE 51 } 52 } 53