1 /*
2  * Copyright (C) 2019 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 androidx.core.role;
18 
19 /**
20  * This class contains the name and documentation for roles that might be available in the system.
21  * <p>
22  * The list of available roles might change with a system app update, so apps should not make
23  * assumption about the availability of roles. Instead, they should always check if the role is
24  * available using {@link android.app.role.RoleManager#isRoleAvailable(String)} before trying to do
25  * anything with it.
26  *
27  * @see android.app.role.RoleManager
28  */
29 public final class RoleManagerCompat {
30 
31     /**
32      * The name of the assistant role.
33      * <p>
34      * To qualify for this role, an application needs to either implement
35      * {@link android.service.voice.VoiceInteractionService} or handle
36      * {@link android.content.Intent#ACTION_ASSIST}. The application will be able to access call log
37      * and SMS for its functionality.
38      *
39      * @see android.service.voice.VoiceInteractionService
40      * @see android.content.Intent#ACTION_ASSIST
41      */
42     public static final String ROLE_ASSISTANT = "android.app.role.ASSISTANT";
43 
44     /**
45      * The name of the browser role.
46      * <p>
47      * To qualify for this role, an application needs to handle the intent to browse the Internet:
48      * <pre class="prettyprint">{@code
49      * <activity>
50      *     <intent-filter>
51      *         <action android:name="android.intent.action.VIEW" />
52      *         <category android:name="android.intent.category.BROWSABLE" />
53      *         <category android:name="android.intent.category.DEFAULT" />
54      *         <data android:scheme="http" />
55      *     </intent-filter>
56      * </activity>
57      * }</pre>
58      * The application will be able to handle that intent by default.
59      * <p>
60      * Apps that hold this role are allowed to start activities in response to notification clicks
61      * or notification action clicks when targeting {@link android.os.Build.VERSION_CODES#S} to give
62      * browsers time to adapt. This is temporary and browsers will be subjected to the same
63      * trampoline restrictions at some point in future releases. For more details on those
64      * restrictions see {@link android.app.Notification.Builder#setContentIntent(PendingIntent)} and
65      * {@link android.app.Notification.Action.Builder#Builder(android.graphics.drawable.Icon,
66      * java.lang.CharSequence, android.app.PendingIntent)}.
67      *
68      * @see android.content.Intent#CATEGORY_APP_BROWSER
69      */
70     public static final String ROLE_BROWSER = "android.app.role.BROWSER";
71 
72     /**
73      * The name of the dialer role.
74      * <p>
75      * To qualify for this role, an application needs to handle the intent to dial, and implement
76      * an {@link android.telecom.InCallService} if the application targets
77      * {@link android.os.Build.VERSION_CODES.TIRAMISU} or higher:
78      * <pre class="prettyprint">{@code
79      * <activity>
80      *     <intent-filter>
81      *         <action android:name="android.intent.action.DIAL" />
82      *         <category android:name="android.intent.category.DEFAULT"/>
83      *     </intent-filter>
84      *     <intent-filter>
85      *         <action android:name="android.intent.action.DIAL" />
86      *         <category android:name="android.intent.category.DEFAULT"/>
87      *         <data android:scheme="tel" />
88      *     </intent-filter>
89      * </activity>
90      * <service android:permission="android.permission.BIND_INCALL_SERVICE">
91      *     <meta-data android:name="android.telecom.IN_CALL_SERVICE_UI" android:value="true" />
92      *     <meta-data
93      *         android:name="android.telecom.IN_CALL_SERVICE_CAR_MODE_UI"
94      *         android:value="false" />
95      *     <intent-filter>
96      *         <action android:name="android.telecom.InCallService" />
97      *     </intent-filter>
98      * </service>
99      *
100      * }</pre>
101      * The application will be able to handle those intents by default, and gain access to phone,
102      * contacts, SMS, microphone and camera.
103      *
104      * @see android.content.Intent#ACTION_DIAL
105      */
106     public static final String ROLE_DIALER = "android.app.role.DIALER";
107 
108     /**
109      * The name of the SMS role.
110      * <p>
111      * To qualify for this role, an application needs to declare the following components:
112      * <pre class="prettyprint">{@code
113      * <activity>
114      *     <intent-filter>
115      *         <action android:name="android.intent.action.SENDTO" />
116      *         <category android:name="android.intent.category.DEFAULT" />
117      *         <data android:scheme="smsto" />
118      *     </intent-filter>
119      * </activity>
120      * <service android:permission="android.permission.SEND_RESPOND_VIA_MESSAGE">
121      *     <intent-filter>
122      *         <action android:name="android.intent.action.RESPOND_VIA_MESSAGE" />
123      *         <category android:name="android.intent.category.DEFAULT" />
124      *         <data android:scheme="smsto" />
125      *     </intent-filter>
126      * </service>
127      * <receiver android:permission="android.permission.BROADCAST_SMS">
128      *     <intent-filter>
129      *         <action android:name="android.provider.Telephony.SMS_DELIVER" />
130      *     </intent-filter>
131      * </receiver>
132      * <receiver android:permission="android.permission.BROADCAST_WAP_PUSH">
133      *     <intent-filter>
134      *         <action android:name="android.provider.Telephony.WAP_PUSH_DELIVER" />
135      *         <data android:mimeType="application/vnd.wap.mms-message" />
136      *     </intent-filter>
137      * </receiver>
138      * }</pre>
139      * The application will be able to handle the intent to send SMS by default, and gain access to
140      * phone, contacts, SMS, storage, microphone and camera.
141      *
142      * @see android.content.Intent#CATEGORY_APP_MESSAGING
143      */
144     public static final String ROLE_SMS = "android.app.role.SMS";
145 
146     /**
147      * The name of the emergency role.
148      * <p>
149      * You may not be able to request for this role on most devices as it's hidden by default and
150      * only for system apps.
151      * <p>
152      * To qualify for this role, an application needs to handle the intent for emergency assitance:
153      * <pre class="prettyprint">{@code
154      * <activity>
155      *     <intent-filter>
156      *         <action android:name="android.telephony.action.EMERGENCY_ASSISTANCE" />
157      *         <category android:name="android.intent.category.DEFAULT" />
158      *     </intent-filter>
159      * </activity>
160      * }</pre>
161      * The application will be used for emergency assistance.
162      */
163     public static final String ROLE_EMERGENCY = "android.app.role.EMERGENCY";
164 
165     /**
166      * The name of the home role.
167      * <p>
168      * To qualify for this role, an application needs to handle the intent for home:
169      * <pre class="prettyprint">{@code
170      * <activity>
171      *     <intent-filter>
172      *         <action android:name="android.intent.action.MAIN" />
173      *         <category android:name="android.intent.category.DEFAULT" />
174      *         <category android:name="android.intent.category.HOME" />
175      *     </intent-filter>
176      * </activity>
177      * }</pre>
178      * The application will be able to handle that intent by default, and used as the default home
179      * app.
180      *
181      * @see android.content.Intent#CATEGORY_HOME
182      */
183     public static final String ROLE_HOME = "android.app.role.HOME";
184 
185     /**
186      * The name of the call redirection role.
187      * <p>
188      * To qualify for this role, an application needs to implement
189      * {@link android.telecom.CallRedirectionService}. The application will be able to re-write the
190      * phone number for an outgoing call to place the call through a call redirection service.
191      *
192      * @see android.telecom.CallRedirectionService
193      */
194     public static final String ROLE_CALL_REDIRECTION = "android.app.role.CALL_REDIRECTION";
195 
196     /**
197      * The name of the call screening and caller id role.
198      * <p>
199      * To qualify for this role, an application needs to implement
200      * {@link android.telecom.CallScreeningService}. The application will be able to screen calls
201      * and provide call identification. The application will also be able to display over other apps
202      * on Android 11 or above.
203      *
204      * @see android.telecom.CallScreeningService
205      */
206     public static final String ROLE_CALL_SCREENING = "android.app.role.CALL_SCREENING";
207 
208     /**
209      * The name of the system gallery role.
210      * <p>
211      * You can not request for this role because it's hidden and only for system apps. It's meant to
212      * be granted out-of-the-box to a gallery app that shipped with the device.
213      * <p>
214      * The application will gain full read and write access to all image and video files on external
215      * storage, including access to location metadata.
216      *
217      * @see android.provider.MediaStore.Images
218      * @see android.provider.MediaStore.Video
219      * @see android.Manifest.permission#ACCESS_MEDIA_LOCATION
220      */
221     public static final String ROLE_SYSTEM_GALLERY = "android.app.role.SYSTEM_GALLERY";
222 
RoleManagerCompat()223     private RoleManagerCompat() {}
224 }
225