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.ui.model
18 
19 import android.content.Intent
20 import android.content.pm.ResolveInfo
21 import android.os.UserHandle
22 import com.android.intentresolver.ext.isHomeIntent
23 import com.android.intentresolver.shared.model.Profile
24 
25 /** All of the things that are consumed from an incoming Intent Resolution request (+Extras). */
26 data class ResolverRequest(
27     /** The intent to be resolved to a target. */
28     val intent: Intent,
29 
30     /**
31      * Supplied by the system to indicate which profile should be selected by default. This is
32      * required since ResolverActivity may be launched as either the originating OR target user when
33      * resolving a cross profile intent.
34      *
35      * Valid values are: [PERSONAL][Profile.Type.PERSONAL] and [WORK][Profile.Type.WORK] and null
36      * when the intent is not a forwarded cross-profile intent.
37      */
38     val selectedProfile: Profile.Type?,
39 
40     /**
41      * When handing a cross profile forwarded intent, this is the user which started the original
42      * intent. This is required to allow ResolverActivity to be launched as the target user under
43      * some conditions.
44      */
45     val callingUser: UserHandle?,
46 
47     /**
48      * Indicates if resolving actions for a connected device which has audio capture capability
49      * (e.g. is a USB Microphone).
50      *
51      * When used to handle a connected device, ResolverActivity uses this signal to present a
52      * warning when a resolved application does not hold the RECORD_AUDIO permission. (If selected
53      * the app would be able to capture audio directly via the device, bypassing audio API
54      * permissions.)
55      */
56     val isAudioCaptureDevice: Boolean = false,
57 
58     /** A list of a resolved activity targets. This list overrides normal intent resolution. */
59     val resolutionList: List<ResolveInfo>? = null,
60 
61     /** A customized title for the resolver interface. */
62     val title: String? = null,
63 ) {
64     val isResolvingHome = intent.isHomeIntent()
65 
66     /** For compatibility with existing code shared between chooser/resolver. */
67     val payloadIntents: List<Intent> = listOf(intent)
68 }
69