From 726a89e9422166e77ceded5849ea9d89e663300d Mon Sep 17 00:00:00 2001 From: Mark Renouf Date: Fri, 16 Feb 2024 09:37:11 -0500 Subject: Moves Profile to shared/model for use with some existing View components. It's more of an identifying token than a UI model and is used in logic not for drawing UI. Bug: 300157408 Test: atest IntentResolver-tests-unit Change-Id: I13cf3a7f15beb985f91647a65731950092236f04 --- .../intentresolver/v2/ResolverActivity.java | 2 +- .../v2/domain/interactor/UserInteractor.kt | 4 +- .../intentresolver/v2/domain/model/Profile.kt | 53 ---------------------- .../intentresolver/v2/shared/model/Profile.kt | 52 +++++++++++++++++++++ .../intentresolver/v2/ui/ProfilePagerResources.kt | 2 +- .../intentresolver/v2/ui/model/ResolverRequest.kt | 2 +- .../v2/ui/viewmodel/ResolverRequestReader.kt | 2 +- 7 files changed, 58 insertions(+), 59 deletions(-) delete mode 100644 java/src/com/android/intentresolver/v2/domain/model/Profile.kt create mode 100644 java/src/com/android/intentresolver/v2/shared/model/Profile.kt (limited to 'java/src') diff --git a/java/src/com/android/intentresolver/v2/ResolverActivity.java b/java/src/com/android/intentresolver/v2/ResolverActivity.java index 2d26932f..241b6735 100644 --- a/java/src/com/android/intentresolver/v2/ResolverActivity.java +++ b/java/src/com/android/intentresolver/v2/ResolverActivity.java @@ -101,7 +101,7 @@ import com.android.intentresolver.icons.DefaultTargetDataLoader; import com.android.intentresolver.icons.TargetDataLoader; import com.android.intentresolver.model.ResolverRankerServiceResolverComparator; import com.android.intentresolver.v2.data.repository.DevicePolicyResources; -import com.android.intentresolver.v2.domain.model.Profile; +import com.android.intentresolver.v2.shared.model.Profile; import com.android.intentresolver.v2.emptystate.NoAppsAvailableEmptyStateProvider; import com.android.intentresolver.v2.emptystate.NoCrossProfileEmptyStateProvider; import com.android.intentresolver.v2.emptystate.NoCrossProfileEmptyStateProvider.DevicePolicyBlockerEmptyState; diff --git a/java/src/com/android/intentresolver/v2/domain/interactor/UserInteractor.kt b/java/src/com/android/intentresolver/v2/domain/interactor/UserInteractor.kt index f12d8197..c8df9684 100644 --- a/java/src/com/android/intentresolver/v2/domain/interactor/UserInteractor.kt +++ b/java/src/com/android/intentresolver/v2/domain/interactor/UserInteractor.kt @@ -19,8 +19,8 @@ package com.android.intentresolver.v2.domain.interactor import android.os.UserHandle import com.android.intentresolver.inject.ApplicationUser import com.android.intentresolver.v2.data.repository.UserRepository -import com.android.intentresolver.v2.domain.model.Profile -import com.android.intentresolver.v2.domain.model.Profile.Type +import com.android.intentresolver.v2.shared.model.Profile +import com.android.intentresolver.v2.shared.model.Profile.Type import com.android.intentresolver.v2.shared.model.User import com.android.intentresolver.v2.shared.model.User.Role import javax.inject.Inject diff --git a/java/src/com/android/intentresolver/v2/domain/model/Profile.kt b/java/src/com/android/intentresolver/v2/domain/model/Profile.kt deleted file mode 100644 index 46015c7a..00000000 --- a/java/src/com/android/intentresolver/v2/domain/model/Profile.kt +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.intentresolver.v2.domain.model - -import com.android.intentresolver.v2.domain.model.Profile.Type -import com.android.intentresolver.v2.shared.model.User - -/** - * A domain layer model which associates [users][User] into a [Type] instance. - * - * This is a simple abstraction which combines a primary [user][User] with an optional - * [cloned apps][User.Role.CLONE] user. This encapsulates the cloned app user id, while still being - * available where needed. - */ -data class Profile( - val type: Type, - val primary: User, - /** - * An optional [User] of which contains second instances of some applications installed for the - * personal user. This value may only be supplied when creating the PERSONAL profile. - */ - val clone: User? = null -) { - - init { - clone?.apply { - require(primary.role == User.Role.PERSONAL) { - "clone is not supported for profile=${this@Profile.type} / primary=$primary" - } - require(role == User.Role.CLONE) { "clone is not a clone user ($this)" } - } - } - - enum class Type { - PERSONAL, - WORK, - PRIVATE - } -} diff --git a/java/src/com/android/intentresolver/v2/shared/model/Profile.kt b/java/src/com/android/intentresolver/v2/shared/model/Profile.kt new file mode 100644 index 00000000..6e37174c --- /dev/null +++ b/java/src/com/android/intentresolver/v2/shared/model/Profile.kt @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.intentresolver.v2.shared.model + +import com.android.intentresolver.v2.shared.model.Profile.Type + +/** + * Associates [users][User] into a [Type] instance. + * + * This is a simple abstraction which combines a primary [user][User] with an optional + * [cloned apps][User.Role.CLONE] user. This encapsulates the cloned app user id, while still being + * available where needed. + */ +data class Profile( + val type: Type, + val primary: User, + /** + * An optional [User] of which contains second instances of some applications installed for the + * personal user. This value may only be supplied when creating the PERSONAL profile. + */ + val clone: User? = null +) { + + init { + clone?.apply { + require(primary.role == User.Role.PERSONAL) { + "clone is not supported for profile=${this@Profile.type} / primary=$primary" + } + require(role == User.Role.CLONE) { "clone is not a clone user ($this)" } + } + } + + enum class Type { + PERSONAL, + WORK, + PRIVATE + } +} diff --git a/java/src/com/android/intentresolver/v2/ui/ProfilePagerResources.kt b/java/src/com/android/intentresolver/v2/ui/ProfilePagerResources.kt index 0d31b23e..1cd72ba5 100644 --- a/java/src/com/android/intentresolver/v2/ui/ProfilePagerResources.kt +++ b/java/src/com/android/intentresolver/v2/ui/ProfilePagerResources.kt @@ -19,7 +19,7 @@ package com.android.intentresolver.v2.ui import android.content.res.Resources import com.android.intentresolver.inject.ApplicationOwned import com.android.intentresolver.v2.data.repository.DevicePolicyResources -import com.android.intentresolver.v2.domain.model.Profile +import com.android.intentresolver.v2.shared.model.Profile import javax.inject.Inject import com.android.intentresolver.R diff --git a/java/src/com/android/intentresolver/v2/ui/model/ResolverRequest.kt b/java/src/com/android/intentresolver/v2/ui/model/ResolverRequest.kt index 5abfb602..a4f74ca9 100644 --- a/java/src/com/android/intentresolver/v2/ui/model/ResolverRequest.kt +++ b/java/src/com/android/intentresolver/v2/ui/model/ResolverRequest.kt @@ -19,7 +19,7 @@ package com.android.intentresolver.v2.ui.model import android.content.Intent import android.content.pm.ResolveInfo import android.os.UserHandle -import com.android.intentresolver.v2.domain.model.Profile +import com.android.intentresolver.v2.shared.model.Profile import com.android.intentresolver.v2.ext.isHomeIntent /** All of the things that are consumed from an incoming Intent Resolution request (+Extras). */ diff --git a/java/src/com/android/intentresolver/v2/ui/viewmodel/ResolverRequestReader.kt b/java/src/com/android/intentresolver/v2/ui/viewmodel/ResolverRequestReader.kt index fc9f1e01..22d76493 100644 --- a/java/src/com/android/intentresolver/v2/ui/viewmodel/ResolverRequestReader.kt +++ b/java/src/com/android/intentresolver/v2/ui/viewmodel/ResolverRequestReader.kt @@ -20,7 +20,7 @@ import android.os.Bundle import android.os.UserHandle import com.android.intentresolver.v2.ResolverActivity.PROFILE_PERSONAL import com.android.intentresolver.v2.ResolverActivity.PROFILE_WORK -import com.android.intentresolver.v2.domain.model.Profile +import com.android.intentresolver.v2.shared.model.Profile import com.android.intentresolver.v2.ui.model.ActivityLaunch import com.android.intentresolver.v2.ui.model.ResolverRequest import com.android.intentresolver.v2.validation.Validation -- cgit v1.2.3-59-g8ed1b