• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006 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 android.content;
18 
19 import static android.content.ContentProvider.maybeAddUserId;
20 import static android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE;
21 import static android.security.Flags.FLAG_FRP_ENFORCEMENT;
22 import static android.security.Flags.FLAG_PREVENT_INTENT_REDIRECT;
23 import static android.security.Flags.preventIntentRedirect;
24 
25 import android.Manifest;
26 import android.accessibilityservice.AccessibilityService;
27 import android.annotation.AnyRes;
28 import android.annotation.BroadcastBehavior;
29 import android.annotation.FlaggedApi;
30 import android.annotation.IntDef;
31 import android.annotation.NonNull;
32 import android.annotation.Nullable;
33 import android.annotation.RequiresPermission;
34 import android.annotation.SdkConstant;
35 import android.annotation.SdkConstant.SdkConstantType;
36 import android.annotation.SuppressLint;
37 import android.annotation.SystemApi;
38 import android.annotation.TestApi;
39 import android.app.Activity;
40 import android.app.ActivityThread;
41 import android.app.AppGlobals;
42 import android.app.StatusBarManager;
43 import android.bluetooth.BluetoothDevice;
44 import android.compat.annotation.UnsupportedAppUsage;
45 import android.content.pm.ActivityInfo;
46 import android.content.pm.ApplicationInfo;
47 import android.content.pm.ComponentInfo;
48 import android.content.pm.PackageManager;
49 import android.content.pm.ResolveInfo;
50 import android.content.pm.ShortcutInfo;
51 import android.content.pm.SuspendDialogInfo;
52 import android.content.pm.verify.domain.DomainVerificationManager;
53 import android.content.res.Resources;
54 import android.content.res.TypedArray;
55 import android.graphics.Rect;
56 import android.net.Uri;
57 import android.os.BadParcelableException;
58 import android.os.Build;
59 import android.os.Bundle;
60 import android.os.BundleMerger;
61 import android.os.CancellationSignal;
62 import android.os.IBinder;
63 import android.os.IncidentManager;
64 import android.os.Parcel;
65 import android.os.Parcelable;
66 import android.os.PersistableBundle;
67 import android.os.Process;
68 import android.os.ResultReceiver;
69 import android.os.ShellCommand;
70 import android.os.StrictMode;
71 import android.os.SystemClock;
72 import android.os.UserHandle;
73 import android.os.storage.StorageManager;
74 import android.provider.ContactsContract.QuickContact;
75 import android.provider.DocumentsContract;
76 import android.provider.DocumentsProvider;
77 import android.provider.MediaStore;
78 import android.provider.OpenableColumns;
79 import android.service.chooser.AdditionalContentContract;
80 import android.service.chooser.ChooserAction;
81 import android.service.chooser.ChooserResult;
82 import android.telecom.PhoneAccount;
83 import android.telecom.TelecomManager;
84 import android.text.TextUtils;
85 import android.util.ArraySet;
86 import android.util.AttributeSet;
87 import android.util.Log;
88 import android.util.proto.ProtoOutputStream;
89 
90 import com.android.internal.util.XmlUtils;
91 import com.android.modules.expresslog.Counter;
92 
93 import org.xmlpull.v1.XmlPullParser;
94 import org.xmlpull.v1.XmlPullParserException;
95 import org.xmlpull.v1.XmlSerializer;
96 
97 import java.io.File;
98 import java.io.IOException;
99 import java.io.PrintWriter;
100 import java.io.Serializable;
101 import java.lang.annotation.Retention;
102 import java.lang.annotation.RetentionPolicy;
103 import java.net.URISyntaxException;
104 import java.util.ArrayList;
105 import java.util.HashSet;
106 import java.util.List;
107 import java.util.Locale;
108 import java.util.Objects;
109 import java.util.Set;
110 import java.util.TimeZone;
111 import java.util.function.Consumer;
112 
113 /**
114  * An intent is an abstract description of an operation to be performed.  It
115  * can be used with {@link Context#startActivity(Intent) startActivity} to
116  * launch an {@link android.app.Activity},
117  * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
118  * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
119  * and {@link android.content.Context#startService} or
120  * {@link android.content.Context#bindService} to communicate with a
121  * background {@link android.app.Service}.
122  *
123  * <p>An Intent provides a facility for performing late runtime binding between the code in
124  * different applications. Its most significant use is in the launching of activities, where it
125  * can be thought of as the glue between activities. It is basically a passive data structure
126  * holding an abstract description of an action to be performed.</p>
127  *
128  * <div class="special reference">
129  * <h3>Developer Guides</h3>
130  * <p>For information about how to create and resolve intents, read the
131  * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
132  * developer guide.</p>
133  * </div>
134  *
135  * <a name="IntentStructure"></a>
136  * <h3>Intent Structure</h3>
137  * <p>The primary pieces of information in an intent are:</p>
138  *
139  * <ul>
140  *   <li> <p><b>action</b> -- The general action to be performed, such as
141  *     {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
142  *     etc.</p>
143  *   </li>
144  *   <li> <p><b>data</b> -- The data to operate on, such as a person record
145  *     in the contacts database, expressed as a {@link android.net.Uri}.</p>
146  *   </li>
147  * </ul>
148  *
149  *
150  * <p>Some examples of action/data pairs are:</p>
151  *
152  * <ul>
153  *   <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
154  *     information about the person whose identifier is "1".</p>
155  *   </li>
156  *   <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
157  *     the phone dialer with the person filled in.</p>
158  *   </li>
159  *   <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
160  *     the phone dialer with the given number filled in.  Note how the
161  *     VIEW action does what is considered the most reasonable thing for
162  *     a particular URI.</p>
163  *   </li>
164  *   <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
165  *     the phone dialer with the given number filled in.</p>
166  *   </li>
167  *   <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
168  *     information about the person whose identifier is "1".</p>
169  *   </li>
170  *   <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
171  *     a list of people, which the user can browse through.  This example is a
172  *     typical top-level entry into the Contacts application, showing you the
173  *     list of people. Selecting a particular person to view would result in a
174  *     new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
175  *     being used to start an activity to display that person.</p>
176  *   </li>
177  * </ul>
178  *
179  * <p>In addition to these primary attributes, there are a number of secondary
180  * attributes that you can also include with an intent:</p>
181  *
182  * <ul>
183  *     <li> <p><b>category</b> -- Gives additional information about the action
184  *         to execute.  For example, {@link #CATEGORY_LAUNCHER} means it should
185  *         appear in the Launcher as a top-level application, while
186  *         {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
187  *         of alternative actions the user can perform on a piece of data.</p>
188  *     <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
189  *         intent data.  Normally the type is inferred from the data itself.
190  *         By setting this attribute, you disable that evaluation and force
191  *         an explicit type.</p>
192  *     <li> <p><b>component</b> -- Specifies an explicit name of a component
193  *         class to use for the intent.  Normally this is determined by looking
194  *         at the other information in the intent (the action, data/type, and
195  *         categories) and matching that with a component that can handle it.
196  *         If this attribute is set then none of the evaluation is performed,
197  *         and this component is used exactly as is.  By specifying this attribute,
198  *         all of the other Intent attributes become optional.</p>
199  *     <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
200  *         This can be used to provide extended information to the component.
201  *         For example, if we have a action to send an e-mail message, we could
202  *         also include extra pieces of data here to supply a subject, body,
203  *         etc.</p>
204  * </ul>
205  *
206  * <p>Here are some examples of other operations you can specify as intents
207  * using these additional parameters:</p>
208  *
209  * <ul>
210  *   <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
211  *     Launch the home screen.</p>
212  *   </li>
213  *   <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
214  *     <i>{@link android.provider.Contacts.Phones#CONTENT_URI
215  *     vnd.android.cursor.item/phone}</i></b>
216  *     -- Display the list of people's phone numbers, allowing the user to
217  *     browse through them and pick one and return it to the parent activity.</p>
218  *   </li>
219  *   <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
220  *     <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
221  *     -- Display all pickers for data that can be opened with
222  *     {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
223  *     allowing the user to pick one of them and then some data inside of it
224  *     and returning the resulting URI to the caller.  This can be used,
225  *     for example, in an e-mail application to allow the user to pick some
226  *     data to include as an attachment.</p>
227  *   </li>
228  * </ul>
229  *
230  * <p>There are a variety of standard Intent action and category constants
231  * defined in the Intent class, but applications can also define their own.
232  * These strings use Java-style scoping, to ensure they are unique -- for
233  * example, the standard {@link #ACTION_VIEW} is called
234  * "android.intent.action.VIEW".</p>
235  *
236  * <p>Put together, the set of actions, data types, categories, and extra data
237  * defines a language for the system allowing for the expression of phrases
238  * such as "call john smith's cell".  As applications are added to the system,
239  * they can extend this language by adding new actions, types, and categories, or
240  * they can modify the behavior of existing phrases by supplying their own
241  * activities that handle them.</p>
242  *
243  * <a name="IntentResolution"></a>
244  * <h3>Intent Resolution</h3>
245  *
246  * <p>There are two primary forms of intents you will use.
247  *
248  * <ul>
249  *     <li> <p><b>Explicit Intents</b> have specified a component (via
250  *     {@link #setComponent} or {@link #setClass}), which provides the exact
251  *     class to be run.  Often these will not include any other information,
252  *     simply being a way for an application to launch various internal
253  *     activities it has as the user interacts with the application.
254  *
255  *     <li> <p><b>Implicit Intents</b> have not specified a component;
256  *     instead, they must include enough information for the system to
257  *     determine which of the available components is best to run for that
258  *     intent.
259  * </ul>
260  *
261  * <p>When using implicit intents, given such an arbitrary intent we need to
262  * know what to do with it. This is handled by the process of <em>Intent
263  * resolution</em>, which maps an Intent to an {@link android.app.Activity},
264  * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
265  * more activities/receivers) that can handle it.</p>
266  *
267  * <p>The intent resolution mechanism basically revolves around matching an
268  * Intent against all of the &lt;intent-filter&gt; descriptions in the
269  * installed application packages.  (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
270  * objects explicitly registered with {@link Context#registerReceiver}.)  More
271  * details on this can be found in the documentation on the {@link
272  * IntentFilter} class.</p>
273  *
274  * <p>There are three pieces of information in the Intent that are used for
275  * resolution: the action, type, and category.  Using this information, a query
276  * is done on the {@link PackageManager} for a component that can handle the
277  * intent. The appropriate component is determined based on the intent
278  * information supplied in the <code>AndroidManifest.xml</code> file as
279  * follows:</p>
280  *
281  * <ul>
282  *     <li> <p>The <b>action</b>, if given, must be listed by the component as
283  *         one it handles.</p>
284  *     <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
285  *         already supplied in the Intent.  Like the action, if a type is
286  *         included in the intent (either explicitly or implicitly in its
287  *         data), then this must be listed by the component as one it handles.</p>
288  *     <li> For data that is not a <code>content:</code> URI and where no explicit
289  *         type is included in the Intent, instead the <b>scheme</b> of the
290  *         intent data (such as <code>http:</code> or <code>mailto:</code>) is
291  *         considered. Again like the action, if we are matching a scheme it
292  *         must be listed by the component as one it can handle.
293  *     <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
294  *         by the activity as categories it handles.  That is, if you include
295  *         the categories {@link #CATEGORY_LAUNCHER} and
296  *         {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
297  *         with an intent that lists <em>both</em> of those categories.
298  *         Activities will very often need to support the
299  *         {@link #CATEGORY_DEFAULT} so that they can be found by
300  *         {@link Context#startActivity Context.startActivity()}.</p>
301  * </ul>
302  *
303  * <p>For example, consider the Note Pad sample application that
304  * allows a user to browse through a list of notes data and view details about
305  * individual items.  Text in italics indicates places where you would replace a
306  * name with one specific to your own package.</p>
307  *
308  * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
309  *       package="<i>com.android.notepad</i>"&gt;
310  *     &lt;application android:icon="@drawable/app_notes"
311  *             android:label="@string/app_name"&gt;
312  *
313  *         &lt;provider class=".NotePadProvider"
314  *                 android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
315  *
316  *         &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
317  *             &lt;intent-filter&gt;
318  *                 &lt;action android:name="android.intent.action.MAIN" /&gt;
319  *                 &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
320  *             &lt;/intent-filter&gt;
321  *             &lt;intent-filter&gt;
322  *                 &lt;action android:name="android.intent.action.VIEW" /&gt;
323  *                 &lt;action android:name="android.intent.action.EDIT" /&gt;
324  *                 &lt;action android:name="android.intent.action.PICK" /&gt;
325  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
326  *                 &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
327  *             &lt;/intent-filter&gt;
328  *             &lt;intent-filter&gt;
329  *                 &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
330  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
331  *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
332  *             &lt;/intent-filter&gt;
333  *         &lt;/activity&gt;
334  *
335  *         &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
336  *             &lt;intent-filter android:label="@string/resolve_edit"&gt;
337  *                 &lt;action android:name="android.intent.action.VIEW" /&gt;
338  *                 &lt;action android:name="android.intent.action.EDIT" /&gt;
339  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
340  *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
341  *             &lt;/intent-filter&gt;
342  *
343  *             &lt;intent-filter&gt;
344  *                 &lt;action android:name="android.intent.action.INSERT" /&gt;
345  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
346  *                 &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
347  *             &lt;/intent-filter&gt;
348  *
349  *         &lt;/activity&gt;
350  *
351  *         &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
352  *                 android:theme="@android:style/Theme.Dialog"&gt;
353  *             &lt;intent-filter android:label="@string/resolve_title"&gt;
354  *                 &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
355  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
356  *                 &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
357  *                 &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
358  *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
359  *             &lt;/intent-filter&gt;
360  *         &lt;/activity&gt;
361  *
362  *     &lt;/application&gt;
363  * &lt;/manifest&gt;</pre>
364  *
365  * <p>The first activity,
366  * <code>com.android.notepad.NotesList</code>, serves as our main
367  * entry into the app.  It can do three things as described by its three intent
368  * templates:
369  * <ol>
370  * <li><pre>
371  * &lt;intent-filter&gt;
372  *     &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
373  *     &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
374  * &lt;/intent-filter&gt;</pre>
375  * <p>This provides a top-level entry into the NotePad application: the standard
376  * MAIN action is a main entry point (not requiring any other information in
377  * the Intent), and the LAUNCHER category says that this entry point should be
378  * listed in the application launcher.</p>
379  * <li><pre>
380  * &lt;intent-filter&gt;
381  *     &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
382  *     &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
383  *     &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
384  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
385  *     &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
386  * &lt;/intent-filter&gt;</pre>
387  * <p>This declares the things that the activity can do on a directory of
388  * notes.  The type being supported is given with the &lt;type&gt; tag, where
389  * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
390  * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
391  * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
392  * The activity allows the user to view or edit the directory of data (via
393  * the VIEW and EDIT actions), or to pick a particular note and return it
394  * to the caller (via the PICK action).  Note also the DEFAULT category
395  * supplied here: this is <em>required</em> for the
396  * {@link Context#startActivity Context.startActivity} method to resolve your
397  * activity when its component name is not explicitly specified.</p>
398  * <li><pre>
399  * &lt;intent-filter&gt;
400  *     &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
401  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
402  *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
403  * &lt;/intent-filter&gt;</pre>
404  * <p>This filter describes the ability to return to the caller a note selected by
405  * the user without needing to know where it came from.  The data type
406  * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
407  * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
408  * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
409  * The GET_CONTENT action is similar to the PICK action, where the activity
410  * will return to its caller a piece of data selected by the user.  Here,
411  * however, the caller specifies the type of data they desire instead of
412  * the type of data the user will be picking from.</p>
413  * </ol>
414  *
415  * <p>Given these capabilities, the following intents will resolve to the
416  * NotesList activity:</p>
417  *
418  * <ul>
419  *     <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
420  *         activities that can be used as top-level entry points into an
421  *         application.</p>
422  *     <li> <p><b>{ action=android.app.action.MAIN,
423  *         category=android.app.category.LAUNCHER }</b> is the actual intent
424  *         used by the Launcher to populate its top-level list.</p>
425  *     <li> <p><b>{ action=android.intent.action.VIEW
426  *          data=content://com.google.provider.NotePad/notes }</b>
427  *         displays a list of all the notes under
428  *         "content://com.google.provider.NotePad/notes", which
429  *         the user can browse through and see the details on.</p>
430  *     <li> <p><b>{ action=android.app.action.PICK
431  *          data=content://com.google.provider.NotePad/notes }</b>
432  *         provides a list of the notes under
433  *         "content://com.google.provider.NotePad/notes", from which
434  *         the user can pick a note whose data URL is returned back to the caller.</p>
435  *     <li> <p><b>{ action=android.app.action.GET_CONTENT
436  *          type=vnd.android.cursor.item/vnd.google.note }</b>
437  *         is similar to the pick action, but allows the caller to specify the
438  *         kind of data they want back so that the system can find the appropriate
439  *         activity to pick something of that data type.</p>
440  * </ul>
441  *
442  * <p>The second activity,
443  * <code>com.android.notepad.NoteEditor</code>, shows the user a single
444  * note entry and allows them to edit it.  It can do two things as described
445  * by its two intent templates:
446  * <ol>
447  * <li><pre>
448  * &lt;intent-filter android:label="@string/resolve_edit"&gt;
449  *     &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
450  *     &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
451  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
452  *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
453  * &lt;/intent-filter&gt;</pre>
454  * <p>The first, primary, purpose of this activity is to let the user interact
455  * with a single note, as decribed by the MIME type
456  * <code>vnd.android.cursor.item/vnd.google.note</code>.  The activity can
457  * either VIEW a note or allow the user to EDIT it.  Again we support the
458  * DEFAULT category to allow the activity to be launched without explicitly
459  * specifying its component.</p>
460  * <li><pre>
461  * &lt;intent-filter&gt;
462  *     &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
463  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
464  *     &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
465  * &lt;/intent-filter&gt;</pre>
466  * <p>The secondary use of this activity is to insert a new note entry into
467  * an existing directory of notes.  This is used when the user creates a new
468  * note: the INSERT action is executed on the directory of notes, causing
469  * this activity to run and have the user create the new note data which
470  * it then adds to the content provider.</p>
471  * </ol>
472  *
473  * <p>Given these capabilities, the following intents will resolve to the
474  * NoteEditor activity:</p>
475  *
476  * <ul>
477  *     <li> <p><b>{ action=android.intent.action.VIEW
478  *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
479  *         shows the user the content of note <var>{ID}</var>.</p>
480  *     <li> <p><b>{ action=android.app.action.EDIT
481  *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
482  *         allows the user to edit the content of note <var>{ID}</var>.</p>
483  *     <li> <p><b>{ action=android.app.action.INSERT
484  *          data=content://com.google.provider.NotePad/notes }</b>
485  *         creates a new, empty note in the notes list at
486  *         "content://com.google.provider.NotePad/notes"
487  *         and allows the user to edit it.  If they keep their changes, the URI
488  *         of the newly created note is returned to the caller.</p>
489  * </ul>
490  *
491  * <p>The last activity,
492  * <code>com.android.notepad.TitleEditor</code>, allows the user to
493  * edit the title of a note.  This could be implemented as a class that the
494  * application directly invokes (by explicitly setting its component in
495  * the Intent), but here we show a way you can publish alternative
496  * operations on existing data:</p>
497  *
498  * <pre>
499  * &lt;intent-filter android:label="@string/resolve_title"&gt;
500  *     &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
501  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
502  *     &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
503  *     &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
504  *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
505  * &lt;/intent-filter&gt;</pre>
506  *
507  * <p>In the single intent template here, we
508  * have created our own private action called
509  * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
510  * edit the title of a note.  It must be invoked on a specific note
511  * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
512  * view and edit actions, but here displays and edits the title contained
513  * in the note data.
514  *
515  * <p>In addition to supporting the default category as usual, our title editor
516  * also supports two other standard categories: ALTERNATIVE and
517  * SELECTED_ALTERNATIVE.  Implementing
518  * these categories allows others to find the special action it provides
519  * without directly knowing about it, through the
520  * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
521  * more often to build dynamic menu items with
522  * {@link android.view.Menu#addIntentOptions}.  Note that in the intent
523  * template here was also supply an explicit name for the template
524  * (via <code>android:label="@string/resolve_title"</code>) to better control
525  * what the user sees when presented with this activity as an alternative
526  * action to the data they are viewing.
527  *
528  * <p>Given these capabilities, the following intent will resolve to the
529  * TitleEditor activity:</p>
530  *
531  * <ul>
532  *     <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
533  *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
534  *         displays and allows the user to edit the title associated
535  *         with note <var>{ID}</var>.</p>
536  * </ul>
537  *
538  * <h3>Standard Activity Actions</h3>
539  *
540  * <p>These are the current standard actions that Intent defines for launching
541  * activities (usually through {@link Context#startActivity}.  The most
542  * important, and by far most frequently used, are {@link #ACTION_MAIN} and
543  * {@link #ACTION_EDIT}.
544  *
545  * <ul>
546  *     <li> {@link #ACTION_MAIN}
547  *     <li> {@link #ACTION_VIEW}
548  *     <li> {@link #ACTION_ATTACH_DATA}
549  *     <li> {@link #ACTION_EDIT}
550  *     <li> {@link #ACTION_PICK}
551  *     <li> {@link #ACTION_CHOOSER}
552  *     <li> {@link #ACTION_GET_CONTENT}
553  *     <li> {@link #ACTION_DIAL}
554  *     <li> {@link #ACTION_CALL}
555  *     <li> {@link #ACTION_SEND}
556  *     <li> {@link #ACTION_SENDTO}
557  *     <li> {@link #ACTION_ANSWER}
558  *     <li> {@link #ACTION_INSERT}
559  *     <li> {@link #ACTION_DELETE}
560  *     <li> {@link #ACTION_RUN}
561  *     <li> {@link #ACTION_SYNC}
562  *     <li> {@link #ACTION_PICK_ACTIVITY}
563  *     <li> {@link #ACTION_SEARCH}
564  *     <li> {@link #ACTION_WEB_SEARCH}
565  *     <li> {@link #ACTION_FACTORY_TEST}
566  * </ul>
567  *
568  * <h3>Standard Broadcast Actions</h3>
569  *
570  * <p>These are the current standard actions that Intent defines for receiving
571  * broadcasts (usually through {@link Context#registerReceiver} or a
572  * &lt;receiver&gt; tag in a manifest).
573  *
574  * <ul>
575  *     <li> {@link #ACTION_TIME_TICK}
576  *     <li> {@link #ACTION_TIME_CHANGED}
577  *     <li> {@link #ACTION_TIMEZONE_CHANGED}
578  *     <li> {@link #ACTION_BOOT_COMPLETED}
579  *     <li> {@link #ACTION_PACKAGE_ADDED}
580  *     <li> {@link #ACTION_PACKAGE_CHANGED}
581  *     <li> {@link #ACTION_PACKAGE_REMOVED}
582  *     <li> {@link #ACTION_PACKAGE_RESTARTED}
583  *     <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
584  *     <li> {@link #ACTION_PACKAGES_SUSPENDED}
585  *     <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
586  *     <li> {@link #ACTION_UID_REMOVED}
587  *     <li> {@link #ACTION_BATTERY_CHANGED}
588  *     <li> {@link #ACTION_POWER_CONNECTED}
589  *     <li> {@link #ACTION_POWER_DISCONNECTED}
590  *     <li> {@link #ACTION_SHUTDOWN}
591  * </ul>
592  *
593  * <p class="note"><strong>Note: </strong>If your app targets Android 11
594  * (API level 30) or higher, registering broadcast such as
595  * {@link #ACTION_PACKAGES_SUSPENDED} that includes package details in the
596  * extras receives a filtered list of apps or nothing. Learn more about how to
597  * <a href="/training/basics/intents/package-visibility">manage package visibility</a>.
598  * </p>
599  *
600  * <h3>Standard Categories</h3>
601  *
602  * <p>These are the current standard categories that can be used to further
603  * clarify an Intent via {@link #addCategory}.
604  *
605  * <ul>
606  *     <li> {@link #CATEGORY_DEFAULT}
607  *     <li> {@link #CATEGORY_BROWSABLE}
608  *     <li> {@link #CATEGORY_TAB}
609  *     <li> {@link #CATEGORY_ALTERNATIVE}
610  *     <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
611  *     <li> {@link #CATEGORY_LAUNCHER}
612  *     <li> {@link #CATEGORY_INFO}
613  *     <li> {@link #CATEGORY_HOME}
614  *     <li> {@link #CATEGORY_PREFERENCE}
615  *     <li> {@link #CATEGORY_TEST}
616  *     <li> {@link #CATEGORY_CAR_DOCK}
617  *     <li> {@link #CATEGORY_DESK_DOCK}
618  *     <li> {@link #CATEGORY_LE_DESK_DOCK}
619  *     <li> {@link #CATEGORY_HE_DESK_DOCK}
620  *     <li> {@link #CATEGORY_CAR_MODE}
621  *     <li> {@link #CATEGORY_APP_MARKET}
622  *     <li> {@link #CATEGORY_VR_HOME}
623  * </ul>
624  *
625  * <h3>Standard Extra Data</h3>
626  *
627  * <p>These are the current standard fields that can be used as extra data via
628  * {@link #putExtra}.
629  *
630  * <ul>
631  *     <li> {@link #EXTRA_ALARM_COUNT}
632  *     <li> {@link #EXTRA_BCC}
633  *     <li> {@link #EXTRA_CC}
634  *     <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
635  *     <li> {@link #EXTRA_DATA_REMOVED}
636  *     <li> {@link #EXTRA_DOCK_STATE}
637  *     <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
638  *     <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
639  *     <li> {@link #EXTRA_DOCK_STATE_CAR}
640  *     <li> {@link #EXTRA_DOCK_STATE_DESK}
641  *     <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
642  *     <li> {@link #EXTRA_DONT_KILL_APP}
643  *     <li> {@link #EXTRA_EMAIL}
644  *     <li> {@link #EXTRA_INITIAL_INTENTS}
645  *     <li> {@link #EXTRA_INTENT}
646  *     <li> {@link #EXTRA_KEY_EVENT}
647  *     <li> {@link #EXTRA_ORIGINATING_URI}
648  *     <li> {@link #EXTRA_PHONE_NUMBER}
649  *     <li> {@link #EXTRA_REFERRER}
650  *     <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
651  *     <li> {@link #EXTRA_REPLACING}
652  *     <li> {@link #EXTRA_SHORTCUT_ICON}
653  *     <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
654  *     <li> {@link #EXTRA_SHORTCUT_INTENT}
655  *     <li> {@link #EXTRA_STREAM}
656  *     <li> {@link #EXTRA_SHORTCUT_NAME}
657  *     <li> {@link #EXTRA_SUBJECT}
658  *     <li> {@link #EXTRA_TEMPLATE}
659  *     <li> {@link #EXTRA_TEXT}
660  *     <li> {@link #EXTRA_TITLE}
661  *     <li> {@link #EXTRA_UID}
662  *     <li> {@link #EXTRA_USER_INITIATED}
663  * </ul>
664  *
665  * <h3>Flags</h3>
666  *
667  * <p>These are the possible flags that can be used in the Intent via
668  * {@link #setFlags} and {@link #addFlags}.  See {@link #setFlags} for a list
669  * of all possible flags.
670  */
671 @android.ravenwood.annotation.RavenwoodKeepWholeClass
672 public class Intent implements Parcelable, Cloneable {
673     private static final String TAG = "Intent";
674     private static final String ATTR_ACTION = "action";
675     private static final String TAG_CATEGORIES = "categories";
676     private static final String ATTR_CATEGORY = "category";
677     private static final String TAG_EXTRA = "extra";
678     private static final String ATTR_TYPE = "type";
679     private static final String ATTR_IDENTIFIER = "ident";
680     private static final String ATTR_COMPONENT = "component";
681     private static final String ATTR_DATA = "data";
682     private static final String ATTR_FLAGS = "flags";
683     private static final String ATTR_PACKAGE = "package";
684 
685     // ---------------------------------------------------------------------
686     // ---------------------------------------------------------------------
687     // Standard intent activity actions (see action variable).
688 
689     /**
690      *  Activity Action: Start as a main entry point, does not expect to
691      *  receive data.
692      *  <p>Input: nothing
693      *  <p>Output: nothing
694      */
695     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
696     public static final String ACTION_MAIN = "android.intent.action.MAIN";
697 
698     /**
699      * Activity Action: Display the data to the user.  This is the most common
700      * action performed on data -- it is the generic action you can use on
701      * a piece of data to get the most reasonable thing to occur.  For example,
702      * when used on a contacts entry it will view the entry; when used on a
703      * mailto: URI it will bring up a compose window filled with the information
704      * supplied by the URI; when used with a tel: URI it will invoke the
705      * dialer.
706      * <p>Input: {@link #getData} is URI from which to retrieve data.
707      * <p>Output: nothing.
708      */
709     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
710     public static final String ACTION_VIEW = "android.intent.action.VIEW";
711 
712     /**
713      * Extra that can be included on activity intents coming from the storage UI
714      * when it launches sub-activities to manage various types of storage.  For example,
715      * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show
716      * the images on the device, and in that case also include this extra to tell the
717      * app it is coming from the storage UI so should help the user manage storage of
718      * this type.
719      */
720     public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE";
721 
722     /**
723      * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
724      * performed on a piece of data.
725      */
726     public static final String ACTION_DEFAULT = ACTION_VIEW;
727 
728     /**
729      * Activity Action: Quick view the data. Launches a quick viewer for
730      * a URI or a list of URIs.
731      * <p>Activities handling this intent action should handle the vast majority of
732      * MIME types rather than only specific ones.
733      * <p>Quick viewers must render the quick view image locally, and must not send
734      * file content outside current device.
735      * <p>Input: {@link #getData} is a mandatory content URI of the item to
736      * preview. {@link #getClipData} contains an optional list of content URIs
737      * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
738      * optional index of the URI in the clip data to show first.
739      * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
740      * that can be shown in the quick view UI.
741      * <p>Output: nothing.
742      * @see #EXTRA_INDEX
743      * @see #EXTRA_QUICK_VIEW_FEATURES
744      */
745     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
746     public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
747 
748     /**
749      * Used to indicate that some piece of data should be attached to some other
750      * place.  For example, image data could be attached to a contact.  It is up
751      * to the recipient to decide where the data should be attached; the intent
752      * does not specify the ultimate destination.
753      * <p>Input: {@link #getData} is URI of data to be attached.
754      * <p>Output: nothing.
755      */
756     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
757     public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
758 
759     /**
760      * Activity Action: Provide explicit editable access to the given data.
761      * <p>Input: {@link #getData} is URI of data to be edited.
762      * <p>Output: nothing.
763      */
764     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
765     public static final String ACTION_EDIT = "android.intent.action.EDIT";
766 
767     /**
768      * Activity Action: Pick an existing item, or insert a new item, and then edit it.
769      * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
770      * The extras can contain type specific data to pass through to the editing/creating
771      * activity.
772      * <p>Output: The URI of the item that was picked.  This must be a content:
773      * URI so that any receiver can access it.
774      */
775     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
776     public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
777 
778     /**
779      * Activity Action: Pick an item from the data, returning what was selected.
780      * <p>Input: {@link #getData} is URI containing a directory of data
781      * (vnd.android.cursor.dir/*) from which to pick an item.
782      * <p>Output: The URI of the item that was picked.
783      */
784     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
785     public static final String ACTION_PICK = "android.intent.action.PICK";
786 
787     /**
788      * Activity Action: Creates a reminder.
789      * <p>Input: {@link #EXTRA_TITLE} The title of the reminder that will be shown to the user.
790      * {@link #EXTRA_TEXT} The reminder text that will be shown to the user. The intent should at
791      * least specify a title or a text. {@link #EXTRA_TIME} The time when the reminder will
792      * be shown to the user. The time is specified in milliseconds since the Epoch (optional).
793      * </p>
794      * <p>Output: Nothing.</p>
795      *
796      * @see #EXTRA_TITLE
797      * @see #EXTRA_TEXT
798      * @see #EXTRA_TIME
799      */
800     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
801     public static final String ACTION_CREATE_REMINDER = "android.intent.action.CREATE_REMINDER";
802 
803     /**
804      * Activity Action: Creates a shortcut.
805      * <p>Input: Nothing.</p>
806      * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
807      * <p>For compatibility with older versions of android the intent may also contain three
808      * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
809      * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
810      * (value: ShortcutIconResource).</p>
811      *
812      * @see android.content.pm.ShortcutManager#createShortcutResultIntent
813      * @see #EXTRA_SHORTCUT_INTENT
814      * @see #EXTRA_SHORTCUT_NAME
815      * @see #EXTRA_SHORTCUT_ICON
816      * @see #EXTRA_SHORTCUT_ICON_RESOURCE
817      * @see android.content.Intent.ShortcutIconResource
818      */
819     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
820     public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
821 
822     /**
823      * The name of the extra used to define the Intent of a shortcut.
824      *
825      * @see #ACTION_CREATE_SHORTCUT
826      * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
827      */
828     @Deprecated
829     public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
830     /**
831      * The name of the extra used to define the name of a shortcut.
832      *
833      * @see #ACTION_CREATE_SHORTCUT
834      * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
835      */
836     @Deprecated
837     public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
838     /**
839      * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
840      *
841      * @see #ACTION_CREATE_SHORTCUT
842      * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
843      */
844     @Deprecated
845     public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
846     /**
847      * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
848      *
849      * @see #ACTION_CREATE_SHORTCUT
850      * @see android.content.Intent.ShortcutIconResource
851      * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
852      */
853     @Deprecated
854     public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
855             "android.intent.extra.shortcut.ICON_RESOURCE";
856 
857     /**
858      * An activity that provides a user interface for adjusting application preferences.
859      * Optional but recommended settings for all applications which have settings.
860      */
861     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
862     public static final String ACTION_APPLICATION_PREFERENCES
863             = "android.intent.action.APPLICATION_PREFERENCES";
864 
865     /**
866      * Activity Action: Launch an activity showing the app information.
867      * For applications which install other applications (such as app stores), it is recommended
868      * to handle this action for providing the app information to the user.
869      *
870      * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
871      * to be displayed.
872      * <p>Output: Nothing.
873      */
874     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
875     public static final String ACTION_SHOW_APP_INFO
876             = "android.intent.action.SHOW_APP_INFO";
877 
878     /**
879      * Activity Action: Placeholder that the component handling it can do activity
880      * recognition. Can be placed on a service. Only one service per package is
881      * supported.
882      *
883      * <p>Input: Nothing.</p>
884      * <p>Output: Nothing </p>
885      *
886      * @hide
887      */
888     @SystemApi
889     @SdkConstant(SdkConstantType.SERVICE_ACTION)
890     public static final String ACTION_ACTIVITY_RECOGNIZER =
891             "android.intent.action.ACTIVITY_RECOGNIZER";
892 
893     /** @hide */
maybeMarkAsMissingCreatorToken(Object object)894     public static void maybeMarkAsMissingCreatorToken(Object object) {
895         if (object instanceof Intent intent) {
896             maybeMarkAsMissingCreatorTokenInternal(intent);
897         } else if (object instanceof Parcelable[] parcelables) {
898             for (Parcelable p : parcelables) {
899                 if (p instanceof Intent intent) {
900                     maybeMarkAsMissingCreatorTokenInternal(intent);
901                 }
902             }
903         } else if (object instanceof ArrayList parcelables) {
904             int N = parcelables.size();
905             for (int i = 0; i < N; i++) {
906                 Object p = parcelables.get(i);
907                 if (p instanceof Intent intent) {
908                     maybeMarkAsMissingCreatorTokenInternal(intent);
909                 }
910             }
911         }
912     }
913 
maybeMarkAsMissingCreatorTokenInternal(Intent intent)914     private static void maybeMarkAsMissingCreatorTokenInternal(Intent intent) {
915         boolean isForeign = (intent.mLocalFlags & LOCAL_FLAG_FROM_PARCEL) != 0;
916         boolean isWithoutTrustedCreatorToken =
917                 (intent.mLocalFlags & Intent.LOCAL_FLAG_TRUSTED_CREATOR_TOKEN_PRESENT) == 0;
918         if (isForeign && isWithoutTrustedCreatorToken && preventIntentRedirect()) {
919             intent.addExtendedFlags(EXTENDED_FLAG_MISSING_CREATOR_OR_INVALID_TOKEN);
920         }
921     }
922 
923     /**
924      * Represents a shortcut/live folder icon resource.
925      *
926      * @see Intent#ACTION_CREATE_SHORTCUT
927      * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
928      * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
929      * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
930      */
931     public static class ShortcutIconResource implements Parcelable {
932         /**
933          * The package name of the application containing the icon.
934          */
935         public String packageName;
936 
937         /**
938          * The resource name of the icon, including package, name and type.
939          */
940         public String resourceName;
941 
942         /**
943          * Creates a new ShortcutIconResource for the specified context and resource
944          * identifier.
945          *
946          * @param context The context of the application.
947          * @param resourceId The resource identifier for the icon.
948          * @return A new ShortcutIconResource with the specified's context package name
949          *         and icon resource identifier.``
950          */
fromContext(Context context, @AnyRes int resourceId)951         public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
952             ShortcutIconResource icon = new ShortcutIconResource();
953             icon.packageName = context.getPackageName();
954             icon.resourceName = context.getResources().getResourceName(resourceId);
955             return icon;
956         }
957 
958         /**
959          * Used to read a ShortcutIconResource from a Parcel.
960          */
961         public static final @android.annotation.NonNull Parcelable.Creator<ShortcutIconResource> CREATOR =
962             new Parcelable.Creator<ShortcutIconResource>() {
963 
964                 public ShortcutIconResource createFromParcel(Parcel source) {
965                     ShortcutIconResource icon = new ShortcutIconResource();
966                     icon.packageName = source.readString8();
967                     icon.resourceName = source.readString8();
968                     return icon;
969                 }
970 
971                 public ShortcutIconResource[] newArray(int size) {
972                     return new ShortcutIconResource[size];
973                 }
974             };
975 
976         /**
977          * No special parcel contents.
978          */
describeContents()979         public int describeContents() {
980             return 0;
981         }
982 
writeToParcel(Parcel dest, int flags)983         public void writeToParcel(Parcel dest, int flags) {
984             dest.writeString8(packageName);
985             dest.writeString8(resourceName);
986         }
987 
988         @Override
toString()989         public String toString() {
990             return resourceName;
991         }
992     }
993 
994     /**
995      * Activity Action: Display an activity chooser, allowing the user to pick
996      * what they want to before proceeding.  This can be used as an alternative
997      * to the standard activity picker that is displayed by the system when
998      * you try to start an activity with multiple possible matches, with these
999      * differences in behavior:
1000      * <ul>
1001      * <li>You can specify the title that will appear in the activity chooser.
1002      * <li>The user does not have the option to make one of the matching
1003      * activities a preferred activity, and all possible activities will
1004      * always be shown even if one of them is currently marked as the
1005      * preferred activity.
1006      * </ul>
1007      * <p>
1008      * This action should be used when the user will naturally expect to
1009      * select an activity in order to proceed.  An example if when not to use
1010      * it is when the user clicks on a "mailto:" link.  They would naturally
1011      * expect to go directly to their mail app, so startActivity() should be
1012      * called directly: it will
1013      * either launch the current preferred app, or put up a dialog allowing the
1014      * user to pick an app to use and optionally marking that as preferred.
1015      * <p>
1016      * In contrast, if the user is selecting a menu item to send a picture
1017      * they are viewing to someone else, there are many different things they
1018      * may want to do at this point: send it through e-mail, upload it to a
1019      * web service, etc.  In this case the CHOOSER action should be used, to
1020      * always present to the user a list of the things they can do, with a
1021      * nice title given by the caller such as "Send this photo with:".
1022      * <p>
1023      * If you need to grant URI permissions through a chooser, you must specify
1024      * the permissions to be granted on the ACTION_CHOOSER Intent
1025      * <em>in addition</em> to the EXTRA_INTENT inside.  This means using
1026      * {@link #setClipData} to specify the URIs to be granted as well as
1027      * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
1028      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
1029      * <p>
1030      * As a convenience, an Intent of this form can be created with the
1031      * {@link #createChooser} function.
1032      * <p>
1033      * Input: No data should be specified.  get*Extra must have
1034      * a {@link #EXTRA_INTENT} field containing the Intent being executed,
1035      * and can optionally have a {@link #EXTRA_TITLE} field containing the
1036      * title text to display in the chooser.
1037      * <p>
1038      * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
1039      */
1040     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1041     public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
1042 
1043     /**
1044      * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
1045      *
1046      * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
1047      * target intent, also optionally supplying a title.  If the target
1048      * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
1049      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
1050      * set in the returned chooser intent, with its ClipData set appropriately:
1051      * either a direct reflection of {@link #getClipData()} if that is non-null,
1052      * or a new ClipData built from {@link #getData()}.
1053      *
1054      * @param target The Intent that the user will be selecting an activity
1055      * to perform.
1056      * @param title Optional title that will be displayed in the chooser,
1057      * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE.
1058      * @return Return a new Intent object that you can hand to
1059      * {@link Context#startActivity(Intent) Context.startActivity()} and
1060      * related methods.
1061      */
createChooser(Intent target, CharSequence title)1062     public static Intent createChooser(Intent target, CharSequence title) {
1063         return createChooser(target, title, null);
1064     }
1065 
1066     /**
1067      * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
1068      *
1069      * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
1070      * target intent, also optionally supplying a title.  If the target
1071      * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
1072      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
1073      * set in the returned chooser intent, with its ClipData set appropriately:
1074      * either a direct reflection of {@link #getClipData()} if that is non-null,
1075      * or a new ClipData built from {@link #getData()}.</p>
1076      *
1077      * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
1078      * when the user makes a choice. This can be useful if the calling application wants
1079      * to remember the last chosen target and surface it as a more prominent or one-touch
1080      * affordance elsewhere in the UI for next time.</p>
1081      *
1082      * @param target The Intent that the user will be selecting an activity
1083      * to perform.
1084      * @param title Optional title that will be displayed in the chooser,
1085      * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE.
1086      * @param sender Optional IntentSender to be called when a choice is made.
1087      * @return Return a new Intent object that you can hand to
1088      * {@link Context#startActivity(Intent) Context.startActivity()} and
1089      * related methods.
1090      */
createChooser(Intent target, CharSequence title, IntentSender sender)1091     public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
1092         Intent intent = new Intent(ACTION_CHOOSER);
1093         intent.putExtra(EXTRA_INTENT, target);
1094         if (title != null) {
1095             intent.putExtra(EXTRA_TITLE, title);
1096         }
1097 
1098         if (sender != null) {
1099             intent.putExtra(EXTRA_CHOOSER_RESULT_INTENT_SENDER, sender);
1100         }
1101 
1102         // Migrate any clip data and flags from target.
1103         int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
1104                 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
1105                 | FLAG_GRANT_PREFIX_URI_PERMISSION);
1106         if (permFlags != 0) {
1107             ClipData targetClipData = target.getClipData();
1108             if (targetClipData == null && target.getData() != null) {
1109                 ClipData.Item item = new ClipData.Item(target.getData());
1110                 String[] mimeTypes;
1111                 if (target.getType() != null) {
1112                     mimeTypes = new String[] { target.getType() };
1113                 } else {
1114                     mimeTypes = new String[] { };
1115                 }
1116                 targetClipData = new ClipData(null, mimeTypes, item);
1117             }
1118             if (targetClipData != null) {
1119                 intent.setClipData(targetClipData);
1120                 intent.addFlags(permFlags);
1121             }
1122         }
1123 
1124         return intent;
1125     }
1126 
1127     /**
1128      * Activity Action: Allow the user to select a particular kind of data and
1129      * return it.  This is different than {@link #ACTION_PICK} in that here we
1130      * just say what kind of data is desired, not a URI of existing data from
1131      * which the user can pick.  An ACTION_GET_CONTENT could allow the user to
1132      * create the data as it runs (for example taking a picture or recording a
1133      * sound), let them browse over the web and download the desired data,
1134      * etc.
1135      * <p>
1136      * There are two main ways to use this action: if you want a specific kind
1137      * of data, such as a person contact, you set the MIME type to the kind of
1138      * data you want and launch it with {@link Context#startActivity(Intent)}.
1139      * The system will then launch the best application to select that kind
1140      * of data for you.
1141      * <p>
1142      * You may also be interested in any of a set of types of content the user
1143      * can pick.  For example, an e-mail application that wants to allow the
1144      * user to add an attachment to an e-mail message can use this action to
1145      * bring up a list of all of the types of content the user can attach.
1146      * <p>
1147      * In this case, you should wrap the GET_CONTENT intent with a chooser
1148      * (through {@link #createChooser}), which will give the proper interface
1149      * for the user to pick how to send your data and allow you to specify
1150      * a prompt indicating what they are doing.  You will usually specify a
1151      * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1152      * broad range of content types the user can select from.
1153      * <p>
1154      * When using such a broad GET_CONTENT action, it is often desirable to
1155      * only pick from data that can be represented as a stream.  This is
1156      * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1157      * <p>
1158      * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
1159      * the launched content chooser only returns results representing data that
1160      * is locally available on the device.  For example, if this extra is set
1161      * to true then an image picker should not show any pictures that are available
1162      * from a remote server but not already on the local device (thus requiring
1163      * they be downloaded when opened).
1164      * <p>
1165      * If the caller can handle multiple returned items (the user performing
1166      * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1167      * to indicate this.
1168      * <p>
1169      * Input: {@link #getType} is the desired MIME type to retrieve.  Note
1170      * that no URI is supplied in the intent, as there are no constraints on
1171      * where the returned data originally comes from.  You may also include the
1172      * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
1173      * opened as a stream.  You may use {@link #EXTRA_LOCAL_ONLY} to limit content
1174      * selection to local data.  You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1175      * allow the user to select multiple items.
1176      * <p>
1177      * Output: The URI of the item that was picked.  This must be a content:
1178      * URI so that any receiver can access it.
1179      */
1180     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1181     public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1182     /**
1183      * Activity Action: Dial a number as specified by the data.  This shows a
1184      * UI with the number being dialed, allowing the user to explicitly
1185      * initiate the call.
1186      * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1187      * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1188      * number.
1189      * <p>Output: nothing.
1190      */
1191     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1192     public static final String ACTION_DIAL = "android.intent.action.DIAL";
1193     /**
1194      * Activity Action: Perform a call to someone specified by the data.
1195      * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1196      * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1197      * number.
1198      * <p>Output: nothing.
1199      *
1200      * <p>Note: there will be restrictions on which applications can initiate a
1201      * call; most applications should use the {@link #ACTION_DIAL}.
1202      * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1203      * numbers.  Applications can <strong>dial</strong> emergency numbers using
1204      * {@link #ACTION_DIAL}, however.
1205      *
1206      * <p>Note: This Intent can only be used to dial call forwarding MMI codes if the application
1207      * using this intent is set as the default or system dialer. The system will treat any other
1208      * application using this Intent for the purpose of dialing call forwarding MMI codes as if the
1209      * {@link #ACTION_DIAL} Intent was used instead.
1210      *
1211      * <p>Note: An app filling the {@link android.app.role.RoleManager#ROLE_DIALER} role should use
1212      * {@link android.telecom.TelecomManager#placeCall(Uri, Bundle)} to place calls rather than
1213      * relying on this intent.
1214      *
1215      * <p>Note: If your app targets {@link android.os.Build.VERSION_CODES#M M}
1216      * or higher and declares as using the {@link android.Manifest.permission#CALL_PHONE}
1217      * permission which is not granted, then attempting to use this action will
1218      * result in a {@link java.lang.SecurityException}.
1219      */
1220     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1221     public static final String ACTION_CALL = "android.intent.action.CALL";
1222     /**
1223      * Activity Action: Perform a call to an emergency number specified by the
1224      * data.
1225      * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1226      * tel: URI of an explicit phone number.
1227      * <p>Output: nothing.
1228      *
1229      * <p class="note"><strong>Note:</strong> It is not guaranteed that the call will be placed on
1230      * the {@link PhoneAccount} provided in the {@link TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE}
1231      * extra (if specified) and may be placed on another {@link PhoneAccount} with the
1232      * {@link PhoneAccount#CAPABILITY_PLACE_EMERGENCY_CALLS} capability, depending on external
1233      * factors, such as network conditions and Modem/SIM status.
1234      * @hide
1235      */
1236     @SystemApi
1237     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1238     public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1239     /**
1240      * Activity Action: Dial a emergency number specified by the data.  This shows a
1241      * UI with the number being dialed, allowing the user to explicitly
1242      * initiate the call.
1243      * <p>Input: If nothing, an empty emergency dialer is started; else {@link #getData}
1244      * is a tel: URI of an explicit emergency phone number.
1245      * <p>Output: nothing.
1246      * @hide
1247      */
1248     @SystemApi
1249     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1250     public static final String ACTION_DIAL_EMERGENCY = "android.intent.action.DIAL_EMERGENCY";
1251     /**
1252      * Activity action: Perform a call to any number (emergency or not)
1253      * specified by the data.
1254      * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1255      * tel: URI of an explicit phone number.
1256      * <p>Output: nothing.
1257      * @hide
1258      */
1259     @SystemApi
1260     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1261     public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1262 
1263     /**
1264      * Activity Action: Main entry point for carrier setup apps.
1265      * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1266      * carrier service and typically require
1267      * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1268      * fulfill their duties.
1269      */
1270     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1271     public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1272     /**
1273      * Activity Action: Send a message to someone specified by the data.
1274      * <p>Input: {@link #getData} is URI describing the target.
1275      * <p>Output: nothing.
1276      */
1277     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1278     public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1279     /**
1280      * Activity Action: Deliver some data to someone else.  Who the data is
1281      * being delivered to is not specified; it is up to the receiver of this
1282      * action to ask the user where the data should be sent.
1283      * <p>
1284      * When launching a SEND intent, you should usually wrap it in a chooser
1285      * (through {@link #createChooser}), which will give the proper interface
1286      * for the user to pick how to send your data and allow you to specify
1287      * a prompt indicating what they are doing.
1288      * <p>
1289      * Input: {@link #getType} is the MIME type of the data being sent.
1290      * get*Extra can have either a {@link #EXTRA_TEXT}
1291      * or {@link #EXTRA_STREAM} field, containing the data to be sent.  If
1292      * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1293      * should be the MIME type of the data in EXTRA_STREAM.  Use {@literal *}/*
1294      * if the MIME type is unknown (this will only allow senders that can
1295      * handle generic data streams).  If using {@link #EXTRA_TEXT}, you can
1296      * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1297      * your text with HTML formatting.
1298      * <p>
1299      * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1300      * being sent can be supplied through {@link #setClipData(ClipData)}.  This
1301      * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1302      * content: URIs and other advanced features of {@link ClipData}.  If
1303      * using this approach, you still must supply the same data through the
1304      * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1305      * for compatibility with old applications.  If you don't set a ClipData,
1306      * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1307      * <p>
1308      * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1309      * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1310      * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1311      * be openable only as asset typed files using
1312      * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1313      * <p>
1314      * Optional standard extras, which may be interpreted by some recipients as
1315      * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1316      * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1317      * <p>
1318      * Output: nothing.
1319      */
1320     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1321     public static final String ACTION_SEND = "android.intent.action.SEND";
1322     /**
1323      * Activity Action: Deliver multiple data to someone else.
1324      * <p>
1325      * Like {@link #ACTION_SEND}, except the data is multiple.
1326      * <p>
1327      * Input: {@link #getType} is the MIME type of the data being sent.
1328      * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
1329      * #EXTRA_STREAM} field, containing the data to be sent.  If using
1330      * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1331      * for clients to retrieve your text with HTML formatting.
1332      * <p>
1333      * Multiple types are supported, and receivers should handle mixed types
1334      * whenever possible. The right way for the receiver to check them is to
1335      * use the content resolver on each URI. The intent sender should try to
1336      * put the most concrete mime type in the intent type, but it can fall
1337      * back to {@literal <type>/*} or {@literal *}/* as needed.
1338      * <p>
1339      * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1340      * be image/jpg, but if you are sending image/jpg and image/png, then the
1341      * intent's type should be image/*.
1342      * <p>
1343      * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1344      * being sent can be supplied through {@link #setClipData(ClipData)}.  This
1345      * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1346      * content: URIs and other advanced features of {@link ClipData}.  If
1347      * using this approach, you still must supply the same data through the
1348      * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1349      * for compatibility with old applications.  If you don't set a ClipData,
1350      * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1351      * <p>
1352      * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1353      * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1354      * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1355      * be openable only as asset typed files using
1356      * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1357      * <p>
1358      * Optional standard extras, which may be interpreted by some recipients as
1359      * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1360      * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1361      * <p>
1362      * Output: nothing.
1363      */
1364     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1365     public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1366     /**
1367      * Activity Action: Handle an incoming phone call.
1368      * <p>Input: nothing.
1369      * <p>Output: nothing.
1370      */
1371     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1372     public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1373     /**
1374      * Activity Action: Insert an empty item into the given container.
1375      * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1376      * in which to place the data.
1377      * <p>Output: URI of the new data that was created.
1378      */
1379     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1380     public static final String ACTION_INSERT = "android.intent.action.INSERT";
1381     /**
1382      * Activity Action: Create a new item in the given container, initializing it
1383      * from the current contents of the clipboard.
1384      * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1385      * in which to place the data.
1386      * <p>Output: URI of the new data that was created.
1387      */
1388     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1389     public static final String ACTION_PASTE = "android.intent.action.PASTE";
1390     /**
1391      * Activity Action: Delete the given data from its container.
1392      * <p>Input: {@link #getData} is URI of data to be deleted.
1393      * <p>Output: nothing.
1394      */
1395     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1396     public static final String ACTION_DELETE = "android.intent.action.DELETE";
1397     /**
1398      * Activity Action: Run the data, whatever that means.
1399      * <p>Input: ?  (Note: this is currently specific to the test harness.)
1400      * <p>Output: nothing.
1401      */
1402     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1403     public static final String ACTION_RUN = "android.intent.action.RUN";
1404     /**
1405      * Activity Action: Perform a data synchronization.
1406      * <p>Input: ?
1407      * <p>Output: ?
1408      */
1409     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1410     public static final String ACTION_SYNC = "android.intent.action.SYNC";
1411     /**
1412      * Activity Action: Pick an activity given an intent, returning the class
1413      * selected.
1414      * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1415      * used with {@link PackageManager#queryIntentActivities} to determine the
1416      * set of activities from which to pick.
1417      * <p>Output: Class name of the activity that was selected.
1418      */
1419     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1420     public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1421     /**
1422      * Activity Action: Perform a search.
1423      * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1424      * is the text to search for.  If empty, simply
1425      * enter your search results Activity with the search UI activated.
1426      * <p>Output: nothing.
1427      */
1428     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1429     public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1430     /**
1431      * Activity Action: Start the platform-defined tutorial
1432      * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1433      * is the text to search for.  If empty, simply
1434      * enter your search results Activity with the search UI activated.
1435      * <p>Output: nothing.
1436      */
1437     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1438     public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1439     /**
1440      * Activity Action: Perform a web search.
1441      * <p>
1442      * Input: {@link android.app.SearchManager#QUERY
1443      * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1444      * a url starts with http or https, the site will be opened. If it is plain
1445      * text, Google search will be applied.
1446      * <p>
1447      * Output: nothing.
1448      */
1449     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1450     public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
1451 
1452     /**
1453      * Activity Action: Perform assist action.
1454      * <p>
1455      * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1456      * additional optional contextual information about where the user was when they
1457      * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1458      * information.
1459      * Output: nothing.
1460      */
1461     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1462     public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
1463 
1464     /**
1465      * Activity Action: Perform voice assist action.
1466      * <p>
1467      * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1468      * additional optional contextual information about where the user was when they
1469      * requested the voice assist.
1470      * Output: nothing.
1471      * @hide
1472      */
1473     @SystemApi
1474     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1475     public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1476 
1477     /**
1478      * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1479      * application package at the time the assist was invoked.
1480      */
1481     public static final String EXTRA_ASSIST_PACKAGE
1482             = "android.intent.extra.ASSIST_PACKAGE";
1483 
1484     /**
1485      * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1486      * application package at the time the assist was invoked.
1487      */
1488     public static final String EXTRA_ASSIST_UID
1489             = "android.intent.extra.ASSIST_UID";
1490 
1491     /**
1492      * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1493      * information supplied by the current foreground app at the time of the assist request.
1494      * This is a {@link Bundle} of additional data.
1495      */
1496     public static final String EXTRA_ASSIST_CONTEXT
1497             = "android.intent.extra.ASSIST_CONTEXT";
1498 
1499     /**
1500      * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1501      * keyboard as the primary input device for assistance.
1502      */
1503     public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1504             "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1505 
1506     /**
1507      * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1508      * that was used to invoke the assist.
1509      */
1510     public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1511             "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1512 
1513     /**
1514      * Activity Action: List all available applications.
1515      * <p>Input: Nothing.
1516      * <p>Output: nothing.
1517      */
1518     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1519     public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1520 
1521     /**
1522      * Activity Action: Action to show the list of all work apps in the launcher. For example,
1523      * shows the work apps folder or tab.
1524      *
1525      * <p>Input: Nothing.
1526      * <p>Output: nothing.
1527      */
1528     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1529     public static final String ACTION_SHOW_WORK_APPS =
1530             "android.intent.action.SHOW_WORK_APPS";
1531 
1532     /**
1533      * Activity Action: Show settings for choosing wallpaper.
1534      * <p>Input: Nothing.
1535      * <p>Output: Nothing.
1536      */
1537     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1538     public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1539 
1540     /**
1541      * Activity Action: Show activity for reporting a bug.
1542      * <p>Input: Nothing.
1543      * <p>Output: Nothing.
1544      */
1545     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1546     public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1547 
1548     /**
1549      *  Activity Action: Main entry point for factory tests.  Only used when
1550      *  the device is booting in factory test node.  The implementing package
1551      *  must be installed in the system image.
1552      *  <p>Input: nothing
1553      *  <p>Output: nothing
1554      */
1555     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1556     public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1557 
1558     /**
1559      * Activity Action: The user pressed the "call" button to go to the dialer
1560      * or other appropriate UI for placing a call.
1561      * <p>Input: Nothing.
1562      * <p>Output: Nothing.
1563      */
1564     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1565     public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1566 
1567     /**
1568      * Activity Action: Start Voice Command.
1569      * <p>Input: Nothing.
1570      * <p>Output: Nothing.
1571      * <p class="note">
1572      * In some cases, a matching Activity may not exist, so ensure you
1573      * safeguard against this.
1574      */
1575     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1576     public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
1577 
1578     /**
1579      * Activity Action: Start action associated with long pressing on the
1580      * search key.
1581      * <p>Input: Nothing.
1582      * <p>Output: Nothing.
1583      */
1584     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1585     public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
1586 
1587     /**
1588      * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1589      * This intent is delivered to the package which installed the application, usually
1590      * Google Play.
1591      * <p>Input: No data is specified. The bug report is passed in using
1592      * an {@link #EXTRA_BUG_REPORT} field.
1593      * <p>Output: Nothing.
1594      *
1595      * @see #EXTRA_BUG_REPORT
1596      */
1597     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1598     public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
1599 
1600     /**
1601      * An incident or bug report has been taken, and a system app has requested it to be shared,
1602      * so trigger the confirmation screen.
1603      *
1604      * This will be sent directly to the registered receiver with the
1605      * android.permission.APPROVE_INCIDENT_REPORTS permission.
1606      * @hide
1607      */
1608     @SystemApi
1609     public static final String ACTION_PENDING_INCIDENT_REPORTS_CHANGED =
1610             "android.intent.action.PENDING_INCIDENT_REPORTS_CHANGED";
1611 
1612     /**
1613      * An incident report has been taken, and the user has approved it for sharing.
1614      * <p>
1615      * This will be sent directly to the registered receiver, which must have
1616      * both the DUMP and USAGE_STATS permissions.
1617      * <p>
1618      * After receiving this, the application should wait until a suitable time
1619      * (e.g. network available), get the list of available reports with
1620      * {@link IncidentManager#getIncidentReportList IncidentManager.getIncidentReportList(String)}
1621      * and then when the reports have been successfully uploaded, call
1622      * {@link IncidentManager#deleteIncidentReport IncidentManager.deleteIncidentReport(Uri)}.
1623      *
1624      * @hide
1625      */
1626     @SystemApi
1627     public static final String ACTION_INCIDENT_REPORT_READY =
1628             "android.intent.action.INCIDENT_REPORT_READY";
1629 
1630     /**
1631      * Activity Action: Show power usage information to the user.
1632      * <p>Input: Nothing.
1633      * <p>Output: Nothing.
1634      */
1635     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1636     public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
1637 
1638     /**
1639      * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1640      * to run.
1641      * <p>Input: Nothing.
1642      * <p>Output: Nothing.
1643      * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1644      * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1645      * @hide
1646      * @removed
1647      */
1648     @Deprecated
1649     @SystemApi
1650     public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1651             "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1652 
1653     /**
1654      * Activity Action: Setup wizard to launch after a platform update.  This
1655      * activity should have a string meta-data field associated with it,
1656      * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1657      * the platform for setup.  The activity will be launched only if
1658      * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1659      * same value.
1660      * <p>Input: Nothing.
1661      * <p>Output: Nothing.
1662      * @hide
1663      */
1664     @SystemApi
1665     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1666     public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
1667 
1668     /**
1669      * Activity Action: Start the Keyboard Shortcuts Helper screen.
1670      * <p>Input: Nothing.
1671      * <p>Output: Nothing.
1672      * @hide
1673      */
1674     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1675     public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
1676             "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
1677 
1678     /**
1679      * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1680      * <p>Input: Nothing.
1681      * <p>Output: Nothing.
1682      * @hide
1683      */
1684     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1685     public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
1686             "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
1687 
1688     /**
1689      * Activity Action: Show settings for managing network data usage of a
1690      * specific application. Applications should define an activity that offers
1691      * options to control data usage.
1692      */
1693     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1694     public static final String ACTION_MANAGE_NETWORK_USAGE =
1695             "android.intent.action.MANAGE_NETWORK_USAGE";
1696 
1697     /**
1698      * Activity Action: Launch application installer.
1699      * <p>
1700      * Input: The data must be a content: URI at which the application
1701      * can be retrieved.  As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1702      * you can also use "package:<package-name>" to install an application for the
1703      * current user that is already installed for another user. You can optionally supply
1704      * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1705      * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1706      * <p>
1707      * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1708      * succeeded.
1709      * <p>
1710      * <strong>Note:</strong>If your app is targeting API level higher than 25 you
1711      * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1712      * in order to launch the application installer.
1713      * </p>
1714      *
1715      * @see #EXTRA_INSTALLER_PACKAGE_NAME
1716      * @see #EXTRA_NOT_UNKNOWN_SOURCE
1717      * @see #EXTRA_RETURN_RESULT
1718      *
1719      * @deprecated use {@link android.content.pm.PackageInstaller} instead
1720      */
1721     @Deprecated
1722     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1723     public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1724 
1725     /**
1726      * Activity Action: Activity to handle split installation failures.
1727      * <p>Splits may be installed dynamically. This happens when an Activity is launched,
1728      * but the split that contains the application isn't installed. When a split is
1729      * installed in this manner, the containing package usually doesn't know this is
1730      * happening. However, if an error occurs during installation, the containing
1731      * package can define a single activity handling this action to deal with such
1732      * failures.
1733      * <p>The activity handling this action must be in the base package.
1734      * <p>
1735      * Input: {@link #EXTRA_INTENT} the original intent that started split installation.
1736      * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed.
1737      */
1738     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1739     public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE";
1740 
1741     /**
1742      * Activity Action: Launch instant application installer.
1743      * <p class="note">
1744      * This is a protected intent that can only be sent by the system.
1745      * </p>
1746      *
1747      * @hide
1748      */
1749     @SystemApi
1750     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1751     public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1752             = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
1753 
1754     /**
1755      * Service Action: Resolve instant application.
1756      * <p>
1757      * The system will have a persistent connection to this service.
1758      * This is a protected intent that can only be sent by the system.
1759      * </p>
1760      *
1761      * @hide
1762      */
1763     @SystemApi
1764     @SdkConstant(SdkConstantType.SERVICE_ACTION)
1765     public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1766             = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
1767 
1768     /**
1769      * Activity Action: Launch instant app settings.
1770      *
1771      * <p class="note">
1772      * This is a protected intent that can only be sent by the system.
1773      * </p>
1774      *
1775      * @hide
1776      */
1777     @SystemApi
1778     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1779     public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1780             = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
1781 
1782     /**
1783      * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1784      * package.  Specifies the installer package name; this package will receive the
1785      * {@link #ACTION_APP_ERROR} intent.
1786      */
1787     public static final String EXTRA_INSTALLER_PACKAGE_NAME
1788             = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1789 
1790     /**
1791      * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1792      * package.  Specifies that the application being installed should not be
1793      * treated as coming from an unknown source, but as coming from the app
1794      * invoking the Intent.  For this to work you must start the installer with
1795      * startActivityForResult().
1796      */
1797     public static final String EXTRA_NOT_UNKNOWN_SOURCE
1798             = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1799 
1800     /**
1801      * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1802      * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
1803      * data field originated from.
1804      */
1805     public static final String EXTRA_ORIGINATING_URI
1806             = "android.intent.extra.ORIGINATING_URI";
1807 
1808     /**
1809      * This extra can be used with any Intent used to launch an activity, supplying information
1810      * about who is launching that activity.  This field contains a {@link android.net.Uri}
1811      * object, typically an http: or https: URI of the web site that the referral came from;
1812      * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1813      * a native application that it came from.
1814      *
1815      * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1816      * instead of directly retrieving the extra.  It is also valid for applications to
1817      * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1818      * a string, not a Uri; the field here, if supplied, will always take precedence,
1819      * however.</p>
1820      *
1821      * @see #EXTRA_REFERRER_NAME
1822      */
1823     public static final String EXTRA_REFERRER
1824             = "android.intent.extra.REFERRER";
1825 
1826     /**
1827      * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1828      * than a {@link android.net.Uri} object.  Only for use in cases where Uri objects can
1829      * not be created, in particular when Intent extras are supplied through the
1830      * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1831      * schemes.
1832      *
1833      * @see #EXTRA_REFERRER
1834      */
1835     public static final String EXTRA_REFERRER_NAME
1836             = "android.intent.extra.REFERRER_NAME";
1837 
1838     /**
1839      * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1840      * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
1841      * Currently only a system app that hosts the provider authority "downloads" or holds the
1842      * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
1843      * @hide
1844      */
1845     @SystemApi
1846     public static final String EXTRA_ORIGINATING_UID
1847             = "android.intent.extra.ORIGINATING_UID";
1848 
1849     /**
1850      * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1851      * package.  Tells the installer UI to skip the confirmation with the user
1852      * if the .apk is replacing an existing one.
1853      * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1854      * will no longer show an interstitial message about updating existing
1855      * applications so this is no longer needed.
1856      */
1857     @Deprecated
1858     public static final String EXTRA_ALLOW_REPLACE
1859             = "android.intent.extra.ALLOW_REPLACE";
1860 
1861     /**
1862      * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1863      * {@link #ACTION_UNINSTALL_PACKAGE}.  Specifies that the installer UI should
1864      * return to the application the result code of the install/uninstall.  The returned result
1865      * code will be {@link android.app.Activity#RESULT_OK} on success or
1866      * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1867      */
1868     public static final String EXTRA_RETURN_RESULT
1869             = "android.intent.extra.RETURN_RESULT";
1870 
1871     /**
1872      * Package manager install result code.  @hide because result codes are not
1873      * yet ready to be exposed.
1874      */
1875     @SystemApi
1876     public static final String EXTRA_INSTALL_RESULT = "android.intent.extra.INSTALL_RESULT";
1877 
1878     /**
1879      * Activity Action: Launch application uninstaller.
1880      * <p>
1881      * Input: The data must be a package: URI whose scheme specific part is
1882      * the package name of the current installed package to be uninstalled.
1883      * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1884      * <p>
1885      * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the uninstall
1886      * succeeded.
1887      * <p>
1888      * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES}
1889      * since {@link Build.VERSION_CODES#P}.
1890      *
1891      * @deprecated Use {@link android.content.pm.PackageInstaller#uninstall(String, IntentSender)}
1892      *             instead
1893      */
1894     @Deprecated
1895     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1896     public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1897 
1898     /**
1899      * Specify whether the package should be uninstalled for all users.
1900      * @hide because these should not be part of normal application flow.
1901      */
1902     @SystemApi
1903     public static final String EXTRA_UNINSTALL_ALL_USERS
1904             = "android.intent.extra.UNINSTALL_ALL_USERS";
1905 
1906     /**
1907      * A string that associates with a metadata entry, indicating the last run version of the
1908      * platform that was setup.
1909      *
1910      * @see #ACTION_UPGRADE_SETUP
1911      *
1912      * @hide
1913      */
1914     @SystemApi
1915     public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1916 
1917     /**
1918      * Activity action: Launch UI to manage the permissions of an app.
1919      * <p>
1920      * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1921      * will be managed by the launched UI.
1922      * </p>
1923      * <p>
1924      * Output: Nothing.
1925      * </p>
1926      *
1927      * @see #EXTRA_PACKAGE_NAME
1928      *
1929      * @hide
1930      * @deprecated Use {@link android.provider.Settings#ACTION_APP_PERMISSIONS_SETTINGS}
1931      * instead.
1932      */
1933     @Deprecated
1934     @SystemApi
1935     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1936     public static final String ACTION_MANAGE_APP_PERMISSIONS =
1937             "android.intent.action.MANAGE_APP_PERMISSIONS";
1938 
1939     /**
1940      * Activity action: Launch UI to manage a specific permission group of an app.
1941      * <p>
1942      * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permission
1943      * will be managed by the launched UI.
1944      * </p>
1945      * <p>
1946      * Input: {@link #EXTRA_PERMISSION_NAME} specifies the (individual) permission
1947      * whose group should be managed by the launched UI.
1948      * </p>
1949      * <p>
1950      * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group
1951      * that should be managed by the launched UI. Do not send both this and EXTRA_PERMISSION_NAME
1952      * together.
1953      * </p>
1954      * <p>
1955      * <li> {@link #EXTRA_USER} specifies the {@link UserHandle} of the user that owns the app.
1956      * </p>
1957      * <p>
1958      * Output: Nothing.
1959      * </p>
1960      *
1961      * @see #EXTRA_PACKAGE_NAME
1962      * @see #EXTRA_PERMISSION_NAME
1963      * @see #EXTRA_PERMISSION_GROUP_NAME
1964      * @see #EXTRA_USER
1965      *
1966      * @hide
1967      */
1968     @SystemApi
1969     @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
1970     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1971     public static final String ACTION_MANAGE_APP_PERMISSION =
1972             "android.intent.action.MANAGE_APP_PERMISSION";
1973 
1974     /**
1975      * Activity action: Launch UI to manage permissions.
1976      * <p>
1977      * Input: Nothing.
1978      * </p>
1979      * <p>
1980      * Output: Nothing.
1981      * </p>
1982      *
1983      * @hide
1984      */
1985     @SystemApi
1986     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1987     public static final String ACTION_MANAGE_PERMISSIONS =
1988             "android.intent.action.MANAGE_PERMISSIONS";
1989 
1990     /**
1991      * Activity action: Launch UI to manage auto-revoke state.
1992      *
1993      * This is equivalent to Intent#ACTION_APPLICATION_DETAILS_SETTINGS
1994      *
1995      * <p>
1996      * Input: {@link Intent#setData data} should be a {@code package}-scheme {@link Uri} with
1997      * a package name, whose auto-revoke state will be reviewed (mandatory).
1998      * E.g. {@code Uri.fromParts("package", packageName, null) }
1999      * </p>
2000      * <p>
2001      * Output: Nothing.
2002      * </p>
2003      */
2004     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2005     public static final String ACTION_AUTO_REVOKE_PERMISSIONS =
2006             "android.intent.action.AUTO_REVOKE_PERMISSIONS";
2007 
2008     /**
2009      * Activity action: Launch UI to manage unused apps (hibernated apps).
2010      *
2011      * <p>
2012      * Input: Nothing.
2013      * </p>
2014      * <p>
2015      * Output: Nothing.
2016      * </p>
2017      */
2018     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2019     public static final String ACTION_MANAGE_UNUSED_APPS =
2020             "android.intent.action.MANAGE_UNUSED_APPS";
2021 
2022     /**
2023      * Activity action: Launch UI to review permissions for an app.
2024      * The system uses this intent if permission review for apps not
2025      * supporting the new runtime permissions model is enabled. In
2026      * this mode a permission review is required before any of the
2027      * app components can run.
2028      * <p>
2029      * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
2030      * permissions will be reviewed (mandatory).
2031      * </p>
2032      * <p>
2033      * Input: {@link #EXTRA_INTENT} specifies a pending intent to
2034      * be fired after the permission review (optional).
2035      * </p>
2036      * <p>
2037      * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
2038      * be invoked after the permission review (optional).
2039      * </p>
2040      * <p>
2041      * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
2042      * passed via {@link #EXTRA_INTENT} needs a result (optional).
2043      * </p>
2044      * <p>
2045      * Output: Nothing.
2046      * </p>
2047      *
2048      * @see #EXTRA_PACKAGE_NAME
2049      * @see #EXTRA_INTENT
2050      * @see #EXTRA_REMOTE_CALLBACK
2051      * @see #EXTRA_RESULT_NEEDED
2052      *
2053      * @hide
2054      */
2055     @SystemApi
2056     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2057     public static final String ACTION_REVIEW_PERMISSIONS =
2058             "android.intent.action.REVIEW_PERMISSIONS";
2059 
2060     /**
2061      * Activity action: Launch UI to show information about the usage
2062      * of a given permission group. This action would be handled by apps that
2063      * want to show details about how and why given permission group is being
2064      * used.
2065      * <p>
2066      * <strong>Important:</strong>You must protect the activity that handles
2067      * this action with the {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE
2068      *  START_VIEW_PERMISSION_USAGE} permission to ensure that only the
2069      * system can launch this activity. The system will not launch
2070      * activities that are not properly protected.
2071      *
2072      * <p>
2073      * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group
2074      * for which the launched UI would be targeted.
2075      * </p>
2076      * <p>
2077      * Output: Nothing.
2078      * </p>
2079      */
2080     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2081     @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE)
2082     public static final String ACTION_VIEW_PERMISSION_USAGE =
2083             "android.intent.action.VIEW_PERMISSION_USAGE";
2084 
2085     /**
2086      * Activity action: Launch UI to show information about the usage of a given permission group in
2087      * a given period. This action would be handled by apps that want to show details about how and
2088      * why given permission group is being used.
2089      * <p>
2090      * <strong>Important:</strong>You must protect the activity that handles this action with the
2091      * {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE} permission to ensure that
2092      * only the system can launch this activity. The system will not launch activities that are not
2093      * properly protected.
2094      *
2095      * <p>
2096      * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group for which the
2097      * launched UI would be targeted.
2098      * </p>
2099      * <p>
2100      * Input: {@link #EXTRA_ATTRIBUTION_TAGS} specifies the attribution tags for the usage entry.
2101      * </p>
2102      * <p>
2103      * Input: {@link #EXTRA_START_TIME} specifies the start time of the period (epoch time in
2104      * millis). Both start time and end time are needed and start time must be <= end time.
2105      * </p>
2106      * <p>
2107      * Input: {@link #EXTRA_END_TIME} specifies the end time of the period (epoch time in
2108      * millis). Both start time and end time are needed and start time must be <= end time.
2109      * </p>
2110      * <p>
2111      * Output: Nothing.
2112      * </p>
2113      */
2114     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2115     @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE)
2116     public static final String ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD =
2117             "android.intent.action.VIEW_PERMISSION_USAGE_FOR_PERIOD";
2118 
2119     /**
2120      * Activity action: Launch the Safety Center Quick Settings UI.
2121      *
2122      * <p>
2123      * Input: Nothing.
2124      * </p>
2125      * <p>
2126      * Output: Nothing.
2127      * </p>
2128      *
2129      * @hide
2130      */
2131     @SystemApi
2132     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2133     @RequiresPermission(Manifest.permission.MANAGE_SENSOR_PRIVACY)
2134     public static final String ACTION_VIEW_SAFETY_CENTER_QS =
2135             "android.intent.action.VIEW_SAFETY_CENTER_QS";
2136 
2137     /**
2138      * Activity action: Launch UI to manage a default app.
2139      * <p>
2140      * Input: {@link #EXTRA_ROLE_NAME} specifies the role of the default app which will be managed
2141      * by the launched UI.
2142      * </p>
2143      * <p>
2144      * Output: Nothing.
2145      * </p>
2146      *
2147      * @hide
2148      */
2149     @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS)
2150     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2151     @SystemApi
2152     public static final String ACTION_MANAGE_DEFAULT_APP =
2153             "android.intent.action.MANAGE_DEFAULT_APP";
2154 
2155     /**
2156      * Intent extra: A role name.
2157      * <p>
2158      * Type: String
2159      * </p>
2160      *
2161      * @see android.app.role.RoleManager
2162      *
2163      * @hide
2164      */
2165     @SystemApi
2166     public static final String EXTRA_ROLE_NAME = "android.intent.extra.ROLE_NAME";
2167 
2168     /**
2169      * Activity action: Launch UI to manage special app accesses.
2170      * <p>
2171      * Input: Nothing.
2172      * </p>
2173      * <p>
2174      * Output: Nothing.
2175      * </p>
2176      *
2177      * @hide
2178      */
2179     @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS)
2180     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2181     @SystemApi
2182     public static final String ACTION_MANAGE_SPECIAL_APP_ACCESSES =
2183             "android.intent.action.MANAGE_SPECIAL_APP_ACCESSES";
2184 
2185     /**
2186      * Intent extra: A callback for reporting remote result as a bundle.
2187      * <p>
2188      * Type: IRemoteCallback
2189      * </p>
2190      *
2191      * @hide
2192      */
2193     @SystemApi
2194     public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
2195 
2196     /**
2197      * Intent extra: An app package name.
2198      * <p>
2199      * Type: String
2200      * </p>
2201      *
2202      */
2203     public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
2204 
2205     /**
2206      * Intent extra: A {@link android.os.LocaleList}
2207      * <p>
2208      * Type: LocaleList
2209      * </p>
2210      */
2211     public static final String EXTRA_LOCALE_LIST = "android.intent.extra.LOCALE_LIST";
2212 
2213     /**
2214      * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an
2215      * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}.
2216      *
2217      * <p>The contents of this {@link Bundle} are a contract between the suspended app and the
2218      * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}.
2219      * This is meant to enable the suspended app to better handle the state of being suspended.
2220      *
2221      * @see #ACTION_MY_PACKAGE_SUSPENDED
2222      * @see #ACTION_MY_PACKAGE_UNSUSPENDED
2223      * @see PackageManager#isPackageSuspended()
2224      * @see PackageManager#getSuspendedPackageAppExtras()
2225      */
2226     public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS";
2227 
2228     /**
2229      * Intent extra: An app split name.
2230      * <p>
2231      * Type: String
2232      * </p>
2233      */
2234     public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
2235 
2236     /**
2237      * Intent extra: A {@link ComponentName} value.
2238      * <p>
2239      * Type: String
2240      * </p>
2241      */
2242     public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
2243 
2244     /**
2245      * Intent extra: An extra for specifying whether a result is needed.
2246      * <p>
2247      * Type: boolean
2248      * </p>
2249      *
2250      * @hide
2251      */
2252     @SystemApi
2253     public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
2254 
2255     /**
2256      * Intent extra: ID of the shortcut used to send the share intent. Will be sent with
2257      * {@link #ACTION_SEND}.
2258      *
2259      * @see ShortcutInfo#getId()
2260      *
2261      * <p>
2262      * Type: String
2263      * </p>
2264      */
2265     public static final String EXTRA_SHORTCUT_ID = "android.intent.extra.shortcut.ID";
2266 
2267     /**
2268      * Activity action: Launch UI to manage which apps have a given permission.
2269      * <p>
2270      * Input: {@link #EXTRA_PERMISSION_NAME} or {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the
2271      * permission group which will be managed by the launched UI.
2272      * </p>
2273      * <p>
2274      * Output: Nothing.
2275      * </p>
2276      *
2277      * @see #EXTRA_PERMISSION_NAME
2278      * @see #EXTRA_PERMISSION_GROUP_NAME
2279      *
2280      * @hide
2281      */
2282     @SystemApi
2283     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2284     public static final String ACTION_MANAGE_PERMISSION_APPS =
2285             "android.intent.action.MANAGE_PERMISSION_APPS";
2286 
2287     /**
2288      * Intent extra: The name of a permission.
2289      * <p>
2290      * Type: String
2291      * </p>
2292      *
2293      * @hide
2294      */
2295     @SystemApi
2296     public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
2297 
2298     /**
2299      * Intent extra: The name of a permission group.
2300      * <p>
2301      * Type: String
2302      * </p>
2303      */
2304     public static final String EXTRA_PERMISSION_GROUP_NAME =
2305             "android.intent.extra.PERMISSION_GROUP_NAME";
2306 
2307     /**
2308      * Intent extra: The number of milliseconds.
2309      * <p>
2310      * Type: long
2311      * </p>
2312      */
2313     public static final String EXTRA_DURATION_MILLIS =
2314             "android.intent.extra.DURATION_MILLIS";
2315 
2316     /**
2317      * Activity action: Launch UI to review app uses of permissions.
2318      * <p>
2319      * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission name
2320      * that will be displayed by the launched UI.  Do not pass both this and
2321      * {@link #EXTRA_PERMISSION_GROUP_NAME} .
2322      * </p>
2323      * <p>
2324      * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group name
2325      * that will be displayed by the launched UI.  Do not pass both this and
2326      * {@link #EXTRA_PERMISSION_NAME}.
2327      * </p>
2328      * <p>
2329      * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent
2330      * activity to show (optional).  Must be non-negative.
2331      * </p>
2332      * <p>
2333      * Output: Nothing.
2334      * </p>
2335      * <p class="note">
2336      * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission.
2337      * </p>
2338      *
2339      * @see #EXTRA_PERMISSION_NAME
2340      * @see #EXTRA_PERMISSION_GROUP_NAME
2341      * @see #EXTRA_DURATION_MILLIS
2342      *
2343      * @hide
2344      */
2345     @SystemApi
2346     @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
2347     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2348     public static final String ACTION_REVIEW_PERMISSION_USAGE =
2349             "android.intent.action.REVIEW_PERMISSION_USAGE";
2350 
2351     /**
2352      * Activity action: Launch UI to review the timeline history of permissions.
2353      * <p>
2354      * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group name
2355      * that will be displayed by the launched UI.
2356      * </p>
2357      * <p>
2358      * Output: Nothing.
2359      * </p>
2360      * <p class="note">
2361      * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission.
2362      * </p>
2363      *
2364      * @see #EXTRA_PERMISSION_GROUP_NAME
2365      *
2366      * @hide
2367      */
2368     @SystemApi
2369     @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
2370     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2371     public static final String ACTION_REVIEW_PERMISSION_HISTORY =
2372             "android.intent.action.REVIEW_PERMISSION_HISTORY";
2373 
2374     /**
2375      * Activity action: Launch UI to review ongoing app uses of permissions.
2376      * <p>
2377      * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent
2378      * activity to show (optional).  Must be non-negative.
2379      * </p>
2380      * <p>
2381      * Output: Nothing.
2382      * </p>
2383      * <p class="note">
2384      * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission.
2385      * </p>
2386      *
2387      * @see #EXTRA_DURATION_MILLIS
2388      *
2389      * @hide
2390      */
2391     @SystemApi
2392     @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
2393     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2394     public static final String ACTION_REVIEW_ONGOING_PERMISSION_USAGE =
2395             "android.intent.action.REVIEW_ONGOING_PERMISSION_USAGE";
2396 
2397     /**
2398      * Activity action: Launch UI to review running accessibility services.
2399      * <p>
2400      * Input: Nothing.
2401      * </p>
2402      * <p>
2403      * Output: Nothing.
2404      * </p>
2405      *
2406      * @hide
2407      */
2408     @SystemApi
2409     @RequiresPermission(android.Manifest.permission.REVIEW_ACCESSIBILITY_SERVICES)
2410     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2411     public static final String ACTION_REVIEW_ACCESSIBILITY_SERVICES =
2412             "android.intent.action.REVIEW_ACCESSIBILITY_SERVICES";
2413 
2414     /**
2415      * Activity action: Launch UI to manage the usage of a given permission group.
2416      * This action would be handled by apps that want to show controls about the features
2417      * which use the permission group.
2418      *
2419      * <p>
2420      * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group for
2421      * which the launched UI would be targeted.
2422      * Input: {@link #EXTRA_ATTRIBUTION_TAGS} specifies the attribution tags for the usage entry.
2423      * Input: {@link #EXTRA_START_TIME} specifies the start time of the period (epoch time in
2424      * millis). If both start time and end time are present, start time must be <= end time.
2425      * Input: {@link #EXTRA_END_TIME} specifies the end time of the period (epoch time in
2426      * millis). If the end time is empty, that implies that the permission usage is still in use.
2427      * If both start time and end time are present, start time must be <= end time.
2428      * Input: {@link #EXTRA_SHOWING_ATTRIBUTION} specifies whether the subattribution was shown
2429      * in the UI.
2430      * </p>
2431      * <p>
2432      * Output: Nothing.
2433      * </p>
2434      * <p class="note">
2435      * You must protect the activity that handles this action with the
2436      * {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE} permission to ensure that
2437      * only the system can launch this activity. The system will not launch activities
2438      * that are not properly protected.
2439      * </p>
2440      *
2441      * @see #EXTRA_PERMISSION_GROUP_NAME
2442      * @see #EXTRA_ATTRIBUTION_TAGS
2443      * @see #EXTRA_START_TIME
2444      * @see #EXTRA_END_TIME
2445      * @see #EXTRA_SHOWING_ATTRIBUTION
2446      *
2447      * @hide
2448      */
2449     @SystemApi
2450     @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE)
2451     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2452     public static final String ACTION_MANAGE_PERMISSION_USAGE =
2453             "android.intent.action.MANAGE_PERMISSION_USAGE";
2454 
2455     /**
2456      * Activity action: Launch UI to view the app's feature's information.
2457      *
2458      * <p>
2459      * Output: Nothing.
2460      * </p>
2461      * <p class="note">
2462      * You must protect the activity that handles this action with the
2463      * {@link android.Manifest.permission#START_VIEW_APP_FEATURES} permission to ensure that
2464      * only the system can launch this activity. The system will not launch activities
2465      * that are not properly protected.
2466      *
2467      * An optional <meta-data> tag in the activity's manifest with
2468      * android:name=app_features_preference_summary and android:resource=@string/<string name> will
2469      * be used to add a summary line for the "All Services" preference in settings.
2470      * </p>
2471      * @hide
2472      */
2473     @SystemApi
2474     @RequiresPermission(android.Manifest.permission.START_VIEW_APP_FEATURES)
2475     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2476     public static final String ACTION_VIEW_APP_FEATURES =
2477             "android.intent.action.VIEW_APP_FEATURES";
2478 
2479     /**
2480      * Activity action: Launch UI to open the Safety Center, which highlights the user's security
2481      * and privacy status.
2482      */
2483     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2484     public static final String ACTION_SAFETY_CENTER =
2485             "android.intent.action.SAFETY_CENTER";
2486 
2487     /**
2488      * Activity action: Launch the UI to view recent updates that installed apps have made to their
2489      * data sharing policy in their safety labels.
2490      *
2491      * <p>
2492      * Input: Nothing.
2493      * </p>
2494      * <p>
2495      * Output: Nothing.
2496      * </p>
2497      *
2498      * <p class="note">
2499      * This intent action requires the {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS}
2500      * permission.
2501      * </p>
2502      *
2503      * @hide
2504      */
2505     @SystemApi
2506     @RequiresPermission(Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
2507     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2508     public static final String ACTION_REVIEW_APP_DATA_SHARING_UPDATES =
2509             "android.intent.action.REVIEW_APP_DATA_SHARING_UPDATES";
2510 
2511     // ---------------------------------------------------------------------
2512     // ---------------------------------------------------------------------
2513     // Standard intent broadcast actions (see action variable).
2514 
2515     /**
2516      * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
2517      * <p>
2518      * For historical reasons, the name of this broadcast action refers to the power
2519      * state of the screen but it is actually sent in response to changes in the
2520      * overall interactive state of the device.
2521      * </p><p>
2522      * This broadcast is sent when the device becomes non-interactive which may have
2523      * nothing to do with the screen turning off.  To determine the
2524      * actual state of the screen, use {@link android.view.Display#getState}.
2525      * </p><p>
2526      * See {@link android.os.PowerManager#isInteractive} for details.
2527      * </p>
2528      * You <em>cannot</em> receive this through components declared in
2529      * manifests, only by explicitly registering for it with
2530      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2531      * Context.registerReceiver()}.
2532      *
2533      * <p class="note">This is a protected intent that can only be sent
2534      * by the system.
2535      */
2536     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2537     public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
2538 
2539     /**
2540      * Broadcast Action: Sent when the device wakes up and becomes interactive.
2541      * <p>
2542      * For historical reasons, the name of this broadcast action refers to the power
2543      * state of the screen but it is actually sent in response to changes in the
2544      * overall interactive state of the device.
2545      * </p><p>
2546      * This broadcast is sent when the device becomes interactive which may have
2547      * nothing to do with the screen turning on.  To determine the
2548      * actual state of the screen, use {@link android.view.Display#getState}.
2549      * </p><p>
2550      * See {@link android.os.PowerManager#isInteractive} for details.
2551      * </p>
2552      * You <em>cannot</em> receive this through components declared in
2553      * manifests, only by explicitly registering for it with
2554      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2555      * Context.registerReceiver()}.
2556      *
2557      * <p class="note">This is a protected intent that can only be sent
2558      * by the system.
2559      */
2560     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2561     public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
2562 
2563     /**
2564      * Broadcast Action: Sent after the system stops dreaming.
2565      *
2566      * <p class="note">This is a protected intent that can only be sent by the system.
2567      * It is only sent to registered receivers.</p>
2568      */
2569     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2570     public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
2571 
2572     /**
2573      * Broadcast Action: Sent after the system starts dreaming.
2574      *
2575      * <p class="note">This is a protected intent that can only be sent by the system.
2576      * It is only sent to registered receivers.</p>
2577      */
2578     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2579     public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
2580 
2581     /**
2582      * Broadcast Action: Sent when the user is present after device wakes up (e.g when the
2583      * keyguard is gone).
2584      *
2585      * <p class="note">This is a protected intent that can only be sent
2586      * by the system.
2587      */
2588     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2589     public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
2590 
2591     /**
2592      * Broadcast Action: The current time has changed.  Sent every
2593      * minute.  You <em>cannot</em> receive this through components declared
2594      * in manifests, only by explicitly registering for it with
2595      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2596      * Context.registerReceiver()}.
2597      *
2598      * <p class="note">This is a protected intent that can only be sent
2599      * by the system.
2600      */
2601     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2602     public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
2603     /**
2604      * Broadcast Action: The time was set.
2605      */
2606     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2607     public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
2608     /**
2609      * Broadcast Action: The date has changed.
2610      */
2611     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2612     public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
2613     /**
2614      * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
2615      * <ul>
2616      *   <li>{@link #EXTRA_TIMEZONE} - The java.util.TimeZone.getID() value identifying the new
2617      *   time zone.</li>
2618      * </ul>
2619      *
2620      * <p class="note">This is a protected intent that can only be sent
2621      * by the system.
2622      */
2623     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2624     public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2625     /**
2626      * Alarm Changed Action: This is broadcast when the AlarmClock
2627      * application's alarm is set or unset.  It is used by the
2628      * AlarmClock application and the StatusBar service.
2629      * @hide
2630      */
2631     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2632     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
2633     public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
2634 
2635     /**
2636      * Broadcast Action: This is broadcast once, after the user has finished
2637      * booting, but while still in the "locked" state. It can be used to perform
2638      * application-specific initialization, such as installing alarms. You must
2639      * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2640      * permission in order to receive this broadcast.
2641      * <p>
2642      * This broadcast is sent immediately at boot by all devices (regardless of
2643      * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2644      * higher. Upon receipt of this broadcast, the user is still locked and only
2645      * device-protected storage can be accessed safely. If you want to access
2646      * credential-protected storage, you need to wait for the user to be
2647      * unlocked (typically by entering their lock pattern or PIN for the first
2648      * time), after which the {@link #ACTION_USER_UNLOCKED} and
2649      * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2650      * <p>
2651      * To receive this broadcast, your receiver component must be marked as
2652      * being {@link ComponentInfo#directBootAware}.
2653      * <p class="note">
2654      * This is a protected intent that can only be sent by the system.
2655      *
2656      * @see Context#createDeviceProtectedStorageContext()
2657      */
2658     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2659     public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2660 
2661     /**
2662      * Broadcast Action: This is broadcast once, after the user has finished
2663      * booting. It can be used to perform application-specific initialization,
2664      * such as installing alarms. You must hold the
2665      * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2666      * order to receive this broadcast.
2667      * <p>
2668      * This broadcast is sent at boot by all devices (both with and without
2669      * direct boot support). Upon receipt of this broadcast, the user is
2670      * unlocked and both device-protected and credential-protected storage can
2671      * accessed safely.
2672      * <p>
2673      * If you need to run while the user is still locked (before they've entered
2674      * their lock pattern or PIN for the first time), you can listen for the
2675      * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2676      * <p class="note">
2677      * This is a protected intent that can only be sent by the system.
2678      */
2679     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2680     @BroadcastBehavior(includeBackground = true)
2681     public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
2682 
2683     /**
2684      * Broadcast Action: This is broadcast when a user action should request a
2685      * temporary system dialog to dismiss.  Some examples of temporary system
2686      * dialogs are the notification window-shade and the recent tasks dialog.
2687      *
2688      * @deprecated This intent is deprecated for third-party applications starting from Android
2689      *     {@link Build.VERSION_CODES#S} for security reasons. Unauthorized usage by applications
2690      *     will result in the broadcast intent being dropped for apps targeting API level less than
2691      *     {@link Build.VERSION_CODES#S} and in a {@link SecurityException} for apps targeting SDK
2692      *     level {@link Build.VERSION_CODES#S} or higher. Instrumentation initiated from the shell
2693      *     (eg. tests) is still able to use the intent. The platform will automatically collapse
2694      *     the proper system dialogs in the proper use-cases. For all others, the user is the one in
2695      *     control of closing dialogs.
2696      *
2697      * @see AccessibilityService#GLOBAL_ACTION_DISMISS_NOTIFICATION_SHADE
2698      */
2699     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2700     @RequiresPermission(android.Manifest.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS)
2701     @Deprecated
2702     public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2703     /**
2704      * Broadcast Action: Trigger the download and eventual installation
2705      * of a package.
2706      * <p>Input: {@link #getData} is the URI of the package file to download.
2707      *
2708      * <p class="note">This is a protected intent that can only be sent
2709      * by the system.
2710      *
2711      * @deprecated This constant has never been used.
2712      */
2713     @Deprecated
2714     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2715     public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2716     /**
2717      * Broadcast Action: A new application package has been installed on the
2718      * device. The data contains the name of the package.  Note that the
2719      * newly installed package does <em>not</em> receive this broadcast.
2720      * <p>May include the following extras:
2721      * <ul>
2722      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2723      * <li> {@link #EXTRA_REPLACING} is set to true if this is following
2724      * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2725      * </ul>
2726      *
2727      * <p class="note">This is a protected intent that can only be sent
2728      * by the system.
2729      */
2730     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2731     public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2732     /**
2733      * Broadcast Action: A new version of an application package has been
2734      * installed, replacing an existing version that was previously installed.
2735      * The data contains the name of the package.
2736      * <p>May include the following extras:
2737      * <ul>
2738      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2739      * </ul>
2740      *
2741      * <p class="note">This is a protected intent that can only be sent
2742      * by the system.
2743      */
2744     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2745     public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2746     /**
2747      * Broadcast Action: A new version of your application has been installed
2748      * over an existing one.  This is only sent to the application that was
2749      * replaced.  It does not contain any additional data; to receive it, just
2750      * use an intent filter for this action.
2751      *
2752      * <p class="note">This is a protected intent that can only be sent
2753      * by the system.
2754      */
2755     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2756     public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2757     /**
2758      * Broadcast Action: An existing application package has been removed from
2759      * the device.  The data contains the name of the package.  The package
2760      * that is being removed does <em>not</em> receive this Intent.
2761      * <ul>
2762      * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2763      * to the package.
2764      * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2765      * application -- data and code -- is being removed.
2766      * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2767      * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2768      * <li> {@link #EXTRA_USER_INITIATED} containing boolean field to signal that the application
2769      * was removed with the user-initiated action.
2770      * </ul>
2771      *
2772      * <p class="note">This is a protected intent that can only be sent
2773      * by the system.
2774      */
2775     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2776     public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2777     /**
2778      * Broadcast Action: An existing application package has been removed from
2779      * the device. The data contains the name of the package and the visibility
2780      * allow list. The package that is being removed does <em>not</em> receive
2781      * this Intent.
2782      * <ul>
2783      * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2784      * to the package.
2785      * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2786      * application -- data and code -- is being removed.
2787      * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2788      * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2789      * <li> {@link #EXTRA_USER_INITIATED} containing boolean field to signal
2790      * that the application was removed with the user-initiated action.
2791      * <li> {@link #EXTRA_VISIBILITY_ALLOW_LIST} containing an int array to
2792      * indicate the visibility allow list.
2793      * </ul>
2794      *
2795      * <p class="note">This is a protected intent that can only be sent
2796      * by the system.
2797      *
2798      * @hide This broadcast is used internally by the system.
2799      */
2800     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2801     public static final String ACTION_PACKAGE_REMOVED_INTERNAL =
2802             "android.intent.action.PACKAGE_REMOVED_INTERNAL";
2803     /**
2804      * Broadcast Action: An existing application package has been completely
2805      * removed from the device.  The data contains the name of the package.
2806      * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2807      * {@link #EXTRA_DATA_REMOVED} is true and
2808      * {@link #EXTRA_REPLACING} is false of that broadcast.
2809      *
2810      * <ul>
2811      * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2812      * to the package.
2813      * </ul>
2814      *
2815      * <p class="note">This is a protected intent that can only be sent
2816      * by the system.
2817      */
2818     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2819     public static final String ACTION_PACKAGE_FULLY_REMOVED
2820             = "android.intent.action.PACKAGE_FULLY_REMOVED";
2821     /**
2822      * Broadcast Action: An existing application package has been changed (for
2823      * example, a component has been enabled or disabled).  The data contains
2824      * the name of the package.
2825      * <ul>
2826      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2827      * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
2828      * of the changed components (or the package name itself).
2829      * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2830      * default action of restarting the application.
2831      * </ul>
2832      *
2833      * <p class="note">This is a protected intent that can only be sent
2834      * by the system.
2835      */
2836     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2837     public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2838 
2839     /**
2840      * Broadcast Action: An application package that was previously in the stopped state has been
2841      * started and is no longer considered stopped.
2842      * <p>When a package is force-stopped, the {@link #ACTION_PACKAGE_RESTARTED} broadcast is sent
2843      * and the package in the stopped state cannot self-start for any reason unless there's an
2844      * explicit request to start a component in the package. The {@link #ACTION_PACKAGE_UNSTOPPED}
2845      * broadcast is sent when such an explicit process start occurs and the package is taken
2846      * out of the stopped state. The data contains the name of the package.
2847      * </p>
2848      * <ul>
2849      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2850      * <li> {@link #EXTRA_TIME} containing the {@link SystemClock#elapsedRealtime()
2851      *          elapsed realtime} of when the package was unstopped.
2852      * </ul>
2853      *
2854      * <p class="note">This is a protected intent that can only be sent by the system.
2855      *
2856      * @see ApplicationInfo#FLAG_STOPPED
2857      * @see #ACTION_PACKAGE_RESTARTED
2858      */
2859     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2860     @FlaggedApi(android.content.pm.Flags.FLAG_STAY_STOPPED)
2861     public static final String ACTION_PACKAGE_UNSTOPPED = "android.intent.action.PACKAGE_UNSTOPPED";
2862 
2863     /**
2864      * Broadcast Action: Sent to the system rollback manager when a package
2865      * needs to have rollback enabled.
2866      * <p class="note">
2867      * This is a protected intent that can only be sent by the system.
2868      * </p>
2869      *
2870      * @hide This broadcast is used internally by the system.
2871      */
2872     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2873     public static final String ACTION_PACKAGE_ENABLE_ROLLBACK =
2874             "android.intent.action.PACKAGE_ENABLE_ROLLBACK";
2875     /**
2876      * Broadcast Action: Sent to the system rollback manager when the rollback for a certain
2877      * package needs to be cancelled.
2878      *
2879      * <p class="note">This intent is sent by PackageManagerService to notify RollbackManager
2880      * that enabling a specific rollback has timed out.
2881      *
2882      * @hide
2883      */
2884     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2885     public static final String ACTION_CANCEL_ENABLE_ROLLBACK =
2886             "android.intent.action.CANCEL_ENABLE_ROLLBACK";
2887     /**
2888      * Broadcast Action: A rollback has been committed.
2889      *
2890      * <p class="note">This is a protected intent that can only be sent
2891      * by the system. The receiver must hold MANAGE_ROLLBACK permission.
2892      *
2893      * @hide
2894      */
2895     @SystemApi
2896     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2897     public static final String ACTION_ROLLBACK_COMMITTED =
2898             "android.intent.action.ROLLBACK_COMMITTED";
2899     /**
2900      * @hide
2901      * Broadcast Action: Ask system services if there is any reason to
2902      * restart the given package.  The data contains the name of the
2903      * package.
2904      * <ul>
2905      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2906      * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2907      * </ul>
2908      *
2909      * <p class="note">This is a protected intent that can only be sent
2910      * by the system.
2911      */
2912     @SystemApi
2913     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2914     public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2915     /**
2916      * Broadcast Action: The user has restarted a package, and all of its
2917      * processes have been killed.  All runtime state
2918      * associated with it (processes, alarms, notifications, etc) should
2919      * be removed.  Note that the restarted package does <em>not</em>
2920      * receive this broadcast.
2921      * The data contains the name of the package.
2922      * <ul>
2923      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2924      * </ul>
2925      *
2926      * <p class="note">This is a protected intent that can only be sent
2927      * by the system.
2928      * <p>
2929      * Starting in Android V, an extra timestamp
2930      * {@link #EXTRA_TIME} is included with this broadcast to indicate the exact time the package
2931      * was restarted, in {@link SystemClock#elapsedRealtime() elapsed realtime}.
2932      * </p>
2933      */
2934     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2935     public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2936 
2937     /**
2938      * Broadcast Action: The user has cleared the data of a package.  This should
2939      * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
2940      * its persistent data is erased and this broadcast sent.
2941      * Note that the cleared package does <em>not</em>
2942      * receive this broadcast. The data contains the name of the package.
2943      * <ul>
2944      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2945      *      package whose data was cleared is an uninstalled instant app, then the UID
2946      *      will be -1. The platform keeps some meta-data associated with instant apps
2947      *      after they are uninstalled.
2948      * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2949      *      data was for an instant app.
2950      * </ul>
2951      *
2952      * <p class="note">This is a protected intent that can only be sent
2953      * by the system.
2954      */
2955     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2956     public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2957     /**
2958      * Broadcast Action: Packages have been suspended.
2959      * <p>Includes the following extras:
2960      * <ul>
2961      * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2962      * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been suspended
2963      * </ul>
2964      *
2965      * <p class="note">This is a protected intent that can only be sent
2966      * by the system. It is only sent to registered receivers.
2967      */
2968     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2969     public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2970     /**
2971      * Broadcast Action: Packages have been unsuspended.
2972      * <p>Includes the following extras:
2973      * <ul>
2974      * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2975      * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been unsuspended
2976      * </ul>
2977      *
2978      * <p class="note">This is a protected intent that can only be sent
2979      * by the system. It is only sent to registered receivers.
2980      */
2981     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2982     public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2983     /**
2984      * Broadcast Action: One of the suspend conditions have been modified for the packages.
2985      * <p>Includes the following extras:
2986      * <ul>
2987      * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been modified
2988      * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been modified
2989      * </ul>
2990      *
2991      * <p class="note">This is a protected intent that can only be sent
2992      * by the system. It is only sent to registered receivers.
2993      *
2994      * @hide
2995      */
2996     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2997     public static final String ACTION_PACKAGES_SUSPENSION_CHANGED =
2998             "android.intent.action.PACKAGES_SUSPENSION_CHANGED";
2999 
3000     /**
3001      * Broadcast Action: Distracting packages have been changed.
3002      * <p>Includes the following extras:
3003      * <ul>
3004      * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been changed.
3005      * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been changed.
3006      * <li> {@link #EXTRA_DISTRACTION_RESTRICTIONS} the new restrictions set on these packages.
3007      * </ul>
3008      *
3009      * <p class="note">This is a protected intent that can only be sent
3010      * by the system. It is only sent to registered receivers.
3011      *
3012      * @see PackageManager#setDistractingPackageRestrictions(String[], int)
3013      * @hide
3014      */
3015     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3016     public static final String ACTION_DISTRACTING_PACKAGES_CHANGED =
3017             "android.intent.action.DISTRACTING_PACKAGES_CHANGED";
3018 
3019     /**
3020      * Broadcast Action: Sent to a package that has been suspended by the system. This is sent
3021      * whenever a package is put into a suspended state or any of its app extras change while in the
3022      * suspended state.
3023      * <p> Optionally includes the following extras:
3024      * <ul>
3025      *     <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain
3026      *     useful information for the app being suspended.
3027      * </ul>
3028      * <p class="note">This is a protected intent that can only be sent
3029      * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
3030      * the manifest.</em>
3031      *
3032      * @see #ACTION_MY_PACKAGE_UNSUSPENDED
3033      * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
3034      * @see PackageManager#isPackageSuspended()
3035      * @see PackageManager#getSuspendedPackageAppExtras()
3036      */
3037     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3038     public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED";
3039 
3040     /**
3041      * Activity Action: Started to show more details about why an application was suspended.
3042      *
3043      * <p>Whenever the system detects an activity launch for a suspended app, this action can
3044      * be used to show more details about the reason for suspension.
3045      *
3046      * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity
3047      * handling this intent and protect it with
3048      * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}.
3049      *
3050      * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package.
3051      *
3052      * <p class="note">This is a protected intent that can only be sent
3053      * by the system.
3054      *
3055      * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
3056      * PersistableBundle, String)
3057      * @see PackageManager#isPackageSuspended()
3058      * @see #ACTION_PACKAGES_SUSPENDED
3059      *
3060      * @hide
3061      */
3062     @SystemApi
3063     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3064     public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS =
3065             "android.intent.action.SHOW_SUSPENDED_APP_DETAILS";
3066 
3067     /**
3068      * Broadcast Action: Sent to indicate that the user unsuspended a package.
3069      *
3070      * <p>This can happen when the user taps on the neutral button of the
3071      * {@linkplain SuspendDialogInfo suspend-dialog} which was created by using
3072      * {@link SuspendDialogInfo#BUTTON_ACTION_UNSUSPEND}. This broadcast is only sent to the
3073      * suspending app that originally specified this dialog while calling
3074      * {@link PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
3075      * PersistableBundle, SuspendDialogInfo)}.
3076      *
3077      * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the package that just
3078      * got unsuspended.
3079      *
3080      * <p class="note">This is a protected intent that can only be sent
3081      * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
3082      * the manifest.</em>
3083      *
3084      * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
3085      * PersistableBundle, SuspendDialogInfo)
3086      * @see PackageManager#isPackageSuspended()
3087      * @see SuspendDialogInfo#BUTTON_ACTION_MORE_DETAILS
3088      * @hide
3089      */
3090     @SystemApi
3091     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3092     public static final String ACTION_PACKAGE_UNSUSPENDED_MANUALLY =
3093             "android.intent.action.PACKAGE_UNSUSPENDED_MANUALLY";
3094 
3095     /**
3096      * Broadcast Action: Sent to a package that has been unsuspended.
3097      *
3098      * <p class="note">This is a protected intent that can only be sent
3099      * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
3100      * the manifest.</em>
3101      *
3102      * @see #ACTION_MY_PACKAGE_SUSPENDED
3103      * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
3104      * @see PackageManager#isPackageSuspended()
3105      * @see PackageManager#getSuspendedPackageAppExtras()
3106      */
3107     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3108     public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED";
3109 
3110     /**
3111      * Broadcast Action: A uid has been removed from the system.  The uid
3112      * number is stored in the extra data under {@link #EXTRA_UID}.
3113      *
3114      * In certain instances, {@link #EXTRA_REPLACING} is set to true if the UID is not being
3115      * fully removed.
3116      *
3117      * <p class="note">This is a protected intent that can only be sent
3118      * by the system.
3119      */
3120     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3121     public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
3122 
3123     /**
3124      * Broadcast Action: Sent to the installer package of an application when
3125      * that application is first launched (that is the first time it is moved
3126      * out of the stopped state).  The data contains the name of the package.
3127      *
3128      * <p>When the application is first launched, the application itself doesn't receive this
3129      * broadcast.</p>
3130      *
3131      * <p class="note">This is a protected intent that can only be sent
3132      * by the system.
3133      */
3134     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3135     public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
3136 
3137     /**
3138      * Broadcast Action: Sent to the system package verifier when a package
3139      * needs to be verified. The data contains the package URI.
3140      * <p class="note">
3141      * This is a protected intent that can only be sent by the system.
3142      * </p>
3143      */
3144     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3145     public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
3146 
3147     /**
3148      * Broadcast Action: Sent to the system package verifier when a package is
3149      * verified. The data contains the package URI.
3150      * <p class="note">
3151      * This is a protected intent that can only be sent by the system.
3152      */
3153     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3154     public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
3155 
3156     /**
3157      * Broadcast Action: Sent to the system intent filter verifier when an
3158      * intent filter needs to be verified. The data contains the filter data
3159      * hosts to be verified against.
3160      * <p class="note">
3161      * This is a protected intent that can only be sent by the system.
3162      * </p>
3163      *
3164      * @hide
3165      * @deprecated Superseded by domain verification APIs. See {@link DomainVerificationManager}.
3166      */
3167     @Deprecated
3168     @SystemApi
3169     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3170     public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION =
3171             "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
3172 
3173 
3174     /**
3175      * Broadcast Action: Sent to the system domain verification agent when an app's domains need
3176      * to be verified. The data contains the domains hosts to be verified against.
3177      * <p class="note">
3178      * This is a protected intent that can only be sent by the system.
3179      * </p>
3180      *
3181      * @hide
3182      */
3183     @SystemApi
3184     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3185     public static final String ACTION_DOMAINS_NEED_VERIFICATION =
3186             "android.intent.action.DOMAINS_NEED_VERIFICATION";
3187 
3188     /**
3189      * Broadcast Action: Resources for a set of packages (which were
3190      * previously unavailable) are currently
3191      * available since the media on which they exist is available.
3192      * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
3193      * list of packages whose availability changed.
3194      * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
3195      * list of uids of packages whose availability changed.
3196      * Note that the
3197      * packages in this list do <em>not</em> receive this broadcast.
3198      * The specified set of packages are now available on the system.
3199      * <p>Includes the following extras:
3200      * <ul>
3201      * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
3202      * whose resources(were previously unavailable) are currently available.
3203      * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
3204      * packages whose resources(were previously unavailable)
3205      * are  currently available.
3206      * </ul>
3207      *
3208      * <p class="note">This is a protected intent that can only be sent
3209      * by the system.
3210      */
3211     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3212     public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
3213         "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
3214 
3215     /**
3216      * Broadcast Action: Resources for a set of packages are currently
3217      * unavailable since the media on which they exist is unavailable.
3218      * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
3219      * list of packages whose availability changed.
3220      * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
3221      * list of uids of packages whose availability changed.
3222      * The specified set of packages can no longer be
3223      * launched and are practically unavailable on the system.
3224      * <p>Inclues the following extras:
3225      * <ul>
3226      * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
3227      * whose resources are no longer available.
3228      * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
3229      * whose resources are no longer available.
3230      * </ul>
3231      *
3232      * <p class="note">This is a protected intent that can only be sent
3233      * by the system.
3234      */
3235     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3236     public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
3237         "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
3238 
3239     /**
3240      * Broadcast Action: preferred activities have changed *explicitly*.
3241      *
3242      * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
3243      * when an app is installed or uninstalled, but in such cases this broadcast will *not*
3244      * be sent.
3245      *
3246      * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
3247      *
3248      * @hide
3249      */
3250     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3251     public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
3252             "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
3253 
3254 
3255     /**
3256      * Broadcast Action:  The current system wallpaper has changed.  See
3257      * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
3258      * This should <em>only</em> be used to determine when the wallpaper
3259      * has changed to show the new wallpaper to the user.  You should certainly
3260      * never, in response to this, change the wallpaper or other attributes of
3261      * it such as the suggested size.  That would be unexpected, right?  You'd cause
3262      * all kinds of loops, especially if other apps are doing similar things,
3263      * right?  Of course.  So please don't do this.
3264      *
3265      * @deprecated Modern applications should use
3266      * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
3267      * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
3268      * shown behind their UI, rather than watching for this broadcast and
3269      * rendering the wallpaper on their own.
3270      */
3271     @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3272     public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
3273     /**
3274      * Broadcast Action: The current device {@link android.content.res.Configuration}
3275      * (orientation, locale, etc) has changed.  When such a change happens, the
3276      * UIs (view hierarchy) will need to be rebuilt based on this new
3277      * information; for the most part, applications don't need to worry about
3278      * this, because the system will take care of stopping and restarting the
3279      * application to make sure it sees the new changes.  Some system code that
3280      * can not be restarted will need to watch for this action and handle it
3281      * appropriately.
3282      *
3283      * <p class="note">
3284      * You <em>cannot</em> receive this through components declared
3285      * in manifests, only by explicitly registering for it with
3286      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3287      * Context.registerReceiver()}.
3288      *
3289      * <p class="note">This is a protected intent that can only be sent
3290      * by the system.
3291      *
3292      * @see android.content.res.Configuration
3293      */
3294     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3295     public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
3296 
3297     /**
3298      * Broadcast Action: The current device {@link android.content.res.Configuration} has changed
3299      * such that the device may be eligible for the installation of additional configuration splits.
3300      * Configuration properties that can trigger this broadcast include locale and display density.
3301      *
3302      * <p class="note">
3303      * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through
3304      * components declared in manifests. However, the receiver <em>must</em> hold the
3305      * {@link android.Manifest.permission#INSTALL_PACKAGES} permission.
3306      *
3307      * <p class="note">
3308      * This is a protected intent that can only be sent by the system.
3309      *
3310      * @hide
3311      */
3312     @SystemApi
3313     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3314     public static final String ACTION_SPLIT_CONFIGURATION_CHANGED =
3315             "android.intent.action.SPLIT_CONFIGURATION_CHANGED";
3316     /**
3317      * Broadcast Action: The receiver's effective locale has changed.
3318      *
3319      * This happens when the device locale, the receiving app's locale
3320      * (set via {@link android.app.LocaleManager#setApplicationLocales}) or language tags
3321      * of Regional preferences changed.
3322      *
3323      * Can be received by manifest-declared receivers.
3324      *
3325      * <p class="note"> If only the app locale changed, includes the following extras:
3326      * <ul>
3327      * <li>{@link #EXTRA_PACKAGE_NAME} is the name of the package for which locale changed.
3328      * <li>{@link #EXTRA_LOCALE_LIST} contains locales that are currently set for specified app
3329      * </ul>
3330      *
3331      * <p class="note">This is a protected intent that can only be sent
3332      * by the system.
3333      */
3334     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3335     public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
3336     /**
3337      * Broadcast Action: Locale of a particular app has changed.
3338      *
3339      * <p class="note"> This broadcast is explicitly sent to the
3340      * {@link android.content.pm.InstallSourceInfo#getInstallingPackageName} installer
3341      *     of the app whose locale has changed.
3342      * <p class="note"> The broadcast could also be received by manifest-declared receivers with
3343      * {@code android.permission.READ_APP_SPECIFIC_LOCALES}
3344      *
3345      * <p class="note">This is a protected intent that can only be sent
3346      * by the system.
3347      *
3348      * <p>Includes the following extras:
3349      * <ul>
3350      * <li>{@link #EXTRA_PACKAGE_NAME} is the name of the package for which locale changed.
3351      * <li>{@link #EXTRA_LOCALE_LIST} contains locales that are currently set for specified app
3352      * </ul>
3353      */
3354     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3355     public static final String ACTION_APPLICATION_LOCALE_CHANGED =
3356             "android.intent.action.APPLICATION_LOCALE_CHANGED";
3357     /**
3358      * Broadcast Action:  This is a <em>sticky broadcast</em> containing the
3359      * charging state, level, and other information about the battery.
3360      * See {@link android.os.BatteryManager} for documentation on the
3361      * contents of the Intent.
3362      *
3363      * <p class="note">
3364      * You <em>cannot</em> receive this through components declared
3365      * in manifests, only by explicitly registering for it with
3366      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3367      * Context.registerReceiver()}.  See {@link #ACTION_BATTERY_LOW},
3368      * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
3369      * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
3370      * broadcasts that are sent and can be received through manifest
3371      * receivers.
3372      *
3373      * <p class="note">This is a protected intent that can only be sent
3374      * by the system.
3375      */
3376     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3377     public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
3378 
3379 
3380     /**
3381      * Broadcast Action: Sent when the current battery level or plug type changes.
3382      *
3383      * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle}
3384      * instances representing individual battery level changes with associated
3385      * extras from {@link #ACTION_BATTERY_CHANGED}.
3386      *
3387      * <p class="note">
3388      * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission.
3389      *
3390      * @hide
3391      */
3392     @SystemApi
3393     public static final String ACTION_BATTERY_LEVEL_CHANGED =
3394             "android.intent.action.BATTERY_LEVEL_CHANGED";
3395     /**
3396      * Broadcast Action:  Indicates low battery condition on the device.
3397      * This broadcast corresponds to the "Low battery warning" system dialog.
3398      *
3399      * <p class="note">This is a protected intent that can only be sent
3400      * by the system.
3401      */
3402     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3403     public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
3404     /**
3405      * Broadcast Action:  Indicates the battery is now okay after being low.
3406      * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
3407      * gone back up to an okay state.
3408      *
3409      * <p class="note">This is a protected intent that can only be sent
3410      * by the system.
3411      */
3412     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3413     public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
3414     /**
3415      * Broadcast Action:  External power has been connected to the device.
3416      * This is intended for applications that wish to register specifically to this notification.
3417      * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
3418      * stay active to receive this notification.  This action can be used to implement actions
3419      * that wait until power is available to trigger.
3420      *
3421      * <p class="note">This is a protected intent that can only be sent
3422      * by the system.
3423      */
3424     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3425     public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
3426     /**
3427      * Broadcast Action:  External power has been removed from the device.
3428      * This is intended for applications that wish to register specifically to this notification.
3429      * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
3430      * stay active to receive this notification.  This action can be used to implement actions
3431      * that wait until power is available to trigger.
3432      *
3433      * <p class="note">This is a protected intent that can only be sent
3434      * by the system.
3435      */
3436     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3437     public static final String ACTION_POWER_DISCONNECTED =
3438             "android.intent.action.ACTION_POWER_DISCONNECTED";
3439     /**
3440      * Broadcast Action:  Device is shutting down.
3441      * This is broadcast when the device is being shut down (completely turned
3442      * off, not sleeping).  Once the broadcast is complete, the final shutdown
3443      * will proceed and all unsaved data lost.  Apps will not normally need
3444      * to handle this, since the foreground activity will be paused as well.
3445      * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered
3446      * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3447      * Context.registerReceiver}.
3448      *
3449      * <p class="note">This is a protected intent that can only be sent
3450      * by the system.
3451      * <p>May include the following extras:
3452      * <ul>
3453      * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
3454      * shutdown is only for userspace processes.  If not set, assumed to be false.
3455      * </ul>
3456      */
3457     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3458     public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
3459     /**
3460      * Activity Action:  Start this activity to request system shutdown.
3461      * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
3462      * to request confirmation from the user before shutting down. The optional boolean
3463      * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
3464      * indicate that the shutdown is requested by the user.
3465      *
3466      * <p class="note">This is a protected intent that can only be sent
3467      * by the system.
3468      *
3469      * {@hide}
3470      */
3471     public static final String ACTION_REQUEST_SHUTDOWN
3472             = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
3473     /**
3474      * Broadcast Action: A sticky broadcast that indicates low storage space
3475      * condition on the device
3476      * <p class="note">
3477      * This is a protected intent that can only be sent by the system.
3478      *
3479      * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3480      *             or above, this broadcast will no longer be delivered to any
3481      *             {@link BroadcastReceiver} defined in your manifest. Instead,
3482      *             apps are strongly encouraged to use the improved
3483      *             {@link Context#getCacheDir()} behavior so the system can
3484      *             automatically free up storage when needed.
3485      */
3486     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3487     @Deprecated
3488     public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
3489     /**
3490      * Broadcast Action: Indicates low storage space condition on the device no
3491      * longer exists
3492      * <p class="note">
3493      * This is a protected intent that can only be sent by the system.
3494      *
3495      * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3496      *             or above, this broadcast will no longer be delivered to any
3497      *             {@link BroadcastReceiver} defined in your manifest. Instead,
3498      *             apps are strongly encouraged to use the improved
3499      *             {@link Context#getCacheDir()} behavior so the system can
3500      *             automatically free up storage when needed.
3501      */
3502     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3503     @Deprecated
3504     public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
3505     /**
3506      * Broadcast Action: A sticky broadcast that indicates a storage space full
3507      * condition on the device. This is intended for activities that want to be
3508      * able to fill the data partition completely, leaving only enough free
3509      * space to prevent system-wide SQLite failures.
3510      * <p class="note">
3511      * This is a protected intent that can only be sent by the system.
3512      *
3513      * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3514      *             or above, this broadcast will no longer be delivered to any
3515      *             {@link BroadcastReceiver} defined in your manifest. Instead,
3516      *             apps are strongly encouraged to use the improved
3517      *             {@link Context#getCacheDir()} behavior so the system can
3518      *             automatically free up storage when needed.
3519      * @hide
3520      */
3521     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3522     @Deprecated
3523     public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
3524     /**
3525      * Broadcast Action: Indicates storage space full condition on the device no
3526      * longer exists.
3527      * <p class="note">
3528      * This is a protected intent that can only be sent by the system.
3529      *
3530      * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3531      *             or above, this broadcast will no longer be delivered to any
3532      *             {@link BroadcastReceiver} defined in your manifest. Instead,
3533      *             apps are strongly encouraged to use the improved
3534      *             {@link Context#getCacheDir()} behavior so the system can
3535      *             automatically free up storage when needed.
3536      * @hide
3537      */
3538     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3539     @Deprecated
3540     public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
3541     /**
3542      * Broadcast Action:  Indicates low memory condition notification acknowledged by user
3543      * and package management should be started.
3544      * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
3545      * notification.
3546      */
3547     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3548     public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
3549     /**
3550      * Broadcast Action:  The device has entered USB Mass Storage mode.
3551      * This is used mainly for the USB Settings panel.
3552      * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
3553      * when the SD card file system is mounted or unmounted
3554      * @deprecated replaced by android.os.storage.StorageEventListener
3555      */
3556     @Deprecated
3557     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3558     public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
3559 
3560     /**
3561      * Broadcast Action:  The device has exited USB Mass Storage mode.
3562      * This is used mainly for the USB Settings panel.
3563      * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
3564      * when the SD card file system is mounted or unmounted
3565      * @deprecated replaced by android.os.storage.StorageEventListener
3566      */
3567     @Deprecated
3568     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3569     public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
3570 
3571     /**
3572      * Broadcast Action:  External media has been removed.
3573      * The path to the mount point for the removed media is contained in the Intent.mData field.
3574      */
3575     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3576     public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
3577 
3578     /**
3579      * Broadcast Action:  External media is present, but not mounted at its mount point.
3580      * The path to the mount point for the unmounted media is contained in the Intent.mData field.
3581      */
3582     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3583     public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
3584 
3585     /**
3586      * Broadcast Action:  External media is present, and being disk-checked
3587      * The path to the mount point for the checking media is contained in the Intent.mData field.
3588      */
3589     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3590     public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
3591 
3592     /**
3593      * Broadcast Action:  External media is present, but is using an incompatible fs (or is blank)
3594      * The path to the mount point for the checking media is contained in the Intent.mData field.
3595      */
3596     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3597     public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
3598 
3599     /**
3600      * Broadcast Action:  External media is present and mounted at its mount point.
3601      * The path to the mount point for the mounted media is contained in the Intent.mData field.
3602      * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
3603      * media was mounted read only.
3604      */
3605     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3606     public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
3607 
3608     /**
3609      * Broadcast Action:  External media is unmounted because it is being shared via USB mass storage.
3610      * The path to the mount point for the shared media is contained in the Intent.mData field.
3611      */
3612     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3613     public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
3614 
3615     /**
3616      * Broadcast Action:  External media is no longer being shared via USB mass storage.
3617      * The path to the mount point for the previously shared media is contained in the Intent.mData field.
3618      *
3619      * @hide
3620      */
3621     public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
3622 
3623     /**
3624      * Broadcast Action:  External media was removed from SD card slot, but mount point was not unmounted.
3625      * The path to the mount point for the removed media is contained in the Intent.mData field.
3626      */
3627     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3628     public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
3629 
3630     /**
3631      * Broadcast Action:  External media is present but cannot be mounted.
3632      * The path to the mount point for the unmountable media is contained in the Intent.mData field.
3633      */
3634     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3635     public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
3636 
3637    /**
3638      * Broadcast Action:  User has expressed the desire to remove the external storage media.
3639      * Applications should close all files they have open within the mount point when they receive this intent.
3640      * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
3641      */
3642     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3643     public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
3644 
3645     /**
3646      * Broadcast Action:  The media scanner has started scanning a directory.
3647      * The path to the directory being scanned is contained in the Intent.mData field.
3648      */
3649     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3650     public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
3651 
3652    /**
3653      * Broadcast Action:  The media scanner has finished scanning a directory.
3654      * The path to the scanned directory is contained in the Intent.mData field.
3655      */
3656     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3657     public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
3658 
3659     /**
3660      * Broadcast Action: Request the media scanner to scan a file and add it to
3661      * the media database.
3662      * <p>
3663      * The path to the file is contained in {@link Intent#getData()}.
3664      *
3665      * @deprecated Callers should migrate to inserting items directly into
3666      *             {@link MediaStore}, where they will be automatically scanned
3667      *             after each mutation.
3668      */
3669     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3670     @Deprecated
3671     public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
3672 
3673    /**
3674      * Broadcast Action:  The "Media Button" was pressed.  Includes a single
3675      * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3676      * caused the broadcast.
3677      */
3678     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3679     public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
3680 
3681     /**
3682      * Broadcast Action:  The "Camera Button" was pressed.  Includes a single
3683      * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3684      * caused the broadcast.
3685      */
3686     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3687     public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
3688 
3689     // *** NOTE: @todo(*) The following really should go into a more domain-specific
3690     // location; they are not general-purpose actions.
3691 
3692     /**
3693      * Broadcast Action: A GTalk connection has been established.
3694      */
3695     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3696     public static final String ACTION_GTALK_SERVICE_CONNECTED =
3697             "android.intent.action.GTALK_CONNECTED";
3698 
3699     /**
3700      * Broadcast Action: A GTalk connection has been disconnected.
3701      */
3702     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3703     public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
3704             "android.intent.action.GTALK_DISCONNECTED";
3705 
3706     /**
3707      * Broadcast Action: An input method has been changed.
3708      */
3709     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3710     public static final String ACTION_INPUT_METHOD_CHANGED =
3711             "android.intent.action.INPUT_METHOD_CHANGED";
3712 
3713     /**
3714      * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
3715      * more radios have been turned off or on. The intent will have the following extra value:</p>
3716      * <ul>
3717      *   <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
3718      *   then cell radio and possibly other radios such as bluetooth or WiFi may have also been
3719      *   turned off</li>
3720      * </ul>
3721      *
3722      * <p class="note">This is a protected intent that can only be sent by the system.</p>
3723      */
3724     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3725     public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
3726 
3727     /**
3728      * Broadcast Action: Some content providers have parts of their namespace
3729      * where they publish new events or items that the user may be especially
3730      * interested in. For these things, they may broadcast this action when the
3731      * set of interesting items change.
3732      *
3733      * For example, GmailProvider sends this notification when the set of unread
3734      * mail in the inbox changes.
3735      *
3736      * <p>The data of the intent identifies which part of which provider
3737      * changed. When queried through the content resolver, the data URI will
3738      * return the data set in question.
3739      *
3740      * <p>The intent will have the following extra values:
3741      * <ul>
3742      *   <li><em>count</em> - The number of items in the data set. This is the
3743      *       same as the number of items in the cursor returned by querying the
3744      *       data URI. </li>
3745      * </ul>
3746      *
3747      * This intent will be sent at boot (if the count is non-zero) and when the
3748      * data set changes. It is possible for the data set to change without the
3749      * count changing (for example, if a new unread message arrives in the same
3750      * sync operation in which a message is archived). The phone should still
3751      * ring/vibrate/etc as normal in this case.
3752      */
3753     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3754     public static final String ACTION_PROVIDER_CHANGED =
3755             "android.intent.action.PROVIDER_CHANGED";
3756 
3757     /**
3758      * Broadcast Action: Wired Headset plugged in or unplugged.
3759      *
3760      * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
3761      *   and documentation.
3762      * <p>If the minimum SDK version of your application is
3763      * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
3764      * to the <code>AudioManager</code> constant in your receiver registration code instead.
3765      */
3766     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3767     public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
3768 
3769     /**
3770      * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
3771      * <ul>
3772      *   <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
3773      * </ul>
3774      *
3775      * <p class="note">This is a protected intent that can only be sent
3776      * by the system.
3777      *
3778      * @hide
3779      */
3780     //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3781     public static final String ACTION_ADVANCED_SETTINGS_CHANGED
3782             = "android.intent.action.ADVANCED_SETTINGS";
3783 
3784     /**
3785      *  Broadcast Action: Sent after application restrictions are changed.
3786      *
3787      * <p class="note">This is a protected intent that can only be sent
3788      * by the system.</p>
3789      */
3790     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3791     public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
3792             "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
3793 
3794     /**
3795      * Broadcast Action: An outgoing call is about to be placed.
3796      *
3797      * <p>The Intent will have the following extra value:</p>
3798      * <ul>
3799      *   <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
3800      *       the phone number dialed.</li>
3801      * </ul>
3802      * <p class="note">Starting in Android 15, this broadcast is no longer sent as an ordered
3803      * broadcast.  The <code>resultData</code> no longer has any effect and will not determine the
3804      * actual routing of the call.  Further, receivers of this broadcast do not get foreground
3805      * priority and cannot launch background activities.</p>
3806      * <p>Once the broadcast is finished, the resultData is used as the actual
3807      * number to call.  If  <code>null</code>, no call will be placed.</p>
3808      * <p>It is perfectly acceptable for multiple receivers to process the
3809      * outgoing call in turn: for example, a parental control application
3810      * might verify that the user is authorized to place the call at that
3811      * time, then a number-rewriting application might add an area code if
3812      * one was not specified.</p>
3813      * <p>For consistency, any receiver whose purpose is to prohibit phone
3814      * calls should have a priority of 0, to ensure it will see the final
3815      * phone number to be dialed.
3816      * Any receiver whose purpose is to rewrite phone numbers to be called
3817      * should have a positive priority.
3818      * Negative priorities are reserved for the system for this broadcast;
3819      * using them may cause problems.</p>
3820      * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
3821      * abort the broadcast.</p>
3822      * <p>Emergency calls cannot be intercepted using this mechanism, and
3823      * other calls cannot be modified to call emergency numbers using this
3824      * mechanism.
3825      * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
3826      * call to use their own service instead. Those apps should first prevent
3827      * the call from being placed by setting resultData to <code>null</code>
3828      * and then start their own app to make the call.
3829      * <p>You must hold the
3830      * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
3831      * permission to receive this Intent.</p>
3832      *
3833      * <p class="note">Starting in {@link Build.VERSION_CODES#VANILLA_ICE_CREAM}, this broadcast is
3834      * no longer sent as an ordered broadcast, and does not allow activity launches.  This means
3835      * that receivers may no longer change the phone number for the outgoing call, or cancel the
3836      * outgoing call.  This functionality is only possible using the
3837      * {@link android.telecom.CallRedirectionService} API.  Although background receivers are
3838      * woken up to handle this intent, no guarantee is made as to the timeliness of the broadcast.
3839      * </p>
3840      *
3841      * <p class="note">This is a protected intent that can only be sent
3842      * by the system.
3843      *
3844      * <p class="note">If the user has chosen a {@link android.telecom.CallRedirectionService} to
3845      * handle redirection of outgoing calls, this intent will NOT be sent as an ordered broadcast.
3846      * This means that attempts to re-write the outgoing call by other apps using this intent will
3847      * be ignored.
3848      * </p>
3849      *
3850      * @deprecated Apps that redirect outgoing calls should use the
3851      * {@link android.telecom.CallRedirectionService} API.  Apps that perform call screening
3852      * should use the {@link android.telecom.CallScreeningService} API.  Apps which need to be
3853      * notified of basic call state should use
3854      * {@link android.telephony.TelephonyCallback.CallStateListener} to determine when a new
3855      * outgoing call is placed.
3856      */
3857     @Deprecated
3858     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3859     public static final String ACTION_NEW_OUTGOING_CALL =
3860             "android.intent.action.NEW_OUTGOING_CALL";
3861 
3862     /**
3863      * Broadcast Action: Have the device reboot.  This is only for use by
3864      * system code.
3865      *
3866      * <p class="note">This is a protected intent that can only be sent
3867      * by the system.
3868      */
3869     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3870     public static final String ACTION_REBOOT =
3871             "android.intent.action.REBOOT";
3872 
3873     /**
3874      * Broadcast Action:  A sticky broadcast for changes in the physical
3875      * docking state of the device.
3876      *
3877      * <p>The intent will have the following extra values:
3878      * <ul>
3879      *   <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
3880      *       state, indicating which dock the device is physically in.</li>
3881      * </ul>
3882      * <p>This is intended for monitoring the current physical dock state.
3883      * See {@link android.app.UiModeManager} for the normal API dealing with
3884      * dock mode changes.
3885      */
3886     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3887     public static final String ACTION_DOCK_EVENT =
3888             "android.intent.action.DOCK_EVENT";
3889 
3890     /**
3891      * Broadcast Action: A broadcast when idle maintenance can be started.
3892      * This means that the user is not interacting with the device and is
3893      * not expected to do so soon. Typical use of the idle maintenance is
3894      * to perform somehow expensive tasks that can be postponed at a moment
3895      * when they will not degrade user experience.
3896      * <p>
3897      * <p class="note">In order to keep the device responsive in case of an
3898      * unexpected user interaction, implementations of a maintenance task
3899      * should be interruptible. In such a scenario a broadcast with action
3900      * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
3901      * should not do the maintenance work in
3902      * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
3903      * maintenance service by {@link Context#startService(Intent)}. Also
3904      * you should hold a wake lock while your maintenance service is running
3905      * to prevent the device going to sleep.
3906      * </p>
3907      * <p>
3908      * <p class="note">This is a protected intent that can only be sent by
3909      * the system.
3910      * </p>
3911      *
3912      * @see #ACTION_IDLE_MAINTENANCE_END
3913      *
3914      * @hide
3915      */
3916     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3917     public static final String ACTION_IDLE_MAINTENANCE_START =
3918             "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
3919 
3920     /**
3921      * Broadcast Action:  A broadcast when idle maintenance should be stopped.
3922      * This means that the user was not interacting with the device as a result
3923      * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
3924      * was sent and now the user started interacting with the device. Typical
3925      * use of the idle maintenance is to perform somehow expensive tasks that
3926      * can be postponed at a moment when they will not degrade user experience.
3927      * <p>
3928      * <p class="note">In order to keep the device responsive in case of an
3929      * unexpected user interaction, implementations of a maintenance task
3930      * should be interruptible. Hence, on receiving a broadcast with this
3931      * action, the maintenance task should be interrupted as soon as possible.
3932      * In other words, you should not do the maintenance work in
3933      * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
3934      * maintenance service that was started on receiving of
3935      * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
3936      * lock you acquired when your maintenance service started.
3937      * </p>
3938      * <p class="note">This is a protected intent that can only be sent
3939      * by the system.
3940      *
3941      * @see #ACTION_IDLE_MAINTENANCE_START
3942      *
3943      * @hide
3944      */
3945     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3946     public static final String ACTION_IDLE_MAINTENANCE_END =
3947             "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
3948 
3949     /**
3950      * Broadcast Action: A broadcast sent to the main user when the main user changes their
3951      * Lock Screen Knowledge Factor, either because they changed the current value, or because
3952      * they added or removed it.
3953      *
3954      * <p class="note">At present, this intent is only broadcast to listeners with the
3955      * CONFIGURE_FACTORY_RESET_PROTECTION signature|privileged permiession.</p>
3956      *
3957      * <p class="note">This is a protected intent that can only be sent by the system.</p>
3958      *
3959      * @hide
3960      */
3961     @FlaggedApi(FLAG_FRP_ENFORCEMENT)
3962     @SystemApi
3963     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3964     @BroadcastBehavior(protectedBroadcast = true)
3965     public static final String
3966             ACTION_MAIN_USER_LOCKSCREEN_KNOWLEDGE_FACTOR_CHANGED =
3967             "android.intent.action.MAIN_USER_LOCKSCREEN_KNOWLEDGE_FACTOR_CHANGED";
3968 
3969     /**
3970      * Broadcast Action: a remote intent is to be broadcasted.
3971      *
3972      * A remote intent is used for remote RPC between devices. The remote intent
3973      * is serialized and sent from one device to another device. The receiving
3974      * device parses the remote intent and broadcasts it. Note that anyone can
3975      * broadcast a remote intent. However, if the intent receiver of the remote intent
3976      * does not trust intent broadcasts from arbitrary intent senders, it should require
3977      * the sender to hold certain permissions so only trusted sender's broadcast will be
3978      * let through.
3979      * @hide
3980      */
3981     public static final String ACTION_REMOTE_INTENT =
3982             "com.google.android.c2dm.intent.RECEIVE";
3983 
3984     /**
3985      * Broadcast Action: This is broadcast once when the user is booting after a
3986      * system update. It can be used to perform cleanup or upgrades after a
3987      * system update.
3988      * <p>
3989      * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
3990      * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
3991      * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
3992      * sent to receivers in the system image.
3993      *
3994      * @hide
3995      */
3996     @SystemApi
3997     public static final String ACTION_PRE_BOOT_COMPLETED =
3998             "android.intent.action.PRE_BOOT_COMPLETED";
3999 
4000     /**
4001      * Broadcast to a specific application to query any supported restrictions to impose
4002      * on restricted users. The broadcast intent contains an extra
4003      * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
4004      * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
4005      * String[] depending on the restriction type.<p/>
4006      * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
4007      * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
4008      * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
4009      * The activity specified by that intent will be launched for a result which must contain
4010      * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
4011      * The keys and values of the returned restrictions will be persisted.
4012      * @see RestrictionEntry
4013      */
4014     public static final String ACTION_GET_RESTRICTION_ENTRIES =
4015             "android.intent.action.GET_RESTRICTION_ENTRIES";
4016 
4017     /**
4018      * Sent the first time a user is starting, to allow system apps to
4019      * perform one time initialization.  (This will not be seen by third
4020      * party applications because a newly initialized user does not have any
4021      * third party applications installed for it.)  This is sent early in
4022      * starting the user, around the time the home app is started, before
4023      * {@link #ACTION_BOOT_COMPLETED} is sent.  This is sent as a foreground
4024      * broadcast, since it is part of a visible user interaction; be as quick
4025      * as possible when handling it.
4026      *
4027      * <p><b>Note:</b> This broadcast is not sent to the system user.
4028      */
4029     public static final String ACTION_USER_INITIALIZE =
4030             "android.intent.action.USER_INITIALIZE";
4031 
4032     /**
4033      * Sent after a user switch is complete, if the switch caused the process's user to be
4034      * brought to the foreground.  This is only sent to receivers registered
4035      * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
4036      * Context.registerReceiver}.  It is sent to the user that is going to the
4037      * foreground.  This is sent as a foreground
4038      * broadcast, since it is part of a visible user interaction; be as quick
4039      * as possible when handling it.
4040      */
4041     public static final String ACTION_USER_FOREGROUND =
4042             "android.intent.action.USER_FOREGROUND";
4043 
4044     /**
4045      * Sent after a user switch is complete, if the switch caused the process's user to be
4046      * sent to the background.  This is only sent to receivers registered
4047      * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
4048      * Context.registerReceiver}.  It is sent to the user that is going to the
4049      * background.  This is sent as a foreground
4050      * broadcast, since it is part of a visible user interaction; be as quick
4051      * as possible when handling it.
4052      */
4053     public static final String ACTION_USER_BACKGROUND =
4054             "android.intent.action.USER_BACKGROUND";
4055 
4056     /**
4057      * Broadcast sent to the system when a user is added.
4058      * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the new user
4059      * (and for legacy reasons, also carries an int extra {@link #EXTRA_USER_HANDLE} specifying that
4060      * user's user ID).
4061      * It is sent to all running users.
4062      * You must hold {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
4063      * @hide
4064      */
4065     @SystemApi
4066     public static final String ACTION_USER_ADDED =
4067             "android.intent.action.USER_ADDED";
4068 
4069     /**
4070      * Broadcast sent by the system when a user is started. Carries an extra
4071      * {@link #EXTRA_USER_HANDLE} that has the user ID of the user.  This is only sent to
4072      * registered receivers, not manifest receivers.  It is sent to the user
4073      * that has been started.  This is sent as a foreground
4074      * broadcast, since it is part of a visible user interaction; be as quick
4075      * as possible when handling it.
4076      *
4077      * <p>
4078      * <b>Note:</b> The user's actual state might have changed by the time the broadcast is
4079      * received. For example, the user could have been removed, started or stopped already,
4080      * regardless of which broadcast you receive. Because of that, receivers should always check
4081      * the current state of the user.
4082      * @hide
4083      */
4084     public static final String ACTION_USER_STARTED =
4085             "android.intent.action.USER_STARTED";
4086 
4087     /**
4088      * Broadcast sent when a user is in the process of starting.  Carries an extra
4089      * {@link #EXTRA_USER_HANDLE} that has the user ID of the user.  This is only
4090      * sent to registered receivers, not manifest receivers.  It is sent to all
4091      * users (including the one that is being started).  You must hold
4092      * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
4093      * this broadcast.  This is sent as a background broadcast, since
4094      * its result is not part of the primary UX flow; to safely keep track of
4095      * started/stopped state of a user you can use this in conjunction with
4096      * {@link #ACTION_USER_STOPPING}.  It is <b>not</b> generally safe to use with
4097      * other user state broadcasts since those are foreground broadcasts so can
4098      * execute in a different order.
4099      *
4100      * <p>
4101      * <b>Note:</b> The user's actual state might have changed by the time the broadcast is
4102      * received. For example, the user could have been removed, started or stopped already,
4103      * regardless of which broadcast you receive. Because of that, receivers should always check
4104      * the current state of the user.
4105      * @hide
4106      */
4107     public static final String ACTION_USER_STARTING =
4108             "android.intent.action.USER_STARTING";
4109 
4110     /**
4111      * Broadcast sent when a user is going to be stopped.  Carries an extra
4112      * {@link #EXTRA_USER_HANDLE} that has the user ID of the user.  This is only
4113      * sent to registered receivers, not manifest receivers.  It is sent to all
4114      * users (including the one that is being stopped).  You must hold
4115      * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
4116      * this broadcast.  The user will not stop until all receivers have
4117      * handled the broadcast.  This is sent as a background broadcast, since
4118      * its result is not part of the primary UX flow; to safely keep track of
4119      * started/stopped state of a user you can use this in conjunction with
4120      * {@link #ACTION_USER_STARTING}.  It is <b>not</b> generally safe to use with
4121      * other user state broadcasts since those are foreground broadcasts so can
4122      * execute in a different order.
4123      * <p>
4124      * <b>Note:</b> The user's actual state might have changed by the time the broadcast is
4125      * received. For example, the user could have been removed, started or stopped already,
4126      * regardless of which broadcast you receive. Because of that, receivers should always check
4127      * the current state of the user.
4128      * @hide
4129      */
4130     public static final String ACTION_USER_STOPPING =
4131             "android.intent.action.USER_STOPPING";
4132 
4133     /**
4134      * Broadcast sent to the system when a user is stopped. Carries an extra
4135      * {@link #EXTRA_USER_HANDLE} that has the user ID of the user.  This is similar to
4136      * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
4137      * specific package.  This is only sent to registered receivers, not manifest
4138      * receivers.  It is sent to all running users <em>except</em> the one that
4139      * has just been stopped (which is no longer running).
4140      *
4141      * <p>
4142      * <b>Note:</b> The user's actual state might have changed by the time the broadcast is
4143      * received. For example, the user could have been removed, started or stopped already,
4144      * regardless of which broadcast you receive. Because of that, receivers should always check
4145      * the current state of the user.
4146      * @hide
4147      */
4148     @TestApi
4149     public static final String ACTION_USER_STOPPED =
4150             "android.intent.action.USER_STOPPED";
4151 
4152     /**
4153      * Broadcast sent to the system when a user is removed.
4154      * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the user that
4155      * was removed
4156      * (and for legacy reasons, also carries an int extra {@link #EXTRA_USER_HANDLE} specifying that
4157      * user's user ID).
4158      * It is sent to all running users except the
4159      * one that has been removed. The user will not be completely removed until all receivers have
4160      * handled the broadcast. You must hold
4161      * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
4162      * @hide
4163      */
4164     @SystemApi
4165     public static final String ACTION_USER_REMOVED =
4166             "android.intent.action.USER_REMOVED";
4167 
4168     /**
4169      * Broadcast sent to the system when the user switches.
4170      * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle}
4171      * of the user to become the current one
4172      * (and for legacy reasons, also carries an int extra {@link #EXTRA_USER_HANDLE} specifying that
4173      * user's user ID).
4174      * This is only sent to registered receivers, not manifest receivers.
4175      * It is sent to all running users.
4176      * You must hold
4177      * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
4178      *
4179      * <p>
4180      * <b>Note:</b> The user's actual state might have changed by the time the broadcast is
4181      * received. For example, the user could have been removed, started or stopped already,
4182      * regardless of which broadcast you receive. Because of that, receivers should always check
4183      * the current state of the user.
4184      * @hide
4185      */
4186     /*
4187      * This broadcast is sent after the user switch is complete. In case a task needs to be done
4188      * while the switch is happening (i.e. while the screen is frozen to hide UI jank), please use
4189      * ActivityManagerService.registerUserSwitchObserver method.
4190      */
4191     @SystemApi
4192     public static final String ACTION_USER_SWITCHED =
4193             "android.intent.action.USER_SWITCHED";
4194 
4195     /**
4196      * Broadcast Action: Sent when the credential-encrypted private storage has
4197      * become unlocked for the target user. This is only sent to registered
4198      * receivers, not manifest receivers.
4199      *
4200      * <p>
4201      * <b>Note:</b> The user's actual state might have changed by the time the broadcast is
4202      * received. For example, the user could have been removed, started or stopped already,
4203      * regardless of which broadcast you receive. Because of that, receivers should always check
4204      * the current state of the user.
4205      */
4206     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4207     public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
4208 
4209     /**
4210      * Broadcast sent to the system when a user's information changes. Carries an extra
4211      * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
4212      * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
4213      * @hide
4214      */
4215     public static final String ACTION_USER_INFO_CHANGED =
4216             "android.intent.action.USER_INFO_CHANGED";
4217 
4218 
4219     /**
4220      * Broadcast sent to the system when a user's information changes. Carries an extra
4221      * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
4222      * This is only sent to permission protected manifest receivers. It is sent to all users.
4223      * @hide
4224      */
4225     @BroadcastBehavior(includeBackground = true)
4226     public static final String ACTION_USER_INFO_CHANGED_BACKGROUND =
4227             "android.intent.action.USER_INFO_CHANGED_BACKGROUND";
4228 
4229     /**
4230      * Broadcast sent to the primary user when an associated managed profile is added (the profile
4231      * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
4232      * the {@link UserHandle} of the profile that was added. Only applications (for example
4233      * Launchers) that need to display merged content across both primary and managed profiles need
4234      * to worry about this broadcast. This is only sent to registered receivers,
4235      * not manifest receivers.
4236      */
4237     public static final String ACTION_MANAGED_PROFILE_ADDED =
4238             "android.intent.action.MANAGED_PROFILE_ADDED";
4239 
4240     /**
4241      * Broadcast sent to the primary user when an associated managed profile is removed.
4242      * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile
4243      * that was removed.
4244      * Only applications (for example Launchers) that need to display merged content across both
4245      * primary and managed profiles need to worry about this broadcast. This is only sent to
4246      * registered receivers, not manifest receivers.
4247      */
4248     public static final String ACTION_MANAGED_PROFILE_REMOVED =
4249             "android.intent.action.MANAGED_PROFILE_REMOVED";
4250 
4251     /**
4252      * Broadcast sent to the primary user when the credential-encrypted private storage for
4253      * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
4254      * specifies the {@link UserHandle} of the profile that was unlocked. Only applications (for
4255      * example Launchers) that need to display merged content across both primary and managed
4256      * profiles need to worry about this broadcast. This is only sent to registered receivers,
4257      * not manifest receivers.
4258      */
4259     public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
4260             "android.intent.action.MANAGED_PROFILE_UNLOCKED";
4261 
4262     /**
4263      * Broadcast sent to the primary user when an associated managed profile has become available.
4264      * Currently this includes when the user disables quiet mode for the profile. Carries an extra
4265      * {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile. When quiet mode is
4266      * changed, this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the
4267      * new state of quiet mode. This is only sent to registered receivers, not manifest receivers.
4268      */
4269     public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
4270             "android.intent.action.MANAGED_PROFILE_AVAILABLE";
4271 
4272     /**
4273      * Broadcast sent to the primary user when an associated managed profile has become unavailable.
4274      * Currently this includes when the user enables quiet mode for the profile. Carries an extra
4275      * {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile. When quiet mode is
4276      * changed, this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the
4277      * new state of quiet mode. This is only sent to registered receivers, not manifest receivers.
4278      */
4279     public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
4280             "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
4281 
4282     /**
4283      * Broadcast sent to the primary user when an associated profile has become available.
4284      * This is sent when a user disables quiet mode for the profile. Carries an extra
4285      * {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile. When quiet mode is
4286      * changed, this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the
4287      * new state of quiet mode. This is only sent to registered receivers, not manifest receivers.
4288      *
4289      * <p>This broadcast is similar to {@link #ACTION_MANAGED_PROFILE_AVAILABLE} but functions as a
4290      * generic broadcast for all users of type {@link android.os.UserManager#isProfile()}}. In
4291      * case of a managed profile, both {@link #ACTION_MANAGED_PROFILE_AVAILABLE} and
4292      * {@link #ACTION_PROFILE_AVAILABLE} broadcasts are sent.
4293      */
4294     @FlaggedApi(FLAG_ALLOW_PRIVATE_PROFILE)
4295     public static final String ACTION_PROFILE_AVAILABLE =
4296             "android.intent.action.PROFILE_AVAILABLE";
4297 
4298     /**
4299      * Broadcast sent to the primary user when an associated profile has become unavailable.
4300      * This is sent when a user enables quiet mode for the profile. Carries an extra
4301      * {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile. When quiet mode is
4302      * changed, this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the
4303      * new state of quiet mode. This is only sent to registered receivers, not manifest receivers.
4304      *
4305      * <p>This broadcast is similar to {@link #ACTION_MANAGED_PROFILE_UNAVAILABLE} but functions as
4306      * a generic broadcast for all users of type {@link android.os.UserManager#isProfile()}}. In
4307      * case of a managed profile, both {@link #ACTION_MANAGED_PROFILE_UNAVAILABLE} and
4308      * {@link #ACTION_PROFILE_UNAVAILABLE} broadcasts are sent.
4309      */
4310     @FlaggedApi(FLAG_ALLOW_PRIVATE_PROFILE)
4311     public static final String ACTION_PROFILE_UNAVAILABLE =
4312             "android.intent.action.PROFILE_UNAVAILABLE";
4313 
4314     /**
4315      * Broadcast sent to the parent user when an associated profile has been started and unlocked.
4316      * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile.
4317      * This is only sent to registered receivers, not manifest receivers.
4318      */
4319     public static final String ACTION_PROFILE_ACCESSIBLE =
4320             "android.intent.action.PROFILE_ACCESSIBLE";
4321 
4322     /**
4323      * Broadcast sent to the parent user when an associated profile has stopped.
4324      * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile.
4325      * This is only sent to registered receivers, not manifest receivers.
4326      */
4327     public static final String ACTION_PROFILE_INACCESSIBLE =
4328             "android.intent.action.PROFILE_INACCESSIBLE";
4329 
4330     /**
4331      * Broadcast sent to the parent user when an associated profile is removed.
4332      * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile
4333      * that was removed.
4334      *
4335      * <p>This broadcast is similar to {@link #ACTION_MANAGED_PROFILE_REMOVED} but functions as a
4336      * generic broadcast for all profile users.
4337      * It is sent in addition to the {@link #ACTION_MANAGED_PROFILE_REMOVED} broadcast when a
4338      * managed user is removed.
4339      *
4340      * <p>Only applications (for example Launchers) that need to display merged content across both
4341      * the parent user and its associated profiles need to worry about this broadcast.
4342      * This is only sent to registered receivers created with {@link Context#registerReceiver}.
4343      * It is not sent to manifest receivers.
4344      */
4345     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4346     public static final String ACTION_PROFILE_REMOVED =
4347             "android.intent.action.PROFILE_REMOVED";
4348 
4349     /**
4350      * Broadcast sent to the parent user when an associated profile is added (the profile was
4351      * created and is ready to be used).
4352      * Carries an extra {@link #EXTRA_USER} that specifies the  {@link UserHandle} of the profile
4353      * that was added.
4354      *
4355      * <p>This broadcast is similar to {@link #ACTION_MANAGED_PROFILE_ADDED} but functions as a
4356      * generic broadcast for all profile users.
4357      * It is sent in addition to the {@link #ACTION_MANAGED_PROFILE_ADDED} broadcast when a
4358      * managed user is added.
4359      *
4360      * <p>Only applications (for example Launchers) that need to display merged content across both
4361      * the parent user and its associated profiles need to worry about this broadcast.
4362      * This is only sent to registered receivers created with {@link Context#registerReceiver}.
4363      * It is not sent to manifest receivers.
4364      */
4365     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4366     public static final String ACTION_PROFILE_ADDED =
4367             "android.intent.action.PROFILE_ADDED";
4368 
4369     /**
4370      * Broadcast sent to the system user when the 'device locked' state changes for any user.
4371      * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
4372      * the device was locked or unlocked.
4373      *
4374      * This is only sent to registered receivers.
4375      *
4376      * @hide
4377      */
4378     public static final String ACTION_DEVICE_LOCKED_CHANGED =
4379             "android.intent.action.DEVICE_LOCKED_CHANGED";
4380 
4381     /**
4382      * Sent when the user taps on the clock widget in the system's "quick settings" area.
4383      */
4384     public static final String ACTION_QUICK_CLOCK =
4385             "android.intent.action.QUICK_CLOCK";
4386 
4387     /**
4388      * Activity Action: Shows the brightness setting dialog.
4389      * @hide
4390      */
4391     public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
4392             "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
4393 
4394     /**
4395      * Intent Extra: holds boolean that determines whether brightness dialog is full width when
4396      * in landscape mode.
4397      * @hide
4398      */
4399     public static final String EXTRA_BRIGHTNESS_DIALOG_IS_FULL_WIDTH =
4400             "android.intent.extra.BRIGHTNESS_DIALOG_IS_FULL_WIDTH";
4401 
4402     /**
4403      * Broadcast Action:  A global button was pressed.  Includes a single
4404      * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
4405      * caused the broadcast.
4406      * @hide
4407      */
4408     @SystemApi
4409     public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
4410 
4411     /**
4412      * Broadcast Action: Sent when media resource is granted.
4413      * <p>
4414      * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
4415      * granted.
4416      * </p>
4417      * <p class="note">
4418      * This is a protected intent that can only be sent by the system.
4419      * </p>
4420      * <p class="note">
4421      * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
4422      * </p>
4423      *
4424      * @hide
4425      */
4426     public static final String ACTION_MEDIA_RESOURCE_GRANTED =
4427             "android.intent.action.MEDIA_RESOURCE_GRANTED";
4428 
4429     /**
4430      * Broadcast Action: An overlay package has changed. The data contains the
4431      * name of the overlay package which has changed. This is broadcast on all
4432      * changes to the OverlayInfo returned by {@link
4433      * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
4434      * most common change is a state change that will change whether the
4435      * overlay is enabled or not.
4436      * @hide
4437      */
4438     public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
4439 
4440     /**
4441      * Activity Action: Allow the user to select and return one or more existing
4442      * documents. When invoked, the system will display the various
4443      * {@link DocumentsProvider} instances installed on the device, letting the
4444      * user interactively navigate through them. These documents include local
4445      * media, such as photos and video, and documents provided by installed
4446      * cloud storage providers.
4447      * <p>
4448      * Each document is represented as a {@code content://} URI backed by a
4449      * {@link DocumentsProvider}, which can be opened as a stream with
4450      * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
4451      * {@link android.provider.DocumentsContract.Document} metadata.
4452      * <p>
4453      * All selected documents are returned to the calling application with
4454      * persistable read and write permission grants. If you want to maintain
4455      * access to the documents across device reboots, you need to explicitly
4456      * take the persistable permissions using
4457      * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
4458      * <p>
4459      * Callers must indicate the acceptable document MIME types through
4460      * {@link #setType(String)}. For example, to select photos, use
4461      * {@code image/*}. If multiple disjoint MIME types are acceptable, define
4462      * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
4463      * {@literal *}/*.
4464      * <p>
4465      * If the caller can handle multiple returned items (the user performing
4466      * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
4467      * to indicate this.
4468      * <p>
4469      * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
4470      * URIs that can be opened with
4471      * {@link ContentResolver#openFileDescriptor(Uri, String)}.
4472      * <p>
4473      * Callers can set a document URI through
4474      * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
4475      * location of documents navigator. System will do its best to launch the
4476      * navigator in the specified document if it's a folder, or the folder that
4477      * contains the specified document if not.
4478      * <p>
4479      * Output: The URI of the item that was picked, returned in
4480      * {@link #getData()}. This must be a {@code content://} URI so that any
4481      * receiver can access it. If multiple documents were selected, they are
4482      * returned in {@link #getClipData()}.
4483      *
4484      * @see DocumentsContract
4485      * @see #ACTION_OPEN_DOCUMENT_TREE
4486      * @see #ACTION_CREATE_DOCUMENT
4487      * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4488      */
4489     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4490     public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
4491 
4492     /**
4493      * Activity Action: Allow the user to create a new document. When invoked,
4494      * the system will display the various {@link DocumentsProvider} instances
4495      * installed on the device, letting the user navigate through them. The
4496      * returned document may be a newly created document with no content, or it
4497      * may be an existing document with the requested MIME type.
4498      * <p>
4499      * Each document is represented as a {@code content://} URI backed by a
4500      * {@link DocumentsProvider}, which can be opened as a stream with
4501      * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
4502      * {@link android.provider.DocumentsContract.Document} metadata.
4503      * <p>
4504      * Callers must indicate the concrete MIME type of the document being
4505      * created by setting {@link #setType(String)}. This MIME type cannot be
4506      * changed after the document is created.
4507      * <p>
4508      * Callers can provide an initial display name through {@link #EXTRA_TITLE},
4509      * but the user may change this value before creating the file.
4510      * <p>
4511      * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
4512      * URIs that can be opened with
4513      * {@link ContentResolver#openFileDescriptor(Uri, String)}.
4514      * <p>
4515      * Callers can set a document URI through
4516      * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
4517      * location of documents navigator. System will do its best to launch the
4518      * navigator in the specified document if it's a folder, or the folder that
4519      * contains the specified document if not.
4520      * <p>
4521      * Output: The URI of the item that was created. This must be a
4522      * {@code content://} URI so that any receiver can access it.
4523      *
4524      * @see DocumentsContract
4525      * @see #ACTION_OPEN_DOCUMENT
4526      * @see #ACTION_OPEN_DOCUMENT_TREE
4527      * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4528      */
4529     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4530     public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
4531 
4532     /**
4533      * Activity Action: Allow the user to pick a directory subtree. When
4534      * invoked, the system will display the various {@link DocumentsProvider}
4535      * instances installed on the device, letting the user navigate through
4536      * them. Apps can fully manage documents within the returned directory.
4537      * <p>
4538      * To gain access to descendant (child, grandchild, etc) documents, use
4539      * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
4540      * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
4541      * with the returned URI.
4542      * <p>
4543      * Callers can set a document URI through
4544      * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
4545      * location of documents navigator. System will do its best to launch the
4546      * navigator in the specified document if it's a folder, or the folder that
4547      * contains the specified document if not.
4548      * <p>
4549      * Output: The URI representing the selected directory tree.
4550      *
4551      * @see DocumentsContract
4552      */
4553     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4554     public static final String
4555             ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
4556 
4557 
4558     /**
4559      * Activity Action: Perform text translation.
4560      * <p>
4561      * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to translate.
4562      * <p>
4563      * Output: nothing.
4564      */
4565     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4566     public static final String ACTION_TRANSLATE = "android.intent.action.TRANSLATE";
4567 
4568     /**
4569      * Activity Action: Define the meaning of the selected word(s).
4570      * <p>
4571      * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to define.
4572      * <p>
4573      * Output: nothing.
4574      */
4575     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4576     public static final String ACTION_DEFINE = "android.intent.action.DEFINE";
4577 
4578     /**
4579      * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
4580      * exisiting sensor being disconnected.
4581      *
4582      * <p class="note">This is a protected intent that can only be sent by the system.</p>
4583      *
4584      * {@hide}
4585      */
4586     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4587     public static final String
4588             ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
4589 
4590     /**
4591      * Deprecated - use ACTION_FACTORY_RESET instead.
4592      * @hide
4593      * @removed
4594      */
4595     @Deprecated
4596     @SystemApi
4597     public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
4598 
4599     /**
4600      * Broadcast intent sent by the RecoverySystem to inform listeners that a global clear (wipe)
4601      * is about to be performed.
4602      * @hide
4603      */
4604     @SystemApi
4605     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4606     @RequiresPermission(Manifest.permission.MASTER_CLEAR)
4607     public static final String ACTION_MASTER_CLEAR_NOTIFICATION
4608             = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
4609 
4610     /**
4611      * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
4612      * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
4613      *
4614      * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
4615      *
4616      * @hide
4617      */
4618     @Deprecated
4619     public static final String EXTRA_FORCE_MASTER_CLEAR =
4620             "android.intent.extra.FORCE_MASTER_CLEAR";
4621 
4622     /**
4623      * A broadcast action to trigger a factory reset.
4624      *
4625      * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The
4626      * reason for the factory reset should be specified as {@link #EXTRA_REASON}.
4627      *
4628      * <p>Not for use by third-party applications.
4629      *
4630      * @see #EXTRA_FORCE_FACTORY_RESET
4631      *
4632      * {@hide}
4633      */
4634     @SystemApi
4635     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4636     public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
4637 
4638     /**
4639      * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
4640      * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
4641      *
4642      * <p>Not for use by third-party applications.
4643      *
4644      * @hide
4645      */
4646     @SystemApi
4647     public static final String EXTRA_FORCE_FACTORY_RESET =
4648             "android.intent.extra.FORCE_FACTORY_RESET";
4649 
4650     /**
4651      * Broadcast action: report that a settings element is being restored from backup. The intent
4652      * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
4653      * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
4654      * is the value of that settings entry prior to the restore operation, and
4655      * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
4656      * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
4657      * values are represented as strings, the fourth one as int.
4658      *
4659      * <p>This broadcast is sent only for settings provider entries known to require special
4660      * handling around restore time to specific receivers. These entries are found in the
4661      * BROADCAST_ON_RESTORE table within the provider's backup agent implementation.
4662      *
4663      * @see #EXTRA_SETTING_NAME
4664      * @see #EXTRA_SETTING_PREVIOUS_VALUE
4665      * @see #EXTRA_SETTING_NEW_VALUE
4666      * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
4667      * {@hide}
4668      */
4669     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
4670     @SuppressLint("ActionValue")
4671     public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
4672 
4673     /**
4674      * String intent extra to be used with {@link ACTION_SETTING_RESTORED}.
4675      * Contain the name of the restored setting.
4676      * {@hide}
4677      */
4678     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
4679     @SuppressLint("ActionValue")
4680     public static final String EXTRA_SETTING_NAME = "setting_name";
4681 
4682     /**
4683      * String intent extra to be used with {@link ACTION_SETTING_RESTORED}.
4684      * Contain the value of the {@link EXTRA_SETTING_NAME} settings entry prior to the restore
4685      * operation.
4686      * {@hide}
4687      */
4688     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
4689     @SuppressLint("ActionValue")
4690     public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
4691 
4692     /**
4693      * String intent extra to be used with {@link ACTION_SETTING_RESTORED}.
4694      * Contain the value of the {@link EXTRA_SETTING_NAME} settings entry being restored.
4695      * {@hide}
4696      */
4697     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
4698     @SuppressLint("ActionValue")
4699     public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
4700 
4701     /**
4702      * Int intent extra to be used with {@link ACTION_SETTING_RESTORED}.
4703      * Contain the version of the SDK that the setting has been restored from (corresponds to
4704      * {@link android.os.Build.VERSION#SDK_INT}).
4705      * {@hide}
4706      */
4707     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
4708     @SuppressLint("ActionValue")
4709     public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
4710 
4711     /**
4712      * Activity Action: Process a piece of text.
4713      * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
4714      * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
4715      * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
4716      */
4717     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4718     public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
4719 
4720     /**
4721      * Broadcast Action: The sim card state has changed.
4722      * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
4723      * because TelephonyIntents is an internal class.
4724      * The intent will have following extras.</p>
4725      * <p>
4726      * @see #EXTRA_SIM_STATE
4727      * @see #EXTRA_SIM_LOCKED_REASON
4728      * @see #EXTRA_REBROADCAST_ON_UNLOCK
4729      *
4730      * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} or
4731      * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED}
4732      *
4733      * @hide
4734      */
4735     @Deprecated
4736     @SystemApi
4737     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4738     public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
4739 
4740     /**
4741      * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for broadcasting SIM STATE.
4742      * This will have one of the following intent values.
4743      * @see #SIM_STATE_UNKNOWN
4744      * @see #SIM_STATE_NOT_READY
4745      * @see #SIM_STATE_ABSENT
4746      * @see #SIM_STATE_PRESENT
4747      * @see #SIM_STATE_CARD_IO_ERROR
4748      * @see #SIM_STATE_CARD_RESTRICTED
4749      * @see #SIM_STATE_LOCKED
4750      * @see #SIM_STATE_READY
4751      * @see #SIM_STATE_IMSI
4752      * @see #SIM_STATE_LOADED
4753      * @hide
4754      * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED}
4755      */
4756     public static final String EXTRA_SIM_STATE = "ss";
4757 
4758     /**
4759      * The intent value UNKNOWN represents the SIM state unknown
4760      * @hide
4761      * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED}
4762      */
4763     public static final String SIM_STATE_UNKNOWN = "UNKNOWN";
4764 
4765     /**
4766      * The intent value NOT_READY means that the SIM is not ready eg. radio is off or powering on
4767      * @hide
4768      * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED}
4769      */
4770     public static final String SIM_STATE_NOT_READY = "NOT_READY";
4771 
4772     /**
4773      * The intent value ABSENT means the SIM card is missing
4774      * @hide
4775      * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED}
4776      */
4777     public static final String SIM_STATE_ABSENT = "ABSENT";
4778 
4779     /**
4780      * The intent value PRESENT means the device has a SIM card inserted
4781      * @hide
4782      * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED}
4783      */
4784     public static final String SIM_STATE_PRESENT = "PRESENT";
4785 
4786     /**
4787      * The intent value CARD_IO_ERROR means for three consecutive times there was SIM IO error
4788      * @hide
4789      * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED}
4790      */
4791     static public final String SIM_STATE_CARD_IO_ERROR = "CARD_IO_ERROR";
4792 
4793     /**
4794      * The intent value CARD_RESTRICTED means card is present but not usable due to carrier
4795      * restrictions
4796      * @hide
4797      * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED}
4798      */
4799     static public final String SIM_STATE_CARD_RESTRICTED = "CARD_RESTRICTED";
4800 
4801     /**
4802      * The intent value LOCKED means the SIM is locked by PIN or by network
4803      * @hide
4804      * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED}
4805      */
4806     public static final String SIM_STATE_LOCKED = "LOCKED";
4807 
4808     /**
4809      * The intent value READY means the SIM is ready to be accessed
4810      * @hide
4811      * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED}
4812      */
4813     public static final String SIM_STATE_READY = "READY";
4814 
4815     /**
4816      * The intent value IMSI means the SIM IMSI is ready in property
4817      * @hide
4818      * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED}
4819      */
4820     public static final String SIM_STATE_IMSI = "IMSI";
4821 
4822     /**
4823      * The intent value LOADED means all SIM records, including IMSI, are loaded
4824      * @hide
4825      * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED}
4826      */
4827     public static final String SIM_STATE_LOADED = "LOADED";
4828 
4829     /**
4830      * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for broadcasting SIM STATE.
4831      * This extra will have one of the following intent values.
4832      * <p>
4833      * @see #SIM_LOCKED_ON_PIN
4834      * @see #SIM_LOCKED_ON_PUK
4835      * @see #SIM_LOCKED_NETWORK
4836      * @see #SIM_ABSENT_ON_PERM_DISABLED
4837      *
4838      * @hide
4839      * @deprecated Use
4840      * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED}
4841      */
4842     public static final String EXTRA_SIM_LOCKED_REASON = "reason";
4843 
4844     /**
4845      * The intent value PIN means the SIM is locked on PIN1
4846      * @hide
4847      * @deprecated Use
4848      * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED}
4849      */
4850     public static final String SIM_LOCKED_ON_PIN = "PIN";
4851 
4852     /**
4853      * The intent value PUK means the SIM is locked on PUK1
4854      * @hide
4855      * @deprecated Use
4856      * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED}
4857      */
4858     /* PUK means ICC is locked on PUK1 */
4859     public static final String SIM_LOCKED_ON_PUK = "PUK";
4860 
4861     /**
4862      * The intent value NETWORK means the SIM is locked on NETWORK PERSONALIZATION
4863      * @hide
4864      * @deprecated Use
4865      * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED}
4866      */
4867     public static final String SIM_LOCKED_NETWORK = "NETWORK";
4868 
4869     /**
4870      * The intent value PERM_DISABLED means SIM is permanently disabled due to puk fails
4871      * @hide
4872      * @deprecated Use
4873      * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED}
4874      */
4875     public static final String SIM_ABSENT_ON_PERM_DISABLED = "PERM_DISABLED";
4876 
4877     /**
4878      * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for indicating whether this broadcast
4879      * is a rebroadcast on unlock. Defaults to {@code false} if not specified.
4880      *
4881      * @hide
4882      * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} or
4883      * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED}
4884      */
4885     public static final String EXTRA_REBROADCAST_ON_UNLOCK = "rebroadcastOnUnlock";
4886 
4887     /**
4888      * Broadcast Action: indicate that the phone service state has changed.
4889      * The intent will have the following extra values:</p>
4890      * <p>
4891      * @see #EXTRA_VOICE_REG_STATE
4892      * @see #EXTRA_DATA_REG_STATE
4893      * @see #EXTRA_VOICE_ROAMING_TYPE
4894      * @see #EXTRA_DATA_ROAMING_TYPE
4895      * @see #EXTRA_OPERATOR_ALPHA_LONG
4896      * @see #EXTRA_OPERATOR_ALPHA_SHORT
4897      * @see #EXTRA_OPERATOR_NUMERIC
4898      * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
4899      * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
4900      * @see #EXTRA_DATA_OPERATOR_NUMERIC
4901      * @see #EXTRA_MANUAL
4902      * @see #EXTRA_VOICE_RADIO_TECH
4903      * @see #EXTRA_DATA_RADIO_TECH
4904      * @see #EXTRA_CSS_INDICATOR
4905      * @see #EXTRA_NETWORK_ID
4906      * @see #EXTRA_SYSTEM_ID
4907      * @see #EXTRA_CDMA_ROAMING_INDICATOR
4908      * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
4909      * @see #EXTRA_EMERGENCY_ONLY
4910      * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
4911      * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
4912      * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
4913      *
4914      * <p class="note">
4915      * Requires the READ_PHONE_STATE permission.
4916      *
4917      * <p class="note">This is a protected intent that can only be sent by the system.
4918      * @hide
4919      * @removed
4920      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable} and the helper
4921      * functions {@code ServiceStateTable.getUriForSubscriptionIdAndField} and
4922      * {@code ServiceStateTable.getUriForSubscriptionId} to subscribe to changes to the ServiceState
4923      * for a given subscription id and field with a ContentObserver or using JobScheduler.
4924      */
4925     @Deprecated
4926     @SystemApi
4927     @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
4928     public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
4929 
4930     /**
4931      * Used by {@link services.core.java.com.android.server.pm.DataLoaderManagerService}
4932      * for querying Data Loader Service providers. Data loader service providers register this
4933      * intent filter in their manifests, so that they can be looked up and bound to by
4934      * {@code DataLoaderManagerService}.
4935      *
4936      * <p class="note">This is a protected intent that can only be sent by the system.
4937      *
4938      * Data loader service providers must be privileged apps.
4939      * See {@link com.android.server.pm.PackageManagerShellCommandDataLoader} as an example of such
4940      * data loader service provider.
4941      *
4942      * @hide
4943      */
4944     @SystemApi
4945     @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION)
4946     public static final String ACTION_LOAD_DATA = "android.intent.action.LOAD_DATA";
4947 
4948     /**
4949      * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
4950      * state.
4951      * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
4952      * @see android.telephony.ServiceState#STATE_IN_SERVICE
4953      * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
4954      * @see android.telephony.ServiceState#STATE_POWER_OFF
4955      * @hide
4956      * @removed
4957      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_REG_STATE}.
4958      */
4959     @Deprecated
4960     @SystemApi
4961     public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
4962 
4963     /**
4964      * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
4965      * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
4966      * @see android.telephony.ServiceState#STATE_IN_SERVICE
4967      * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
4968      * @see android.telephony.ServiceState#STATE_POWER_OFF
4969      * @hide
4970      * @removed
4971      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_REG_STATE}.
4972      */
4973     @Deprecated
4974     @SystemApi
4975     public static final String EXTRA_DATA_REG_STATE = "dataRegState";
4976 
4977     /**
4978      * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
4979      * type.
4980      * @hide
4981      * @removed
4982      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_ROAMING_TYPE}.
4983      */
4984     @Deprecated
4985     @SystemApi
4986     public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
4987 
4988     /**
4989      * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
4990      * type.
4991      * @hide
4992      * @removed
4993      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_ROAMING_TYPE}.
4994      */
4995     @Deprecated
4996     @SystemApi
4997     public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
4998 
4999     /**
5000      * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
5001      * registered voice operator name in long alphanumeric format.
5002      * {@code null} if the operator name is not known or unregistered.
5003      * @hide
5004      * @removed
5005      * @deprecated Use
5006      * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_LONG}.
5007      */
5008     @Deprecated
5009     @SystemApi
5010     public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
5011 
5012     /**
5013      * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
5014      * registered voice operator name in short alphanumeric format.
5015      * {@code null} if the operator name is not known or unregistered.
5016      * @hide
5017      * @removed
5018      * @deprecated Use
5019      * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_SHORT}.
5020      */
5021     @Deprecated
5022     @SystemApi
5023     public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
5024 
5025     /**
5026      * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
5027      * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
5028      * network.
5029      * @hide
5030      * @removed
5031      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_NUMERIC}.
5032      */
5033     @Deprecated
5034     @SystemApi
5035     public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
5036 
5037     /**
5038      * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
5039      * registered data operator name in long alphanumeric format.
5040      * {@code null} if the operator name is not known or unregistered.
5041      * @hide
5042      * @removed
5043      * @deprecated Use
5044      * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_LONG}.
5045      */
5046     @Deprecated
5047     @SystemApi
5048     public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
5049 
5050     /**
5051      * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
5052      * registered data operator name in short alphanumeric format.
5053      * {@code null} if the operator name is not known or unregistered.
5054      * @hide
5055      * @removed
5056      * @deprecated Use
5057      * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_SHORT}.
5058      */
5059     @Deprecated
5060     @SystemApi
5061     public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
5062 
5063     /**
5064      * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
5065      * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
5066      * data operator.
5067      * @hide
5068      * @removed
5069      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_NUMERIC}.
5070      */
5071     @Deprecated
5072     @SystemApi
5073     public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
5074 
5075     /**
5076      * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
5077      * network selection mode is manual.
5078      * Will be {@code true} if manual mode, {@code false} if automatic mode.
5079      * @hide
5080      * @removed
5081      * @deprecated Use
5082      * {@link android.provider.Telephony.ServiceStateTable#IS_MANUAL_NETWORK_SELECTION}.
5083      */
5084     @Deprecated
5085     @SystemApi
5086     public static final String EXTRA_MANUAL = "manual";
5087 
5088     /**
5089      * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
5090      * radio technology.
5091      * @hide
5092      * @removed
5093      * @deprecated Use
5094      * {@link android.provider.Telephony.ServiceStateTable#RIL_VOICE_RADIO_TECHNOLOGY}.
5095      */
5096     @Deprecated
5097     @SystemApi
5098     public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
5099 
5100     /**
5101      * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
5102      * radio technology.
5103      * @hide
5104      * @removed
5105      * @deprecated Use
5106      * {@link android.provider.Telephony.ServiceStateTable#RIL_DATA_RADIO_TECHNOLOGY}.
5107      */
5108     @Deprecated
5109     @SystemApi
5110     public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
5111 
5112     /**
5113      * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
5114      * support on CDMA network.
5115      * Will be {@code true} if support, {@code false} otherwise.
5116      * @hide
5117      * @removed
5118      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CSS_INDICATOR}.
5119      */
5120     @Deprecated
5121     @SystemApi
5122     public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
5123 
5124     /**
5125      * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
5126      * id. {@code Integer.MAX_VALUE} if unknown.
5127      * @hide
5128      * @removed
5129      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#NETWORK_ID}.
5130      */
5131     @Deprecated
5132     @SystemApi
5133     public static final String EXTRA_NETWORK_ID = "networkId";
5134 
5135     /**
5136      * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
5137      * {@code Integer.MAX_VALUE} if unknown.
5138      * @hide
5139      * @removed
5140      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#SYSTEM_ID}.
5141      */
5142     @Deprecated
5143     @SystemApi
5144     public static final String EXTRA_SYSTEM_ID = "systemId";
5145 
5146     /**
5147      * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
5148      * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
5149      * @hide
5150      * @removed
5151      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CDMA_ROAMING_INDICATOR}.
5152      */
5153     @Deprecated
5154     @SystemApi
5155     public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
5156 
5157     /**
5158      * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
5159      * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
5160      * @hide
5161      * @removed
5162      * @deprecated Use
5163      * {@link android.provider.Telephony.ServiceStateTable#CDMA_DEFAULT_ROAMING_INDICATOR}.
5164      */
5165     @Deprecated
5166     @SystemApi
5167     public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
5168 
5169     /**
5170      * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
5171      * only mode.
5172      * {@code true} if in emergency only mode, {@code false} otherwise.
5173      * @hide
5174      * @removed
5175      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#IS_EMERGENCY_ONLY}.
5176      */
5177     @Deprecated
5178     @SystemApi
5179     public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
5180 
5181     /**
5182      * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
5183      * registration state is roaming.
5184      * {@code true} if registration indicates roaming, {@code false} otherwise
5185      * @hide
5186      * @removed
5187      * @deprecated Use
5188      * {@link android.provider.Telephony.ServiceStateTable#IS_DATA_ROAMING_FROM_REGISTRATION}.
5189      */
5190     @Deprecated
5191     @SystemApi
5192     public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
5193             "isDataRoamingFromRegistration";
5194 
5195     /**
5196      * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
5197      * aggregation is in use.
5198      * {@code true} if carrier aggregation is in use, {@code false} otherwise.
5199      * @hide
5200      * @removed
5201      * @deprecated Use
5202      * {@link android.provider.Telephony.ServiceStateTable#IS_USING_CARRIER_AGGREGATION}.
5203      */
5204     @Deprecated
5205     @SystemApi
5206     public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
5207 
5208     /**
5209      * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
5210      * is reduced from the rsrp threshold while calculating signal strength level.
5211      * @hide
5212      * @removed
5213      */
5214     @Deprecated
5215     @SystemApi
5216     public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
5217 
5218     /**
5219      * The name of the extra used to define the text to be processed, as a
5220      * CharSequence. Note that this may be a styled CharSequence, so you must use
5221      * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
5222      */
5223     public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
5224     /**
5225      * The name of the boolean extra used to define if the processed text will be used as read-only.
5226      */
5227     public static final String EXTRA_PROCESS_TEXT_READONLY =
5228             "android.intent.extra.PROCESS_TEXT_READONLY";
5229 
5230     /**
5231      * Broadcast action: reports when a new thermal event has been reached. When the device
5232      * is reaching its maximum temperatue, the thermal level reported
5233      * {@hide}
5234      */
5235     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
5236     public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
5237 
5238     /** {@hide} */
5239     public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
5240 
5241     /**
5242      * Thermal state when the device is normal. This state is sent in the
5243      * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
5244      * {@hide}
5245      */
5246     public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
5247 
5248     /**
5249      * Thermal state where the device is approaching its maximum threshold. This state is sent in
5250      * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
5251      * {@hide}
5252      */
5253     public static final int EXTRA_THERMAL_STATE_WARNING = 1;
5254 
5255     /**
5256      * Thermal state where the device has reached its maximum threshold. This state is sent in the
5257      * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
5258      * {@hide}
5259      */
5260     public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
5261 
5262     /**
5263      * Broadcast Action: Indicates the dock in idle state while device is docked.
5264      *
5265      * <p class="note">This is a protected intent that can only be sent
5266      * by the system.
5267      *
5268      * @hide
5269      */
5270     public static final String ACTION_DOCK_IDLE = "android.intent.action.DOCK_IDLE";
5271 
5272     /**
5273      * Broadcast Action: Indicates the dock in active state while device is docked.
5274      *
5275      * <p class="note">This is a protected intent that can only be sent
5276      * by the system.
5277      *
5278      * @hide
5279      */
5280     public static final String ACTION_DOCK_ACTIVE = "android.intent.action.DOCK_ACTIVE";
5281 
5282     /**
5283      * Broadcast Action: Indicates that a new device customization has been
5284      * downloaded and applied (packages installed, runtime resource overlays
5285      * enabled, xml files copied, ...), and that it is time for components that
5286      * need to for example clear their caches to do so now.
5287      *
5288      * @hide
5289      */
5290     @SystemApi
5291     public static final String ACTION_DEVICE_CUSTOMIZATION_READY =
5292             "android.intent.action.DEVICE_CUSTOMIZATION_READY";
5293 
5294 
5295     /**
5296      * Activity Action: Display an activity state associated with an unique {@link LocusId}.
5297      *
5298      * <p>For example, a chat app could use the context to resume a conversation between 2 users.
5299      *
5300      * <p>Input: {@link #EXTRA_LOCUS_ID} specifies the unique identifier of the locus in the
5301      * app domain. Should be stable across reboots and backup / restore.
5302      * <p>Output: nothing.
5303      */
5304     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
5305     public static final String ACTION_VIEW_LOCUS = "android.intent.action.VIEW_LOCUS";
5306 
5307     /**
5308      * Activity Action: Starts a note-taking activity that can be used to create a note. This action
5309      * can be used to start an activity on the lock screen. Activity should ensure to appropriately
5310      * handle privacy sensitive data and features when launched on the lock screen. See
5311      * {@link android.app.KeyguardManager} for lock screen checks.
5312      */
5313     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
5314     public static final String ACTION_CREATE_NOTE = "android.intent.action.CREATE_NOTE";
5315 
5316     /**
5317      * A boolean extra used with {@link #ACTION_CREATE_NOTE} indicating whether the launched
5318      * note-taking activity should show a UI that is suitable to use with stylus input.
5319      */
5320     public static final String EXTRA_USE_STYLUS_MODE = "android.intent.extra.USE_STYLUS_MODE";
5321 
5322     /**
5323      * Activity Action: Use with startActivityForResult to start a system activity that captures
5324      * content on the screen to take a screenshot and present it to the user for editing. The
5325      * edited screenshot is saved on device and returned to the calling activity as a {@link Uri}
5326      * through {@link #getData()}. User interaction is required to return the edited screenshot to
5327      * the calling activity.
5328      *
5329      * <p>The response {@link Intent} may include additional data to "backlink" directly back to the
5330      * application for which the screenshot was captured. If present, the application "backlink" can
5331      * be retrieved via {@link #getClipData()}. The data is present only if the user accepted to
5332      * include the link information with the screenshot. The data can contain one of the following:
5333      * <ul>
5334      *     <li>A deeplinking {@link Uri} or an {@link Intent} if the captured app integrates with
5335      *         {@link android.app.assist.AssistContent}.</li>
5336      *     <li>Otherwise, a main launcher intent that launches the screenshotted application to
5337      *         its home screen.</li>
5338      * </ul>
5339      * The "backlink" to the screenshotted application will be set within {@link ClipData}, either
5340      * as a {@link Uri} or an {@link Intent} if present.
5341      *
5342      * <p>This intent action requires the permission
5343      * {@link android.Manifest.permission#LAUNCH_CAPTURE_CONTENT_ACTIVITY_FOR_NOTE}.
5344      *
5345      * <p>Callers should query
5346      * {@link StatusBarManager#canLaunchCaptureContentActivityForNote(Activity)} before showing a UI
5347      * element that allows users to trigger this flow.
5348      *
5349      * <p>Callers should query for {@link #EXTRA_CAPTURE_CONTENT_FOR_NOTE_STATUS_CODE} in the
5350      * response {@link Intent} to check if the request was a success.
5351      */
5352     @RequiresPermission(Manifest.permission.LAUNCH_CAPTURE_CONTENT_ACTIVITY_FOR_NOTE)
5353     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
5354     public static final String ACTION_LAUNCH_CAPTURE_CONTENT_ACTIVITY_FOR_NOTE =
5355             "android.intent.action.LAUNCH_CAPTURE_CONTENT_ACTIVITY_FOR_NOTE";
5356 
5357     /**
5358      * An int extra used by activity started with
5359      * {@link #ACTION_LAUNCH_CAPTURE_CONTENT_ACTIVITY_FOR_NOTE} to indicate status of the response.
5360      * This extra is used along with result code set to {@link android.app.Activity#RESULT_OK}.
5361      *
5362      * <p>The value for this extra can be one of the following:
5363      * <ul>
5364      *     <li>{@link #CAPTURE_CONTENT_FOR_NOTE_SUCCESS}</li>
5365      *     <li>{@link #CAPTURE_CONTENT_FOR_NOTE_FAILED}</li>
5366      *     <li>{@link #CAPTURE_CONTENT_FOR_NOTE_USER_CANCELED}</li>
5367      *     <li>{@link #CAPTURE_CONTENT_FOR_NOTE_WINDOW_MODE_UNSUPPORTED}</li>
5368      *     <li>{@link #CAPTURE_CONTENT_FOR_NOTE_BLOCKED_BY_ADMIN}</li>
5369      * </ul>
5370      */
5371     public static final String EXTRA_CAPTURE_CONTENT_FOR_NOTE_STATUS_CODE =
5372             "android.intent.extra.CAPTURE_CONTENT_FOR_NOTE_STATUS_CODE";
5373 
5374     /**
5375      * A response code used with {@link #EXTRA_CAPTURE_CONTENT_FOR_NOTE_STATUS_CODE} to indicate
5376      * that the request was a success.
5377      *
5378      * <p>This code will only be returned after the user has interacted with the system screenshot
5379      * activity to consent to sharing the data with the note.
5380      *
5381      * <p>The captured screenshot is returned as a {@link Uri} through {@link #getData()}.
5382      */
5383     public static final int CAPTURE_CONTENT_FOR_NOTE_SUCCESS = 0;
5384 
5385     /**
5386      * A response code used with {@link #EXTRA_CAPTURE_CONTENT_FOR_NOTE_STATUS_CODE} to indicate
5387      * that something went wrong.
5388      */
5389     public static final int CAPTURE_CONTENT_FOR_NOTE_FAILED = 1;
5390 
5391     /**
5392      * A response code used with {@link #EXTRA_CAPTURE_CONTENT_FOR_NOTE_STATUS_CODE} to indicate
5393      * that user canceled the content capture flow.
5394      */
5395     public static final int CAPTURE_CONTENT_FOR_NOTE_USER_CANCELED = 2;
5396 
5397     /**
5398      * A response code used with {@link #EXTRA_CAPTURE_CONTENT_FOR_NOTE_STATUS_CODE} to indicate
5399      * that the intent action {@link #ACTION_LAUNCH_CAPTURE_CONTENT_ACTIVITY_FOR_NOTE} was started
5400      * by an activity that is running in a non-supported window mode.
5401      */
5402     public static final int CAPTURE_CONTENT_FOR_NOTE_WINDOW_MODE_UNSUPPORTED = 3;
5403 
5404     /**
5405      * A response code used with {@link #EXTRA_CAPTURE_CONTENT_FOR_NOTE_STATUS_CODE} to indicate
5406      * that screenshot is blocked by IT admin.
5407      */
5408     public static final int CAPTURE_CONTENT_FOR_NOTE_BLOCKED_BY_ADMIN = 4;
5409 
5410     /** @hide */
5411     @IntDef(value = {
5412             CAPTURE_CONTENT_FOR_NOTE_SUCCESS, CAPTURE_CONTENT_FOR_NOTE_FAILED,
5413             CAPTURE_CONTENT_FOR_NOTE_WINDOW_MODE_UNSUPPORTED,
5414             CAPTURE_CONTENT_FOR_NOTE_BLOCKED_BY_ADMIN})
5415     @Retention(RetentionPolicy.SOURCE)
5416     public @interface CaptureContentForNoteStatusCodes {}
5417 
5418     /**
5419      * Broadcast Action: Sent to the integrity component when a package
5420      * needs to be verified. The data contains the package URI along with other relevant
5421      * information.
5422      *
5423      * <p class="note">
5424      * This is a protected intent that can only be sent by the system.
5425      * </p>
5426      *
5427      * @hide
5428      */
5429     @SystemApi
5430     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
5431     public static final String ACTION_PACKAGE_NEEDS_INTEGRITY_VERIFICATION =
5432             "android.intent.action.PACKAGE_NEEDS_INTEGRITY_VERIFICATION";
5433 
5434     /**
5435      * Broadcast Action: Start the foreground service manager.
5436      *
5437      * <p class="note">
5438      * This is a protected intent that can only be sent by the system.
5439      * </p>
5440      *
5441      * @hide
5442      */
5443     public static final String ACTION_SHOW_FOREGROUND_SERVICE_MANAGER =
5444             "android.intent.action.SHOW_FOREGROUND_SERVICE_MANAGER";
5445 
5446     /**
5447      * Broadcast Action: Sent to the responsible installer of an archived package when unarchival
5448      * is requested.
5449      *
5450      * @see android.content.pm.PackageInstaller#requestUnarchive
5451      */
5452     @FlaggedApi(android.content.pm.Flags.FLAG_ARCHIVING)
5453     @BroadcastBehavior(explicitOnly = true)
5454     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
5455     public static final String ACTION_UNARCHIVE_PACKAGE = "android.intent.action.UNARCHIVE_PACKAGE";
5456 
5457     // ---------------------------------------------------------------------
5458     // ---------------------------------------------------------------------
5459     // Standard intent categories (see addCategory()).
5460 
5461     /**
5462      * Set if the activity should be an option for the default action
5463      * (center press) to perform on a piece of data.  Setting this will
5464      * hide from the user any activities without it set when performing an
5465      * action on some data.  Note that this is normally -not- set in the
5466      * Intent when initiating an action -- it is for use in intent filters
5467      * specified in packages.
5468      */
5469     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5470     public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
5471     /**
5472      * Activities that can be safely invoked from a browser must support this
5473      * category.  For example, if the user is viewing a web page or an e-mail
5474      * and clicks on a link in the text, the Intent generated to execute that
5475      * link will require the BROWSABLE category, so that only activities
5476      * supporting this category will be considered as possible actions.  By
5477      * supporting this category, you are promising that there is nothing
5478      * damaging (without user intervention) that can happen by invoking any
5479      * matching Intent.
5480      */
5481     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5482     public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
5483     /**
5484      * Categories for activities that can participate in voice interaction.
5485      * An activity that supports this category must be prepared to run with
5486      * no UI shown at all (though in some case it may have a UI shown), and
5487      * rely on {@link android.app.VoiceInteractor} to interact with the user.
5488      */
5489     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5490     public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
5491     /**
5492      * Set if the activity should be considered as an alternative action to
5493      * the data the user is currently viewing.  See also
5494      * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
5495      * applies to the selection in a list of items.
5496      *
5497      * <p>Supporting this category means that you would like your activity to be
5498      * displayed in the set of alternative things the user can do, usually as
5499      * part of the current activity's options menu.  You will usually want to
5500      * include a specific label in the &lt;intent-filter&gt; of this action
5501      * describing to the user what it does.
5502      *
5503      * <p>The action of IntentFilter with this category is important in that it
5504      * describes the specific action the target will perform.  This generally
5505      * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
5506      * a specific name such as "com.android.camera.action.CROP.  Only one
5507      * alternative of any particular action will be shown to the user, so using
5508      * a specific action like this makes sure that your alternative will be
5509      * displayed while also allowing other applications to provide their own
5510      * overrides of that particular action.
5511      */
5512     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5513     public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
5514     /**
5515      * Set if the activity should be considered as an alternative selection
5516      * action to the data the user has currently selected.  This is like
5517      * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
5518      * of items from which the user can select, giving them alternatives to the
5519      * default action that will be performed on it.
5520      */
5521     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5522     public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
5523     /**
5524      * Intended to be used as a tab inside of a containing TabActivity.
5525      */
5526     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5527     public static final String CATEGORY_TAB = "android.intent.category.TAB";
5528     /**
5529      * Should be displayed in the top-level launcher.
5530      */
5531     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5532     public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
5533     /**
5534      * Indicates an activity optimized for Leanback mode, and that should
5535      * be displayed in the Leanback launcher.
5536      */
5537     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5538     public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
5539     /**
5540      * Indicates the preferred entry-point activity when an application is launched from a Car
5541      * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a
5542      * fallback, or exclude the application entirely.
5543      * @hide
5544      */
5545     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5546     public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER";
5547     /**
5548      * Used to indicate that the activity can be used in communal mode.
5549      * @hide
5550      */
5551     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5552     public static final String CATEGORY_COMMUNAL_MODE = "android.intent.category.COMMUNAL_MODE";
5553     /**
5554      * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
5555      * @hide
5556      */
5557     @SystemApi
5558     public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
5559     /**
5560      * Provides information about the package it is in; typically used if
5561      * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
5562      * a front-door to the user without having to be shown in the all apps list.
5563      */
5564     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5565     public static final String CATEGORY_INFO = "android.intent.category.INFO";
5566     /**
5567      * This is the home activity, that is the first activity that is displayed
5568      * when the device boots.
5569      */
5570     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5571     public static final String CATEGORY_HOME = "android.intent.category.HOME";
5572     /**
5573      * This is the home activity that is displayed when the device is finished setting up and ready
5574      * for use.
5575      * @hide
5576      */
5577     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5578     public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
5579     /**
5580      * The home activity shown on secondary displays that support showing home activities.
5581      */
5582     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5583     public static final String CATEGORY_SECONDARY_HOME = "android.intent.category.SECONDARY_HOME";
5584     /**
5585      * This is the setup wizard activity, that is the first activity that is displayed
5586      * when the user sets up the device for the first time.
5587      * @hide
5588      */
5589     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5590     public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
5591     /**
5592      * This is the home activity, that is the activity that serves as the launcher app
5593      * from there the user can start other apps. Often components with lower/higher
5594      * priority intent filters handle the home intent, for example SetupWizard, to
5595      * setup the device and we need to be able to distinguish the home app from these
5596      * setup helpers.
5597      * @hide
5598      */
5599     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5600     public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
5601     /**
5602      * This activity is a preference panel.
5603      */
5604     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5605     public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
5606     /**
5607      * This activity is a development preference panel.
5608      */
5609     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5610     public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
5611     /**
5612      * Capable of running inside a parent activity container.
5613      */
5614     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5615     public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
5616     /**
5617      * This activity allows the user to browse and download new applications.
5618      */
5619     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5620     public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
5621     /**
5622      * This activity may be exercised by the monkey or other automated test tools.
5623      */
5624     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5625     public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
5626     /**
5627      * To be used as a test (not part of the normal user experience).
5628      */
5629     public static final String CATEGORY_TEST = "android.intent.category.TEST";
5630     /**
5631      * To be used as a unit test (run through the Test Harness).
5632      */
5633     public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
5634     /**
5635      * To be used as a sample code example (not part of the normal user
5636      * experience).
5637      */
5638     public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
5639 
5640     /**
5641      * Used to indicate that an intent only wants URIs that can be opened with
5642      * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
5643      * must support at least the columns defined in {@link OpenableColumns} when
5644      * queried.
5645      *
5646      * @see #ACTION_GET_CONTENT
5647      * @see #ACTION_OPEN_DOCUMENT
5648      * @see #ACTION_CREATE_DOCUMENT
5649      */
5650     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5651     public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
5652 
5653     /**
5654      * Used to indicate that an intent filter can accept files which are not necessarily
5655      * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
5656      * at least streamable via
5657      * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
5658      * using one of the stream types exposed via
5659      * {@link ContentResolver#getStreamTypes(Uri, String)}.
5660      *
5661      * @see #ACTION_SEND
5662      * @see #ACTION_SEND_MULTIPLE
5663      */
5664     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5665     public static final String CATEGORY_TYPED_OPENABLE  =
5666             "android.intent.category.TYPED_OPENABLE";
5667 
5668     /**
5669      * To be used as code under test for framework instrumentation tests.
5670      */
5671     public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
5672             "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
5673     /**
5674      * An activity to run when device is inserted into a car dock.
5675      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
5676      * information, see {@link android.app.UiModeManager}.
5677      */
5678     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5679     public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
5680     /**
5681      * An activity to run when device is inserted into a desk dock.
5682      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
5683      * information, see {@link android.app.UiModeManager}.
5684      */
5685     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5686     public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
5687     /**
5688      * An activity to run when device is inserted into a analog (low end) dock.
5689      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
5690      * information, see {@link android.app.UiModeManager}.
5691      */
5692     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5693     public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
5694 
5695     /**
5696      * An activity to run when device is inserted into a digital (high end) dock.
5697      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
5698      * information, see {@link android.app.UiModeManager}.
5699      */
5700     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5701     public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
5702 
5703     /**
5704      * Used to indicate that the activity can be used in a car environment.
5705      */
5706     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5707     public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
5708 
5709     /**
5710      * An activity to use for the launcher when the device is placed in a VR Headset viewer.
5711      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
5712      * information, see {@link android.app.UiModeManager}.
5713      */
5714     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5715     public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
5716 
5717     /**
5718      * The accessibility shortcut is a global gesture for users with disabilities to trigger an
5719      * important for them accessibility feature to help developers determine whether they want to
5720      * make their activity a shortcut target.
5721      * <p>
5722      * An activity of interest to users with accessibility needs may request to be the target of
5723      * the accessibility shortcut. It handles intent {@link #ACTION_MAIN} with this category,
5724      * which will be dispatched by the system when the user activates the shortcut when it is
5725      * configured to point at this target.
5726      * </p>
5727      * <p>
5728      * An activity declared itself to be a target of the shortcut in AndroidManifest.xml. It must
5729      * also do two things:
5730      * <ul>
5731      *     <ol>
5732      *         Specify that it handles the <code>android.intent.action.MAIN</code>
5733      *         {@link android.content.Intent}
5734      *         with category <code>android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET</code>.
5735      *     </ol>
5736      *     <ol>
5737      *         Provide a meta-data entry <code>android.accessibilityshortcut.target</code> in the
5738      *         manifest when declaring the activity.
5739      *     </ol>
5740      * </ul>
5741      * If either of these items is missing, the system will ignore the accessibility shortcut
5742      * target. Following is an example declaration:
5743      * </p>
5744      * <pre>
5745      * &lt;activity android:name=".MainActivity"
5746      * . . .
5747      *   &lt;intent-filter&gt;
5748      *       &lt;action android:name="android.intent.action.MAIN" /&gt;
5749      *       &lt;category android:name="android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET" /&gt;
5750      *   &lt;/intent-filter&gt;
5751      *   &lt;meta-data android:name="android.accessibilityshortcut.target"
5752      *                   android:resource="@xml/accessibilityshortcut" /&gt;
5753      * &lt;/activity&gt;
5754      * </pre>
5755      * <p> This is a sample XML file configuring a accessibility shortcut target: </p>
5756      * <pre>
5757      * &lt;accessibility-shortcut-target
5758      *     android:description="@string/shortcut_target_description"
5759      *     android:summary="@string/shortcut_target_summary"
5760      *     android:animatedImageDrawable="@drawable/shortcut_target_animated_image"
5761      *     android:htmlDescription="@string/shortcut_target_html_description"
5762      *     android:settingsActivity="com.example.android.shortcut.target.SettingsActivity" /&gt;
5763      * </pre>
5764      * <p>
5765      * Both description and summary are necessary. The system will ignore the accessibility
5766      * shortcut target if they are missing. The animated image and html description are supported
5767      * to help users understand how to use the shortcut target. The settings activity is a
5768      * component name that allows the user to modify the settings for this accessibility shortcut
5769      * target.
5770      * </p>
5771      */
5772     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5773     public static final String CATEGORY_ACCESSIBILITY_SHORTCUT_TARGET =
5774             "android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET";
5775     // ---------------------------------------------------------------------
5776     // ---------------------------------------------------------------------
5777     // Application launch intent categories (see addCategory()).
5778 
5779     /**
5780      * Used with {@link #ACTION_MAIN} to launch the browser application.
5781      * The activity should be able to browse the Internet.
5782      * <p>NOTE: This should not be used as the primary key of an Intent,
5783      * since it will not result in the app launching with the correct
5784      * action and category.  Instead, use this with
5785      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5786      * Intent with this category in the selector.</p>
5787      */
5788     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5789     public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
5790 
5791     /**
5792      * Used with {@link #ACTION_MAIN} to launch the calculator application.
5793      * The activity should be able to perform standard arithmetic operations.
5794      * <p>NOTE: This should not be used as the primary key of an Intent,
5795      * since it will not result in the app launching with the correct
5796      * action and category.  Instead, use this with
5797      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5798      * Intent with this category in the selector.</p>
5799      */
5800     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5801     public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
5802 
5803     /**
5804      * Used with {@link #ACTION_MAIN} to launch the calendar application.
5805      * The activity should be able to view and manipulate calendar entries.
5806      * <p>NOTE: This should not be used as the primary key of an Intent,
5807      * since it will not result in the app launching with the correct
5808      * action and category.  Instead, use this with
5809      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5810      * Intent with this category in the selector.</p>
5811      */
5812     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5813     public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
5814 
5815     /**
5816      * Used with {@link #ACTION_MAIN} to launch the contacts application.
5817      * The activity should be able to view and manipulate address book entries.
5818      * <p>NOTE: This should not be used as the primary key of an Intent,
5819      * since it will not result in the app launching with the correct
5820      * action and category.  Instead, use this with
5821      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5822      * Intent with this category in the selector.</p>
5823      */
5824     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5825     public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
5826 
5827     /**
5828      * Used with {@link #ACTION_MAIN} to launch the email application.
5829      * The activity should be able to send and receive email.
5830      * <p>NOTE: This should not be used as the primary key of an Intent,
5831      * since it will not result in the app launching with the correct
5832      * action and category.  Instead, use this with
5833      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5834      * Intent with this category in the selector.</p>
5835      */
5836     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5837     public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
5838 
5839     /**
5840      * Used with {@link #ACTION_MAIN} to launch the gallery application.
5841      * The activity should be able to view and manipulate image and video files
5842      * stored on the device.
5843      * <p>NOTE: This should not be used as the primary key of an Intent,
5844      * since it will not result in the app launching with the correct
5845      * action and category.  Instead, use this with
5846      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5847      * Intent with this category in the selector.</p>
5848      */
5849     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5850     public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
5851 
5852     /**
5853      * Used with {@link #ACTION_MAIN} to launch the maps application.
5854      * The activity should be able to show the user's current location and surroundings.
5855      * <p>NOTE: This should not be used as the primary key of an Intent,
5856      * since it will not result in the app launching with the correct
5857      * action and category.  Instead, use this with
5858      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5859      * Intent with this category in the selector.</p>
5860      */
5861     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5862     public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
5863 
5864     /**
5865      * Used with {@link #ACTION_MAIN} to launch the messaging application.
5866      * The activity should be able to send and receive text messages.
5867      * <p>NOTE: This should not be used as the primary key of an Intent,
5868      * since it will not result in the app launching with the correct
5869      * action and category.  Instead, use this with
5870      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5871      * Intent with this category in the selector.</p>
5872      */
5873     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5874     public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
5875 
5876     /**
5877      * Used with {@link #ACTION_MAIN} to launch the music application.
5878      * The activity should be able to play, browse, or manipulate music files
5879      * stored on the device.
5880      * <p>NOTE: This should not be used as the primary key of an Intent,
5881      * since it will not result in the app launching with the correct
5882      * action and category.  Instead, use this with
5883      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5884      * Intent with this category in the selector.</p>
5885      */
5886     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5887     public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
5888 
5889     /**
5890      * Used with {@link #ACTION_MAIN} to launch the files application.
5891      * The activity should be able to browse and manage files stored on the device.
5892      * <p>NOTE: This should not be used as the primary key of an Intent,
5893      * since it will not result in the app launching with the correct
5894      * action and category.  Instead, use this with
5895      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5896      * Intent with this category in the selector.</p>
5897      */
5898     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5899     public static final String CATEGORY_APP_FILES = "android.intent.category.APP_FILES";
5900 
5901     /**
5902      * Used with {@link #ACTION_MAIN} to launch the weather application.
5903      * The activity should be able to give the user information about the weather
5904      * <p>NOTE: This should not be used as the primary key of an Intent,
5905      * since it will not result in the app launching with the correct
5906      * action and category.  Instead, use this with
5907      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5908      * Intent with this category in the selector.</p>
5909      */
5910     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5911     public static final String CATEGORY_APP_WEATHER = "android.intent.category.APP_WEATHER";
5912 
5913     /**
5914      * Used with {@link #ACTION_MAIN} to launch the fitness application.
5915      * The activity should be able to give the user fitness information and manage workouts
5916      * <p>NOTE: This should not be used as the primary key of an Intent,
5917      * since it will not result in the app launching with the correct
5918      * action and category.  Instead, use this with
5919      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5920      * Intent with this category in the selector.</p>
5921      */
5922     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5923     public static final String CATEGORY_APP_FITNESS = "android.intent.category.APP_FITNESS";
5924 
5925     // ---------------------------------------------------------------------
5926     // ---------------------------------------------------------------------
5927     // Standard extra data keys.
5928 
5929     /**
5930      * The initial data to place in a newly created record.  Use with
5931      * {@link #ACTION_INSERT}.  The data here is a Map containing the same
5932      * fields as would be given to the underlying ContentProvider.insert()
5933      * call.
5934      */
5935     public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
5936 
5937     /**
5938      * A constant CharSequence that is associated with the Intent, used with
5939      * {@link #ACTION_SEND} to supply the literal data to be sent.  Note that
5940      * this may be a styled CharSequence, so you must use
5941      * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
5942      * retrieve it.
5943      */
5944     public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
5945 
5946     /**
5947      * A constant String that is associated with the Intent, used with
5948      * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
5949      * as HTML formatted text.  Note that you <em>must</em> also supply
5950      * {@link #EXTRA_TEXT}.
5951      */
5952     public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
5953 
5954     /**
5955      * A content: URI holding a stream of data associated with the Intent,
5956      * used with {@link #ACTION_SEND} to supply the data being sent.
5957      */
5958     public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
5959 
5960     /**
5961      * A String[] holding e-mail addresses that should be delivered to.
5962      */
5963     public static final String EXTRA_EMAIL       = "android.intent.extra.EMAIL";
5964 
5965     /**
5966      * A String[] holding e-mail addresses that should be carbon copied.
5967      */
5968     public static final String EXTRA_CC       = "android.intent.extra.CC";
5969 
5970     /**
5971      * A String[] holding e-mail addresses that should be blind carbon copied.
5972      */
5973     public static final String EXTRA_BCC      = "android.intent.extra.BCC";
5974 
5975     /**
5976      * A constant string holding the desired subject line of a message.
5977      */
5978     public static final String EXTRA_SUBJECT  = "android.intent.extra.SUBJECT";
5979 
5980     /**
5981      * An Intent describing the choices you would like shown with
5982      * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
5983      */
5984     public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
5985 
5986     /**
5987      * An int representing the user ID to be used.
5988      *
5989      * @hide
5990      */
5991     public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
5992 
5993     /**
5994      * An int representing the task id to be retrieved. This is used when a launch from recents is
5995      * intercepted by another action such as credentials confirmation to remember which task should
5996      * be resumed when complete.
5997      *
5998      * @hide
5999      */
6000     public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
6001 
6002     /**
6003      * A String[] holding attribution tags when used with
6004      * {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD}
6005      * and ACTION_MANAGE_PERMISSION_USAGE
6006      *
6007      * E.g. an attribution tag could be location_provider, com.google.android.gms.*, etc.
6008      */
6009     public static final String EXTRA_ATTRIBUTION_TAGS = "android.intent.extra.ATTRIBUTION_TAGS";
6010 
6011     /**
6012      * A long representing the start timestamp (epoch time in millis) of the permission usage
6013      * when used with {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD}
6014      * and ACTION_MANAGE_PERMISSION_USAGE
6015      */
6016     public static final String EXTRA_START_TIME = "android.intent.extra.START_TIME";
6017 
6018     /**
6019      * A long representing the end timestamp (epoch time in millis) of the permission usage when
6020      * used with {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD}
6021      * and ACTION_MANAGE_PERMISSION_USAGE
6022      */
6023     public static final String EXTRA_END_TIME = "android.intent.extra.END_TIME";
6024 
6025     /**
6026      * A boolean extra, when used with {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD}
6027      * and {@link #ACTION_MANAGE_PERMISSION_USAGE},
6028      * that specifies whether the permission usage system UI is showing attribution information
6029      * for the chosen entry.
6030      *
6031      * <p> The extra can only be true if application has specified attributionsAreUserVisible
6032      * in its manifest. </p>
6033      *
6034      * <p> Applications can use this extra to improve their permission usage explanation
6035      * experience. </p>
6036      * @hide
6037      */
6038     @SystemApi
6039     public static final String EXTRA_SHOWING_ATTRIBUTION =
6040             "android.intent.extra.SHOWING_ATTRIBUTION";
6041 
6042     /**
6043      * An Intent[] describing additional, alternate choices you would like shown with
6044      * {@link #ACTION_CHOOSER}.
6045      *
6046      * <p>An app may be capable of providing several different payload types to complete a
6047      * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
6048      * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
6049      * several different supported sending mechanisms for sharing, such as the actual "image/*"
6050      * photo data or a hosted link where the photos can be viewed.</p>
6051      *
6052      * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
6053      * first/primary/preferred intent in the set. Additional intents specified in
6054      * this extra are ordered; by default intents that appear earlier in the array will be
6055      * preferred over intents that appear later in the array as matches for the same
6056      * target component. To alter this preference, a calling app may also supply
6057      * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
6058      */
6059     public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
6060 
6061     /**
6062      * A {@link ComponentName ComponentName[]} describing components that should be filtered out
6063      * and omitted from a list of components presented to the user.
6064      *
6065      * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
6066      * in this array if it otherwise would have shown them. Useful for omitting specific targets
6067      * from your own package or other apps from your organization if the idea of sending to those
6068      * targets would be redundant with other app functionality. Filtered components will not
6069      * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
6070      */
6071     public static final String EXTRA_EXCLUDE_COMPONENTS
6072             = "android.intent.extra.EXCLUDE_COMPONENTS";
6073 
6074     /**
6075      * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
6076      * describing additional high-priority deep-link targets for the chooser to present to the user.
6077      *
6078      * <p>Targets provided in this way will be presented inline with all other targets provided
6079      * by services from other apps. They will be prioritized before other service targets, but
6080      * after those targets provided by sources that the user has manually pinned to the front.
6081      * You can provide up to two targets on this extra (the limit of two targets
6082      * starts in Android 10).</p>
6083      *
6084      * @see #ACTION_CHOOSER
6085      */
6086     public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
6087 
6088     /**
6089      * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
6090      * from the chooser activity presented by {@link #ACTION_CHOOSER}.
6091      *
6092      * <p>An app preparing an action for another app to complete may wish to allow the user to
6093      * disambiguate between several options for completing the action based on the chosen target
6094      * or otherwise refine the action before it is invoked.
6095      * </p>
6096      *
6097      * <p>When sent, this IntentSender may be filled in with the following extras:</p>
6098      * <ul>
6099      *     <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
6100      *     <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
6101      *     chosen target beyond the first</li>
6102      *     <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
6103      *     should fill in and send once the disambiguation is complete</li>
6104      * </ul>
6105      */
6106     public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
6107             = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
6108 
6109     /**
6110      * A Parcelable[] of {@link ChooserAction} objects to provide the Android Sharesheet with
6111      * app-specific actions to be presented to the user when invoking {@link #ACTION_CHOOSER}.
6112      * You can provide as many as five custom actions.
6113      */
6114     public static final String EXTRA_CHOOSER_CUSTOM_ACTIONS =
6115             "android.intent.extra.CHOOSER_CUSTOM_ACTIONS";
6116 
6117     /**
6118      * Optional argument to be used with {@link #ACTION_CHOOSER}.
6119      * A {@link ChooserAction} to allow the user to modify what is being shared in some way. This
6120      * may be integrated into the content preview on sharesheets that have a preview UI.
6121      */
6122     public static final String EXTRA_CHOOSER_MODIFY_SHARE_ACTION =
6123             "android.intent.extra.CHOOSER_MODIFY_SHARE_ACTION";
6124 
6125     /**
6126      * Optional integer extra to be used with {@link #ACTION_CHOOSER} to describe conteng being
6127      * shared.
6128      * <p>
6129      * If provided, sharesheets may customize their UI presentation to include a more precise
6130      * description of the content being shared.
6131      *
6132      * @see #CHOOSER_CONTENT_TYPE_ALBUM
6133      * @see #createChooser(Intent, CharSequence)
6134      */
6135     public static final String EXTRA_CHOOSER_CONTENT_TYPE_HINT =
6136             "android.intent.extra.CHOOSER_CONTENT_TYPE_HINT";
6137 
6138     /** @hide */
6139     @IntDef(prefix = {"CHOOSER_CONTENT_TYPE_"}, value = {
6140             CHOOSER_CONTENT_TYPE_ALBUM,
6141     })
6142     @Retention(RetentionPolicy.SOURCE)
6143     public @interface ChooserContentType {}
6144 
6145     /**
6146      * Indicates that the content being shared with {@link #ACTION_SEND} represents an album
6147      * (e.g. containing photos).
6148      *
6149      * @see #EXTRA_CHOOSER_CONTENT_TYPE_HINT
6150      */
6151     public static final int CHOOSER_CONTENT_TYPE_ALBUM = 1;
6152 
6153     /**
6154      * Optional argument used to provide a {@link ContentProvider} {@link Uri} to an
6155      * {@link #ACTION_CHOOSER} Intent which allows additional toggleable items to be included
6156      * in the sharing UI.
6157      * <p>
6158      * For example, this could be  used to show photos being shared in the context of the user's
6159      * entire photo roll, with the option to change the set of photos being shared.
6160      * <p>
6161      * When this is provided in an {@link #ACTION_CHOOSER} Intent with an {@link #ACTION_SEND} or
6162      * {@link #ACTION_SEND_MULTIPLE} target Intent, the sharesheet will query (see
6163      * {@link ContentProvider#query(Uri, String[], Bundle, CancellationSignal)}) this URI to
6164      * retrieve a set of additional items available for selection. The set of items returned by the
6165      * content provider is expected to contain all the items from the {@link #EXTRA_STREAM}
6166      * argument, in their relative order, which will be marked as selected. The URI's authority
6167      * must be different from any shared items URI provided in {@link #EXTRA_STREAM} or returned by
6168      * the provider.
6169      *
6170      * <p>The {@link Bundle} argument of the
6171      * {@link ContentProvider#query(Uri, String[], Bundle, CancellationSignal)}
6172      * method will contains the original intent Chooser has been launched with under the
6173      * {@link #EXTRA_INTENT} key as a context for the current sharing session. The returned
6174      * {@link android.database.Cursor} should contain:
6175      * <ul>
6176      * <li>{@link android.service.chooser.AdditionalContentContract.Columns#URI} column for the item
6177      * URI.</li>
6178      * <li>Optional columns {@link MediaStore.MediaColumns#WIDTH} and
6179      * {@link MediaStore.MediaColumns#HEIGHT} for the dimensions of the preview image.
6180      * These columns can also be returned for each {@link #EXTRA_STREAM} item metadata
6181      * {@link ContentProvider#query(Uri, String[], Bundle, CancellationSignal)} call.</li>
6182      * <li>Optional {@link AdditionalContentContract.CursorExtraKeys#POSITION} extra that
6183      * specifies the cursor starting position; the item at this position is expected to match the
6184      * item specified by {@link #EXTRA_CHOOSER_FOCUSED_ITEM_POSITION}.</li></ul></p>
6185      *
6186      * <p>When the user makes a selection change,
6187      * {@link ContentProvider#call(String, String, Bundle)} method will be invoked with the "method"
6188      * argument set to
6189      * {@link android.service.chooser.AdditionalContentContract.MethodNames#ON_SELECTION_CHANGED},
6190      * the "arg" argument set to this argument's value, and the "extras" {@link Bundle} argument
6191      * containing {@link #EXTRA_INTENT} key containing the original intent Chooser has been launched
6192      * with but with the modified target intent --Chooser will modify the target intent according to
6193      * the selection changes made by the user.
6194      * Applications may implement this method to change any of the following Chooser arguments by
6195      * returning new values in the result bundle:
6196      * {@link #EXTRA_CHOOSER_TARGETS},
6197      * {@link #EXTRA_ALTERNATE_INTENTS},
6198      * {@link #EXTRA_CHOOSER_CUSTOM_ACTIONS},
6199      * {@link #EXTRA_CHOOSER_MODIFY_SHARE_ACTION},
6200      * {@link #EXTRA_METADATA_TEXT},
6201      * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER},
6202      * {@link #EXTRA_CHOOSER_RESULT_INTENT_SENDER},
6203      * {@link #EXTRA_EXCLUDE_COMPONENTS}.
6204      * </p>
6205      */
6206     public static final String EXTRA_CHOOSER_ADDITIONAL_CONTENT_URI =
6207             "android.intent.extra.CHOOSER_ADDITIONAL_CONTENT_URI";
6208 
6209     /**
6210      * Optional argument to be used with {@link #EXTRA_CHOOSER_ADDITIONAL_CONTENT_URI}, used in
6211      * combination with {@link #EXTRA_CHOOSER_ADDITIONAL_CONTENT_URI}.
6212      * An integer, zero-based index into {@link #EXTRA_STREAM} argument indicating the item that
6213      * should be focused by the Chooser in preview.
6214      */
6215     public static final String EXTRA_CHOOSER_FOCUSED_ITEM_POSITION =
6216             "android.intent.extra.CHOOSER_FOCUSED_ITEM_POSITION";
6217 
6218     /**
6219      * An {@code ArrayList} of {@code String} annotations describing content for
6220      * {@link #ACTION_CHOOSER}.
6221      *
6222      * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
6223      * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
6224      *
6225      * <p>Annotations should describe the major components or topics of the content. It is up to
6226      * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
6227      * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
6228      * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
6229      * character. Performance on customized annotations can suffer, if they are rarely used for
6230      * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
6231      * following annotations when applicable.</p>
6232      * <ul>
6233      *     <li>"product" represents that the topic of the content is mainly about products, e.g.,
6234      *     health & beauty, and office supplies.</li>
6235      *     <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
6236      *     happy, and sad.</li>
6237      *     <li>"person" represents that the topic of the content is mainly about persons, e.g.,
6238      *     face, finger, standing, and walking.</li>
6239      *     <li>"child" represents that the topic of the content is mainly about children, e.g.,
6240      *     child, and baby.</li>
6241      *     <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
6242      *     <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
6243      *     <li>"party" represents that the topic of the content is mainly about parties.</li>
6244      *     <li>"animal" represent that the topic of the content is mainly about animals.</li>
6245      *     <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
6246      *     flowers.</li>
6247      *     <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
6248      *     <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
6249      *     sunglasses, jewelry, handbags and clothing.</li>
6250      *     <li>"material" represents that the topic of the content is mainly about materials, e.g.,
6251      *     paper, and silk.</li>
6252      *     <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
6253      *     cars, and boats.</li>
6254      *     <li>"document" represents that the topic of the content is mainly about documents, e.g.
6255      *     posters.</li>
6256      *     <li>"design" represents that the topic of the content is mainly about design, e.g. arts
6257      *     and designs of houses.</li>
6258      *     <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
6259      *     Christmas and Thanksgiving.</li>
6260      * </ul>
6261      */
6262     public static final String EXTRA_CONTENT_ANNOTATIONS
6263             = "android.intent.extra.CONTENT_ANNOTATIONS";
6264 
6265     /**
6266      * A {@link ResultReceiver} used to return data back to the sender.
6267      *
6268      * <p>Used to complete an app-specific
6269      * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
6270      *
6271      * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
6272      * used to start a {@link #ACTION_CHOOSER} activity this extra will be
6273      * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
6274      * when the user selects a target component from the chooser. It is up to the recipient
6275      * to send a result to this ResultReceiver to signal that disambiguation is complete
6276      * and that the chooser should invoke the user's choice.</p>
6277      *
6278      * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
6279      * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
6280      * to match and fill in the final Intent or ChooserTarget before starting it.
6281      * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
6282      * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
6283      * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
6284      *
6285      * <p>The result code passed to the ResultReceiver should be
6286      * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
6287      * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
6288      * the chooser should finish without starting a target.</p>
6289      */
6290     public static final String EXTRA_RESULT_RECEIVER
6291             = "android.intent.extra.RESULT_RECEIVER";
6292 
6293     /**
6294      * A CharSequence dialog title to provide to the user when used with a
6295      * {@link #ACTION_CHOOSER}.
6296      */
6297     public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
6298 
6299     /**
6300      * A Parcelable[] of {@link Intent} or
6301      * {@link android.content.pm.LabeledIntent} objects as set with
6302      * {@link #putExtra(String, Parcelable[])} to place
6303      * at the front of the list of choices, when shown to the user with an
6304      * {@link #ACTION_CHOOSER}. You can choose up to two additional activities
6305      * to show before the app suggestions (the limit of two additional activities starts in
6306      * Android 10).
6307      */
6308     public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
6309 
6310     /**
6311      * A CharSequence of additional text describing the content being shared. This text will be
6312      * displayed to the user as a part of the sharesheet when included in an
6313      * {@link #ACTION_CHOOSER} {@link Intent}.
6314      *
6315      * <p>e.g. When sharing a photo, metadata could inform the user that location data is included
6316      * in the photo they are sharing.</p>
6317      */
6318     public static final String EXTRA_METADATA_TEXT = "android.intent.extra.METADATA_TEXT";
6319 
6320     /**
6321      * A {@link IntentSender} to start after instant app installation success.
6322      * @hide
6323      */
6324     @SystemApi
6325     public static final String EXTRA_INSTANT_APP_SUCCESS =
6326             "android.intent.extra.INSTANT_APP_SUCCESS";
6327 
6328     /**
6329      * A {@link IntentSender} to start after instant app installation failure.
6330      * @hide
6331      */
6332     @SystemApi
6333     public static final String EXTRA_INSTANT_APP_FAILURE =
6334             "android.intent.extra.INSTANT_APP_FAILURE";
6335 
6336     /**
6337      * The host name that triggered an instant app resolution.
6338      * @hide
6339      */
6340     @SystemApi
6341     public static final String EXTRA_INSTANT_APP_HOSTNAME =
6342             "android.intent.extra.INSTANT_APP_HOSTNAME";
6343 
6344     /**
6345      * An opaque token to track instant app resolution.
6346      * @hide
6347      */
6348     @SystemApi
6349     public static final String EXTRA_INSTANT_APP_TOKEN =
6350             "android.intent.extra.INSTANT_APP_TOKEN";
6351 
6352     /**
6353      * The action that triggered an instant application resolution.
6354      * @hide
6355      */
6356     @SystemApi
6357     public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION";
6358 
6359     /**
6360      * An array of {@link Bundle}s containing details about resolved instant apps..
6361      * @hide
6362      */
6363     @SystemApi
6364     public static final String EXTRA_INSTANT_APP_BUNDLES =
6365             "android.intent.extra.INSTANT_APP_BUNDLES";
6366 
6367     /**
6368      * A {@link Bundle} of metadata that describes the instant application that needs to be
6369      * installed. This data is populated from the response to
6370      * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered
6371      * instant application resolver.
6372      * @hide
6373      */
6374     @SystemApi
6375     public static final String EXTRA_INSTANT_APP_EXTRAS =
6376             "android.intent.extra.INSTANT_APP_EXTRAS";
6377 
6378     /**
6379      * A boolean value indicating that the instant app resolver was unable to state with certainty
6380      * that it did or did not have an app for the sanitized {@link Intent} defined at
6381      * {@link #EXTRA_INTENT}.
6382      * @hide
6383      */
6384     @SystemApi
6385     public static final String EXTRA_UNKNOWN_INSTANT_APP =
6386             "android.intent.extra.UNKNOWN_INSTANT_APP";
6387 
6388     /**
6389      * The version code of the app to install components from.
6390      * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE).
6391      * @hide
6392      */
6393     @Deprecated
6394     public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
6395 
6396     /**
6397      * The version code of the app to install components from.
6398      * @hide
6399      */
6400     @SystemApi
6401     public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE";
6402 
6403     /**
6404      * The app that triggered the instant app installation.
6405      * @hide
6406      */
6407     @SystemApi
6408     public static final String EXTRA_CALLING_PACKAGE
6409             = "android.intent.extra.CALLING_PACKAGE";
6410 
6411     /**
6412      * Optional calling app provided bundle containing additional launch information the
6413      * installer may use.
6414      * @hide
6415      */
6416     @SystemApi
6417     public static final String EXTRA_VERIFICATION_BUNDLE
6418             = "android.intent.extra.VERIFICATION_BUNDLE";
6419 
6420     /**
6421      * A Bundle forming a mapping of potential target package names to different extras Bundles
6422      * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
6423      * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
6424      * be currently installed on the device.
6425      *
6426      * <p>An application may choose to provide alternate extras for the case where a user
6427      * selects an activity from a predetermined set of target packages. If the activity
6428      * the user selects from the chooser belongs to a package with its package name as
6429      * a key in this bundle, the corresponding extras for that package will be merged with
6430      * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
6431      * extra has the same key as an extra already present in the intent it will overwrite
6432      * the extra from the intent.</p>
6433      *
6434      * <p><em>Examples:</em>
6435      * <ul>
6436      *     <li>An application may offer different {@link #EXTRA_TEXT} to an application
6437      *     when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
6438      *     parameters for that target.</li>
6439      *     <li>An application may offer additional metadata for known targets of a given intent
6440      *     to pass along information only relevant to that target such as account or content
6441      *     identifiers already known to that application.</li>
6442      * </ul></p>
6443      */
6444     public static final String EXTRA_REPLACEMENT_EXTRAS =
6445             "android.intent.extra.REPLACEMENT_EXTRAS";
6446 
6447     /**
6448      * An {@link IntentSender} that will be notified if a user successfully chooses a target
6449      * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
6450      * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
6451      * {@link ComponentName} of the chosen component.
6452      *
6453      * <p>In some situations this callback may never come, for example if the user abandons
6454      * the chooser, switches to another task or any number of other reasons. Apps should not
6455      * be written assuming that this callback will always occur.</p>
6456      */
6457     public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
6458             "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
6459 
6460     /**
6461      * An {@link IntentSender} that will be notified when a user successfully chooses a target
6462      * component or initiates an action such as copy or edit within an {@link #ACTION_CHOOSER}
6463      * activity. The IntentSender will have the extra {@link #EXTRA_CHOOSER_RESULT} describing
6464      * the result.
6465      */
6466     public static final String EXTRA_CHOOSER_RESULT_INTENT_SENDER =
6467             "android.intent.extra.CHOOSER_RESULT_INTENT_SENDER";
6468 
6469     /**
6470      * A {@link ChooserResult} which describes how the sharing session completed.
6471      * <p>
6472      * An instance is supplied to the optional IntentSender provided to
6473      * {@link #createChooser(Intent, CharSequence, IntentSender)} when the session completes.
6474      */
6475     public static final String EXTRA_CHOOSER_RESULT = "android.intent.extra.CHOOSER_RESULT";
6476 
6477     /**
6478      * The {@link ComponentName} chosen by the user to complete an action.
6479      *
6480      * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
6481      */
6482     public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
6483 
6484     /**
6485      * A {@link android.view.KeyEvent} object containing the event that
6486      * triggered the creation of the Intent it is in.
6487      */
6488     public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
6489 
6490     /**
6491      * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
6492      * before shutting down.
6493      *
6494      * {@hide}
6495      */
6496     public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
6497 
6498     /**
6499      * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
6500      * requested by the user.
6501      *
6502      * {@hide}
6503      */
6504     public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
6505             "android.intent.extra.USER_REQUESTED_SHUTDOWN";
6506 
6507     /**
6508      * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
6509      * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
6510      * of restarting the application.
6511      */
6512     public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
6513 
6514     /**
6515      * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
6516      * intents to signal that the application was removed with the user-initiated action.
6517      */
6518     public static final String EXTRA_USER_INITIATED = "android.intent.extra.USER_INITIATED";
6519 
6520     /**
6521      * A String holding the phone number originally entered in
6522      * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
6523      * number to call in a {@link android.content.Intent#ACTION_CALL}.
6524      */
6525     public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
6526 
6527     /**
6528      * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
6529      * intents to supply the uid the package had been assigned.  Also an optional
6530      * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
6531      * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
6532      * purpose.
6533      */
6534     public static final String EXTRA_UID = "android.intent.extra.UID";
6535 
6536     /**
6537      * String array of package names.
6538      */
6539     public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
6540 
6541     /**
6542      * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
6543      * intents to indicate whether this represents a full uninstall (removing
6544      * both the code and its data) or a partial uninstall (leaving its data,
6545      * implying that this is an update).
6546      */
6547     public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
6548 
6549     /**
6550      * @hide
6551      * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
6552      * intents to indicate that at this point the package has been removed for
6553      * all users on the device.
6554      */
6555     public static final String EXTRA_REMOVED_FOR_ALL_USERS
6556             = "android.intent.extra.REMOVED_FOR_ALL_USERS";
6557 
6558     /**
6559      * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
6560      * intents to indicate that this is a replacement of the package, so this
6561      * broadcast will immediately be followed by an add broadcast for a
6562      * different version of the same package.
6563      */
6564     public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
6565 
6566     /**
6567      * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_ADDED} and
6568      * {@link android.content.Intent#ACTION_PACKAGE_REMOVED} intents to indicate that
6569      * the package is being archived. Either by removing the existing APK, or by installing
6570      * a package without an APK.
6571      */
6572     @FlaggedApi(android.content.pm.Flags.FLAG_ARCHIVING)
6573     public static final String EXTRA_ARCHIVAL = "android.intent.extra.ARCHIVAL";
6574 
6575     /**
6576      * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
6577      * intents to indicate that this is a system update uninstall.
6578      * @hide
6579      */
6580     public static final String EXTRA_SYSTEM_UPDATE_UNINSTALL =
6581             "android.intent.extra.SYSTEM_UPDATE_UNINSTALL";
6582 
6583     /**
6584      * Used as an int extra field in {@link android.app.AlarmManager} pending intents
6585      * to tell the application being invoked how many pending alarms are being
6586      * delivered with the intent.  For one-shot alarms this will always be 1.
6587      * For recurring alarms, this might be greater than 1 if the device was
6588      * asleep or powered off at the time an earlier alarm would have been
6589      * delivered.
6590      *
6591      * <p>Note: You must supply a <b>mutable</b> {@link android.app.PendingIntent} to
6592      * {@code AlarmManager} while setting your alarms to be able to read this value on receiving
6593      * them. <em>Mutability of pending intents must be explicitly specified by apps targeting
6594      * {@link Build.VERSION_CODES#S} or higher</em>.
6595      *
6596      * @see android.app.PendingIntent#FLAG_MUTABLE
6597      *
6598      */
6599     public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
6600 
6601     /**
6602      * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
6603      * intents to request the dock state.  Possible values are
6604      * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
6605      * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
6606      * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
6607      * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
6608      * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
6609      */
6610     public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
6611 
6612     /**
6613      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
6614      * to represent that the phone is not in any dock.
6615      */
6616     public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
6617 
6618     /**
6619      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
6620      * to represent that the phone is in a desk dock.
6621      */
6622     public static final int EXTRA_DOCK_STATE_DESK = 1;
6623 
6624     /**
6625      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
6626      * to represent that the phone is in a car dock.
6627      */
6628     public static final int EXTRA_DOCK_STATE_CAR = 2;
6629 
6630     /**
6631      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
6632      * to represent that the phone is in a analog (low end) dock.
6633      */
6634     public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
6635 
6636     /**
6637      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
6638      * to represent that the phone is in a digital (high end) dock.
6639      */
6640     public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
6641 
6642     /**
6643      * Boolean that can be supplied as meta-data with a dock activity, to
6644      * indicate that the dock should take over the home key when it is active.
6645      */
6646     public static final String METADATA_DOCK_HOME = "android.dock_home";
6647 
6648     /**
6649      * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
6650      * the bug report.
6651      */
6652     public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
6653 
6654     /**
6655      * Used in the extra field in the remote intent. It's a string token passed with the
6656      * remote intent.
6657      */
6658     public static final String EXTRA_REMOTE_INTENT_TOKEN =
6659             "android.intent.extra.remote_intent_token";
6660 
6661     /**
6662      * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
6663      * will contain only the first name in the list.
6664      */
6665     @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
6666             "android.intent.extra.changed_component_name";
6667 
6668     /**
6669      * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
6670      * and contains a string array of all of the components that have changed.  If
6671      * the state of the overall package has changed, then it will contain an entry
6672      * with the package name itself.
6673      */
6674     public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
6675             "android.intent.extra.changed_component_name_list";
6676 
6677     /**
6678      * This field is part of
6679      * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
6680      * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
6681      * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
6682      * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
6683      * and contains a string array of all of the components that have changed.
6684      */
6685     public static final String EXTRA_CHANGED_PACKAGE_LIST =
6686             "android.intent.extra.changed_package_list";
6687 
6688     /**
6689      * This field is part of
6690      * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
6691      * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
6692      * and contains an integer array of uids of all of the components
6693      * that have changed.
6694      */
6695     public static final String EXTRA_CHANGED_UID_LIST =
6696             "android.intent.extra.changed_uid_list";
6697 
6698     /**
6699      * This field is part of
6700      * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
6701      * and only present if the packages were quarantined.
6702      * @hide
6703      */
6704     public static final String EXTRA_QUARANTINED =
6705             "android.intent.extra.quarantined";
6706 
6707     /**
6708      * An integer denoting a bitwise combination of restrictions set on distracting packages via
6709      * {@link PackageManager#setDistractingPackageRestrictions(String[], int)}
6710      *
6711      * @hide
6712      * @see PackageManager.DistractionRestriction
6713      * @see PackageManager#setDistractingPackageRestrictions(String[], int)
6714      */
6715     public static final String EXTRA_DISTRACTION_RESTRICTIONS =
6716             "android.intent.extra.distraction_restrictions";
6717 
6718     /**
6719      * @hide
6720      * Magic extra system code can use when binding, to give a label for
6721      * who it is that has bound to a service.  This is an integer giving
6722      * a framework string resource that can be displayed to the user.
6723      */
6724     public static final String EXTRA_CLIENT_LABEL =
6725             "android.intent.extra.client_label";
6726 
6727     /**
6728      * @hide
6729      * Magic extra system code can use when binding, to give a PendingIntent object
6730      * that can be launched for the user to disable the system's use of this
6731      * service.
6732      */
6733     public static final String EXTRA_CLIENT_INTENT =
6734             "android.intent.extra.client_intent";
6735 
6736     /**
6737      * Extra used to indicate that an intent should only return data that is on
6738      * the local device. This is a boolean extra; the default is false. If true,
6739      * an implementation should only allow the user to select data that is
6740      * already on the device, not requiring it be downloaded from a remote
6741      * service when opened.
6742      *
6743      * @see #ACTION_GET_CONTENT
6744      * @see #ACTION_OPEN_DOCUMENT
6745      * @see #ACTION_OPEN_DOCUMENT_TREE
6746      * @see #ACTION_CREATE_DOCUMENT
6747      */
6748     public static final String EXTRA_LOCAL_ONLY =
6749             "android.intent.extra.LOCAL_ONLY";
6750 
6751     /**
6752      * Extra used to indicate that an intent can allow the user to select and
6753      * return multiple items. This is a boolean extra; the default is false. If
6754      * true, an implementation is allowed to present the user with a UI where
6755      * they can pick multiple items that are all returned to the caller. When
6756      * this happens, they should be returned as the {@link #getClipData()} part
6757      * of the result Intent.
6758      *
6759      * @see #ACTION_GET_CONTENT
6760      * @see #ACTION_OPEN_DOCUMENT
6761      */
6762     public static final String EXTRA_ALLOW_MULTIPLE =
6763             "android.intent.extra.ALLOW_MULTIPLE";
6764 
6765     /**
6766      * The user ID integer carried with broadcast intents related to addition,
6767      * removal and switching of users and managed profiles - {@link #ACTION_USER_ADDED},
6768      * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
6769      *
6770      * @hide
6771      */
6772     @SystemApi
6773     @SuppressLint("ActionValue")
6774     public static final String EXTRA_USER_HANDLE =
6775             "android.intent.extra.user_handle";
6776 
6777     /**
6778      * The {@link UserHandle} carried with intents.
6779      */
6780     public static final String EXTRA_USER =
6781             "android.intent.extra.USER";
6782 
6783     /**
6784      * Extra used in the response from a BroadcastReceiver that handles
6785      * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
6786      * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
6787      */
6788     public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
6789 
6790     /**
6791      * Extra sent in the intent to the BroadcastReceiver that handles
6792      * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
6793      * the restrictions as key/value pairs.
6794      */
6795     public static final String EXTRA_RESTRICTIONS_BUNDLE =
6796             "android.intent.extra.restrictions_bundle";
6797 
6798     /**
6799      * Extra used in the response from a BroadcastReceiver that handles
6800      * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
6801      */
6802     public static final String EXTRA_RESTRICTIONS_INTENT =
6803             "android.intent.extra.restrictions_intent";
6804 
6805     /**
6806      * Extra used to communicate a set of acceptable MIME types. The type of the
6807      * extra is {@code String[]}. Values may be a combination of concrete MIME
6808      * types (such as "image/png") and/or partial MIME types (such as
6809      * "audio/*").
6810      *
6811      * @see #ACTION_GET_CONTENT
6812      * @see #ACTION_OPEN_DOCUMENT
6813      */
6814     public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
6815 
6816     /**
6817      * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
6818      * this shutdown is only for the user space of the system, not a complete shutdown.
6819      * When this is true, hardware devices can use this information to determine that
6820      * they shouldn't do a complete shutdown of their device since this is not a
6821      * complete shutdown down to the kernel, but only user space restarting.
6822      * The default if not supplied is false.
6823      */
6824     public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
6825             = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
6826 
6827     /**
6828      * Optional extra specifying a time in milliseconds. The timebase depends on the Intent
6829      * including this extra. The value must be non-negative.
6830      * <p>
6831      * Type: long
6832      * </p>
6833      */
6834     public static final String EXTRA_TIME = "android.intent.extra.TIME";
6835 
6836     /**
6837      * Extra sent with {@link #ACTION_TIMEZONE_CHANGED} specifying the new time zone of the device.
6838      *
6839      * <p>Type: String, the same as returned by {@link TimeZone#getID()} to identify time zones.
6840      */
6841     @SuppressLint("ActionValue")
6842     public static final String EXTRA_TIMEZONE = "time-zone";
6843 
6844     /**
6845      * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
6846      * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
6847      * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
6848      * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
6849      *
6850      * @hide for internal use only.
6851      */
6852     public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
6853             "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
6854     /** @hide */
6855     public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
6856     /** @hide */
6857     public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
6858     /** @hide */
6859     public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
6860 
6861     /**
6862      * Intent extra: the reason that the operation associated with this intent is being performed.
6863      *
6864      * <p>Type: String
6865      * @hide
6866      */
6867     @SystemApi
6868     public static final String EXTRA_REASON = "android.intent.extra.REASON";
6869 
6870     /**
6871      * Intent extra: Whether to show the wipe progress UI or to skip it.
6872      *
6873      * <p>Type: boolean
6874      * @hide
6875      */
6876     public static final String EXTRA_SHOW_WIPE_PROGRESS = "android.intent.extra.SHOW_WIPE_PROGRESS";
6877 
6878     /**
6879      * {@hide}
6880      * This extra will be send together with {@link #ACTION_FACTORY_RESET}
6881      */
6882     public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
6883 
6884     /**
6885      * {@hide}
6886      * This extra will be set to true when the user choose to wipe the data on eSIM during factory
6887      * reset for the device with eSIM. This extra will be sent together with
6888      * {@link #ACTION_FACTORY_RESET}
6889      */
6890     public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
6891 
6892     /**
6893      * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
6894      * activation request.
6895      * TODO: Add information about the structure and response data used with the pending intent.
6896      * @hide
6897      */
6898     public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
6899             "android.intent.extra.SIM_ACTIVATION_RESPONSE";
6900 
6901     /**
6902      * Optional index with semantics depending on the intent action.
6903      *
6904      * <p>The value must be an integer greater or equal to 0.
6905      * @see #ACTION_QUICK_VIEW
6906      */
6907     public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
6908 
6909     /**
6910      * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
6911      * such as opening in other apps, sharing, opening, editing, printing, deleting,
6912      * casting, etc.
6913      *
6914      * <p>The value is boolean. By default false.
6915      * @see #ACTION_QUICK_VIEW
6916      * @removed
6917      */
6918     @Deprecated
6919     public static final String EXTRA_QUICK_VIEW_ADVANCED =
6920             "android.intent.extra.QUICK_VIEW_ADVANCED";
6921 
6922     /**
6923      * An optional extra of {@code String[]} indicating which quick view features should be made
6924      * available to the user in the quick view UI while handing a
6925      * {@link Intent#ACTION_QUICK_VIEW} intent.
6926      * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
6927      * Quick viewer can implement features not listed below.
6928      * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
6929      * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE},
6930      * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND},
6931      * {@link QuickViewConstants#FEATURE_PRINT}.
6932      * <p>
6933      * Requirements:
6934      * <li>Quick viewer shouldn't show a feature if the feature is absent in
6935      * {@link #EXTRA_QUICK_VIEW_FEATURES}.
6936      * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
6937      * internal policies.
6938      * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
6939      * requirement that the feature be shown. Quick viewer may, according to its own policies,
6940      * disable or hide features.
6941      *
6942      * @see #ACTION_QUICK_VIEW
6943      */
6944     public static final String EXTRA_QUICK_VIEW_FEATURES =
6945             "android.intent.extra.QUICK_VIEW_FEATURES";
6946 
6947     /**
6948      * Optional boolean extra indicating whether quiet mode has been switched on or off.
6949      * When a profile goes into quiet mode, all apps in the profile are killed and the
6950      * profile user is stopped. Widgets originating from the profile are masked, and app
6951      * launcher icons are grayed out.
6952      */
6953     public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
6954 
6955     /**
6956      * Optional CharSequence extra to provide a search query.
6957      * The format of this query is dependent on the receiving application.
6958      *
6959      * <p>Applicable to {@link Intent} with actions:
6960      * <ul>
6961      *      <li>{@link Intent#ACTION_GET_CONTENT}</li>
6962      *      <li>{@link Intent#ACTION_OPEN_DOCUMENT}</li>
6963      * </ul>
6964      */
6965     public static final String EXTRA_CONTENT_QUERY = "android.intent.extra.CONTENT_QUERY";
6966 
6967     /**
6968      * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
6969      * intents to specify the resource type granted. Possible values are
6970      * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
6971      * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
6972      *
6973      * @hide
6974      */
6975     public static final String EXTRA_MEDIA_RESOURCE_TYPE =
6976             "android.intent.extra.MEDIA_RESOURCE_TYPE";
6977 
6978     /**
6979      * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
6980      * whether to show the chooser or not when there is only one application available
6981      * to choose from.
6982      */
6983     public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
6984             "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
6985 
6986     /**
6987      * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
6988      * to represent that a video codec is allowed to use.
6989      *
6990      * @hide
6991      */
6992     public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
6993 
6994     /**
6995      * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
6996      * to represent that a audio codec is allowed to use.
6997      *
6998      * @hide
6999      */
7000     public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
7001 
7002     /**
7003      * Intent extra: ID of the context used on {@link #ACTION_VIEW_LOCUS}.
7004      *
7005      * <p>
7006      * Type: {@link LocusId}
7007      * </p>
7008      */
7009     public static final String EXTRA_LOCUS_ID = "android.intent.extra.LOCUS_ID";
7010 
7011     /**
7012      * Used as an int array extra field in
7013      * {@link android.content.Intent#ACTION_PACKAGE_REMOVED_INTERNAL}
7014      * intents to indicate that visibility allow list of this removed package.
7015      *
7016      * @hide
7017      */
7018     public static final String EXTRA_VISIBILITY_ALLOW_LIST =
7019             "android.intent.extra.VISIBILITY_ALLOW_LIST";
7020 
7021     /**
7022      * A boolean extra used with {@link #ACTION_PACKAGE_DATA_CLEARED} which indicates if the intent
7023      * is broadcast as part of a restore operation.
7024      *
7025      * @hide
7026      */
7027     public static final String EXTRA_IS_RESTORE =
7028             "android.intent.extra.IS_RESTORE";
7029 
7030     // ---------------------------------------------------------------------
7031     // ---------------------------------------------------------------------
7032     // Intent flags (see mFlags variable).
7033 
7034     /** @hide */
7035     @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
7036             FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
7037             FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
7038     @Retention(RetentionPolicy.SOURCE)
7039     public @interface GrantUriMode {}
7040 
7041     /** @hide */
7042     @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
7043             FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
7044     @Retention(RetentionPolicy.SOURCE)
7045     public @interface AccessUriMode {}
7046 
7047     /**
7048      * Test if given mode flags specify an access mode, which must be at least
7049      * read and/or write.
7050      *
7051      * @hide
7052      */
isAccessUriMode(int modeFlags)7053     public static boolean isAccessUriMode(int modeFlags) {
7054         return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
7055                 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
7056     }
7057 
7058     /** @hide */
7059     @IntDef(flag = true, prefix = { "FLAG_" }, value = {
7060             FLAG_GRANT_READ_URI_PERMISSION,
7061             FLAG_GRANT_WRITE_URI_PERMISSION,
7062             FLAG_FROM_BACKGROUND,
7063             FLAG_DEBUG_LOG_RESOLUTION,
7064             FLAG_EXCLUDE_STOPPED_PACKAGES,
7065             FLAG_INCLUDE_STOPPED_PACKAGES,
7066             FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
7067             FLAG_GRANT_PREFIX_URI_PERMISSION,
7068             FLAG_DEBUG_TRIAGED_MISSING,
7069             FLAG_IGNORE_EPHEMERAL,
7070             FLAG_ACTIVITY_MATCH_EXTERNAL,
7071             FLAG_ACTIVITY_NO_HISTORY,
7072             FLAG_ACTIVITY_SINGLE_TOP,
7073             FLAG_ACTIVITY_NEW_TASK,
7074             FLAG_ACTIVITY_MULTIPLE_TASK,
7075             FLAG_ACTIVITY_CLEAR_TOP,
7076             FLAG_ACTIVITY_FORWARD_RESULT,
7077             FLAG_ACTIVITY_PREVIOUS_IS_TOP,
7078             FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
7079             FLAG_ACTIVITY_BROUGHT_TO_FRONT,
7080             FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
7081             FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
7082             FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
7083             FLAG_ACTIVITY_NEW_DOCUMENT,
7084             FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
7085             FLAG_ACTIVITY_NO_USER_ACTION,
7086             FLAG_ACTIVITY_REORDER_TO_FRONT,
7087             FLAG_ACTIVITY_NO_ANIMATION,
7088             FLAG_ACTIVITY_CLEAR_TASK,
7089             FLAG_ACTIVITY_TASK_ON_HOME,
7090             FLAG_ACTIVITY_RETAIN_IN_RECENTS,
7091             FLAG_ACTIVITY_LAUNCH_ADJACENT,
7092             FLAG_ACTIVITY_REQUIRE_NON_BROWSER,
7093             FLAG_ACTIVITY_REQUIRE_DEFAULT,
7094             FLAG_RECEIVER_REGISTERED_ONLY,
7095             FLAG_RECEIVER_REPLACE_PENDING,
7096             FLAG_RECEIVER_FOREGROUND,
7097             FLAG_RECEIVER_NO_ABORT,
7098             FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
7099             FLAG_RECEIVER_BOOT_UPGRADE,
7100             FLAG_RECEIVER_INCLUDE_BACKGROUND,
7101             FLAG_RECEIVER_EXCLUDE_BACKGROUND,
7102             FLAG_RECEIVER_FROM_SHELL,
7103             FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
7104             FLAG_RECEIVER_OFFLOAD,
7105             FLAG_RECEIVER_OFFLOAD_FOREGROUND,
7106     })
7107     @Retention(RetentionPolicy.SOURCE)
7108     public @interface Flags {}
7109 
7110     /** @hide */
7111     @IntDef(flag = true, prefix = { "FLAG_" }, value = {
7112             FLAG_FROM_BACKGROUND,
7113             FLAG_DEBUG_LOG_RESOLUTION,
7114             FLAG_EXCLUDE_STOPPED_PACKAGES,
7115             FLAG_INCLUDE_STOPPED_PACKAGES,
7116             FLAG_DEBUG_TRIAGED_MISSING,
7117             FLAG_IGNORE_EPHEMERAL,
7118             FLAG_ACTIVITY_MATCH_EXTERNAL,
7119             FLAG_ACTIVITY_NO_HISTORY,
7120             FLAG_ACTIVITY_SINGLE_TOP,
7121             FLAG_ACTIVITY_NEW_TASK,
7122             FLAG_ACTIVITY_MULTIPLE_TASK,
7123             FLAG_ACTIVITY_CLEAR_TOP,
7124             FLAG_ACTIVITY_FORWARD_RESULT,
7125             FLAG_ACTIVITY_PREVIOUS_IS_TOP,
7126             FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
7127             FLAG_ACTIVITY_BROUGHT_TO_FRONT,
7128             FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
7129             FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
7130             FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
7131             FLAG_ACTIVITY_NEW_DOCUMENT,
7132             FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
7133             FLAG_ACTIVITY_NO_USER_ACTION,
7134             FLAG_ACTIVITY_REORDER_TO_FRONT,
7135             FLAG_ACTIVITY_NO_ANIMATION,
7136             FLAG_ACTIVITY_CLEAR_TASK,
7137             FLAG_ACTIVITY_TASK_ON_HOME,
7138             FLAG_ACTIVITY_RETAIN_IN_RECENTS,
7139             FLAG_ACTIVITY_LAUNCH_ADJACENT,
7140             FLAG_RECEIVER_REGISTERED_ONLY,
7141             FLAG_RECEIVER_REPLACE_PENDING,
7142             FLAG_RECEIVER_FOREGROUND,
7143             FLAG_RECEIVER_NO_ABORT,
7144             FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
7145             FLAG_RECEIVER_BOOT_UPGRADE,
7146             FLAG_RECEIVER_INCLUDE_BACKGROUND,
7147             FLAG_RECEIVER_EXCLUDE_BACKGROUND,
7148             FLAG_RECEIVER_FROM_SHELL,
7149             FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
7150             FLAG_RECEIVER_OFFLOAD,
7151             FLAG_RECEIVER_OFFLOAD_FOREGROUND,
7152     })
7153     @Retention(RetentionPolicy.SOURCE)
7154     public @interface MutableFlags {}
7155 
7156     /**
7157      * If set, the recipient of this Intent will be granted permission to
7158      * perform read operations on the URI in the Intent's data and any URIs
7159      * specified in its ClipData.  When applying to an Intent's ClipData,
7160      * all URIs as well as recursive traversals through data or other ClipData
7161      * in Intent items will be granted; only the grant flags of the top-level
7162      * Intent are used.
7163      */
7164     public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
7165     /**
7166      * If set, the recipient of this Intent will be granted permission to
7167      * perform write operations on the URI in the Intent's data and any URIs
7168      * specified in its ClipData.  When applying to an Intent's ClipData,
7169      * all URIs as well as recursive traversals through data or other ClipData
7170      * in Intent items will be granted; only the grant flags of the top-level
7171      * Intent are used.
7172      */
7173     public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
7174     /**
7175      * Can be set by the caller to indicate that this Intent is coming from
7176      * a background operation, not from direct user interaction.
7177      */
7178     public static final int FLAG_FROM_BACKGROUND = 0x00000004;
7179     /**
7180      * A flag you can enable for debugging: when set, log messages will be
7181      * printed during the resolution of this intent to show you what has
7182      * been found to create the final resolved list.
7183      */
7184     public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
7185     /**
7186      * If set, this intent will not match any components in packages that
7187      * are currently
7188      * {@linkplain android.content.pm.ApplicationInfo#FLAG_STOPPED stopped}.
7189      * If this is not set, then the default behavior is to include such
7190      * applications in the result.
7191      */
7192     public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
7193     /**
7194      * If set, this intent will always match any components in packages that
7195      * are currently
7196      * {@linkplain android.content.pm.ApplicationInfo#FLAG_STOPPED stopped}.
7197      * This is the default behavior when
7198      * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set.  If both of these
7199      * flags are set, this one wins (it allows overriding of exclude for
7200      * places where the framework may automatically set the exclude flag,
7201      * such as broadcasts).
7202      */
7203     public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
7204 
7205     /**
7206      * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
7207      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
7208      * persisted across device reboots until explicitly revoked with
7209      * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
7210      * grant for possible persisting; the receiving application must call
7211      * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
7212      * actually persist.
7213      *
7214      * @see ContentResolver#takePersistableUriPermission(Uri, int)
7215      * @see ContentResolver#releasePersistableUriPermission(Uri, int)
7216      * @see ContentResolver#getPersistedUriPermissions()
7217      * @see ContentResolver#getOutgoingPersistedUriPermissions()
7218      */
7219     public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
7220 
7221     /**
7222      * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
7223      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
7224      * applies to any URI that is a prefix match against the original granted
7225      * URI. (Without this flag, the URI must match exactly for access to be
7226      * granted.) Another URI is considered a prefix match only when scheme,
7227      * authority, and all path segments defined by the prefix are an exact
7228      * match.
7229      */
7230     public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
7231 
7232     /**
7233      * Flag used to automatically match intents based on their Direct Boot
7234      * awareness and the current user state.
7235      * <p>
7236      * Since the default behavior is to automatically apply the current user
7237      * state, this is effectively a sentinel value that doesn't change the
7238      * output of any queries based on its presence or absence.
7239      * <p>
7240      * Instead, this value can be useful in conjunction with
7241      * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()}
7242      * to detect when a caller is relying on implicit automatic matching,
7243      * instead of confirming the explicit behavior they want.
7244      */
7245     public static final int FLAG_DIRECT_BOOT_AUTO = 0x00000100;
7246 
7247     /** {@hide} */
7248     @Deprecated
7249     public static final int FLAG_DEBUG_TRIAGED_MISSING = FLAG_DIRECT_BOOT_AUTO;
7250 
7251     /**
7252      * Internal flag used to indicate ephemeral applications should not be
7253      * considered when resolving the intent.
7254      *
7255      * @hide
7256      */
7257     public static final int FLAG_IGNORE_EPHEMERAL = 0x80000000;
7258 
7259     /**
7260      * If set, the new activity is not kept in the history stack.  As soon as
7261      * the user navigates away from it, the activity is finished.  This may also
7262      * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
7263      * noHistory} attribute.
7264      *
7265      * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
7266      * is never invoked when the current activity starts a new activity which
7267      * sets a result and finishes.
7268      */
7269     public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
7270     /**
7271      * If set, the activity will not be launched if it is already running
7272      * at the top of the history stack.  See
7273      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html#TaskLaunchModes">
7274      * Tasks and Back Stack</a> for more information.
7275      */
7276     public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
7277     /**
7278      * If set, this activity will become the start of a new task on this
7279      * history stack.  A task (from the activity that started it to the
7280      * next task activity) defines an atomic group of activities that the
7281      * user can move to.  Tasks can be moved to the foreground and background;
7282      * all of the activities inside of a particular task always remain in
7283      * the same order.  See
7284      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
7285      * Stack</a> for more information about tasks.
7286      *
7287      * <p>This flag is generally used by activities that want
7288      * to present a "launcher" style behavior: they give the user a list of
7289      * separate things that can be done, which otherwise run completely
7290      * independently of the activity launching them.
7291      *
7292      * <p>When using this flag, if a task is already running for the activity
7293      * you are now starting, then a new activity will not be started; instead,
7294      * the current task will simply be brought to the front of the screen with
7295      * the state it was last in.  See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
7296      * to disable this behavior.
7297      *
7298      * <p>This flag can not be used when the caller is requesting a result from
7299      * the activity being launched.
7300      */
7301     public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
7302     /**
7303      * This flag is used to create a new task and launch an activity into it.
7304      * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
7305      * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
7306      * search through existing tasks for ones matching this Intent. Only if no such
7307      * task is found would a new task be created. When paired with
7308      * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
7309      * the search for a matching task and unconditionally start a new task.
7310      *
7311      * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
7312      * flag unless you are implementing your own
7313      * top-level application launcher.</strong>  Used in conjunction with
7314      * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
7315      * behavior of bringing an existing task to the foreground.  When set,
7316      * a new task is <em>always</em> started to host the Activity for the
7317      * Intent, regardless of whether there is already an existing task running
7318      * the same thing.
7319      *
7320      * <p><strong>Because the default system does not include graphical task management,
7321      * you should not use this flag unless you provide some way for a user to
7322      * return back to the tasks you have launched.</strong>
7323      *
7324      * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
7325      * creating new document tasks.
7326      *
7327      * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
7328      * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
7329      *
7330      * <p>See
7331      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
7332      * Stack</a> for more information about tasks.
7333      *
7334      * @see #FLAG_ACTIVITY_NEW_DOCUMENT
7335      * @see #FLAG_ACTIVITY_NEW_TASK
7336      */
7337     public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
7338     /**
7339      * If set, and the activity being launched is already running in the
7340      * current task, then instead of launching a new instance of that activity,
7341      * all of the other activities on top of it will be closed and this Intent
7342      * will be delivered to the (now on top) old activity as a new Intent.
7343      *
7344      * <p>For example, consider a task consisting of the activities: A, B, C, D.
7345      * If D calls startActivity() with an Intent that resolves to the component
7346      * of activity B, then C and D will be finished and B receive the given
7347      * Intent, resulting in the stack now being: A, B.
7348      *
7349      * <p>The currently running instance of activity B in the above example will
7350      * either receive the new intent you are starting here in its
7351      * onNewIntent() method, or be itself finished and restarted with the
7352      * new intent.  If it has declared its launch mode to be "multiple" (the
7353      * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
7354      * the same intent, then it will be finished and re-created; for all other
7355      * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
7356      * Intent will be delivered to the current instance's onNewIntent().
7357      *
7358      * <p>This launch mode can also be used to good effect in conjunction with
7359      * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
7360      * of a task, it will bring any currently running instance of that task
7361      * to the foreground, and then clear it to its root state.  This is
7362      * especially useful, for example, when launching an activity from the
7363      * notification manager.
7364      *
7365      * <p>See
7366      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
7367      * Stack</a> for more information about tasks.
7368      */
7369     public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
7370     /**
7371      * If set and this intent is being used to launch a new activity from an
7372      * existing one, then the reply target of the existing activity will be
7373      * transferred to the new activity.  This way, the new activity can call
7374      * {@link android.app.Activity#setResult} and have that result sent back to
7375      * the reply target of the original activity.
7376      */
7377     public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
7378     /**
7379      * If set and this intent is being used to launch a new activity from an
7380      * existing one, the current activity will not be counted as the top
7381      * activity for deciding whether the new intent should be delivered to
7382      * the top instead of starting a new one.  The previous activity will
7383      * be used as the top, with the assumption being that the current activity
7384      * will finish itself immediately.
7385      */
7386     public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
7387     /**
7388      * If set, the new activity is not kept in the list of recently launched
7389      * activities.
7390      */
7391     public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
7392     /**
7393      * This flag is not normally set by application code, but set for you by
7394      * the system as described in the
7395      * {@link android.R.styleable#AndroidManifestActivity_launchMode
7396      * launchMode} documentation for the singleTask mode.
7397      */
7398     public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
7399     /**
7400      * If set, and this activity is either being started in a new task or
7401      * bringing to the top an existing task, then it will be launched as
7402      * the front door of the task.  This will result in the application of
7403      * any affinities needed to have that task in the proper state (either
7404      * moving activities to or from it), or simply resetting that task to
7405      * its initial state if needed.
7406      *
7407      * @see android.R.attr#allowTaskReparenting
7408      * @see android.R.attr#clearTaskOnLaunch
7409      * @see android.R.attr#finishOnTaskLaunch
7410      */
7411     public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
7412     /**
7413      * This flag is not normally set by application code, but set for you by
7414      * the system if this activity is being launched from history.
7415      */
7416     public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
7417     /**
7418      * @deprecated As of API 21 this performs identically to
7419      * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
7420      */
7421     @Deprecated
7422     public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
7423     /**
7424      * This flag is used to open a document into a new task rooted at the activity launched
7425      * by this Intent. Through the use of this flag, or its equivalent attribute,
7426      * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
7427      * containing different documents will appear in the recent tasks list.
7428      *
7429      * <p>The use of the activity attribute form of this,
7430      * {@link android.R.attr#documentLaunchMode}, is
7431      * preferred over the Intent flag described here. The attribute form allows the
7432      * Activity to specify multiple document behavior for all launchers of the Activity
7433      * whereas using this flag requires each Intent that launches the Activity to specify it.
7434      *
7435      * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
7436      * it is kept after the activity is finished is different than the use of
7437      * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
7438      * this flag is being used to create a new recents entry, then by default that entry
7439      * will be removed once the activity is finished.  You can modify this behavior with
7440      * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
7441      *
7442      * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
7443      * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
7444      * equivalent of the Activity manifest specifying {@link
7445      * android.R.attr#documentLaunchMode}="intoExisting". When used with
7446      * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
7447      * {@link android.R.attr#documentLaunchMode}="always". The flag is ignored even in
7448      * conjunction with {@link #FLAG_ACTIVITY_MULTIPLE_TASK} when the Activity manifest specifies
7449      * {@link android.R.attr#documentLaunchMode}="never".
7450      *
7451      * Refer to {@link android.R.attr#documentLaunchMode} for more information.
7452      *
7453      * @see android.R.attr#documentLaunchMode
7454      * @see #FLAG_ACTIVITY_MULTIPLE_TASK
7455      */
7456     public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
7457     /**
7458      * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
7459      * callback from occurring on the current frontmost activity before it is
7460      * paused as the newly-started activity is brought to the front.
7461      *
7462      * <p>Typically, an activity can rely on that callback to indicate that an
7463      * explicit user action has caused their activity to be moved out of the
7464      * foreground. The callback marks an appropriate point in the activity's
7465      * lifecycle for it to dismiss any notifications that it intends to display
7466      * "until the user has seen them," such as a blinking LED.
7467      *
7468      * <p>If an activity is ever started via any non-user-driven events such as
7469      * phone-call receipt or an alarm handler, this flag should be passed to {@link
7470      * Context#startActivity Context.startActivity}, ensuring that the pausing
7471      * activity does not think the user has acknowledged its notification.
7472      */
7473     public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
7474     /**
7475      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
7476      * this flag will cause the launched activity to be brought to the front of its
7477      * task's history stack if it is already running.
7478      *
7479      * <p>For example, consider a task consisting of four activities: A, B, C, D.
7480      * If D calls startActivity() with an Intent that resolves to the component
7481      * of activity B, then B will be brought to the front of the history stack,
7482      * with this resulting order:  A, C, D, B.
7483      *
7484      * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
7485      * specified.
7486      */
7487     public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
7488     /**
7489      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
7490      * this flag will prevent the system from applying an activity transition
7491      * animation to go to the next activity state.  This doesn't mean an
7492      * animation will never run -- if another activity change happens that doesn't
7493      * specify this flag before the activity started here is displayed, then
7494      * that transition will be used.  This flag can be put to good use
7495      * when you are going to do a series of activity operations but the
7496      * animation seen by the user shouldn't be driven by the first activity
7497      * change but rather a later one.
7498      */
7499     public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
7500     /**
7501      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
7502      * this flag will cause any existing task that would be associated with the
7503      * activity to be cleared before the activity is started.  That is, the activity
7504      * becomes the new root of an otherwise empty task, and any old activities
7505      * are finished.  This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
7506      */
7507     public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
7508     /**
7509      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
7510      * this flag will cause a newly launching task to be placed on top of the current
7511      * home activity task (if there is one).  That is, pressing back from the task
7512      * will always return the user to home even if that was not the last activity they
7513      * saw.   This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
7514      */
7515     public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
7516     /**
7517      * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
7518      * have its entry in recent tasks removed when the user closes it (with back
7519      * or however else it may finish()). If you would like to instead allow the
7520      * document to be kept in recents so that it can be re-launched, you can use
7521      * this flag. When set and the task's activity is finished, the recents
7522      * entry will remain in the interface for the user to re-launch it, like a
7523      * recents entry for a top-level application.
7524      * <p>
7525      * The receiving activity can override this request with
7526      * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
7527      * {@link android.app.Activity#finishAndRemoveTask()
7528      * Activity.finishAndRemoveTask()}.
7529      */
7530     public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
7531 
7532     /**
7533      * This flag is only used for split-screen multi-window mode. The new activity will be displayed
7534      * adjacent to the one launching it if possible. This can only be used in conjunction with
7535      * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
7536      * required if you want a new instance of an existing activity to be created.
7537      */
7538     public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
7539 
7540 
7541     /**
7542      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
7543      * this flag will attempt to launch an instant app if no full app on the device can already
7544      * handle the intent.
7545      * <p>
7546      * When attempting to resolve instant apps externally, the following {@link Intent} properties
7547      * are supported:
7548      * <ul>
7549      *     <li>{@link Intent#setAction(String)}</li>
7550      *     <li>{@link Intent#addCategory(String)}</li>
7551      *     <li>{@link Intent#setData(Uri)}</li>
7552      *     <li>{@link Intent#setType(String)}</li>
7553      *     <li>{@link Intent#setPackage(String)}</li>
7554      *     <li>{@link Intent#addFlags(int)}</li>
7555      * </ul>
7556      * <p>
7557      * In the case that no instant app can be found, the installer will be launched to notify the
7558      * user that the intent could not be resolved. On devices that do not support instant apps,
7559      * the flag will be ignored.
7560      */
7561     public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800;
7562 
7563     /**
7564      * If set in an intent passed to {@link Context#startActivity Context.startActivity()}, this
7565      * flag will only launch the intent if it resolves to a result that is not a browser. If no such
7566      * result exists, an {@link ActivityNotFoundException} will be thrown.
7567      */
7568     public static final int FLAG_ACTIVITY_REQUIRE_NON_BROWSER = 0x00000400;
7569 
7570     /**
7571      * If set in an intent passed to {@link Context#startActivity Context.startActivity()}, this
7572      * flag will only launch the intent if it resolves to a single result. If no such result exists
7573      * or if the system chooser would otherwise be displayed, an {@link ActivityNotFoundException}
7574      * will be thrown.
7575      */
7576     public static final int FLAG_ACTIVITY_REQUIRE_DEFAULT = 0x00000200;
7577 
7578     /**
7579      * If set, when sending a broadcast only registered receivers will be
7580      * called -- no BroadcastReceiver components will be launched.
7581      */
7582     public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
7583     /**
7584      * If set, when sending a broadcast the new broadcast will replace
7585      * any existing pending broadcast that matches it.  Matching is defined
7586      * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
7587      * true for the intents of the two broadcasts.  When a match is found,
7588      * the new broadcast (and receivers associated with it) will replace the
7589      * existing one in the pending broadcast list, remaining at the same
7590      * position in the list.
7591      *
7592      * <p>This flag is most typically used with sticky broadcasts, which
7593      * only care about delivering the most recent values of the broadcast
7594      * to their receivers.
7595      */
7596     public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
7597     /**
7598      * If set, when sending a broadcast the recipient is allowed to run at
7599      * foreground priority, with a shorter timeout interval.  During normal
7600      * broadcasts the receivers are not automatically hoisted out of the
7601      * background priority class.
7602      */
7603     public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
7604     /**
7605      * If set, when sending a broadcast the recipient will be run on the offload queue.
7606      *
7607      * @hide
7608      */
7609     public static final int FLAG_RECEIVER_OFFLOAD = 0x80000000;
7610     /**
7611      * If set, when sending a broadcast the recipient will run on the system dedicated queue.
7612      *
7613      * @hide
7614      */
7615     public static final int FLAG_RECEIVER_OFFLOAD_FOREGROUND = 0x00000800;
7616 
7617     /**
7618      * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
7619      * They can still propagate results through to later receivers, but they can not prevent
7620      * later receivers from seeing the broadcast.
7621      */
7622     public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
7623     /**
7624      * If set, when sending a broadcast <i>before the system has fully booted up
7625      * (which is even before {@link #ACTION_LOCKED_BOOT_COMPLETED} has been sent)"</i> only
7626      * registered receivers will be called -- no BroadcastReceiver components
7627      * will be launched.  Sticky intent state will be recorded properly even
7628      * if no receivers wind up being called.  If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
7629      * is specified in the broadcast intent, this flag is unnecessary.
7630      *
7631      * <p>This flag is only for use by system services (even services from mainline modules) as a
7632      * convenience to avoid having to implement a more complex mechanism around detection
7633      * of boot completion.
7634      *
7635      * <p>This is useful to system server mainline modules
7636      *
7637      * @hide
7638      */
7639     @SystemApi
7640     public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
7641     /**
7642      * Set when this broadcast is for a boot upgrade, a special mode that
7643      * allows the broadcast to be sent before the system is ready and launches
7644      * the app process with no providers running in it.
7645      * @hide
7646      */
7647     public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
7648     /**
7649      * If set, the broadcast will always go to manifest receivers in background (cached
7650      * or not running) apps, regardless of whether that would be done by default.  By
7651      * default they will only receive broadcasts if the broadcast has specified an
7652      * explicit component or package name.
7653      *
7654      * NOTE: dumpstate uses this flag numerically, so when its value is changed
7655      * the broadcast code there must also be changed to match.
7656      *
7657      * @hide
7658      */
7659     @SystemApi
7660     public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
7661     /**
7662      * If set, the broadcast will never go to manifest receivers in background (cached
7663      * or not running) apps, regardless of whether that would be done by default.  By
7664      * default they will receive broadcasts if the broadcast has specified an
7665      * explicit component or package name.
7666      * @hide
7667      */
7668     public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
7669     /**
7670      * If set, this broadcast is being sent from the shell.
7671      * @hide
7672      */
7673     public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
7674 
7675     /**
7676      * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
7677      * will not receive broadcasts.
7678      *
7679      * <em>This flag has no effect when used by an Instant App.</em>
7680      */
7681     public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
7682 
7683     /**
7684      * @hide Flags that can't be changed with PendingIntent.
7685      */
7686     public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
7687             | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
7688             | FLAG_GRANT_PREFIX_URI_PERMISSION;
7689 
7690     /**
7691      * Local flag indicating this instance was created by copy constructor.
7692      */
7693     private static final int LOCAL_FLAG_FROM_COPY = 1 << 0;
7694 
7695     /**
7696      * Local flag indicating this instance was created from a {@link Parcel}.
7697      */
7698     private static final int LOCAL_FLAG_FROM_PARCEL = 1 << 1;
7699 
7700     /**
7701      * Local flag indicating this instance was delivered through a protected
7702      * component, such as an activity that requires a signature permission, or a
7703      * protected broadcast. Note that this flag <em>cannot</em> be recursively
7704      * applied to any contained instances, since a malicious app may have
7705      * controlled them via {@link #fillIn(Intent, int)}.
7706      */
7707     private static final int LOCAL_FLAG_FROM_PROTECTED_COMPONENT = 1 << 2;
7708 
7709     /**
7710      * Local flag indicating this instance had unfiltered extras copied into it. This could be
7711      * from either {@link #putExtras(Intent)} when an unparceled Intent is provided or {@link
7712      * #putExtras(Bundle)} when the provided Bundle has not been unparceled.
7713      */
7714     private static final int LOCAL_FLAG_UNFILTERED_EXTRAS = 1 << 3;
7715 
7716     /**
7717      * Local flag indicating this instance was created from a {@link Uri}.
7718      */
7719     private static final int LOCAL_FLAG_FROM_URI = 1 << 4;
7720 
7721     /**
7722      * Local flag indicating this instance was created by the system.
7723      */
7724     /** @hide */
7725     public static final int LOCAL_FLAG_FROM_SYSTEM = 1 << 5;
7726 
7727     /**
7728      * This flag indicates the creator token of this intent has been verified.
7729      */
7730     private static final int LOCAL_FLAG_TRUSTED_CREATOR_TOKEN_PRESENT = 1 << 6;
7731 
7732     /** @hide */
7733     @IntDef(flag = true, prefix = { "EXTENDED_FLAG_" }, value = {
7734             EXTENDED_FLAG_FILTER_MISMATCH,
7735             EXTENDED_FLAG_MISSING_CREATOR_OR_INVALID_TOKEN,
7736             EXTENDED_FLAG_NESTED_INTENT_KEYS_COLLECTED,
7737     })
7738     @Retention(RetentionPolicy.SOURCE)
7739     public @interface ExtendedFlags {}
7740 
7741     /**
7742      * This flag is not normally set by application code, but set for you by the system if
7743      * an external intent does not match the receiving component's intent filter.
7744      *
7745      * @hide
7746      */
7747     @TestApi
7748     public static final int EXTENDED_FLAG_FILTER_MISMATCH = 1 << 0;
7749 
7750     /**
7751      * This flag indicates the creator token of this intent is either missing or invalid.
7752      *
7753      * @hide
7754      */
7755     public static final int EXTENDED_FLAG_MISSING_CREATOR_OR_INVALID_TOKEN = 1 << 1;
7756 
7757     /**
7758      * This flag indicates this intent called {@link #collectExtraIntentKeys()}.
7759      *
7760      * @hide
7761      */
7762     public static final int EXTENDED_FLAG_NESTED_INTENT_KEYS_COLLECTED = 1 << 2;
7763 
7764     // ---------------------------------------------------------------------
7765     // ---------------------------------------------------------------------
7766     // toUri() and parseUri() options.
7767 
7768     /** @hide */
7769     @IntDef(flag = true, prefix = {"URI_"}, value = {
7770             URI_ALLOW_UNSAFE,
7771             URI_ANDROID_APP_SCHEME,
7772             URI_INTENT_SCHEME,
7773     })
7774     @Retention(RetentionPolicy.SOURCE)
7775     public @interface UriFlags {}
7776 
7777     /**
7778      * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
7779      * always has the "intent:" scheme.  This syntax can be used when you want
7780      * to later disambiguate between URIs that are intended to describe an
7781      * Intent vs. all others that should be treated as raw URIs.  When used
7782      * with {@link #parseUri}, any other scheme will result in a generic
7783      * VIEW action for that raw URI.
7784      */
7785     public static final int URI_INTENT_SCHEME = 1<<0;
7786 
7787     /**
7788      * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
7789      * always has the "android-app:" scheme.  This is a variation of
7790      * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
7791      * http/https URI being delivered to a specific package name.  The format
7792      * is:
7793      *
7794      * <pre class="prettyprint">
7795      * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
7796      *
7797      * <p>In this scheme, only the <code>package_id</code> is required.  If you include a host,
7798      * you must also include a scheme; including a path also requires both a host and a scheme.
7799      * The final #Intent; fragment can be used without a scheme, host, or path.
7800      * Note that this can not be
7801      * used with intents that have a {@link #setSelector}, since the base intent
7802      * will always have an explicit package name.</p>
7803      *
7804      * <p>Some examples of how this scheme maps to Intent objects:</p>
7805      * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
7806      *     <colgroup align="left" />
7807      *     <colgroup align="left" />
7808      *     <thead>
7809      *     <tr><th>URI</th> <th>Intent</th></tr>
7810      *     </thead>
7811      *
7812      *     <tbody>
7813      *     <tr><td><code>android-app://com.example.app</code></td>
7814      *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
7815      *             <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
7816      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
7817      *         </table></td>
7818      *     </tr>
7819      *     <tr><td><code>android-app://com.example.app/http/example.com</code></td>
7820      *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
7821      *             <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
7822      *             <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
7823      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
7824      *         </table></td>
7825      *     </tr>
7826      *     <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
7827      *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
7828      *             <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
7829      *             <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
7830      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
7831      *         </table></td>
7832      *     </tr>
7833      *     <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
7834      *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
7835      *             <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
7836      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
7837      *         </table></td>
7838      *     </tr>
7839      *     <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
7840      *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
7841      *             <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
7842      *             <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
7843      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
7844      *         </table></td>
7845      *     </tr>
7846      *     <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;<br />i.some_int=100;S.some_str=hello;end</code></td>
7847      *         <td><table border="" style="margin:0" >
7848      *             <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
7849      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
7850      *             <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
7851      *         </table></td>
7852      *     </tr>
7853      *     </tbody>
7854      * </table>
7855      */
7856     public static final int URI_ANDROID_APP_SCHEME = 1<<1;
7857 
7858     /**
7859      * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
7860      * of unsafe information.  In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
7861      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
7862      * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
7863      * generated Intent can not cause unexpected data access to happen.
7864      *
7865      * <p>If you do not trust the source of the URI being parsed, you should still do further
7866      * processing to protect yourself from it.  In particular, when using it to start an
7867      * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
7868      * that can handle it.</p>
7869      */
7870     public static final int URI_ALLOW_UNSAFE = 1<<2;
7871 
7872     static {
7873         Bundle.intentClass = Intent.class;
7874     }
7875 
7876     // ---------------------------------------------------------------------
7877 
7878     private String mAction;
7879     private Uri mData;
7880     private String mType;
7881     private String mIdentifier;
7882     private String mPackage;
7883     private ComponentName mComponent;
7884     private int mFlags;
7885     /** Set of in-process flags which are never parceled */
7886     private int mLocalFlags;
7887     private int mExtendedFlags;
7888     private ArraySet<String> mCategories;
7889     @UnsupportedAppUsage
7890     private Bundle mExtras;
7891     private Rect mSourceBounds;
7892     private Intent mSelector;
7893     private ClipData mClipData;
7894     private int mContentUserHint = UserHandle.USER_CURRENT;
7895     /** Token to track instant app launches. Local only; do not copy cross-process. */
7896     private String mLaunchToken;
7897     private Intent mOriginalIntent; // Used for the experimental "component alias" feature.
7898 
7899     // ---------------------------------------------------------------------
7900 
7901     private static final int COPY_MODE_ALL = 0;
7902     private static final int COPY_MODE_FILTER = 1;
7903     private static final int COPY_MODE_HISTORY = 2;
7904 
7905     /** @hide */
7906     @IntDef(prefix = { "COPY_MODE_" }, value = {
7907             COPY_MODE_ALL,
7908             COPY_MODE_FILTER,
7909             COPY_MODE_HISTORY
7910     })
7911     @Retention(RetentionPolicy.SOURCE)
7912     public @interface CopyMode {}
7913 
7914     /**
7915      * Create an empty intent.
7916      */
Intent()7917     public Intent() {
7918     }
7919 
7920     /**
7921      * Copy constructor.
7922      */
Intent(Intent o)7923     public Intent(Intent o) {
7924         this(o, COPY_MODE_ALL);
7925     }
7926 
Intent(Intent o, @CopyMode int copyMode)7927     private Intent(Intent o, @CopyMode int copyMode) {
7928         this.mAction = o.mAction;
7929         this.mData = o.mData;
7930         this.mType = o.mType;
7931         this.mIdentifier = o.mIdentifier;
7932         this.mPackage = o.mPackage;
7933         this.mComponent = o.mComponent;
7934         this.mOriginalIntent = o.mOriginalIntent;
7935         this.mCreatorTokenInfo = o.mCreatorTokenInfo;
7936 
7937         if (o.mCategories != null) {
7938             this.mCategories = new ArraySet<>(o.mCategories);
7939         }
7940 
7941         // Inherit flags from the original, plus mark that we were
7942         // created by this copy constructor
7943         this.mLocalFlags = o.mLocalFlags;
7944         this.mLocalFlags |= LOCAL_FLAG_FROM_COPY;
7945 
7946         if (copyMode != COPY_MODE_FILTER) {
7947             this.mFlags = o.mFlags;
7948             this.mExtendedFlags = o.mExtendedFlags;
7949             this.mContentUserHint = o.mContentUserHint;
7950             this.mLaunchToken = o.mLaunchToken;
7951             if (o.mSourceBounds != null) {
7952                 this.mSourceBounds = new Rect(o.mSourceBounds);
7953             }
7954             if (o.mSelector != null) {
7955                 this.mSelector = new Intent(o.mSelector);
7956             }
7957 
7958             if (copyMode != COPY_MODE_HISTORY) {
7959                 if (o.mExtras != null) {
7960                     this.mExtras = new Bundle(o.mExtras);
7961                 }
7962                 if (o.mClipData != null) {
7963                     this.mClipData = new ClipData(o.mClipData);
7964                 }
7965             } else {
7966                 if (o.mExtras != null && !o.mExtras.isDefinitelyEmpty()) {
7967                     this.mExtras = Bundle.STRIPPED;
7968                 }
7969 
7970                 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
7971                 // history.
7972             }
7973         }
7974     }
7975 
7976     @Override
clone()7977     public Object clone() {
7978         return new Intent(this);
7979     }
7980 
7981     /**
7982      * Make a clone of only the parts of the Intent that are relevant for
7983      * filter matching: the action, data, type, component, and categories.
7984      */
cloneFilter()7985     public @NonNull Intent cloneFilter() {
7986         return new Intent(this, COPY_MODE_FILTER);
7987     }
7988 
7989     /**
7990      * Make a copy of all members important to identify an intent with its creator token.
7991      * @hide
7992      */
cloneForCreatorToken()7993     public @NonNull Intent cloneForCreatorToken() {
7994         Intent clone = new Intent()
7995                 .setAction(this.mAction)
7996                 .setDataAndType(this.mData, this.mType)
7997                 .setPackage(this.mPackage)
7998                 .setComponent(this.mComponent)
7999                 .setFlags(this.mFlags & IMMUTABLE_FLAGS);
8000         if (this.mClipData != null) {
8001             clone.setClipData(this.mClipData.cloneOnlyUriItems());
8002         }
8003         clone.mCreatorTokenInfo = this.mCreatorTokenInfo;
8004         return clone;
8005     }
8006 
8007     /**
8008      * Create an intent with a given action.  All other fields (data, type,
8009      * class) are null.  Note that the action <em>must</em> be in a
8010      * namespace because Intents are used globally in the system -- for
8011      * example the system VIEW action is android.intent.action.VIEW; an
8012      * application's custom action would be something like
8013      * com.google.app.myapp.CUSTOM_ACTION.
8014      *
8015      * @param action The Intent action, such as ACTION_VIEW.
8016      */
Intent(String action)8017     public Intent(String action) {
8018         setAction(action);
8019     }
8020 
8021     /**
8022      * Create an intent with a given action and for a given data url.  Note
8023      * that the action <em>must</em> be in a namespace because Intents are
8024      * used globally in the system -- for example the system VIEW action is
8025      * android.intent.action.VIEW; an application's custom action would be
8026      * something like com.google.app.myapp.CUSTOM_ACTION.
8027      *
8028      * <p><em>Note: scheme and host name matching in the Android framework is
8029      * case-sensitive, unlike the formal RFC.  As a result,
8030      * you should always ensure that you write your Uri with these elements
8031      * using lower case letters, and normalize any Uris you receive from
8032      * outside of Android to ensure the scheme and host is lower case.</em></p>
8033      *
8034      * @param action The Intent action, such as ACTION_VIEW.
8035      * @param uri The Intent data URI.
8036      */
Intent(String action, Uri uri)8037     public Intent(String action, Uri uri) {
8038         setAction(action);
8039         mData = uri;
8040     }
8041 
8042     /**
8043      * Create an intent for a specific component.  All other fields (action, data,
8044      * type, class) are null, though they can be modified later with explicit
8045      * calls.  This provides a convenient way to create an intent that is
8046      * intended to execute a hard-coded class name, rather than relying on the
8047      * system to find an appropriate class for you; see {@link #setComponent}
8048      * for more information on the repercussions of this.
8049      *
8050      * @param packageContext A Context of the application package implementing
8051      * this class.
8052      * @param cls The component class that is to be used for the intent.
8053      *
8054      * @see #setClass
8055      * @see #setComponent
8056      * @see #Intent(String, android.net.Uri , Context, Class)
8057      */
Intent(Context packageContext, Class<?> cls)8058     public Intent(Context packageContext, Class<?> cls) {
8059         mComponent = new ComponentName(packageContext, cls);
8060     }
8061 
8062     /**
8063      * Create an intent for a specific component with a specified action and data.
8064      * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
8065      * construct the Intent and then calling {@link #setClass} to set its
8066      * class.
8067      *
8068      * <p><em>Note: scheme and host name matching in the Android framework is
8069      * case-sensitive, unlike the formal RFC.  As a result,
8070      * you should always ensure that you write your Uri with these elements
8071      * using lower case letters, and normalize any Uris you receive from
8072      * outside of Android to ensure the scheme and host is lower case.</em></p>
8073      *
8074      * @param action The Intent action, such as ACTION_VIEW.
8075      * @param uri The Intent data URI.
8076      * @param packageContext A Context of the application package implementing
8077      * this class.
8078      * @param cls The component class that is to be used for the intent.
8079      *
8080      * @see #Intent(String, android.net.Uri)
8081      * @see #Intent(Context, Class)
8082      * @see #setClass
8083      * @see #setComponent
8084      */
Intent(String action, Uri uri, Context packageContext, Class<?> cls)8085     public Intent(String action, Uri uri,
8086             Context packageContext, Class<?> cls) {
8087         setAction(action);
8088         mData = uri;
8089         mComponent = new ComponentName(packageContext, cls);
8090     }
8091 
8092     /**
8093      * Create an intent to launch the main (root) activity of a task.  This
8094      * is the Intent that is started when the application's is launched from
8095      * Home.  For anything else that wants to launch an application in the
8096      * same way, it is important that they use an Intent structured the same
8097      * way, and can use this function to ensure this is the case.
8098      *
8099      * <p>The returned Intent has the given Activity component as its explicit
8100      * component, {@link #ACTION_MAIN} as its action, and includes the
8101      * category {@link #CATEGORY_LAUNCHER}.  This does <em>not</em> have
8102      * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
8103      * to do that through {@link #addFlags(int)} on the returned Intent.
8104      *
8105      * @param mainActivity The main activity component that this Intent will
8106      * launch.
8107      * @return Returns a newly created Intent that can be used to launch the
8108      * activity as a main application entry.
8109      *
8110      * @see #setClass
8111      * @see #setComponent
8112      */
makeMainActivity(ComponentName mainActivity)8113     public static Intent makeMainActivity(ComponentName mainActivity) {
8114         Intent intent = new Intent(ACTION_MAIN);
8115         intent.setComponent(mainActivity);
8116         intent.addCategory(CATEGORY_LAUNCHER);
8117         return intent;
8118     }
8119 
8120     /**
8121      * Make an Intent for the main activity of an application, without
8122      * specifying a specific activity to run but giving a selector to find
8123      * the activity.  This results in a final Intent that is structured
8124      * the same as when the application is launched from
8125      * Home.  For anything else that wants to launch an application in the
8126      * same way, it is important that they use an Intent structured the same
8127      * way, and can use this function to ensure this is the case.
8128      *
8129      * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
8130      * category {@link #CATEGORY_LAUNCHER}.  This does <em>not</em> have
8131      * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
8132      * to do that through {@link #addFlags(int)} on the returned Intent.
8133      *
8134      * @param selectorAction The action name of the Intent's selector.
8135      * @param selectorCategory The name of a category to add to the Intent's
8136      * selector.
8137      * @return Returns a newly created Intent that can be used to launch the
8138      * activity as a main application entry.
8139      *
8140      * @see #setSelector(Intent)
8141      */
makeMainSelectorActivity(String selectorAction, String selectorCategory)8142     public static Intent makeMainSelectorActivity(String selectorAction,
8143             String selectorCategory) {
8144         Intent intent = new Intent(ACTION_MAIN);
8145         intent.addCategory(CATEGORY_LAUNCHER);
8146         Intent selector = new Intent();
8147         selector.setAction(selectorAction);
8148         selector.addCategory(selectorCategory);
8149         intent.setSelector(selector);
8150         return intent;
8151     }
8152 
8153     /**
8154      * Make an Intent that can be used to re-launch an application's task
8155      * in its base state.  This is like {@link #makeMainActivity(ComponentName)},
8156      * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
8157      * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
8158      *
8159      * @param mainActivity The activity component that is the root of the
8160      * task; this is the activity that has been published in the application's
8161      * manifest as the main launcher icon.
8162      *
8163      * @return Returns a newly created Intent that can be used to relaunch the
8164      * activity's task in its root state.
8165      */
makeRestartActivityTask(ComponentName mainActivity)8166     public static Intent makeRestartActivityTask(ComponentName mainActivity) {
8167         Intent intent = makeMainActivity(mainActivity);
8168         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
8169                 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
8170         return intent;
8171     }
8172 
8173     /**
8174      * Call {@link #parseUri} with 0 flags.
8175      * @deprecated Use {@link #parseUri} instead.
8176      */
8177     @Deprecated
getIntent(String uri)8178     public static Intent getIntent(String uri) throws URISyntaxException {
8179         return parseUri(uri, 0);
8180     }
8181 
8182     /**
8183      * Create an intent from a URI.  This URI may encode the action,
8184      * category, and other intent fields, if it was returned by
8185      * {@link #toUri}.  If the Intent was not generated by toUri(), its data
8186      * will be the entire URI and its action will be ACTION_VIEW.
8187      *
8188      * <p>The URI given here must not be relative -- that is, it must include
8189      * the scheme and full path.
8190      *
8191      * @param uri The URI to turn into an Intent.
8192      * @param flags Additional processing flags.
8193      *
8194      * @return Intent The newly created Intent object.
8195      *
8196      * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
8197      * it bad (as parsed by the Uri class) or the Intent data within the
8198      * URI is invalid.
8199      *
8200      * @see #toUri
8201      */
parseUri(String uri, @UriFlags int flags)8202     public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
8203         Intent intent = parseUriInternal(uri, flags);
8204         intent.mLocalFlags |= LOCAL_FLAG_FROM_URI;
8205         return intent;
8206     }
8207 
8208     /**
8209      * @see #parseUri(String, int)
8210      */
parseUriInternal(String uri, @UriFlags int flags)8211     private static Intent parseUriInternal(String uri, @UriFlags int flags)
8212             throws URISyntaxException {
8213         int i = 0;
8214         try {
8215             final boolean androidApp = uri.startsWith("android-app:");
8216 
8217             // Validate intent scheme if requested.
8218             if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
8219                 if (!uri.startsWith("intent:") && !androidApp) {
8220                     Intent intent = new Intent(ACTION_VIEW);
8221                     try {
8222                         intent.setData(Uri.parse(uri));
8223                     } catch (IllegalArgumentException e) {
8224                         throw new URISyntaxException(uri, e.getMessage());
8225                     }
8226                     return intent;
8227                 }
8228             }
8229 
8230             i = uri.lastIndexOf("#");
8231             // simple case
8232             if (i == -1) {
8233                 if (!androidApp) {
8234                     return new Intent(ACTION_VIEW, Uri.parse(uri));
8235                 }
8236 
8237             // old format Intent URI
8238             } else if (!uri.startsWith("#Intent;", i)) {
8239                 if (!androidApp) {
8240                     return getIntentOld(uri, flags);
8241                 } else {
8242                     i = -1;
8243                 }
8244             }
8245 
8246             // new format
8247             Intent intent = new Intent(ACTION_VIEW);
8248             Intent baseIntent = intent;
8249             boolean explicitAction = false;
8250             boolean inSelector = false;
8251 
8252             // fetch data part, if present
8253             String scheme = null;
8254             String data;
8255             if (i >= 0) {
8256                 data = uri.substring(0, i);
8257                 i += 8; // length of "#Intent;"
8258             } else {
8259                 data = uri;
8260             }
8261 
8262             // loop over contents of Intent, all name=value;
8263             while (i >= 0 && !uri.startsWith("end", i)) {
8264                 int eq = uri.indexOf('=', i);
8265                 if (eq < 0) eq = i-1;
8266                 int semi = uri.indexOf(';', i);
8267                 if (semi < 0) {
8268                     throw new URISyntaxException(uri, "uri end not found");
8269                 }
8270                 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
8271 
8272                 // action
8273                 if (uri.startsWith("action=", i)) {
8274                     intent.setAction(value);
8275                     if (!inSelector) {
8276                         explicitAction = true;
8277                     }
8278                 }
8279 
8280                 // categories
8281                 else if (uri.startsWith("category=", i)) {
8282                     intent.addCategory(value);
8283                 }
8284 
8285                 // type
8286                 else if (uri.startsWith("type=", i)) {
8287                     intent.mType = value;
8288                 }
8289 
8290                 // identifier
8291                 else if (uri.startsWith("identifier=", i)) {
8292                     intent.mIdentifier = value;
8293                 }
8294 
8295                 // launch flags
8296                 else if (uri.startsWith("launchFlags=", i)) {
8297                     intent.mFlags = decodeInteger(value);
8298                     if ((flags& URI_ALLOW_UNSAFE) == 0) {
8299                         intent.mFlags &= ~IMMUTABLE_FLAGS;
8300                     }
8301                 }
8302 
8303                 // extended flags
8304                 else if (uri.startsWith("extendedLaunchFlags=", i)) {
8305                     intent.mExtendedFlags = decodeInteger(value);
8306                 }
8307 
8308                 // package
8309                 else if (uri.startsWith("package=", i)) {
8310                     intent.mPackage = value;
8311                 }
8312 
8313                 // component
8314                 else if (uri.startsWith("component=", i)) {
8315                     intent.mComponent = ComponentName.unflattenFromString(value);
8316                 }
8317 
8318                 // scheme
8319                 else if (uri.startsWith("scheme=", i)) {
8320                     if (inSelector) {
8321                         intent.mData = Uri.parse(value + ":");
8322                     } else {
8323                         scheme = value;
8324                     }
8325                 }
8326 
8327                 // source bounds
8328                 else if (uri.startsWith("sourceBounds=", i)) {
8329                     intent.mSourceBounds = Rect.unflattenFromString(value);
8330                 }
8331 
8332                 // selector
8333                 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
8334                     intent = new Intent();
8335                     inSelector = true;
8336                 }
8337 
8338                 // extra
8339                 else {
8340                     String key = Uri.decode(uri.substring(i + 2, eq));
8341                     // create Bundle if it doesn't already exist
8342                     if (intent.mExtras == null) intent.mExtras = new Bundle();
8343                     Bundle b = intent.mExtras;
8344                     // add EXTRA
8345                     if      (uri.startsWith("S.", i)) b.putString(key, value);
8346                     else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
8347                     else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
8348                     else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
8349                     else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
8350                     else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
8351                     else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
8352                     else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
8353                     else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
8354                     else throw new URISyntaxException(uri, "unknown EXTRA type", i);
8355                 }
8356 
8357                 // move to the next item
8358                 i = semi + 1;
8359             }
8360 
8361             if (inSelector) {
8362                 // The Intent had a selector; fix it up.
8363                 if (baseIntent.mPackage == null) {
8364                     baseIntent.setSelector(intent);
8365                 }
8366                 intent = baseIntent;
8367             }
8368 
8369             if (data != null) {
8370                 if (data.startsWith("intent:")) {
8371                     data = data.substring(7);
8372                     if (scheme != null) {
8373                         data = scheme + ':' + data;
8374                     }
8375                 } else if (data.startsWith("android-app:")) {
8376                     if (data.charAt(12) == '/' && data.charAt(13) == '/') {
8377                         // Correctly formed android-app, first part is package name.
8378                         int end = data.indexOf('/', 14);
8379                         if (end < 0) {
8380                             // All we have is a package name.
8381                             intent.mPackage = Uri.decodeIfNeeded(data.substring(14));
8382                             if (!explicitAction) {
8383                                 intent.setAction(ACTION_MAIN);
8384                             }
8385                             data = "";
8386                         } else {
8387                             // Target the Intent at the given package name always.
8388                             String authority = null;
8389                             intent.mPackage = Uri.decodeIfNeeded(data.substring(14, end));
8390                             int newEnd;
8391                             if ((end+1) < data.length()) {
8392                                 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
8393                                     // Found a scheme, remember it.
8394                                     scheme = Uri.decodeIfNeeded(data.substring(end + 1, newEnd));
8395                                     end = newEnd;
8396                                     if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
8397                                         // Found a authority, remember it.
8398                                         authority = Uri.decodeIfNeeded(
8399                                                 data.substring(end + 1, newEnd));
8400                                         end = newEnd;
8401                                     }
8402                                 } else {
8403                                     // All we have is a scheme.
8404                                     scheme = Uri.decodeIfNeeded(data.substring(end + 1));
8405                                 }
8406                             }
8407                             if (scheme == null) {
8408                                 // If there was no scheme, then this just targets the package.
8409                                 if (!explicitAction) {
8410                                     intent.setAction(ACTION_MAIN);
8411                                 }
8412                                 data = "";
8413                             } else if (authority == null) {
8414                                 data = scheme + ":";
8415                             } else {
8416                                 data = scheme + "://" + authority + data.substring(end);
8417                             }
8418                         }
8419                     } else {
8420                         data = "";
8421                     }
8422                 }
8423 
8424                 if (data.length() > 0) {
8425                     try {
8426                         intent.mData = Uri.parse(data);
8427                     } catch (IllegalArgumentException e) {
8428                         throw new URISyntaxException(uri, e.getMessage());
8429                     }
8430                 }
8431             }
8432 
8433             return intent;
8434 
8435         } catch (IndexOutOfBoundsException e) {
8436             throw new URISyntaxException(uri, "illegal Intent URI format", i);
8437         }
8438     }
8439 
8440     public static Intent getIntentOld(String uri) throws URISyntaxException {
8441         Intent intent = getIntentOld(uri, 0);
8442         intent.mLocalFlags |= LOCAL_FLAG_FROM_URI;
8443         return intent;
8444     }
8445 
8446     private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
8447         Intent intent;
8448 
8449         int i = uri.lastIndexOf('#');
8450         if (i >= 0) {
8451             String action = null;
8452             final int intentFragmentStart = i;
8453             boolean isIntentFragment = false;
8454 
8455             i++;
8456 
8457             if (uri.regionMatches(i, "action(", 0, 7)) {
8458                 isIntentFragment = true;
8459                 i += 7;
8460                 int j = uri.indexOf(')', i);
8461                 action = uri.substring(i, j);
8462                 i = j + 1;
8463             }
8464 
8465             intent = new Intent(action);
8466 
8467             if (uri.regionMatches(i, "categories(", 0, 11)) {
8468                 isIntentFragment = true;
8469                 i += 11;
8470                 int j = uri.indexOf(')', i);
8471                 while (i < j) {
8472                     int sep = uri.indexOf('!', i);
8473                     if (sep < 0 || sep > j) sep = j;
8474                     if (i < sep) {
8475                         intent.addCategory(uri.substring(i, sep));
8476                     }
8477                     i = sep + 1;
8478                 }
8479                 i = j + 1;
8480             }
8481 
8482             if (uri.regionMatches(i, "type(", 0, 5)) {
8483                 isIntentFragment = true;
8484                 i += 5;
8485                 int j = uri.indexOf(')', i);
8486                 intent.mType = uri.substring(i, j);
8487                 i = j + 1;
8488             }
8489 
8490             if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
8491                 isIntentFragment = true;
8492                 i += 12;
8493                 int j = uri.indexOf(')', i);
8494                 intent.mFlags = decodeInteger(uri.substring(i, j));
8495                 if ((flags& URI_ALLOW_UNSAFE) == 0) {
8496                     intent.mFlags &= ~IMMUTABLE_FLAGS;
8497                 }
8498                 i = j + 1;
8499             }
8500 
8501             if (uri.regionMatches(i, "component(", 0, 10)) {
8502                 isIntentFragment = true;
8503                 i += 10;
8504                 int j = uri.indexOf(')', i);
8505                 int sep = uri.indexOf('!', i);
8506                 if (sep >= 0 && sep < j) {
8507                     String pkg = uri.substring(i, sep);
8508                     String cls = uri.substring(sep + 1, j);
8509                     intent.mComponent = new ComponentName(pkg, cls);
8510                 }
8511                 i = j + 1;
8512             }
8513 
8514             if (uri.regionMatches(i, "extras(", 0, 7)) {
8515                 isIntentFragment = true;
8516                 i += 7;
8517 
8518                 final int closeParen = uri.indexOf(')', i);
8519                 if (closeParen == -1) throw new URISyntaxException(uri,
8520                         "EXTRA missing trailing ')'", i);
8521 
8522                 while (i < closeParen) {
8523                     // fetch the key value
8524                     int j = uri.indexOf('=', i);
8525                     if (j <= i + 1 || i >= closeParen) {
8526                         throw new URISyntaxException(uri, "EXTRA missing '='", i);
8527                     }
8528                     char type = uri.charAt(i);
8529                     i++;
8530                     String key = uri.substring(i, j);
8531                     i = j + 1;
8532 
8533                     // get type-value
8534                     j = uri.indexOf('!', i);
8535                     if (j == -1 || j >= closeParen) j = closeParen;
8536                     if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
8537                     String value = uri.substring(i, j);
8538                     i = j;
8539 
8540                     // create Bundle if it doesn't already exist
8541                     if (intent.mExtras == null) intent.mExtras = new Bundle();
8542 
8543                     // add item to bundle
8544                     try {
8545                         switch (type) {
8546                             case 'S':
8547                                 intent.mExtras.putString(key, Uri.decode(value));
8548                                 break;
8549                             case 'B':
8550                                 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
8551                                 break;
8552                             case 'b':
8553                                 intent.mExtras.putByte(key, Byte.parseByte(value));
8554                                 break;
8555                             case 'c':
8556                                 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
8557                                 break;
8558                             case 'd':
8559                                 intent.mExtras.putDouble(key, Double.parseDouble(value));
8560                                 break;
8561                             case 'f':
8562                                 intent.mExtras.putFloat(key, Float.parseFloat(value));
8563                                 break;
8564                             case 'i':
8565                                 intent.mExtras.putInt(key, Integer.parseInt(value));
8566                                 break;
8567                             case 'l':
8568                                 intent.mExtras.putLong(key, Long.parseLong(value));
8569                                 break;
8570                             case 's':
8571                                 intent.mExtras.putShort(key, Short.parseShort(value));
8572                                 break;
8573                             default:
8574                                 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
8575                         }
8576                     } catch (NumberFormatException e) {
8577                         throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
8578                     }
8579 
8580                     char ch = uri.charAt(i);
8581                     if (ch == ')') break;
8582                     if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
8583                     i++;
8584                 }
8585             }
8586 
8587             if (isIntentFragment) {
8588                 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
8589             } else {
8590                 intent.mData = Uri.parse(uri);
8591             }
8592 
8593             if (intent.mAction == null) {
8594                 // By default, if no action is specified, then use VIEW.
8595                 intent.mAction = ACTION_VIEW;
8596             }
8597 
8598         } else {
8599             intent = new Intent(ACTION_VIEW, Uri.parse(uri));
8600         }
8601 
8602         return intent;
8603     }
8604 
decodeInteger(String value)8605     private static Integer decodeInteger(String value) {
8606         try {
8607             return Integer.decode(value);
8608         } catch (NumberFormatException e) {
8609             try {
8610                 if (value != null && value.startsWith("0x")) {
8611                     // In toUriInner, we do "0x".append(Integer.toHexString).
8612                     // Sometimes "decode" fails to parse, e.g. 0x90000000.
8613                     return Integer.parseUnsignedInt(value.substring(2), 16);
8614                 }
8615             } catch (NumberFormatException ignored) {
8616                 // ignored, throw the original exception
8617             }
8618             throw e;
8619         }
8620     }
8621 
8622     /** @hide */
8623     public interface CommandOptionHandler {
8624         boolean handleOption(String opt, ShellCommand cmd);
8625     }
8626 
8627     /** @hide */
8628     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
8629     @SuppressWarnings("AndroidFrameworkEfficientCollections")
parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)8630     public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
8631             throws URISyntaxException {
8632         Intent intent = new Intent();
8633         Intent baseIntent = intent;
8634         boolean hasIntentInfo = false;
8635 
8636         Uri data = null;
8637         String type = null;
8638 
8639         String opt;
8640         while ((opt=cmd.getNextOption()) != null) {
8641             switch (opt) {
8642                 case "-a":
8643                     intent.setAction(cmd.getNextArgRequired());
8644                     if (intent == baseIntent) {
8645                         hasIntentInfo = true;
8646                     }
8647                     break;
8648                 case "-d":
8649                     data = Uri.parse(cmd.getNextArgRequired());
8650                     if (intent == baseIntent) {
8651                         hasIntentInfo = true;
8652                     }
8653                     break;
8654                 case "-t":
8655                     type = cmd.getNextArgRequired();
8656                     if (intent == baseIntent) {
8657                         hasIntentInfo = true;
8658                     }
8659                     break;
8660                 case "-i":
8661                     intent.setIdentifier(cmd.getNextArgRequired());
8662                     if (intent == baseIntent) {
8663                         hasIntentInfo = true;
8664                     }
8665                     break;
8666                 case "-c":
8667                     intent.addCategory(cmd.getNextArgRequired());
8668                     if (intent == baseIntent) {
8669                         hasIntentInfo = true;
8670                     }
8671                     break;
8672                 case "-e":
8673                 case "--es": {
8674                     String key = cmd.getNextArgRequired();
8675                     String value = cmd.getNextArgRequired();
8676                     intent.putExtra(key, value);
8677                 }
8678                 break;
8679                 case "--esn": {
8680                     String key = cmd.getNextArgRequired();
8681                     intent.putExtra(key, (String) null);
8682                 }
8683                 break;
8684                 case "--ei": {
8685                     String key = cmd.getNextArgRequired();
8686                     String value = cmd.getNextArgRequired();
8687                     intent.putExtra(key, decodeInteger(value));
8688                 }
8689                 break;
8690                 case "--eu": {
8691                     String key = cmd.getNextArgRequired();
8692                     String value = cmd.getNextArgRequired();
8693                     intent.putExtra(key, Uri.parse(value));
8694                 }
8695                 break;
8696                 case "--ecn": {
8697                     String key = cmd.getNextArgRequired();
8698                     String value = cmd.getNextArgRequired();
8699                     ComponentName cn = ComponentName.unflattenFromString(value);
8700                     if (cn == null)
8701                         throw new IllegalArgumentException("Bad component name: " + value);
8702                     intent.putExtra(key, cn);
8703                 }
8704                 break;
8705                 case "--eia": {
8706                     String key = cmd.getNextArgRequired();
8707                     String value = cmd.getNextArgRequired();
8708                     String[] strings = value.split(",");
8709                     int[] list = new int[strings.length];
8710                     for (int i = 0; i < strings.length; i++) {
8711                         list[i] = decodeInteger(strings[i]);
8712                     }
8713                     intent.putExtra(key, list);
8714                 }
8715                 break;
8716                 case "--eial": {
8717                     String key = cmd.getNextArgRequired();
8718                     String value = cmd.getNextArgRequired();
8719                     String[] strings = value.split(",");
8720                     ArrayList<Integer> list = new ArrayList<>(strings.length);
8721                     for (int i = 0; i < strings.length; i++) {
8722                         list.add(decodeInteger(strings[i]));
8723                     }
8724                     intent.putExtra(key, list);
8725                 }
8726                 break;
8727                 case "--el": {
8728                     String key = cmd.getNextArgRequired();
8729                     String value = cmd.getNextArgRequired();
8730                     intent.putExtra(key, Long.valueOf(value));
8731                 }
8732                 break;
8733                 case "--ela": {
8734                     String key = cmd.getNextArgRequired();
8735                     String value = cmd.getNextArgRequired();
8736                     String[] strings = value.split(",");
8737                     long[] list = new long[strings.length];
8738                     for (int i = 0; i < strings.length; i++) {
8739                         list[i] = Long.valueOf(strings[i]);
8740                     }
8741                     intent.putExtra(key, list);
8742                     hasIntentInfo = true;
8743                 }
8744                 break;
8745                 case "--elal": {
8746                     String key = cmd.getNextArgRequired();
8747                     String value = cmd.getNextArgRequired();
8748                     String[] strings = value.split(",");
8749                     ArrayList<Long> list = new ArrayList<>(strings.length);
8750                     for (int i = 0; i < strings.length; i++) {
8751                         list.add(Long.valueOf(strings[i]));
8752                     }
8753                     intent.putExtra(key, list);
8754                     hasIntentInfo = true;
8755                 }
8756                 break;
8757                 case "--ef": {
8758                     String key = cmd.getNextArgRequired();
8759                     String value = cmd.getNextArgRequired();
8760                     intent.putExtra(key, Float.valueOf(value));
8761                     hasIntentInfo = true;
8762                 }
8763                 break;
8764                 case "--efa": {
8765                     String key = cmd.getNextArgRequired();
8766                     String value = cmd.getNextArgRequired();
8767                     String[] strings = value.split(",");
8768                     float[] list = new float[strings.length];
8769                     for (int i = 0; i < strings.length; i++) {
8770                         list[i] = Float.valueOf(strings[i]);
8771                     }
8772                     intent.putExtra(key, list);
8773                     hasIntentInfo = true;
8774                 }
8775                 break;
8776                 case "--efal": {
8777                     String key = cmd.getNextArgRequired();
8778                     String value = cmd.getNextArgRequired();
8779                     String[] strings = value.split(",");
8780                     ArrayList<Float> list = new ArrayList<>(strings.length);
8781                     for (int i = 0; i < strings.length; i++) {
8782                         list.add(Float.valueOf(strings[i]));
8783                     }
8784                     intent.putExtra(key, list);
8785                     hasIntentInfo = true;
8786                 }
8787                 break;
8788                 case "--ed": {
8789                     String key = cmd.getNextArgRequired();
8790                     String value = cmd.getNextArgRequired();
8791                     intent.putExtra(key, Double.valueOf(value));
8792                     hasIntentInfo = true;
8793                 }
8794                 break;
8795                 case "--eda": {
8796                     String key = cmd.getNextArgRequired();
8797                     String value = cmd.getNextArgRequired();
8798                     String[] strings = value.split(",");
8799                     double[] list = new double[strings.length];
8800                     for (int i = 0; i < strings.length; i++) {
8801                         list[i] = Double.valueOf(strings[i]);
8802                     }
8803                     intent.putExtra(key, list);
8804                     hasIntentInfo = true;
8805                 }
8806                 break;
8807                 case "--edal": {
8808                     String key = cmd.getNextArgRequired();
8809                     String value = cmd.getNextArgRequired();
8810                     String[] strings = value.split(",");
8811                     ArrayList<Double> list = new ArrayList<>(strings.length);
8812                     for (int i = 0; i < strings.length; i++) {
8813                         list.add(Double.valueOf(strings[i]));
8814                     }
8815                     intent.putExtra(key, list);
8816                     hasIntentInfo = true;
8817                 }
8818                 break;
8819                 case "--esa": {
8820                     String key = cmd.getNextArgRequired();
8821                     String value = cmd.getNextArgRequired();
8822                     // Split on commas unless they are preceeded by an escape.
8823                     // The escape character must be escaped for the string and
8824                     // again for the regex, thus four escape characters become one.
8825                     String[] strings = value.split("(?<!\\\\),");
8826                     intent.putExtra(key, strings);
8827                     hasIntentInfo = true;
8828                 }
8829                 break;
8830                 case "--esal": {
8831                     String key = cmd.getNextArgRequired();
8832                     String value = cmd.getNextArgRequired();
8833                     // Split on commas unless they are preceeded by an escape.
8834                     // The escape character must be escaped for the string and
8835                     // again for the regex, thus four escape characters become one.
8836                     String[] strings = value.split("(?<!\\\\),");
8837                     ArrayList<String> list = new ArrayList<>(strings.length);
8838                     for (int i = 0; i < strings.length; i++) {
8839                         list.add(strings[i]);
8840                     }
8841                     intent.putExtra(key, list);
8842                     hasIntentInfo = true;
8843                 }
8844                 break;
8845                 case "--ez": {
8846                     String key = cmd.getNextArgRequired();
8847                     String value = cmd.getNextArgRequired().toLowerCase();
8848                     // Boolean.valueOf() results in false for anything that is not "true", which is
8849                     // error-prone in shell commands
8850                     boolean arg;
8851                     if ("true".equals(value) || "t".equals(value)) {
8852                         arg = true;
8853                     } else if ("false".equals(value) || "f".equals(value)) {
8854                         arg = false;
8855                     } else {
8856                         try {
8857                             arg = decodeInteger(value) != 0;
8858                         } catch (NumberFormatException ex) {
8859                             throw new IllegalArgumentException("Invalid boolean value: " + value);
8860                         }
8861                     }
8862 
8863                     intent.putExtra(key, arg);
8864                 }
8865                 break;
8866                 case "-n": {
8867                     String str = cmd.getNextArgRequired();
8868                     ComponentName cn = ComponentName.unflattenFromString(str);
8869                     if (cn == null)
8870                         throw new IllegalArgumentException("Bad component name: " + str);
8871                     intent.setComponent(cn);
8872                     if (intent == baseIntent) {
8873                         hasIntentInfo = true;
8874                     }
8875                 }
8876                 break;
8877                 case "-p": {
8878                     String str = cmd.getNextArgRequired();
8879                     intent.setPackage(str);
8880                     if (intent == baseIntent) {
8881                         hasIntentInfo = true;
8882                     }
8883                 }
8884                 break;
8885                 case "-f":
8886                     String str = cmd.getNextArgRequired();
8887                     intent.setFlags(decodeInteger(str).intValue());
8888                     break;
8889                 case "--grant-read-uri-permission":
8890                     intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
8891                     break;
8892                 case "--grant-write-uri-permission":
8893                     intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
8894                     break;
8895                 case "--grant-persistable-uri-permission":
8896                     intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
8897                     break;
8898                 case "--grant-prefix-uri-permission":
8899                     intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
8900                     break;
8901                 case "--exclude-stopped-packages":
8902                     intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
8903                     break;
8904                 case "--include-stopped-packages":
8905                     intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
8906                     break;
8907                 case "--debug-log-resolution":
8908                     intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
8909                     break;
8910                 case "--activity-brought-to-front":
8911                     intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
8912                     break;
8913                 case "--activity-clear-top":
8914                     intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
8915                     break;
8916                 case "--activity-clear-when-task-reset":
8917                     intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
8918                     break;
8919                 case "--activity-exclude-from-recents":
8920                     intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
8921                     break;
8922                 case "--activity-launched-from-history":
8923                     intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
8924                     break;
8925                 case "--activity-multiple-task":
8926                     intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
8927                     break;
8928                 case "--activity-no-animation":
8929                     intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
8930                     break;
8931                 case "--activity-no-history":
8932                     intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
8933                     break;
8934                 case "--activity-no-user-action":
8935                     intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
8936                     break;
8937                 case "--activity-previous-is-top":
8938                     intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
8939                     break;
8940                 case "--activity-reorder-to-front":
8941                     intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
8942                     break;
8943                 case "--activity-reset-task-if-needed":
8944                     intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
8945                     break;
8946                 case "--activity-single-top":
8947                     intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
8948                     break;
8949                 case "--activity-clear-task":
8950                     intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
8951                     break;
8952                 case "--activity-task-on-home":
8953                     intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
8954                     break;
8955                 case "--activity-match-external":
8956                     intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL);
8957                     break;
8958                 case "--receiver-registered-only":
8959                     intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
8960                     break;
8961                 case "--receiver-replace-pending":
8962                     intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
8963                     break;
8964                 case "--receiver-foreground":
8965                     intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
8966                     break;
8967                 case "--receiver-no-abort":
8968                     intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
8969                     break;
8970                 case "--receiver-include-background":
8971                     intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
8972                     break;
8973                 case "--selector":
8974                     intent.setDataAndType(data, type);
8975                     intent = new Intent();
8976                     break;
8977                 default:
8978                     if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
8979                         // Okay, caller handled this option.
8980                     } else {
8981                         throw new IllegalArgumentException("Unknown option: " + opt);
8982                     }
8983                     break;
8984             }
8985         }
8986         intent.setDataAndType(data, type);
8987 
8988         final boolean hasSelector = intent != baseIntent;
8989         if (hasSelector) {
8990             // A selector was specified; fix up.
8991             baseIntent.setSelector(intent);
8992             intent = baseIntent;
8993         }
8994 
8995         String arg = cmd.getNextArg();
8996         baseIntent = null;
8997         if (arg == null) {
8998             if (hasSelector) {
8999                 // If a selector has been specified, and no arguments
9000                 // have been supplied for the main Intent, then we can
9001                 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
9002                 // need to have a component name specified yet, the
9003                 // selector will take care of that.
9004                 baseIntent = new Intent(Intent.ACTION_MAIN);
9005                 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
9006             }
9007         } else if (arg.indexOf(':') >= 0) {
9008             // The argument is a URI.  Fully parse it, and use that result
9009             // to fill in any data not specified so far.
9010             baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
9011                     | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
9012         } else if (arg.indexOf('/') >= 0) {
9013             // The argument is a component name.  Build an Intent to launch
9014             // it.
9015             baseIntent = new Intent(Intent.ACTION_MAIN);
9016             baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
9017             baseIntent.setComponent(ComponentName.unflattenFromString(arg));
9018         } else {
9019             // Assume the argument is a package name.
9020             baseIntent = new Intent(Intent.ACTION_MAIN);
9021             baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
9022             baseIntent.setPackage(arg);
9023         }
9024         if (baseIntent != null) {
9025             Bundle extras = intent.getExtras();
9026             intent.replaceExtras((Bundle)null);
9027             Bundle uriExtras = baseIntent.getExtras();
9028             baseIntent.replaceExtras((Bundle)null);
9029             if (intent.getAction() != null && baseIntent.getCategories() != null) {
9030                 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
9031                 for (String c : cats) {
9032                     baseIntent.removeCategory(c);
9033                 }
9034             }
9035             intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
9036             if (extras == null) {
9037                 extras = uriExtras;
9038             } else if (uriExtras != null) {
9039                 uriExtras.putAll(extras);
9040                 extras = uriExtras;
9041             }
9042             intent.replaceExtras(extras);
9043             hasIntentInfo = true;
9044         }
9045 
9046         if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
9047         return intent;
9048     }
9049 
9050     /** @hide */
9051     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
printIntentArgsHelp(PrintWriter pw, String prefix)9052     public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
9053         final String[] lines = new String[] {
9054                 "<INTENT> specifications include these flags and arguments:",
9055                 "    [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] [-i <IDENTIFIER>]",
9056                 "    [-c <CATEGORY> [-c <CATEGORY>] ...]",
9057                 "    [-n <COMPONENT_NAME>]",
9058                 "    [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
9059                 "    [--esn <EXTRA_KEY> ...]",
9060                 "    [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
9061                 "    [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
9062                 "    [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
9063                 "    [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
9064                 "    [--ed <EXTRA_KEY> <EXTRA_DOUBLE_VALUE> ...]",
9065                 "    [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
9066                 "    [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
9067                 "    [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
9068                 "        (multiple extras passed as Integer[])",
9069                 "    [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
9070                 "        (multiple extras passed as List<Integer>)",
9071                 "    [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
9072                 "        (multiple extras passed as Long[])",
9073                 "    [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
9074                 "        (multiple extras passed as List<Long>)",
9075                 "    [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
9076                 "        (multiple extras passed as Float[])",
9077                 "    [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
9078                 "        (multiple extras passed as List<Float>)",
9079                 "    [--eda <EXTRA_KEY> <EXTRA_DOUBLE_VALUE>[,<EXTRA_DOUBLE_VALUE...]]",
9080                 "        (multiple extras passed as Double[])",
9081                 "    [--edal <EXTRA_KEY> <EXTRA_DOUBLE_VALUE>[,<EXTRA_DOUBLE_VALUE...]]",
9082                 "        (multiple extras passed as List<Double>)",
9083                 "    [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
9084                 "        (multiple extras passed as String[]; to embed a comma into a string,",
9085                 "         escape it using \"\\,\")",
9086                 "    [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
9087                 "        (multiple extras passed as List<String>; to embed a comma into a string,",
9088                 "         escape it using \"\\,\")",
9089                 "    [-f <FLAG>]",
9090                 "    [--grant-read-uri-permission] [--grant-write-uri-permission]",
9091                 "    [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
9092                 "    [--debug-log-resolution] [--exclude-stopped-packages]",
9093                 "    [--include-stopped-packages]",
9094                 "    [--activity-brought-to-front] [--activity-clear-top]",
9095                 "    [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
9096                 "    [--activity-launched-from-history] [--activity-multiple-task]",
9097                 "    [--activity-no-animation] [--activity-no-history]",
9098                 "    [--activity-no-user-action] [--activity-previous-is-top]",
9099                 "    [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
9100                 "    [--activity-single-top] [--activity-clear-task]",
9101                 "    [--activity-task-on-home] [--activity-match-external]",
9102                 "    [--receiver-registered-only] [--receiver-replace-pending]",
9103                 "    [--receiver-foreground] [--receiver-no-abort]",
9104                 "    [--receiver-include-background]",
9105                 "    [--selector]",
9106                 "    [<URI> | <PACKAGE> | <COMPONENT>]"
9107         };
9108         for (String line : lines) {
9109             pw.print(prefix);
9110             pw.println(line);
9111         }
9112     }
9113 
9114     /**
9115      * Retrieve the general action to be performed, such as
9116      * {@link #ACTION_VIEW}.  The action describes the general way the rest of
9117      * the information in the intent should be interpreted -- most importantly,
9118      * what to do with the data returned by {@link #getData}.
9119      *
9120      * @return The action of this intent or null if none is specified.
9121      *
9122      * @see #setAction
9123      */
getAction()9124     public @Nullable String getAction() {
9125         return mAction;
9126     }
9127 
9128     /**
9129      * Retrieve data this intent is operating on.  This URI specifies the name
9130      * of the data; often it uses the content: scheme, specifying data in a
9131      * content provider.  Other schemes may be handled by specific activities,
9132      * such as http: by the web browser.
9133      *
9134      * @return The URI of the data this intent is targeting or null.
9135      *
9136      * @see #getScheme
9137      * @see #setData
9138      */
getData()9139     public @Nullable Uri getData() {
9140         return mData;
9141     }
9142 
9143     /**
9144      * The same as {@link #getData()}, but returns the URI as an encoded
9145      * String.
9146      */
getDataString()9147     public @Nullable String getDataString() {
9148         return mData != null ? mData.toString() : null;
9149     }
9150 
9151     /**
9152      * Return the scheme portion of the intent's data.  If the data is null or
9153      * does not include a scheme, null is returned.  Otherwise, the scheme
9154      * prefix without the final ':' is returned, i.e. "http".
9155      *
9156      * <p>This is the same as calling getData().getScheme() (and checking for
9157      * null data).
9158      *
9159      * @return The scheme of this intent.
9160      *
9161      * @see #getData
9162      */
getScheme()9163     public @Nullable String getScheme() {
9164         return mData != null ? mData.getScheme() : null;
9165     }
9166 
9167     /**
9168      * Retrieve any explicit MIME type included in the intent.  This is usually
9169      * null, as the type is determined by the intent data.
9170      *
9171      * @return If a type was manually set, it is returned; else null is
9172      *         returned.
9173      *
9174      * @see #resolveType(ContentResolver)
9175      * @see #setType
9176      */
getType()9177     public @Nullable String getType() {
9178         return mType;
9179     }
9180 
9181 
9182     /**
9183      * @hide For the experimental component alias feature. Do not use, unless you know what it is.
9184      */
9185     @Nullable
getOriginalIntent()9186     public Intent getOriginalIntent() {
9187         return mOriginalIntent;
9188     }
9189 
9190     /**
9191      * @hide For the experimental component alias feature. Do not use, unless you know what it is.
9192      */
setOriginalIntent(@ullable Intent originalIntent)9193     public void setOriginalIntent(@Nullable Intent originalIntent) {
9194         mOriginalIntent = originalIntent;
9195     }
9196 
9197     /**
9198      * Return the MIME data type of this intent.  If the type field is
9199      * explicitly set, that is simply returned.  Otherwise, if the data is set,
9200      * the type of that data is returned.  If neither fields are set, a null is
9201      * returned.
9202      *
9203      * @return The MIME type of this intent.
9204      *
9205      * @see #getType
9206      * @see #resolveType(ContentResolver)
9207      */
resolveType(@onNull Context context)9208     public @Nullable String resolveType(@NonNull Context context) {
9209         return resolveType(context.getContentResolver());
9210     }
9211 
9212     /**
9213      * Return the MIME data type of this intent.  If the type field is
9214      * explicitly set, that is simply returned.  Otherwise, if the data is set,
9215      * the type of that data is returned.  If neither fields are set, a null is
9216      * returned.
9217      *
9218      * @param resolver A ContentResolver that can be used to determine the MIME
9219      *                 type of the intent's data.
9220      *
9221      * @return The MIME type of this intent.
9222      *
9223      * @see #getType
9224      * @see #resolveType(Context)
9225      */
resolveType(@onNull ContentResolver resolver)9226     public @Nullable String resolveType(@NonNull ContentResolver resolver) {
9227         if (mType != null) {
9228             return mType;
9229         }
9230         if (mData != null) {
9231             if ("content".equals(mData.getScheme())) {
9232                 return resolver.getType(mData);
9233             }
9234         }
9235         return null;
9236     }
9237 
9238     /**
9239      * Return the MIME data type of this intent, only if it will be needed for
9240      * intent resolution.  This is not generally useful for application code;
9241      * it is used by the frameworks for communicating with back-end system
9242      * services.
9243      *
9244      * @param resolver A ContentResolver that can be used to determine the MIME
9245      *                 type of the intent's data.
9246      *
9247      * @return The MIME type of this intent, or null if it is unknown or not
9248      *         needed.
9249      */
resolveTypeIfNeeded(@onNull ContentResolver resolver)9250     public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
9251         // Match logic in PackageManagerService#applyEnforceIntentFilterMatching(...)
9252         if (mComponent != null && (Process.myUid() == Process.ROOT_UID
9253                 || Process.myUid() == Process.SYSTEM_UID
9254                 || mComponent.getPackageName().equals(ActivityThread.currentPackageName()))) {
9255             return mType;
9256         }
9257         return resolveType(resolver);
9258     }
9259 
9260     /**
9261      * Retrieve the identifier for this Intent.  If non-null, this is an arbitrary identity
9262      * of the Intent to distinguish it from other Intents.
9263      *
9264      * @return The identifier of this intent or null if none is specified.
9265      *
9266      * @see #setIdentifier
9267      */
getIdentifier()9268     public @Nullable String getIdentifier() {
9269         return mIdentifier;
9270     }
9271 
9272     /**
9273      * Check if a category exists in the intent.
9274      *
9275      * @param category The category to check.
9276      *
9277      * @return boolean True if the intent contains the category, else false.
9278      *
9279      * @see #getCategories
9280      * @see #addCategory
9281      */
hasCategory(String category)9282     public boolean hasCategory(String category) {
9283         return mCategories != null && mCategories.contains(category);
9284     }
9285 
9286     /**
9287      * Return the set of all categories in the intent.  If there are no categories,
9288      * returns NULL.
9289      *
9290      * @return The set of categories you can examine.  Do not modify!
9291      *
9292      * @see #hasCategory
9293      * @see #addCategory
9294      */
getCategories()9295     public Set<String> getCategories() {
9296         return mCategories;
9297     }
9298 
9299     /**
9300      * Return the specific selector associated with this Intent.  If there is
9301      * none, returns null.  See {@link #setSelector} for more information.
9302      *
9303      * @see #setSelector
9304      */
getSelector()9305     public @Nullable Intent getSelector() {
9306         return mSelector;
9307     }
9308 
9309     /**
9310      * Return the {@link ClipData} associated with this Intent.  If there is
9311      * none, returns null.  See {@link #setClipData} for more information.
9312      *
9313      * @see #setClipData
9314      */
getClipData()9315     public @Nullable ClipData getClipData() {
9316         return mClipData;
9317     }
9318 
9319     /** @hide */
getContentUserHint()9320     public int getContentUserHint() {
9321         return mContentUserHint;
9322     }
9323 
9324     /** @hide */
getLaunchToken()9325     public String getLaunchToken() {
9326         return mLaunchToken;
9327     }
9328 
9329     /** @hide */
setLaunchToken(String launchToken)9330     public void setLaunchToken(String launchToken) {
9331         mLaunchToken = launchToken;
9332     }
9333 
9334     /**
9335      * Sets the ClassLoader that will be used when unmarshalling
9336      * any Parcelable values from the extras of this Intent.
9337      *
9338      * @param loader a ClassLoader, or null to use the default loader
9339      * at the time of unmarshalling.
9340      */
setExtrasClassLoader(@ullable ClassLoader loader)9341     public void setExtrasClassLoader(@Nullable ClassLoader loader) {
9342         if (mExtras != null) {
9343             mExtras.setClassLoader(loader);
9344         }
9345     }
9346 
9347     /**
9348      * Returns true if an extra value is associated with the given name.
9349      * @param name the extra's name
9350      * @return true if the given extra is present.
9351      */
hasExtra(String name)9352     public boolean hasExtra(String name) {
9353         return mExtras != null && mExtras.containsKey(name);
9354     }
9355 
9356     /**
9357      * Returns true if the Intent's extras contain a parcelled file descriptor.
9358      * @return true if the Intent contains a parcelled file descriptor.
9359      */
hasFileDescriptors()9360     public boolean hasFileDescriptors() {
9361         return mExtras != null && mExtras.hasFileDescriptors();
9362     }
9363 
9364     /** {@hide} */
9365     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
setAllowFds(boolean allowFds)9366     public void setAllowFds(boolean allowFds) {
9367         if (mExtras != null) {
9368             mExtras.setAllowFds(allowFds);
9369         }
9370     }
9371 
9372     /** {@hide} */
setDefusable(boolean defusable)9373     public void setDefusable(boolean defusable) {
9374         if (mExtras != null) {
9375             mExtras.setDefusable(defusable);
9376         }
9377     }
9378 
9379     /**
9380      * Retrieve extended data from the intent.
9381      *
9382      * @param name The name of the desired item.
9383      *
9384      * @return the value of an item previously added with putExtra(),
9385      * or null if none was found.
9386      *
9387      * @deprecated
9388      * @hide
9389      */
9390     @Deprecated
9391     @UnsupportedAppUsage
getExtra(String name)9392     public Object getExtra(String name) {
9393         return getExtra(name, null);
9394     }
9395 
9396     /**
9397      * Retrieve extended data from the intent.
9398      *
9399      * @param name The name of the desired item.
9400      * @param defaultValue the value to be returned if no value of the desired
9401      * type is stored with the given name.
9402      *
9403      * @return the value of an item previously added with putExtra(),
9404      * or the default value if none was found.
9405      *
9406      * @see #putExtra(String, boolean)
9407      */
getBooleanExtra(String name, boolean defaultValue)9408     public boolean getBooleanExtra(String name, boolean defaultValue) {
9409         return mExtras == null ? defaultValue :
9410             mExtras.getBoolean(name, defaultValue);
9411     }
9412 
9413     /**
9414      * Retrieve extended data from the intent.
9415      *
9416      * @param name The name of the desired item.
9417      * @param defaultValue the value to be returned if no value of the desired
9418      * type is stored with the given name.
9419      *
9420      * @return the value of an item previously added with putExtra(),
9421      * or the default value if none was found.
9422      *
9423      * @see #putExtra(String, byte)
9424      */
getByteExtra(String name, byte defaultValue)9425     public byte getByteExtra(String name, byte defaultValue) {
9426         return mExtras == null ? defaultValue :
9427             mExtras.getByte(name, defaultValue);
9428     }
9429 
9430     /**
9431      * Retrieve extended data from the intent.
9432      *
9433      * @param name The name of the desired item.
9434      * @param defaultValue the value to be returned if no value of the desired
9435      * type is stored with the given name.
9436      *
9437      * @return the value of an item previously added with putExtra(),
9438      * or the default value if none was found.
9439      *
9440      * @see #putExtra(String, short)
9441      */
getShortExtra(String name, short defaultValue)9442     public short getShortExtra(String name, short defaultValue) {
9443         return mExtras == null ? defaultValue :
9444             mExtras.getShort(name, defaultValue);
9445     }
9446 
9447     /**
9448      * Retrieve extended data from the intent.
9449      *
9450      * @param name The name of the desired item.
9451      * @param defaultValue the value to be returned if no value of the desired
9452      * type is stored with the given name.
9453      *
9454      * @return the value of an item previously added with putExtra(),
9455      * or the default value if none was found.
9456      *
9457      * @see #putExtra(String, char)
9458      */
getCharExtra(String name, char defaultValue)9459     public char getCharExtra(String name, char defaultValue) {
9460         return mExtras == null ? defaultValue :
9461             mExtras.getChar(name, defaultValue);
9462     }
9463 
9464     /**
9465      * Retrieve extended data from the intent.
9466      *
9467      * @param name The name of the desired item.
9468      * @param defaultValue the value to be returned if no value of the desired
9469      * type is stored with the given name.
9470      *
9471      * @return the value of an item previously added with putExtra(),
9472      * or the default value if none was found.
9473      *
9474      * @see #putExtra(String, int)
9475      */
getIntExtra(String name, int defaultValue)9476     public int getIntExtra(String name, int defaultValue) {
9477         return mExtras == null ? defaultValue :
9478             mExtras.getInt(name, defaultValue);
9479     }
9480 
9481     /**
9482      * Retrieve extended data from the intent.
9483      *
9484      * @param name The name of the desired item.
9485      * @param defaultValue the value to be returned if no value of the desired
9486      * type is stored with the given name.
9487      *
9488      * @return the value of an item previously added with putExtra(),
9489      * or the default value if none was found.
9490      *
9491      * @see #putExtra(String, long)
9492      */
getLongExtra(String name, long defaultValue)9493     public long getLongExtra(String name, long defaultValue) {
9494         return mExtras == null ? defaultValue :
9495             mExtras.getLong(name, defaultValue);
9496     }
9497 
9498     /**
9499      * Retrieve extended data from the intent.
9500      *
9501      * @param name The name of the desired item.
9502      * @param defaultValue the value to be returned if no value of the desired
9503      * type is stored with the given name.
9504      *
9505      * @return the value of an item previously added with putExtra(),
9506      * or the default value if no such item is present
9507      *
9508      * @see #putExtra(String, float)
9509      */
getFloatExtra(String name, float defaultValue)9510     public float getFloatExtra(String name, float defaultValue) {
9511         return mExtras == null ? defaultValue :
9512             mExtras.getFloat(name, defaultValue);
9513     }
9514 
9515     /**
9516      * Retrieve extended data from the intent.
9517      *
9518      * @param name The name of the desired item.
9519      * @param defaultValue the value to be returned if no value of the desired
9520      * type is stored with the given name.
9521      *
9522      * @return the value of an item previously added with putExtra(),
9523      * or the default value if none was found.
9524      *
9525      * @see #putExtra(String, double)
9526      */
getDoubleExtra(String name, double defaultValue)9527     public double getDoubleExtra(String name, double defaultValue) {
9528         return mExtras == null ? defaultValue :
9529             mExtras.getDouble(name, defaultValue);
9530     }
9531 
9532     /**
9533      * Retrieve extended data from the intent.
9534      *
9535      * @param name The name of the desired item.
9536      *
9537      * @return the value of an item previously added with putExtra(),
9538      * or null if no String value was found.
9539      *
9540      * @see #putExtra(String, String)
9541      */
getStringExtra(String name)9542     public @Nullable String getStringExtra(String name) {
9543         return mExtras == null ? null : mExtras.getString(name);
9544     }
9545 
9546     /**
9547      * Retrieve extended data from the intent.
9548      *
9549      * @param name The name of the desired item.
9550      *
9551      * @return the value of an item previously added with putExtra(),
9552      * or null if no CharSequence value was found.
9553      *
9554      * @see #putExtra(String, CharSequence)
9555      */
getCharSequenceExtra(String name)9556     public @Nullable CharSequence getCharSequenceExtra(String name) {
9557         return mExtras == null ? null : mExtras.getCharSequence(name);
9558     }
9559 
9560     /**
9561      * Retrieve extended data from the intent.
9562      *
9563      * @param name The name of the desired item.
9564      *
9565      * @return the value of an item previously added with putExtra(),
9566      * or null if no Parcelable value was found.
9567      *
9568      * @deprecated Use the type-safer {@link #getParcelableExtra(String, Class)} starting from
9569      *      Android {@link Build.VERSION_CODES#TIRAMISU}.
9570      *
9571      * @see #putExtra(String, Parcelable)
9572      */
9573     @Deprecated
getParcelableExtra(String name)9574     public @Nullable <T extends Parcelable> T getParcelableExtra(String name) {
9575         return mExtras == null ? null : mExtras.<T>getParcelable(name);
9576     }
9577 
9578     /**
9579      * Retrieve extended data from the intent.
9580      *
9581      * @param name The name of the desired item.
9582      * @param clazz The type of the object expected.
9583      *
9584      * @return the value of an item previously added with putExtra(),
9585      * or null if no Parcelable value was found.
9586      *
9587      * @see #putExtra(String, Parcelable)
9588      */
getParcelableExtra(@ullable String name, @NonNull Class<T> clazz)9589     public @Nullable <T> T getParcelableExtra(@Nullable String name, @NonNull Class<T> clazz) {
9590         return mExtras == null ? null : mExtras.getParcelable(name, clazz);
9591     }
9592 
9593     /**
9594      * Retrieve extended data from the intent.
9595      *
9596      * @param name The name of the desired item.
9597      *
9598      * @return the value of an item previously added with putExtra(),
9599      * or null if no Parcelable[] value was found.
9600      *
9601      * @deprecated Use the type-safer {@link #getParcelableArrayExtra(String, Class)} starting from
9602      *      Android {@link Build.VERSION_CODES#TIRAMISU}.
9603      *
9604      * @see #putExtra(String, Parcelable[])
9605      */
9606     @Deprecated
getParcelableArrayExtra(String name)9607     public @Nullable Parcelable[] getParcelableArrayExtra(String name) {
9608         return mExtras == null ? null : mExtras.getParcelableArray(name);
9609     }
9610 
9611     /**
9612      * Retrieve extended data from the intent.
9613      *
9614      * @param name The name of the desired item.
9615      * @param clazz The type of the items inside the array. This is only verified when unparceling.
9616      *
9617      * @return the value of an item previously added with putExtra(),
9618      * or null if no Parcelable[] value was found.
9619      *
9620      * @see #putExtra(String, Parcelable[])
9621      */
9622     @SuppressLint({"ArrayReturn", "NullableCollection"})
getParcelableArrayExtra(@ullable String name, @NonNull Class<T> clazz)9623     public @Nullable <T> T[] getParcelableArrayExtra(@Nullable String name,
9624             @NonNull Class<T> clazz) {
9625         return mExtras == null ? null : mExtras.getParcelableArray(name, clazz);
9626     }
9627 
9628     /**
9629      * Retrieve extended data from the intent.
9630      *
9631      * @param name The name of the desired item.
9632      *
9633      * @return the value of an item previously added with
9634      * putParcelableArrayListExtra(), or null if no
9635      * ArrayList<Parcelable> value was found.
9636      *
9637      * @deprecated Use the type-safer {@link #getParcelableArrayListExtra(String, Class)} starting
9638      *      from Android {@link Build.VERSION_CODES#TIRAMISU}.
9639      *
9640      * @see #putParcelableArrayListExtra(String, ArrayList)
9641      */
9642     @Deprecated
getParcelableArrayListExtra(String name)9643     public @Nullable <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
9644         return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
9645     }
9646 
9647     /**
9648      * Retrieve extended data from the intent.
9649      *
9650      * @param name The name of the desired item.
9651      * @param clazz The type of the items inside the array list. This is only verified when
9652      *     unparceling.
9653      *
9654      * @return the value of an item previously added with
9655      * putParcelableArrayListExtra(), or null if no
9656      * ArrayList<Parcelable> value was found.
9657      *
9658      * @see #putParcelableArrayListExtra(String, ArrayList)
9659      */
9660     @SuppressLint({"ConcreteCollection", "NullableCollection"})
getParcelableArrayListExtra(@ullable String name, @NonNull Class<? extends T> clazz)9661     public @Nullable <T> ArrayList<T> getParcelableArrayListExtra(@Nullable String name,
9662             @NonNull Class<? extends T> clazz) {
9663         return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name, clazz);
9664     }
9665 
9666     /**
9667      * Retrieve extended data from the intent.
9668      *
9669      * @param name The name of the desired item.
9670      *
9671      * @return the value of an item previously added with putExtra(),
9672      * or null if no Serializable value was found.
9673      *
9674      * @deprecated Use the type-safer {@link #getSerializableExtra(String, Class)} starting from
9675      *      Android {@link Build.VERSION_CODES#TIRAMISU}.
9676      *
9677      * @see #putExtra(String, Serializable)
9678      */
getSerializableExtra(String name)9679     public @Nullable Serializable getSerializableExtra(String name) {
9680         return mExtras == null ? null : mExtras.getSerializable(name);
9681     }
9682 
9683     /**
9684      * Retrieve extended data from the intent.
9685      *
9686      * @param name The name of the desired item.
9687      * @param clazz The type of the object expected.
9688      *
9689      * @return the value of an item previously added with putExtra(),
9690      * or null if no Serializable value was found.
9691      *
9692      * @see #putExtra(String, Serializable)
9693      */
getSerializableExtra(@ullable String name, @NonNull Class<T> clazz)9694     public @Nullable <T extends Serializable> T getSerializableExtra(@Nullable String name,
9695             @NonNull Class<T> clazz) {
9696         return mExtras == null ? null : mExtras.getSerializable(name, clazz);
9697     }
9698 
9699     /**
9700      * Retrieve extended data from the intent.
9701      *
9702      * @param name The name of the desired item.
9703      *
9704      * @return the value of an item previously added with
9705      * putIntegerArrayListExtra(), or null if no
9706      * ArrayList<Integer> value was found.
9707      *
9708      * @see #putIntegerArrayListExtra(String, ArrayList)
9709      */
getIntegerArrayListExtra(String name)9710     public @Nullable ArrayList<Integer> getIntegerArrayListExtra(String name) {
9711         return mExtras == null ? null : mExtras.getIntegerArrayList(name);
9712     }
9713 
9714     /**
9715      * Retrieve extended data from the intent.
9716      *
9717      * @param name The name of the desired item.
9718      *
9719      * @return the value of an item previously added with
9720      * putStringArrayListExtra(), or null if no
9721      * ArrayList<String> value was found.
9722      *
9723      * @see #putStringArrayListExtra(String, ArrayList)
9724      */
getStringArrayListExtra(String name)9725     public @Nullable ArrayList<String> getStringArrayListExtra(String name) {
9726         return mExtras == null ? null : mExtras.getStringArrayList(name);
9727     }
9728 
9729     /**
9730      * Retrieve extended data from the intent.
9731      *
9732      * @param name The name of the desired item.
9733      *
9734      * @return the value of an item previously added with
9735      * putCharSequenceArrayListExtra, or null if no
9736      * ArrayList<CharSequence> value was found.
9737      *
9738      * @see #putCharSequenceArrayListExtra(String, ArrayList)
9739      */
getCharSequenceArrayListExtra(String name)9740     public @Nullable ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
9741         return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
9742     }
9743 
9744     /**
9745      * Retrieve extended data from the intent.
9746      *
9747      * @param name The name of the desired item.
9748      *
9749      * @return the value of an item previously added with putExtra(),
9750      * or null if no boolean array value was found.
9751      *
9752      * @see #putExtra(String, boolean[])
9753      */
getBooleanArrayExtra(String name)9754     public @Nullable boolean[] getBooleanArrayExtra(String name) {
9755         return mExtras == null ? null : mExtras.getBooleanArray(name);
9756     }
9757 
9758     /**
9759      * Retrieve extended data from the intent.
9760      *
9761      * @param name The name of the desired item.
9762      *
9763      * @return the value of an item previously added with putExtra(),
9764      * or null if no byte array value was found.
9765      *
9766      * @see #putExtra(String, byte[])
9767      */
getByteArrayExtra(String name)9768     public @Nullable byte[] getByteArrayExtra(String name) {
9769         return mExtras == null ? null : mExtras.getByteArray(name);
9770     }
9771 
9772     /**
9773      * Retrieve extended data from the intent.
9774      *
9775      * @param name The name of the desired item.
9776      *
9777      * @return the value of an item previously added with putExtra(),
9778      * or null if no short array value was found.
9779      *
9780      * @see #putExtra(String, short[])
9781      */
getShortArrayExtra(String name)9782     public @Nullable short[] getShortArrayExtra(String name) {
9783         return mExtras == null ? null : mExtras.getShortArray(name);
9784     }
9785 
9786     /**
9787      * Retrieve extended data from the intent.
9788      *
9789      * @param name The name of the desired item.
9790      *
9791      * @return the value of an item previously added with putExtra(),
9792      * or null if no char array value was found.
9793      *
9794      * @see #putExtra(String, char[])
9795      */
getCharArrayExtra(String name)9796     public @Nullable char[] getCharArrayExtra(String name) {
9797         return mExtras == null ? null : mExtras.getCharArray(name);
9798     }
9799 
9800     /**
9801      * Retrieve extended data from the intent.
9802      *
9803      * @param name The name of the desired item.
9804      *
9805      * @return the value of an item previously added with putExtra(),
9806      * or null if no int array value was found.
9807      *
9808      * @see #putExtra(String, int[])
9809      */
getIntArrayExtra(String name)9810     public @Nullable int[] getIntArrayExtra(String name) {
9811         return mExtras == null ? null : mExtras.getIntArray(name);
9812     }
9813 
9814     /**
9815      * Retrieve extended data from the intent.
9816      *
9817      * @param name The name of the desired item.
9818      *
9819      * @return the value of an item previously added with putExtra(),
9820      * or null if no long array value was found.
9821      *
9822      * @see #putExtra(String, long[])
9823      */
getLongArrayExtra(String name)9824     public @Nullable long[] getLongArrayExtra(String name) {
9825         return mExtras == null ? null : mExtras.getLongArray(name);
9826     }
9827 
9828     /**
9829      * Retrieve extended data from the intent.
9830      *
9831      * @param name The name of the desired item.
9832      *
9833      * @return the value of an item previously added with putExtra(),
9834      * or null if no float array value was found.
9835      *
9836      * @see #putExtra(String, float[])
9837      */
getFloatArrayExtra(String name)9838     public @Nullable float[] getFloatArrayExtra(String name) {
9839         return mExtras == null ? null : mExtras.getFloatArray(name);
9840     }
9841 
9842     /**
9843      * Retrieve extended data from the intent.
9844      *
9845      * @param name The name of the desired item.
9846      *
9847      * @return the value of an item previously added with putExtra(),
9848      * or null if no double array value was found.
9849      *
9850      * @see #putExtra(String, double[])
9851      */
getDoubleArrayExtra(String name)9852     public @Nullable double[] getDoubleArrayExtra(String name) {
9853         return mExtras == null ? null : mExtras.getDoubleArray(name);
9854     }
9855 
9856     /**
9857      * Retrieve extended data from the intent.
9858      *
9859      * @param name The name of the desired item.
9860      *
9861      * @return the value of an item previously added with putExtra(),
9862      * or null if no String array value was found.
9863      *
9864      * @see #putExtra(String, String[])
9865      */
getStringArrayExtra(String name)9866     public @Nullable String[] getStringArrayExtra(String name) {
9867         return mExtras == null ? null : mExtras.getStringArray(name);
9868     }
9869 
9870     /**
9871      * Retrieve extended data from the intent.
9872      *
9873      * @param name The name of the desired item.
9874      *
9875      * @return the value of an item previously added with putExtra(),
9876      * or null if no CharSequence array value was found.
9877      *
9878      * @see #putExtra(String, CharSequence[])
9879      */
getCharSequenceArrayExtra(String name)9880     public @Nullable CharSequence[] getCharSequenceArrayExtra(String name) {
9881         return mExtras == null ? null : mExtras.getCharSequenceArray(name);
9882     }
9883 
9884     /**
9885      * Retrieve extended data from the intent.
9886      *
9887      * @param name The name of the desired item.
9888      *
9889      * @return the value of an item previously added with putExtra(),
9890      * or null if no Bundle value was found.
9891      *
9892      * @see #putExtra(String, Bundle)
9893      */
getBundleExtra(String name)9894     public @Nullable Bundle getBundleExtra(String name) {
9895         return mExtras == null ? null : mExtras.getBundle(name);
9896     }
9897 
9898     /**
9899      * Retrieve extended data from the intent.
9900      *
9901      * @param name The name of the desired item.
9902      *
9903      * @return the value of an item previously added with putExtra(),
9904      * or null if no IBinder value was found.
9905      *
9906      * @see #putExtra(String, IBinder)
9907      *
9908      * @deprecated
9909      * @hide
9910      */
9911     @Deprecated
9912     @UnsupportedAppUsage
getIBinderExtra(String name)9913     public IBinder getIBinderExtra(String name) {
9914         return mExtras == null ? null : mExtras.getIBinder(name);
9915     }
9916 
9917     /**
9918      * Retrieve extended data from the intent.
9919      *
9920      * @param name The name of the desired item.
9921      * @param defaultValue The default value to return in case no item is
9922      * associated with the key 'name'
9923      *
9924      * @return the value of an item previously added with putExtra(),
9925      * or defaultValue if none was found.
9926      *
9927      * @see #putExtra
9928      *
9929      * @deprecated
9930      * @hide
9931      */
9932     @Deprecated
9933     @UnsupportedAppUsage
getExtra(String name, Object defaultValue)9934     public Object getExtra(String name, Object defaultValue) {
9935         Object result = defaultValue;
9936         if (mExtras != null) {
9937             Object result2 = mExtras.get(name);
9938             if (result2 != null) {
9939                 result = result2;
9940             }
9941         }
9942 
9943         return result;
9944     }
9945 
9946     /**
9947      * Retrieves a map of extended data from the intent.
9948      *
9949      * @return the map of all extras previously added with putExtra(),
9950      * or null if none have been added.
9951      */
getExtras()9952     public @Nullable Bundle getExtras() {
9953         return (mExtras != null)
9954                 ? new Bundle(mExtras)
9955                 : null;
9956     }
9957 
9958     /**
9959      * Returns the total size of the extras in bytes, or 0 if no extras are present.
9960      * @hide
9961      */
getExtrasTotalSize()9962     public int getExtrasTotalSize() {
9963         return (mExtras != null)
9964                 ? mExtras.getSize()
9965                 : 0;
9966     }
9967 
9968     /**
9969      * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
9970      * return itself as-is.
9971      * @hide
9972      */
canStripForHistory()9973     public boolean canStripForHistory() {
9974         return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
9975     }
9976 
9977     /**
9978      * Call it when the system needs to keep an intent for logging purposes to remove fields
9979      * that are not needed for logging.
9980      * @hide
9981      */
maybeStripForHistory()9982     public Intent maybeStripForHistory() {
9983         // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
9984 
9985         if (!canStripForHistory()) {
9986             return this;
9987         }
9988         return new Intent(this, COPY_MODE_HISTORY);
9989     }
9990 
9991     /**
9992      * Retrieve any special flags associated with this intent.  You will
9993      * normally just set them with {@link #setFlags} and let the system
9994      * take the appropriate action with them.
9995      *
9996      * @return The currently set flags.
9997      * @see #setFlags
9998      * @see #addFlags
9999      * @see #removeFlags
10000      */
getFlags()10001     public @Flags int getFlags() {
10002         return mFlags;
10003     }
10004 
10005     /**
10006      * Retrieve any extended flags associated with this intent.  You will
10007      * normally just set them with {@link #setExtendedFlags} and let the system
10008      * take the appropriate action with them.
10009      *
10010      * @return The currently set extended flags.
10011      * @see #addExtendedFlags
10012      * @see #removeExtendedFlags
10013      *
10014      * @hide
10015      */
10016     @TestApi
getExtendedFlags()10017     public @ExtendedFlags int getExtendedFlags() {
10018         return mExtendedFlags;
10019     }
10020 
10021     /** @hide */
10022     @UnsupportedAppUsage
isExcludingStopped()10023     public boolean isExcludingStopped() {
10024         return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
10025                 == FLAG_EXCLUDE_STOPPED_PACKAGES;
10026     }
10027 
10028     /**
10029      * Retrieve the application package name this Intent is limited to.  When
10030      * resolving an Intent, if non-null this limits the resolution to only
10031      * components in the given application package.
10032      *
10033      * @return The name of the application package for the Intent.
10034      *
10035      * @see #resolveActivity
10036      * @see #setPackage
10037      */
getPackage()10038     public @Nullable String getPackage() {
10039         return mPackage;
10040     }
10041 
10042     /**
10043      * Retrieve the concrete component associated with the intent.  When receiving
10044      * an intent, this is the component that was found to best handle it (that is,
10045      * yourself) and will always be non-null; in all other cases it will be
10046      * null unless explicitly set.
10047      *
10048      * @return The name of the application component to handle the intent.
10049      *
10050      * @see #resolveActivity
10051      * @see #setComponent
10052      */
getComponent()10053     public @Nullable ComponentName getComponent() {
10054         return mComponent;
10055     }
10056 
10057     /**
10058      * Get the bounds of the sender of this intent, in screen coordinates.  This can be
10059      * used as a hint to the receiver for animations and the like.  Null means that there
10060      * is no source bounds.
10061      */
getSourceBounds()10062     public @Nullable Rect getSourceBounds() {
10063         return mSourceBounds;
10064     }
10065 
10066     /**
10067      * Return the Activity component that should be used to handle this intent.
10068      * The appropriate component is determined based on the information in the
10069      * intent, evaluated as follows:
10070      *
10071      * <p>If {@link #getComponent} returns an explicit class, that is returned
10072      * without any further consideration.
10073      *
10074      * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
10075      * category to be considered.
10076      *
10077      * <p>If {@link #getAction} is non-NULL, the activity must handle this
10078      * action.
10079      *
10080      * <p>If {@link #resolveType} returns non-NULL, the activity must handle
10081      * this type.
10082      *
10083      * <p>If {@link #addCategory} has added any categories, the activity must
10084      * handle ALL of the categories specified.
10085      *
10086      * <p>If {@link #getPackage} is non-NULL, only activity components in
10087      * that application package will be considered.
10088      *
10089      * <p>If there are no activities that satisfy all of these conditions, a
10090      * null string is returned.
10091      *
10092      * <p>If multiple activities are found to satisfy the intent, the one with
10093      * the highest priority will be used.  If there are multiple activities
10094      * with the same priority, the system will either pick the best activity
10095      * based on user preference, or resolve to a system class that will allow
10096      * the user to pick an activity and forward from there.
10097      *
10098      * <p>This method is implemented simply by calling
10099      * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
10100      * true.</p>
10101      * <p> This API is called for you as part of starting an activity from an
10102      * intent.  You do not normally need to call it yourself.</p>
10103      *
10104      * @param pm The package manager with which to resolve the Intent.
10105      *
10106      * @return Name of the component implementing an activity that can
10107      *         display the intent.
10108      *
10109      * @see #setComponent
10110      * @see #getComponent
10111      * @see #resolveActivityInfo
10112      */
resolveActivity(@onNull PackageManager pm)10113     public ComponentName resolveActivity(@NonNull PackageManager pm) {
10114         if (mComponent != null) {
10115             return mComponent;
10116         }
10117 
10118         ResolveInfo info = pm.resolveActivity(
10119             this, PackageManager.MATCH_DEFAULT_ONLY);
10120         if (info != null) {
10121             return new ComponentName(
10122                     info.activityInfo.applicationInfo.packageName,
10123                     info.activityInfo.name);
10124         }
10125 
10126         return null;
10127     }
10128 
10129     /**
10130      * Resolve the Intent into an {@link ActivityInfo}
10131      * describing the activity that should execute the intent.  Resolution
10132      * follows the same rules as described for {@link #resolveActivity}, but
10133      * you get back the completely information about the resolved activity
10134      * instead of just its class name.
10135      *
10136      * @param pm The package manager with which to resolve the Intent.
10137      * @param flags Addition information to retrieve as per
10138      * {@link PackageManager#getActivityInfo(ComponentName, int)
10139      * PackageManager.getActivityInfo()}.
10140      *
10141      * @return PackageManager.ActivityInfo
10142      *
10143      * @see #resolveActivity
10144      */
resolveActivityInfo(@onNull PackageManager pm, @PackageManager.ComponentInfoFlagsBits int flags)10145     public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
10146             @PackageManager.ComponentInfoFlagsBits int flags) {
10147         ActivityInfo ai = null;
10148         if (mComponent != null) {
10149             try {
10150                 ai = pm.getActivityInfo(mComponent, flags);
10151             } catch (PackageManager.NameNotFoundException e) {
10152                 // ignore
10153             }
10154         } else {
10155             ResolveInfo info = pm.resolveActivity(
10156                 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
10157             if (info != null) {
10158                 ai = info.activityInfo;
10159             }
10160         }
10161 
10162         return ai;
10163     }
10164 
10165     /**
10166      * Special function for use by the system to resolve service
10167      * intents to system apps.  Throws an exception if there are
10168      * multiple potential matches to the Intent.  Returns null if
10169      * there are no matches.
10170      * @hide
10171      */
10172     @UnsupportedAppUsage
resolveSystemService(@onNull PackageManager pm, @PackageManager.ComponentInfoFlagsBits int flags)10173     public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
10174             @PackageManager.ComponentInfoFlagsBits int flags) {
10175         if (mComponent != null) {
10176             return mComponent;
10177         }
10178 
10179         List<ResolveInfo> results = pm.queryIntentServices(this, flags);
10180         if (results == null) {
10181             return null;
10182         }
10183         ComponentName comp = null;
10184         for (int i=0; i<results.size(); i++) {
10185             ResolveInfo ri = results.get(i);
10186             if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
10187                 continue;
10188             }
10189             ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
10190                     ri.serviceInfo.name);
10191             if (comp != null) {
10192                 throw new IllegalStateException("Multiple system services handle " + this
10193                         + ": " + comp + ", " + foundComp);
10194             }
10195             comp = foundComp;
10196         }
10197         return comp;
10198     }
10199 
10200     /**
10201      * Set the general action to be performed.
10202      *
10203      * @param action An action name, such as ACTION_VIEW.  Application-specific
10204      *               actions should be prefixed with the vendor's package name.
10205      *
10206      * @return Returns the same Intent object, for chaining multiple calls
10207      * into a single statement.
10208      *
10209      * @see #getAction
10210      */
setAction(@ullable String action)10211     public @NonNull Intent setAction(@Nullable String action) {
10212         mAction = action != null ? action.intern() : null;
10213         return this;
10214     }
10215 
10216     /**
10217      * Set the data this intent is operating on.  This method automatically
10218      * clears any type that was previously set by {@link #setType} or
10219      * {@link #setTypeAndNormalize}.
10220      *
10221      * <p><em>Note: scheme matching in the Android framework is
10222      * case-sensitive, unlike the formal RFC. As a result,
10223      * you should always write your Uri with a lower case scheme,
10224      * or use {@link Uri#normalizeScheme} or
10225      * {@link #setDataAndNormalize}
10226      * to ensure that the scheme is converted to lower case.</em>
10227      *
10228      * @param data The Uri of the data this intent is now targeting.
10229      *
10230      * @return Returns the same Intent object, for chaining multiple calls
10231      * into a single statement.
10232      *
10233      * @see #getData
10234      * @see #setDataAndNormalize
10235      * @see android.net.Uri#normalizeScheme()
10236      */
setData(@ullable Uri data)10237     public @NonNull Intent setData(@Nullable Uri data) {
10238         mData = data;
10239         mType = null;
10240         return this;
10241     }
10242 
10243     /**
10244      * Normalize and set the data this intent is operating on.
10245      *
10246      * <p>This method automatically clears any type that was
10247      * previously set (for example, by {@link #setType}).
10248      *
10249      * <p>The data Uri is normalized using
10250      * {@link android.net.Uri#normalizeScheme} before it is set,
10251      * so really this is just a convenience method for
10252      * <pre>
10253      * setData(data.normalize())
10254      * </pre>
10255      *
10256      * @param data The Uri of the data this intent is now targeting.
10257      *
10258      * @return Returns the same Intent object, for chaining multiple calls
10259      * into a single statement.
10260      *
10261      * @see #getData
10262      * @see #setType
10263      * @see android.net.Uri#normalizeScheme
10264      */
setDataAndNormalize(@onNull Uri data)10265     public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
10266         return setData(data.normalizeScheme());
10267     }
10268 
10269     /**
10270      * Set an explicit MIME data type.
10271      *
10272      * <p>This is used to create intents that only specify a type and not data,
10273      * for example to indicate the type of data to return.
10274      *
10275      * <p>This method automatically clears any data that was
10276      * previously set (for example by {@link #setData}).
10277      *
10278      * <p><em>Note: MIME type matching in the Android framework is
10279      * case-sensitive, unlike formal RFC MIME types.  As a result,
10280      * you should always write your MIME types with lower case letters,
10281      * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
10282      * to ensure that it is converted to lower case.</em>
10283      *
10284      * @param type The MIME type of the data being handled by this intent.
10285      *
10286      * @return Returns the same Intent object, for chaining multiple calls
10287      * into a single statement.
10288      *
10289      * @see #getType
10290      * @see #setTypeAndNormalize
10291      * @see #setDataAndType
10292      * @see #normalizeMimeType
10293      */
setType(@ullable String type)10294     public @NonNull Intent setType(@Nullable String type) {
10295         mData = null;
10296         mType = type;
10297         return this;
10298     }
10299 
10300     /**
10301      * Normalize and set an explicit MIME data type.
10302      *
10303      * <p>This is used to create intents that only specify a type and not data,
10304      * for example to indicate the type of data to return.
10305      *
10306      * <p>This method automatically clears any data that was
10307      * previously set (for example by {@link #setData}).
10308      *
10309      * <p>The MIME type is normalized using
10310      * {@link #normalizeMimeType} before it is set,
10311      * so really this is just a convenience method for
10312      * <pre>
10313      * setType(Intent.normalizeMimeType(type))
10314      * </pre>
10315      *
10316      * @param type The MIME type of the data being handled by this intent.
10317      *
10318      * @return Returns the same Intent object, for chaining multiple calls
10319      * into a single statement.
10320      *
10321      * @see #getType
10322      * @see #setData
10323      * @see #normalizeMimeType
10324      */
setTypeAndNormalize(@ullable String type)10325     public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
10326         return setType(normalizeMimeType(type));
10327     }
10328 
10329     /**
10330      * (Usually optional) Set the data for the intent along with an explicit
10331      * MIME data type.  This method should very rarely be used -- it allows you
10332      * to override the MIME type that would ordinarily be inferred from the
10333      * data with your own type given here.
10334      *
10335      * <p><em>Note: MIME type and Uri scheme matching in the
10336      * Android framework is case-sensitive, unlike the formal RFC definitions.
10337      * As a result, you should always write these elements with lower case letters,
10338      * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
10339      * {@link #setDataAndTypeAndNormalize}
10340      * to ensure that they are converted to lower case.</em>
10341      *
10342      * @param data The Uri of the data this intent is now targeting.
10343      * @param type The MIME type of the data being handled by this intent.
10344      *
10345      * @return Returns the same Intent object, for chaining multiple calls
10346      * into a single statement.
10347      *
10348      * @see #setType
10349      * @see #setData
10350      * @see #normalizeMimeType
10351      * @see android.net.Uri#normalizeScheme
10352      * @see #setDataAndTypeAndNormalize
10353      */
setDataAndType(@ullable Uri data, @Nullable String type)10354     public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
10355         mData = data;
10356         mType = type;
10357         return this;
10358     }
10359 
10360     /**
10361      * (Usually optional) Normalize and set both the data Uri and an explicit
10362      * MIME data type.  This method should very rarely be used -- it allows you
10363      * to override the MIME type that would ordinarily be inferred from the
10364      * data with your own type given here.
10365      *
10366      * <p>The data Uri and the MIME type are normalize using
10367      * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
10368      * before they are set, so really this is just a convenience method for
10369      * <pre>
10370      * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
10371      * </pre>
10372      *
10373      * @param data The Uri of the data this intent is now targeting.
10374      * @param type The MIME type of the data being handled by this intent.
10375      *
10376      * @return Returns the same Intent object, for chaining multiple calls
10377      * into a single statement.
10378      *
10379      * @see #setType
10380      * @see #setData
10381      * @see #setDataAndType
10382      * @see #normalizeMimeType
10383      * @see android.net.Uri#normalizeScheme
10384      */
setDataAndTypeAndNormalize(@onNull Uri data, @Nullable String type)10385     public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
10386         return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
10387     }
10388 
10389     /**
10390      * Set an identifier for this Intent.  If set, this provides a unique identity for this Intent,
10391      * allowing it to be unique from other Intents that would otherwise look the same.  In
10392      * particular, this will be used by {@link #filterEquals(Intent)} to determine if two
10393      * Intents are the same as with other fields like {@link #setAction}.  However, unlike those
10394      * fields, the identifier is <em>never</em> used for matching against an {@link IntentFilter};
10395      * it is as if the identifier has not been set on the Intent.
10396      *
10397      * <p>This can be used, for example, to make this Intent unique from other Intents that
10398      * are otherwise the same, for use in creating a {@link android.app.PendingIntent}.  (Be aware
10399      * however that the receiver of the PendingIntent will see whatever you put in here.)  The
10400      * structure of this string is completely undefined by the platform, however if you are going
10401      * to be exposing identifier strings across different applications you may need to define
10402      * your own structure if there is no central party defining the contents of this field.</p>
10403      *
10404      * @param identifier The identifier for this Intent.  The contents of the string have no
10405      *                   meaning to the system, except whether they are exactly the same as
10406      *                   another identifier.
10407      *
10408      * @return Returns the same Intent object, for chaining multiple calls
10409      * into a single statement.
10410      *
10411      * @see #getIdentifier
10412      */
setIdentifier(@ullable String identifier)10413     public @NonNull Intent setIdentifier(@Nullable String identifier) {
10414         mIdentifier = identifier;
10415         return this;
10416     }
10417 
10418     /**
10419      * Add a new category to the intent.  Categories provide additional detail
10420      * about the action the intent performs.  When resolving an intent, only
10421      * activities that provide <em>all</em> of the requested categories will be
10422      * used.
10423      *
10424      * @param category The desired category.  This can be either one of the
10425      *               predefined Intent categories, or a custom category in your own
10426      *               namespace.
10427      *
10428      * @return Returns the same Intent object, for chaining multiple calls
10429      * into a single statement.
10430      *
10431      * @see #hasCategory
10432      * @see #removeCategory
10433      */
addCategory(String category)10434     public @NonNull Intent addCategory(String category) {
10435         if (mCategories == null) {
10436             mCategories = new ArraySet<String>();
10437         }
10438         mCategories.add(category.intern());
10439         return this;
10440     }
10441 
10442     /**
10443      * Remove a category from an intent.
10444      *
10445      * @param category The category to remove.
10446      *
10447      * @see #addCategory
10448      */
removeCategory(String category)10449     public void removeCategory(String category) {
10450         if (mCategories != null) {
10451             mCategories.remove(category);
10452             if (mCategories.size() == 0) {
10453                 mCategories = null;
10454             }
10455         }
10456     }
10457 
10458     /**
10459      * Set a selector for this Intent.  This is a modification to the kinds of
10460      * things the Intent will match.  If the selector is set, it will be used
10461      * when trying to find entities that can handle the Intent, instead of the
10462      * main contents of the Intent.  This allows you build an Intent containing
10463      * a generic protocol while targeting it more specifically.
10464      *
10465      * <p>An example of where this may be used is with things like
10466      * {@link #CATEGORY_APP_BROWSER}.  This category allows you to build an
10467      * Intent that will launch the Browser application.  However, the correct
10468      * main entry point of an application is actually {@link #ACTION_MAIN}
10469      * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
10470      * used to specify the actual Activity to launch.  If you launch the browser
10471      * with something different, undesired behavior may happen if the user has
10472      * previously or later launches it the normal way, since they do not match.
10473      * Instead, you can build an Intent with the MAIN action (but no ComponentName
10474      * yet specified) and set a selector with {@link #ACTION_MAIN} and
10475      * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
10476      *
10477      * <p>Setting a selector does not impact the behavior of
10478      * {@link #filterEquals(Intent)} and {@link #filterHashCode()}.  This is part of the
10479      * desired behavior of a selector -- it does not impact the base meaning
10480      * of the Intent, just what kinds of things will be matched against it
10481      * when determining who can handle it.</p>
10482      *
10483      * <p>You can not use both a selector and {@link #setPackage(String)} on
10484      * the same base Intent.</p>
10485      *
10486      * @param selector The desired selector Intent; set to null to not use
10487      * a special selector.
10488      */
setSelector(@ullable Intent selector)10489     public void setSelector(@Nullable Intent selector) {
10490         if (selector == this) {
10491             throw new IllegalArgumentException(
10492                     "Intent being set as a selector of itself");
10493         }
10494         if (selector != null && mPackage != null) {
10495             throw new IllegalArgumentException(
10496                     "Can't set selector when package name is already set");
10497         }
10498         mSelector = selector;
10499     }
10500 
10501     /**
10502      * Set a {@link ClipData} associated with this Intent.  This replaces any
10503      * previously set ClipData.
10504      *
10505      * <p>The ClipData in an intent is not used for Intent matching or other
10506      * such operations.  Semantically it is like extras, used to transmit
10507      * additional data with the Intent.  The main feature of using this over
10508      * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
10509      * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
10510      * items included in the clip data.  This is useful, in particular, if
10511      * you want to transmit an Intent containing multiple <code>content:</code>
10512      * URIs for which the recipient may not have global permission to access the
10513      * content provider.
10514      *
10515      * <p>If the ClipData contains items that are themselves Intents, any
10516      * grant flags in those Intents will be ignored.  Only the top-level flags
10517      * of the main Intent are respected, and will be applied to all Uri or
10518      * Intent items in the clip (or sub-items of the clip).
10519      *
10520      * <p>The MIME type, label, and icon in the ClipData object are not
10521      * directly used by Intent.  Applications should generally rely on the
10522      * MIME type of the Intent itself, not what it may find in the ClipData.
10523      * A common practice is to construct a ClipData for use with an Intent
10524      * with a MIME type of "*&#47;*".
10525      *
10526      * @param clip The new clip to set.  May be null to clear the current clip.
10527      */
setClipData(@ullable ClipData clip)10528     public void setClipData(@Nullable ClipData clip) {
10529         mClipData = clip;
10530     }
10531 
10532     /**
10533      * This is NOT a secure mechanism to identify the user who sent the intent.
10534      * When the intent is sent to a different user, it is used to fix uris by adding the user ID
10535      * who sent the intent.
10536      * @hide
10537      */
prepareToLeaveUser(int userId)10538     public void prepareToLeaveUser(int userId) {
10539         // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
10540         // We want mContentUserHint to refer to the original user, so don't do anything.
10541         if (mContentUserHint == UserHandle.USER_CURRENT) {
10542             mContentUserHint = userId;
10543         }
10544     }
10545 
10546     /**
10547      * Add extended data to the intent.  The name must include a package
10548      * prefix, for example the app com.android.contacts would use names
10549      * like "com.android.contacts.ShowAll".
10550      *
10551      * @param name The name of the extra data, with package prefix.
10552      * @param value The boolean data value.
10553      *
10554      * @return Returns the same Intent object, for chaining multiple calls
10555      * into a single statement.
10556      *
10557      * @see #putExtras
10558      * @see #removeExtra
10559      * @see #getBooleanExtra(String, boolean)
10560      */
putExtra(String name, boolean value)10561     public @NonNull Intent putExtra(String name, boolean value) {
10562         if (mExtras == null) {
10563             mExtras = new Bundle();
10564         }
10565         mExtras.putBoolean(name, value);
10566         return this;
10567     }
10568 
10569     /**
10570      * Add extended data to the intent.  The name must include a package
10571      * prefix, for example the app com.android.contacts would use names
10572      * like "com.android.contacts.ShowAll".
10573      *
10574      * @param name The name of the extra data, with package prefix.
10575      * @param value The byte data value.
10576      *
10577      * @return Returns the same Intent object, for chaining multiple calls
10578      * into a single statement.
10579      *
10580      * @see #putExtras
10581      * @see #removeExtra
10582      * @see #getByteExtra(String, byte)
10583      */
putExtra(String name, byte value)10584     public @NonNull Intent putExtra(String name, byte value) {
10585         if (mExtras == null) {
10586             mExtras = new Bundle();
10587         }
10588         mExtras.putByte(name, value);
10589         return this;
10590     }
10591 
10592     /**
10593      * Add extended data to the intent.  The name must include a package
10594      * prefix, for example the app com.android.contacts would use names
10595      * like "com.android.contacts.ShowAll".
10596      *
10597      * @param name The name of the extra data, with package prefix.
10598      * @param value The char data value.
10599      *
10600      * @return Returns the same Intent object, for chaining multiple calls
10601      * into a single statement.
10602      *
10603      * @see #putExtras
10604      * @see #removeExtra
10605      * @see #getCharExtra(String, char)
10606      */
putExtra(String name, char value)10607     public @NonNull Intent putExtra(String name, char value) {
10608         if (mExtras == null) {
10609             mExtras = new Bundle();
10610         }
10611         mExtras.putChar(name, value);
10612         return this;
10613     }
10614 
10615     /**
10616      * Add extended data to the intent.  The name must include a package
10617      * prefix, for example the app com.android.contacts would use names
10618      * like "com.android.contacts.ShowAll".
10619      *
10620      * @param name The name of the extra data, with package prefix.
10621      * @param value The short data value.
10622      *
10623      * @return Returns the same Intent object, for chaining multiple calls
10624      * into a single statement.
10625      *
10626      * @see #putExtras
10627      * @see #removeExtra
10628      * @see #getShortExtra(String, short)
10629      */
putExtra(String name, short value)10630     public @NonNull Intent putExtra(String name, short value) {
10631         if (mExtras == null) {
10632             mExtras = new Bundle();
10633         }
10634         mExtras.putShort(name, value);
10635         return this;
10636     }
10637 
10638     /**
10639      * Add extended data to the intent.  The name must include a package
10640      * prefix, for example the app com.android.contacts would use names
10641      * like "com.android.contacts.ShowAll".
10642      *
10643      * @param name The name of the extra data, with package prefix.
10644      * @param value The integer data value.
10645      *
10646      * @return Returns the same Intent object, for chaining multiple calls
10647      * into a single statement.
10648      *
10649      * @see #putExtras
10650      * @see #removeExtra
10651      * @see #getIntExtra(String, int)
10652      */
putExtra(String name, int value)10653     public @NonNull Intent putExtra(String name, int value) {
10654         if (mExtras == null) {
10655             mExtras = new Bundle();
10656         }
10657         mExtras.putInt(name, value);
10658         return this;
10659     }
10660 
10661     /**
10662      * Add extended data to the intent.  The name must include a package
10663      * prefix, for example the app com.android.contacts would use names
10664      * like "com.android.contacts.ShowAll".
10665      *
10666      * @param name The name of the extra data, with package prefix.
10667      * @param value The long data value.
10668      *
10669      * @return Returns the same Intent object, for chaining multiple calls
10670      * into a single statement.
10671      *
10672      * @see #putExtras
10673      * @see #removeExtra
10674      * @see #getLongExtra(String, long)
10675      */
putExtra(String name, long value)10676     public @NonNull Intent putExtra(String name, long value) {
10677         if (mExtras == null) {
10678             mExtras = new Bundle();
10679         }
10680         mExtras.putLong(name, value);
10681         return this;
10682     }
10683 
10684     /**
10685      * Add extended data to the intent.  The name must include a package
10686      * prefix, for example the app com.android.contacts would use names
10687      * like "com.android.contacts.ShowAll".
10688      *
10689      * @param name The name of the extra data, with package prefix.
10690      * @param value The float data value.
10691      *
10692      * @return Returns the same Intent object, for chaining multiple calls
10693      * into a single statement.
10694      *
10695      * @see #putExtras
10696      * @see #removeExtra
10697      * @see #getFloatExtra(String, float)
10698      */
putExtra(String name, float value)10699     public @NonNull Intent putExtra(String name, float value) {
10700         if (mExtras == null) {
10701             mExtras = new Bundle();
10702         }
10703         mExtras.putFloat(name, value);
10704         return this;
10705     }
10706 
10707     /**
10708      * Add extended data to the intent.  The name must include a package
10709      * prefix, for example the app com.android.contacts would use names
10710      * like "com.android.contacts.ShowAll".
10711      *
10712      * @param name The name of the extra data, with package prefix.
10713      * @param value The double data value.
10714      *
10715      * @return Returns the same Intent object, for chaining multiple calls
10716      * into a single statement.
10717      *
10718      * @see #putExtras
10719      * @see #removeExtra
10720      * @see #getDoubleExtra(String, double)
10721      */
putExtra(String name, double value)10722     public @NonNull Intent putExtra(String name, double value) {
10723         if (mExtras == null) {
10724             mExtras = new Bundle();
10725         }
10726         mExtras.putDouble(name, value);
10727         return this;
10728     }
10729 
10730     /**
10731      * Add extended data to the intent.  The name must include a package
10732      * prefix, for example the app com.android.contacts would use names
10733      * like "com.android.contacts.ShowAll".
10734      *
10735      * @param name The name of the extra data, with package prefix.
10736      * @param value The String data value.
10737      *
10738      * @return Returns the same Intent object, for chaining multiple calls
10739      * into a single statement.
10740      *
10741      * @see #putExtras
10742      * @see #removeExtra
10743      * @see #getStringExtra(String)
10744      */
putExtra(String name, @Nullable String value)10745     public @NonNull Intent putExtra(String name, @Nullable String value) {
10746         if (mExtras == null) {
10747             mExtras = new Bundle();
10748         }
10749         mExtras.putString(name, value);
10750         return this;
10751     }
10752 
10753     /**
10754      * Add extended data to the intent.  The name must include a package
10755      * prefix, for example the app com.android.contacts would use names
10756      * like "com.android.contacts.ShowAll".
10757      *
10758      * @param name The name of the extra data, with package prefix.
10759      * @param value The CharSequence data value.
10760      *
10761      * @return Returns the same Intent object, for chaining multiple calls
10762      * into a single statement.
10763      *
10764      * @see #putExtras
10765      * @see #removeExtra
10766      * @see #getCharSequenceExtra(String)
10767      */
putExtra(String name, @Nullable CharSequence value)10768     public @NonNull Intent putExtra(String name, @Nullable CharSequence value) {
10769         if (mExtras == null) {
10770             mExtras = new Bundle();
10771         }
10772         mExtras.putCharSequence(name, value);
10773         return this;
10774     }
10775 
10776     /**
10777      * Add extended data to the intent.  The name must include a package
10778      * prefix, for example the app com.android.contacts would use names
10779      * like "com.android.contacts.ShowAll".
10780      *
10781      * @param name The name of the extra data, with package prefix.
10782      * @param value The Parcelable data value.
10783      *
10784      * @return Returns the same Intent object, for chaining multiple calls
10785      * into a single statement.
10786      *
10787      * @see #putExtras
10788      * @see #removeExtra
10789      * @see #getParcelableExtra(String)
10790      */
putExtra(String name, @Nullable Parcelable value)10791     public @NonNull Intent putExtra(String name, @Nullable Parcelable value) {
10792         if (mExtras == null) {
10793             mExtras = new Bundle();
10794         }
10795         mExtras.putParcelable(name, value);
10796         return this;
10797     }
10798 
10799     /**
10800      * Add extended data to the intent.  The name must include a package
10801      * prefix, for example the app com.android.contacts would use names
10802      * like "com.android.contacts.ShowAll".
10803      *
10804      * @param name The name of the extra data, with package prefix.
10805      * @param value The Parcelable[] data value.
10806      *
10807      * @return Returns the same Intent object, for chaining multiple calls
10808      * into a single statement.
10809      *
10810      * @see #putExtras
10811      * @see #removeExtra
10812      * @see #getParcelableArrayExtra(String)
10813      */
putExtra(String name, @Nullable Parcelable[] value)10814     public @NonNull Intent putExtra(String name, @Nullable Parcelable[] value) {
10815         if (mExtras == null) {
10816             mExtras = new Bundle();
10817         }
10818         mExtras.putParcelableArray(name, value);
10819         return this;
10820     }
10821 
10822     /**
10823      * Add extended data to the intent.  The name must include a package
10824      * prefix, for example the app com.android.contacts would use names
10825      * like "com.android.contacts.ShowAll".
10826      *
10827      * @param name The name of the extra data, with package prefix.
10828      * @param value The ArrayList<Parcelable> data value.
10829      *
10830      * @return Returns the same Intent object, for chaining multiple calls
10831      * into a single statement.
10832      *
10833      * @see #putExtras
10834      * @see #removeExtra
10835      * @see #getParcelableArrayListExtra(String)
10836      */
putParcelableArrayListExtra(String name, @Nullable ArrayList<? extends Parcelable> value)10837     public @NonNull Intent putParcelableArrayListExtra(String name,
10838             @Nullable ArrayList<? extends Parcelable> value) {
10839         if (mExtras == null) {
10840             mExtras = new Bundle();
10841         }
10842         mExtras.putParcelableArrayList(name, value);
10843         return this;
10844     }
10845 
10846     /**
10847      * Add extended data to the intent.  The name must include a package
10848      * prefix, for example the app com.android.contacts would use names
10849      * like "com.android.contacts.ShowAll".
10850      *
10851      * @param name The name of the extra data, with package prefix.
10852      * @param value The ArrayList<Integer> data value.
10853      *
10854      * @return Returns the same Intent object, for chaining multiple calls
10855      * into a single statement.
10856      *
10857      * @see #putExtras
10858      * @see #removeExtra
10859      * @see #getIntegerArrayListExtra(String)
10860      */
putIntegerArrayListExtra(String name, @Nullable ArrayList<Integer> value)10861     public @NonNull Intent putIntegerArrayListExtra(String name,
10862             @Nullable ArrayList<Integer> value) {
10863         if (mExtras == null) {
10864             mExtras = new Bundle();
10865         }
10866         mExtras.putIntegerArrayList(name, value);
10867         return this;
10868     }
10869 
10870     /**
10871      * Add extended data to the intent.  The name must include a package
10872      * prefix, for example the app com.android.contacts would use names
10873      * like "com.android.contacts.ShowAll".
10874      *
10875      * @param name The name of the extra data, with package prefix.
10876      * @param value The ArrayList<String> data value.
10877      *
10878      * @return Returns the same Intent object, for chaining multiple calls
10879      * into a single statement.
10880      *
10881      * @see #putExtras
10882      * @see #removeExtra
10883      * @see #getStringArrayListExtra(String)
10884      */
putStringArrayListExtra(String name, @Nullable ArrayList<String> value)10885     public @NonNull Intent putStringArrayListExtra(String name, @Nullable ArrayList<String> value) {
10886         if (mExtras == null) {
10887             mExtras = new Bundle();
10888         }
10889         mExtras.putStringArrayList(name, value);
10890         return this;
10891     }
10892 
10893     /**
10894      * Add extended data to the intent.  The name must include a package
10895      * prefix, for example the app com.android.contacts would use names
10896      * like "com.android.contacts.ShowAll".
10897      *
10898      * @param name The name of the extra data, with package prefix.
10899      * @param value The ArrayList<CharSequence> data value.
10900      *
10901      * @return Returns the same Intent object, for chaining multiple calls
10902      * into a single statement.
10903      *
10904      * @see #putExtras
10905      * @see #removeExtra
10906      * @see #getCharSequenceArrayListExtra(String)
10907      */
putCharSequenceArrayListExtra(String name, @Nullable ArrayList<CharSequence> value)10908     public @NonNull Intent putCharSequenceArrayListExtra(String name,
10909             @Nullable ArrayList<CharSequence> value) {
10910         if (mExtras == null) {
10911             mExtras = new Bundle();
10912         }
10913         mExtras.putCharSequenceArrayList(name, value);
10914         return this;
10915     }
10916 
10917     /**
10918      * Add extended data to the intent.  The name must include a package
10919      * prefix, for example the app com.android.contacts would use names
10920      * like "com.android.contacts.ShowAll".
10921      *
10922      * @param name The name of the extra data, with package prefix.
10923      * @param value The Serializable data value.
10924      *
10925      * @return Returns the same Intent object, for chaining multiple calls
10926      * into a single statement.
10927      *
10928      * @see #putExtras
10929      * @see #removeExtra
10930      * @see #getSerializableExtra(String)
10931      */
putExtra(String name, @Nullable Serializable value)10932     public @NonNull Intent putExtra(String name, @Nullable Serializable value) {
10933         if (mExtras == null) {
10934             mExtras = new Bundle();
10935         }
10936         mExtras.putSerializable(name, value);
10937         return this;
10938     }
10939 
10940     /**
10941      * Add extended data to the intent.  The name must include a package
10942      * prefix, for example the app com.android.contacts would use names
10943      * like "com.android.contacts.ShowAll".
10944      *
10945      * @param name The name of the extra data, with package prefix.
10946      * @param value The boolean array data value.
10947      *
10948      * @return Returns the same Intent object, for chaining multiple calls
10949      * into a single statement.
10950      *
10951      * @see #putExtras
10952      * @see #removeExtra
10953      * @see #getBooleanArrayExtra(String)
10954      */
putExtra(String name, @Nullable boolean[] value)10955     public @NonNull Intent putExtra(String name, @Nullable boolean[] value) {
10956         if (mExtras == null) {
10957             mExtras = new Bundle();
10958         }
10959         mExtras.putBooleanArray(name, value);
10960         return this;
10961     }
10962 
10963     /**
10964      * Add extended data to the intent.  The name must include a package
10965      * prefix, for example the app com.android.contacts would use names
10966      * like "com.android.contacts.ShowAll".
10967      *
10968      * @param name The name of the extra data, with package prefix.
10969      * @param value The byte array data value.
10970      *
10971      * @return Returns the same Intent object, for chaining multiple calls
10972      * into a single statement.
10973      *
10974      * @see #putExtras
10975      * @see #removeExtra
10976      * @see #getByteArrayExtra(String)
10977      */
putExtra(String name, @Nullable byte[] value)10978     public @NonNull Intent putExtra(String name, @Nullable byte[] value) {
10979         if (mExtras == null) {
10980             mExtras = new Bundle();
10981         }
10982         mExtras.putByteArray(name, value);
10983         return this;
10984     }
10985 
10986     /**
10987      * Add extended data to the intent.  The name must include a package
10988      * prefix, for example the app com.android.contacts would use names
10989      * like "com.android.contacts.ShowAll".
10990      *
10991      * @param name The name of the extra data, with package prefix.
10992      * @param value The short array data value.
10993      *
10994      * @return Returns the same Intent object, for chaining multiple calls
10995      * into a single statement.
10996      *
10997      * @see #putExtras
10998      * @see #removeExtra
10999      * @see #getShortArrayExtra(String)
11000      */
putExtra(String name, @Nullable short[] value)11001     public @NonNull Intent putExtra(String name, @Nullable short[] value) {
11002         if (mExtras == null) {
11003             mExtras = new Bundle();
11004         }
11005         mExtras.putShortArray(name, value);
11006         return this;
11007     }
11008 
11009     /**
11010      * Add extended data to the intent.  The name must include a package
11011      * prefix, for example the app com.android.contacts would use names
11012      * like "com.android.contacts.ShowAll".
11013      *
11014      * @param name The name of the extra data, with package prefix.
11015      * @param value The char array data value.
11016      *
11017      * @return Returns the same Intent object, for chaining multiple calls
11018      * into a single statement.
11019      *
11020      * @see #putExtras
11021      * @see #removeExtra
11022      * @see #getCharArrayExtra(String)
11023      */
putExtra(String name, @Nullable char[] value)11024     public @NonNull Intent putExtra(String name, @Nullable char[] value) {
11025         if (mExtras == null) {
11026             mExtras = new Bundle();
11027         }
11028         mExtras.putCharArray(name, value);
11029         return this;
11030     }
11031 
11032     /**
11033      * Add extended data to the intent.  The name must include a package
11034      * prefix, for example the app com.android.contacts would use names
11035      * like "com.android.contacts.ShowAll".
11036      *
11037      * @param name The name of the extra data, with package prefix.
11038      * @param value The int array data value.
11039      *
11040      * @return Returns the same Intent object, for chaining multiple calls
11041      * into a single statement.
11042      *
11043      * @see #putExtras
11044      * @see #removeExtra
11045      * @see #getIntArrayExtra(String)
11046      */
putExtra(String name, @Nullable int[] value)11047     public @NonNull Intent putExtra(String name, @Nullable int[] value) {
11048         if (mExtras == null) {
11049             mExtras = new Bundle();
11050         }
11051         mExtras.putIntArray(name, value);
11052         return this;
11053     }
11054 
11055     /**
11056      * Add extended data to the intent.  The name must include a package
11057      * prefix, for example the app com.android.contacts would use names
11058      * like "com.android.contacts.ShowAll".
11059      *
11060      * @param name The name of the extra data, with package prefix.
11061      * @param value The byte array data value.
11062      *
11063      * @return Returns the same Intent object, for chaining multiple calls
11064      * into a single statement.
11065      *
11066      * @see #putExtras
11067      * @see #removeExtra
11068      * @see #getLongArrayExtra(String)
11069      */
putExtra(String name, @Nullable long[] value)11070     public @NonNull Intent putExtra(String name, @Nullable long[] value) {
11071         if (mExtras == null) {
11072             mExtras = new Bundle();
11073         }
11074         mExtras.putLongArray(name, value);
11075         return this;
11076     }
11077 
11078     /**
11079      * Add extended data to the intent.  The name must include a package
11080      * prefix, for example the app com.android.contacts would use names
11081      * like "com.android.contacts.ShowAll".
11082      *
11083      * @param name The name of the extra data, with package prefix.
11084      * @param value The float array data value.
11085      *
11086      * @return Returns the same Intent object, for chaining multiple calls
11087      * into a single statement.
11088      *
11089      * @see #putExtras
11090      * @see #removeExtra
11091      * @see #getFloatArrayExtra(String)
11092      */
putExtra(String name, @Nullable float[] value)11093     public @NonNull Intent putExtra(String name, @Nullable float[] value) {
11094         if (mExtras == null) {
11095             mExtras = new Bundle();
11096         }
11097         mExtras.putFloatArray(name, value);
11098         return this;
11099     }
11100 
11101     /**
11102      * Add extended data to the intent.  The name must include a package
11103      * prefix, for example the app com.android.contacts would use names
11104      * like "com.android.contacts.ShowAll".
11105      *
11106      * @param name The name of the extra data, with package prefix.
11107      * @param value The double array data value.
11108      *
11109      * @return Returns the same Intent object, for chaining multiple calls
11110      * into a single statement.
11111      *
11112      * @see #putExtras
11113      * @see #removeExtra
11114      * @see #getDoubleArrayExtra(String)
11115      */
putExtra(String name, @Nullable double[] value)11116     public @NonNull Intent putExtra(String name, @Nullable double[] value) {
11117         if (mExtras == null) {
11118             mExtras = new Bundle();
11119         }
11120         mExtras.putDoubleArray(name, value);
11121         return this;
11122     }
11123 
11124     /**
11125      * Add extended data to the intent.  The name must include a package
11126      * prefix, for example the app com.android.contacts would use names
11127      * like "com.android.contacts.ShowAll".
11128      *
11129      * @param name The name of the extra data, with package prefix.
11130      * @param value The String array data value.
11131      *
11132      * @return Returns the same Intent object, for chaining multiple calls
11133      * into a single statement.
11134      *
11135      * @see #putExtras
11136      * @see #removeExtra
11137      * @see #getStringArrayExtra(String)
11138      */
putExtra(String name, @Nullable String[] value)11139     public @NonNull Intent putExtra(String name, @Nullable String[] value) {
11140         if (mExtras == null) {
11141             mExtras = new Bundle();
11142         }
11143         mExtras.putStringArray(name, value);
11144         return this;
11145     }
11146 
11147     /**
11148      * Add extended data to the intent.  The name must include a package
11149      * prefix, for example the app com.android.contacts would use names
11150      * like "com.android.contacts.ShowAll".
11151      *
11152      * @param name The name of the extra data, with package prefix.
11153      * @param value The CharSequence array data value.
11154      *
11155      * @return Returns the same Intent object, for chaining multiple calls
11156      * into a single statement.
11157      *
11158      * @see #putExtras
11159      * @see #removeExtra
11160      * @see #getCharSequenceArrayExtra(String)
11161      */
putExtra(String name, @Nullable CharSequence[] value)11162     public @NonNull Intent putExtra(String name, @Nullable CharSequence[] value) {
11163         if (mExtras == null) {
11164             mExtras = new Bundle();
11165         }
11166         mExtras.putCharSequenceArray(name, value);
11167         return this;
11168     }
11169 
11170     /**
11171      * Add extended data to the intent.  The name must include a package
11172      * prefix, for example the app com.android.contacts would use names
11173      * like "com.android.contacts.ShowAll".
11174      *
11175      * @param name The name of the extra data, with package prefix.
11176      * @param value The Bundle data value.
11177      *
11178      * @return Returns the same Intent object, for chaining multiple calls
11179      * into a single statement.
11180      *
11181      * @see #putExtras
11182      * @see #removeExtra
11183      * @see #getBundleExtra(String)
11184      */
putExtra(String name, @Nullable Bundle value)11185     public @NonNull Intent putExtra(String name, @Nullable Bundle value) {
11186         if (mExtras == null) {
11187             mExtras = new Bundle();
11188         }
11189         mExtras.putBundle(name, value);
11190         return this;
11191     }
11192 
11193     /**
11194      * Add extended data to the intent.  The name must include a package
11195      * prefix, for example the app com.android.contacts would use names
11196      * like "com.android.contacts.ShowAll".
11197      *
11198      * @param name The name of the extra data, with package prefix.
11199      * @param value The IBinder data value.
11200      *
11201      * @return Returns the same Intent object, for chaining multiple calls
11202      * into a single statement.
11203      *
11204      * @see #putExtras
11205      * @see #removeExtra
11206      * @see #getIBinderExtra(String)
11207      *
11208      * @deprecated
11209      * @hide
11210      */
11211     @Deprecated
11212     @UnsupportedAppUsage
putExtra(String name, IBinder value)11213     public @NonNull Intent putExtra(String name, IBinder value) {
11214         if (mExtras == null) {
11215             mExtras = new Bundle();
11216         }
11217         mExtras.putIBinder(name, value);
11218         return this;
11219     }
11220 
11221     /**
11222      * Copy all extras in 'src' in to this intent.
11223      *
11224      * @param src Contains the extras to copy.
11225      *
11226      * @see #putExtra
11227      */
putExtras(@onNull Intent src)11228     public @NonNull Intent putExtras(@NonNull Intent src) {
11229         if (src.mExtras != null) {
11230             if (mExtras == null) {
11231                 mExtras = new Bundle(src.mExtras);
11232             } else {
11233                 mExtras.putAll(src.mExtras);
11234             }
11235         }
11236         // If the provided Intent was unparceled and this is not an Intent delivered to a protected
11237         // component then mark the extras as unfiltered. An Intent delivered to a protected
11238         // component had to come from a trusted component, and if unfiltered data was copied to the
11239         // delivered Intent then it would have been reported when that Intent left the sending
11240         // process.
11241         if ((src.mLocalFlags & LOCAL_FLAG_FROM_PARCEL) != 0
11242                 && (src.mLocalFlags & (
11243                         LOCAL_FLAG_FROM_PROTECTED_COMPONENT
11244                                 | LOCAL_FLAG_FROM_SYSTEM)) == 0) {
11245             mLocalFlags |= LOCAL_FLAG_UNFILTERED_EXTRAS;
11246         }
11247         return this;
11248     }
11249 
11250     /**
11251      * Add a set of extended data to the intent.  The keys must include a package
11252      * prefix, for example the app com.android.contacts would use names
11253      * like "com.android.contacts.ShowAll".
11254      *
11255      * @param extras The Bundle of extras to add to this intent.
11256      *
11257      * @see #putExtra
11258      * @see #removeExtra
11259      */
putExtras(@onNull Bundle extras)11260     public @NonNull Intent putExtras(@NonNull Bundle extras) {
11261         // If the provided Bundle has not yet been unparceled then treat this as unfiltered extras.
11262         if (extras.isParcelled()) {
11263             mLocalFlags |= LOCAL_FLAG_UNFILTERED_EXTRAS;
11264         }
11265         if (mExtras == null) {
11266             mExtras = new Bundle();
11267         }
11268         mExtras.putAll(extras);
11269         return this;
11270     }
11271 
11272     /**
11273      * Completely replace the extras in the Intent with the extras in the
11274      * given Intent.
11275      *
11276      * @param src The exact extras contained in this Intent are copied
11277      * into the target intent, replacing any that were previously there.
11278      */
replaceExtras(@onNull Intent src)11279     public @NonNull Intent replaceExtras(@NonNull Intent src) {
11280         mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
11281         return this;
11282     }
11283 
11284     /**
11285      * Completely replace the extras in the Intent with the given Bundle of
11286      * extras.
11287      *
11288      * @param extras The new set of extras in the Intent, or null to erase
11289      * all extras.
11290      */
replaceExtras(@ullable Bundle extras)11291     public @NonNull Intent replaceExtras(@Nullable Bundle extras) {
11292         mExtras = extras != null ? new Bundle(extras) : null;
11293         return this;
11294     }
11295 
11296     /**
11297      * Remove extended data from the intent.
11298      *
11299      * @see #putExtra
11300      */
removeExtra(String name)11301     public void removeExtra(String name) {
11302         if (mExtras != null) {
11303             mExtras.remove(name);
11304             if (mExtras.size() == 0) {
11305                 mExtras = null;
11306             }
11307         }
11308     }
11309 
11310     /**
11311      * Set special flags controlling how this intent is handled.  Most values
11312      * here depend on the type of component being executed by the Intent,
11313      * specifically the FLAG_ACTIVITY_* flags are all for use with
11314      * {@link Context#startActivity Context.startActivity()} and the
11315      * FLAG_RECEIVER_* flags are all for use with
11316      * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
11317      *
11318      * <p>See the
11319      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
11320      * Stack</a> documentation for important information on how some of these options impact
11321      * the behavior of your application.
11322      *
11323      * @param flags The desired flags.
11324      * @return Returns the same Intent object, for chaining multiple calls
11325      * into a single statement.
11326      * @see #getFlags
11327      * @see #addFlags
11328      * @see #removeFlags
11329      */
setFlags(@lags int flags)11330     public @NonNull Intent setFlags(@Flags int flags) {
11331         mFlags = flags;
11332         return this;
11333     }
11334 
11335     /**
11336      * Add additional flags to the intent (or with existing flags value).
11337      *
11338      * @param flags The new flags to set.
11339      * @return Returns the same Intent object, for chaining multiple calls into
11340      *         a single statement.
11341      * @see #setFlags
11342      * @see #getFlags
11343      * @see #removeFlags
11344      */
addFlags(@lags int flags)11345     public @NonNull Intent addFlags(@Flags int flags) {
11346         mFlags |= flags;
11347         return this;
11348     }
11349 
11350     /**
11351      * Add additional extended flags to the intent (or with existing flags value).
11352      *
11353      * @param flags The new flags to set.
11354      * @return Returns the same Intent object, for chaining multiple calls into
11355      *         a single statement.
11356      * @see #getExtendedFlags
11357      * @see #removeExtendedFlags
11358      *
11359      * @hide
11360      */
11361     @TestApi
addExtendedFlags(@xtendedFlags int flags)11362     public @NonNull Intent addExtendedFlags(@ExtendedFlags int flags) {
11363         mExtendedFlags |= flags;
11364         return this;
11365     }
11366 
11367     /**
11368      * Remove these flags from the intent.
11369      *
11370      * @param flags The flags to remove.
11371      * @see #setFlags
11372      * @see #getFlags
11373      * @see #addFlags
11374      */
removeFlags(@lags int flags)11375     public void removeFlags(@Flags int flags) {
11376         mFlags &= ~flags;
11377     }
11378 
11379     /**
11380      * Remove these extended flags from the intent.
11381      *
11382      * @param flags The flags to remove.
11383      * @see #getExtendedFlags
11384      * @see #addExtendedFlags
11385      *
11386      * @hide
11387      */
removeExtendedFlags(@xtendedFlags int flags)11388     public void removeExtendedFlags(@ExtendedFlags int flags) {
11389         mExtendedFlags &= ~flags;
11390     }
11391 
11392     /**
11393      * (Usually optional) Set an explicit application package name that limits
11394      * the components this Intent will resolve to.  If left to the default
11395      * value of null, all components in all applications will considered.
11396      * If non-null, the Intent can only match the components in the given
11397      * application package.
11398      *
11399      * @param packageName The name of the application package to handle the
11400      * intent, or null to allow any application package.
11401      *
11402      * @return Returns the same Intent object, for chaining multiple calls
11403      * into a single statement.
11404      *
11405      * @see #getPackage
11406      * @see #resolveActivity
11407      */
setPackage(@ullable String packageName)11408     public @NonNull Intent setPackage(@Nullable String packageName) {
11409         if (packageName != null && mSelector != null) {
11410             throw new IllegalArgumentException(
11411                     "Can't set package name when selector is already set");
11412         }
11413         mPackage = packageName;
11414         return this;
11415     }
11416 
11417     /**
11418      * (Usually optional) Explicitly set the component to handle the intent.
11419      * If left with the default value of null, the system will determine the
11420      * appropriate class to use based on the other fields (action, data,
11421      * type, categories) in the Intent.  If this class is defined, the
11422      * specified class will always be used regardless of the other fields.  You
11423      * should only set this value when you know you absolutely want a specific
11424      * class to be used; otherwise it is better to let the system find the
11425      * appropriate class so that you will respect the installed applications
11426      * and user preferences.
11427      *
11428      * @param component The name of the application component to handle the
11429      * intent, or null to let the system find one for you.
11430      *
11431      * @return Returns the same Intent object, for chaining multiple calls
11432      * into a single statement.
11433      *
11434      * @see #setClass
11435      * @see #setClassName(Context, String)
11436      * @see #setClassName(String, String)
11437      * @see #getComponent
11438      * @see #resolveActivity
11439      */
setComponent(@ullable ComponentName component)11440     public @NonNull Intent setComponent(@Nullable ComponentName component) {
11441         mComponent = component;
11442         return this;
11443     }
11444 
11445     /**
11446      * Convenience for calling {@link #setComponent} with an
11447      * explicit class name.
11448      *
11449      * @param packageContext A Context of the application package implementing
11450      * this class.
11451      * @param className The name of a class inside of the application package
11452      * that will be used as the component for this Intent.
11453      *
11454      * @return Returns the same Intent object, for chaining multiple calls
11455      * into a single statement.
11456      *
11457      * @see #setComponent
11458      * @see #setClass
11459      */
setClassName(@onNull Context packageContext, @NonNull String className)11460     public @NonNull Intent setClassName(@NonNull Context packageContext,
11461             @NonNull String className) {
11462         mComponent = new ComponentName(packageContext, className);
11463         return this;
11464     }
11465 
11466     /**
11467      * Convenience for calling {@link #setComponent} with an
11468      * explicit application package name and class name.
11469      *
11470      * @param packageName The name of the package implementing the desired
11471      * component.
11472      * @param className The name of a class inside of the application package
11473      * that will be used as the component for this Intent.
11474      *
11475      * @return Returns the same Intent object, for chaining multiple calls
11476      * into a single statement.
11477      *
11478      * @see #setComponent
11479      * @see #setClass
11480      */
setClassName(@onNull String packageName, @NonNull String className)11481     public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
11482         mComponent = new ComponentName(packageName, className);
11483         return this;
11484     }
11485 
11486     /**
11487      * Convenience for calling {@link #setComponent(ComponentName)} with the
11488      * name returned by a {@link Class} object.
11489      *
11490      * @param packageContext A Context of the application package implementing
11491      * this class.
11492      * @param cls The class name to set, equivalent to
11493      *            <code>setClassName(context, cls.getName())</code>.
11494      *
11495      * @return Returns the same Intent object, for chaining multiple calls
11496      * into a single statement.
11497      *
11498      * @see #setComponent
11499      */
setClass(@onNull Context packageContext, @NonNull Class<?> cls)11500     public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
11501         mComponent = new ComponentName(packageContext, cls);
11502         return this;
11503     }
11504 
11505     /**
11506      * Set the bounds of the sender of this intent, in screen coordinates.  This can be
11507      * used as a hint to the receiver for animations and the like.  Null means that there
11508      * is no source bounds.
11509      */
setSourceBounds(@ullable Rect r)11510     public void setSourceBounds(@Nullable Rect r) {
11511         if (r != null) {
11512             mSourceBounds = new Rect(r);
11513         } else {
11514             mSourceBounds = null;
11515         }
11516     }
11517 
11518     /** @hide */
11519     @IntDef(flag = true, prefix = { "FILL_IN_" }, value = {
11520             FILL_IN_ACTION,
11521             FILL_IN_DATA,
11522             FILL_IN_CATEGORIES,
11523             FILL_IN_COMPONENT,
11524             FILL_IN_PACKAGE,
11525             FILL_IN_SOURCE_BOUNDS,
11526             FILL_IN_SELECTOR,
11527             FILL_IN_CLIP_DATA
11528     })
11529     @Retention(RetentionPolicy.SOURCE)
11530     public @interface FillInFlags {}
11531 
11532     /**
11533      * Use with {@link #fillIn} to allow the current action value to be
11534      * overwritten, even if it is already set.
11535      */
11536     public static final int FILL_IN_ACTION = 1<<0;
11537 
11538     /**
11539      * Use with {@link #fillIn} to allow the current data or type value
11540      * overwritten, even if it is already set.
11541      */
11542     public static final int FILL_IN_DATA = 1<<1;
11543 
11544     /**
11545      * Use with {@link #fillIn} to allow the current categories to be
11546      * overwritten, even if they are already set.
11547      */
11548     public static final int FILL_IN_CATEGORIES = 1<<2;
11549 
11550     /**
11551      * Use with {@link #fillIn} to allow the current component value to be
11552      * overwritten, even if it is already set.
11553      */
11554     public static final int FILL_IN_COMPONENT = 1<<3;
11555 
11556     /**
11557      * Use with {@link #fillIn} to allow the current package value to be
11558      * overwritten, even if it is already set.
11559      */
11560     public static final int FILL_IN_PACKAGE = 1<<4;
11561 
11562     /**
11563      * Use with {@link #fillIn} to allow the current bounds rectangle to be
11564      * overwritten, even if it is already set.
11565      */
11566     public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
11567 
11568     /**
11569      * Use with {@link #fillIn} to allow the current selector to be
11570      * overwritten, even if it is already set.
11571      */
11572     public static final int FILL_IN_SELECTOR = 1<<6;
11573 
11574     /**
11575      * Use with {@link #fillIn} to allow the current ClipData to be
11576      * overwritten, even if it is already set.
11577      */
11578     public static final int FILL_IN_CLIP_DATA = 1<<7;
11579 
11580     /**
11581      * Use with {@link #fillIn} to allow the current identifier value to be
11582      * overwritten, even if it is already set.
11583      */
11584     public static final int FILL_IN_IDENTIFIER = 1<<8;
11585 
11586     /**
11587      * Copy the contents of <var>other</var> in to this object, but only
11588      * where fields are not defined by this object.  For purposes of a field
11589      * being defined, the following pieces of data in the Intent are
11590      * considered to be separate fields:
11591      *
11592      * <ul>
11593      * <li> action, as set by {@link #setAction}.
11594      * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
11595      * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
11596      * <li> identifier, as set by {@link #setIdentifier}.
11597      * <li> categories, as set by {@link #addCategory}.
11598      * <li> package, as set by {@link #setPackage}.
11599      * <li> component, as set by {@link #setComponent(ComponentName)} or
11600      * related methods.
11601      * <li> source bounds, as set by {@link #setSourceBounds}.
11602      * <li> selector, as set by {@link #setSelector(Intent)}.
11603      * <li> clip data, as set by {@link #setClipData(ClipData)}.
11604      * <li> each top-level name in the associated extras.
11605      * </ul>
11606      *
11607      * <p>In addition, you can use the {@link #FILL_IN_ACTION},
11608      * {@link #FILL_IN_DATA}, {@link #FILL_IN_IDENTIFIER}, {@link #FILL_IN_CATEGORIES},
11609      * {@link #FILL_IN_PACKAGE}, {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
11610      * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
11611      * the restriction where the corresponding field will not be replaced if
11612      * it is already set.
11613      *
11614      * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
11615      * is explicitly specified.  The selector will only be copied if
11616      * {@link #FILL_IN_SELECTOR} is explicitly specified.
11617      *
11618      * <p>For example, consider Intent A with {data="foo", categories="bar"}
11619      * and Intent B with {action="gotit", data-type="some/thing",
11620      * categories="one","two"}.
11621      *
11622      * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
11623      * containing: {action="gotit", data-type="some/thing",
11624      * categories="bar"}.
11625      *
11626      * @param other Another Intent whose values are to be used to fill in
11627      * the current one.
11628      * @param flags Options to control which fields can be filled in.
11629      *
11630      * @return Returns a bit mask of {@link #FILL_IN_ACTION},
11631      * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
11632      * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
11633      * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
11634      * changed.
11635      */
11636     @FillInFlags
fillIn(@onNull Intent other, @FillInFlags int flags)11637     public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
11638         int changes = 0;
11639         boolean mayHaveCopiedUris = false;
11640         if (other.mAction != null
11641                 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
11642             mAction = other.mAction;
11643             changes |= FILL_IN_ACTION;
11644         }
11645         if ((other.mData != null || other.mType != null)
11646                 && ((mData == null && mType == null)
11647                         || (flags&FILL_IN_DATA) != 0)) {
11648             mData = other.mData;
11649             mType = other.mType;
11650             changes |= FILL_IN_DATA;
11651             mayHaveCopiedUris = true;
11652         }
11653         if (other.mIdentifier != null
11654                 && (mIdentifier == null || (flags&FILL_IN_IDENTIFIER) != 0)) {
11655             mIdentifier = other.mIdentifier;
11656             changes |= FILL_IN_IDENTIFIER;
11657         }
11658         if (other.mCategories != null
11659                 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
11660             if (other.mCategories != null) {
11661                 mCategories = new ArraySet<String>(other.mCategories);
11662             }
11663             changes |= FILL_IN_CATEGORIES;
11664         }
11665         if (other.mPackage != null
11666                 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
11667             // Only do this if mSelector is not set.
11668             if (mSelector == null) {
11669                 mPackage = other.mPackage;
11670                 changes |= FILL_IN_PACKAGE;
11671             }
11672         }
11673         // Selector is special: it can only be set if explicitly allowed,
11674         // for the same reason as the component name.
11675         if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
11676             if (mPackage == null) {
11677                 mSelector = new Intent(other.mSelector);
11678                 mPackage = null;
11679                 changes |= FILL_IN_SELECTOR;
11680             }
11681         }
11682         if (other.mClipData != null
11683                 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
11684             mClipData = other.mClipData;
11685             changes |= FILL_IN_CLIP_DATA;
11686             mayHaveCopiedUris = true;
11687         }
11688         // Component is special: it can -only- be set if explicitly allowed,
11689         // since otherwise the sender could force the intent somewhere the
11690         // originator didn't intend.
11691         if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
11692             mComponent = other.mComponent;
11693             changes |= FILL_IN_COMPONENT;
11694         }
11695         mFlags |= other.mFlags;
11696         mExtendedFlags |= other.mExtendedFlags;
11697         if (other.mSourceBounds != null
11698                 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
11699             mSourceBounds = new Rect(other.mSourceBounds);
11700             changes |= FILL_IN_SOURCE_BOUNDS;
11701         }
11702         if (mExtras == null) {
11703             if (other.mExtras != null) {
11704                 mExtras = new Bundle(other.mExtras);
11705                 mayHaveCopiedUris = true;
11706             }
11707         } else if (other.mExtras != null) {
11708             try {
11709                 Bundle newb = new Bundle(other.mExtras);
11710                 newb.putAll(mExtras);
11711                 mExtras = newb;
11712                 mayHaveCopiedUris = true;
11713             } catch (RuntimeException e) {
11714                 // Modifying the extras can cause us to unparcel the contents
11715                 // of the bundle, and if we do this in the system process that
11716                 // may fail.  We really should handle this (i.e., the Bundle
11717                 // impl shouldn't be on top of a plain map), but for now just
11718                 // ignore it and keep the original contents. :(
11719                 Log.w(TAG, "Failure filling in extras", e);
11720             }
11721         }
11722         fillInCreatorTokenInfo(other.mCreatorTokenInfo, changes);
11723         if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
11724                 && other.mContentUserHint != UserHandle.USER_CURRENT) {
11725             mContentUserHint = other.mContentUserHint;
11726         }
11727         return changes;
11728     }
11729 
11730     // keep original creator token and merge nested intent keys.
fillInCreatorTokenInfo(CreatorTokenInfo otherCreatorTokenInfo, int changes)11731     private void fillInCreatorTokenInfo(CreatorTokenInfo otherCreatorTokenInfo, int changes) {
11732         if (otherCreatorTokenInfo != null && otherCreatorTokenInfo.mNestedIntentKeys != null) {
11733             if (mCreatorTokenInfo == null) {
11734                 mCreatorTokenInfo = new CreatorTokenInfo();
11735             }
11736             ArraySet<NestedIntentKey> otherNestedIntentKeys =
11737                     otherCreatorTokenInfo.mNestedIntentKeys;
11738             if (mCreatorTokenInfo.mNestedIntentKeys == null) {
11739                 mCreatorTokenInfo.mNestedIntentKeys = new ArraySet<>(otherNestedIntentKeys);
11740             } else {
11741                 ArraySet<NestedIntentKey> otherKeys;
11742                 if ((changes & FILL_IN_CLIP_DATA) == 0) {
11743                     // If clip data is Not filled in from other, do not merge clip data keys.
11744                     otherKeys = new ArraySet<>();
11745                     int N = otherNestedIntentKeys.size();
11746                     for (int i = 0; i < N; i++) {
11747                         NestedIntentKey key = otherNestedIntentKeys.valueAt(i);
11748                         if (key.mType != NestedIntentKey.NESTED_INTENT_KEY_TYPE_CLIP_DATA) {
11749                             otherKeys.add(key);
11750                         }
11751                     }
11752                 } else {
11753                     // If clip data is filled in from other, remove clip data keys from this
11754                     // creatorTokenInfo and then merge every key from the others.
11755                     int N = mCreatorTokenInfo.mNestedIntentKeys.size();
11756                     for (int i = N - 1; i >= 0; i--) {
11757                         NestedIntentKey key = mCreatorTokenInfo.mNestedIntentKeys.valueAt(i);
11758                         if (key.mType == NestedIntentKey.NESTED_INTENT_KEY_TYPE_CLIP_DATA) {
11759                             mCreatorTokenInfo.mNestedIntentKeys.removeAt(i);
11760                         }
11761                     }
11762                     otherKeys = otherNestedIntentKeys;
11763                 }
11764                 mCreatorTokenInfo.mNestedIntentKeys.addAll(otherKeys);
11765             }
11766         }
11767     }
11768 
11769     /**
11770      * Merge the extras data in this intent with that of other supplied intent using the
11771      * strategy specified using {@code extrasMerger}.
11772      *
11773      * <p> Note the extras data in this intent is treated as the {@code first} param
11774      * and the extras data in {@code other} intent is treated as the {@code last} param
11775      * when using the passed in {@link BundleMerger} object.
11776      *
11777      * @hide
11778      */
mergeExtras(@onNull Intent other, @NonNull BundleMerger extrasMerger)11779     public void mergeExtras(@NonNull Intent other, @NonNull BundleMerger extrasMerger) {
11780         mExtras = extrasMerger.merge(mExtras, other.mExtras);
11781     }
11782 
11783     /**
11784      * Wrapper class holding an Intent and implementing comparisons on it for
11785      * the purpose of filtering.  The class implements its
11786      * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
11787      * simple calls to {@link Intent#filterEquals(Intent)}  filterEquals()} and
11788      * {@link android.content.Intent#filterHashCode()}  filterHashCode()}
11789      * on the wrapped Intent.
11790      */
11791     public static final class FilterComparison {
11792         private final Intent mIntent;
11793         private final int mHashCode;
11794 
FilterComparison(Intent intent)11795         public FilterComparison(Intent intent) {
11796             mIntent = intent;
11797             mHashCode = intent.filterHashCode();
11798         }
11799 
11800         /**
11801          * Return the Intent that this FilterComparison represents.
11802          * @return Returns the Intent held by the FilterComparison.  Do
11803          * not modify!
11804          */
getIntent()11805         public Intent getIntent() {
11806             return mIntent;
11807         }
11808 
11809         @Override
equals(@ullable Object obj)11810         public boolean equals(@Nullable Object obj) {
11811             if (obj instanceof FilterComparison) {
11812                 Intent other = ((FilterComparison)obj).mIntent;
11813                 return mIntent.filterEquals(other);
11814             }
11815             return false;
11816         }
11817 
11818         @Override
hashCode()11819         public int hashCode() {
11820             return mHashCode;
11821         }
11822     }
11823 
11824     /**
11825      * Determine if two intents are the same for the purposes of intent
11826      * resolution (filtering). That is, if their action, data, type, identity,
11827      * class, and categories are the same.  This does <em>not</em> compare
11828      * any extra data included in the intents.  Note that technically when actually
11829      * matching against an {@link IntentFilter} the identifier is ignored, while here
11830      * it is directly compared for equality like the other fields.
11831      *
11832      * @param other The other Intent to compare against.
11833      *
11834      * @return Returns true if action, data, type, class, and categories
11835      *         are the same.
11836      */
filterEquals(Intent other)11837     public boolean filterEquals(Intent other) {
11838         if (other == null) {
11839             return false;
11840         }
11841         if (!Objects.equals(this.mAction, other.mAction)) return false;
11842         if (!Objects.equals(this.mData, other.mData)) return false;
11843         if (!Objects.equals(this.mType, other.mType)) return false;
11844         if (!Objects.equals(this.mIdentifier, other.mIdentifier)) return false;
11845         if (!Objects.equals(this.mPackage, other.mPackage)) return false;
11846         if (!Objects.equals(this.mComponent, other.mComponent)) return false;
11847         if (!Objects.equals(this.mCategories, other.mCategories)) return false;
11848 
11849         return true;
11850     }
11851 
11852     /**
11853      * Generate hash code that matches semantics of filterEquals().
11854      *
11855      * @return Returns the hash value of the action, data, type, class, and
11856      *         categories.
11857      *
11858      * @see #filterEquals
11859      */
filterHashCode()11860     public int filterHashCode() {
11861         int code = 0;
11862         if (mAction != null) {
11863             code += mAction.hashCode();
11864         }
11865         if (mData != null) {
11866             code += mData.hashCode();
11867         }
11868         if (mType != null) {
11869             code += mType.hashCode();
11870         }
11871         if (mIdentifier != null) {
11872             code += mIdentifier.hashCode();
11873         }
11874         if (mPackage != null) {
11875             code += mPackage.hashCode();
11876         }
11877         if (mComponent != null) {
11878             code += mComponent.hashCode();
11879         }
11880         if (mCategories != null) {
11881             code += mCategories.hashCode();
11882         }
11883         return code;
11884     }
11885 
11886     @Override
toString()11887     public String toString() {
11888         StringBuilder b = new StringBuilder(128);
11889         toString(b);
11890         return b.toString();
11891     }
11892 
11893     /** @hide */
toString(@onNull StringBuilder b)11894     public void toString(@NonNull StringBuilder b) {
11895         b.append("Intent { ");
11896         toShortString(b, true, true, true, false);
11897         b.append(" }");
11898     }
11899 
11900     /** @hide */
11901     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
toInsecureString()11902     public String toInsecureString() {
11903         StringBuilder b = new StringBuilder(128);
11904 
11905         b.append("Intent { ");
11906         toShortString(b, false, true, true, false);
11907         b.append(" }");
11908 
11909         return b.toString();
11910     }
11911 
11912     /** @hide */
toShortString(boolean secure, boolean comp, boolean extras, boolean clip)11913     public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
11914         StringBuilder b = new StringBuilder(128);
11915         toShortString(b, secure, comp, extras, clip);
11916         return b.toString();
11917     }
11918 
11919     /** @hide */
toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras, boolean clip)11920     public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
11921             boolean clip) {
11922         boolean first = true;
11923         if (mAction != null) {
11924             b.append("act=").append(mAction);
11925             first = false;
11926         }
11927         if (mCategories != null) {
11928             if (!first) {
11929                 b.append(' ');
11930             }
11931             first = false;
11932             b.append("cat=[");
11933             for (int i=0; i<mCategories.size(); i++) {
11934                 if (i > 0) b.append(',');
11935                 b.append(mCategories.valueAt(i));
11936             }
11937             b.append("]");
11938         }
11939         if (mData != null) {
11940             if (!first) {
11941                 b.append(' ');
11942             }
11943             first = false;
11944             b.append("dat=");
11945             if (secure) {
11946                 b.append(mData.toSafeString());
11947             } else {
11948                 b.append(mData);
11949             }
11950         }
11951         if (mType != null) {
11952             if (!first) {
11953                 b.append(' ');
11954             }
11955             first = false;
11956             b.append("typ=").append(mType);
11957         }
11958         if (mIdentifier != null) {
11959             if (!first) {
11960                 b.append(' ');
11961             }
11962             first = false;
11963             b.append("id=").append(mIdentifier);
11964         }
11965         if (mFlags != 0) {
11966             if (!first) {
11967                 b.append(' ');
11968             }
11969             first = false;
11970             b.append("flg=0x").append(Integer.toHexString(mFlags));
11971         }
11972         if (mExtendedFlags != 0) {
11973             if (!first) {
11974                 b.append(' ');
11975             }
11976             first = false;
11977             b.append("xflg=0x").append(Integer.toHexString(mExtendedFlags));
11978         }
11979         if (mPackage != null) {
11980             if (!first) {
11981                 b.append(' ');
11982             }
11983             first = false;
11984             b.append("pkg=").append(mPackage);
11985         }
11986         if (comp && mComponent != null) {
11987             if (!first) {
11988                 b.append(' ');
11989             }
11990             first = false;
11991             b.append("cmp=").append(mComponent.flattenToShortString());
11992         }
11993         if (mSourceBounds != null) {
11994             if (!first) {
11995                 b.append(' ');
11996             }
11997             first = false;
11998             b.append("bnds=").append(mSourceBounds.toShortString());
11999         }
12000         if (mClipData != null) {
12001             if (!first) {
12002                 b.append(' ');
12003             }
12004             b.append("clip={");
12005             mClipData.toShortString(b, !clip || secure);
12006             first = false;
12007             b.append('}');
12008         }
12009         if (extras && mExtras != null) {
12010             if (!first) {
12011                 b.append(' ');
12012             }
12013             first = false;
12014             b.append("(has extras)");
12015         }
12016         if (mContentUserHint != UserHandle.USER_CURRENT) {
12017             if (!first) {
12018                 b.append(' ');
12019             }
12020             first = false;
12021             b.append("u=").append(mContentUserHint);
12022         }
12023         if (mSelector != null) {
12024             b.append(" sel=");
12025             mSelector.toShortString(b, secure, comp, extras, clip);
12026             b.append("}");
12027         }
12028         if (mOriginalIntent != null) {
12029             b.append(" org={");
12030             mOriginalIntent.toShortString(b, secure, comp, extras, clip);
12031             b.append("}");
12032         }
12033     }
12034 
12035     /** @hide */
dumpDebug(ProtoOutputStream proto, long fieldId)12036     public void dumpDebug(ProtoOutputStream proto, long fieldId) {
12037         // Same input parameters that toString() gives to toShortString().
12038         dumpDebug(proto, fieldId, true, true, true, false);
12039     }
12040 
12041     /** @hide */
dumpDebug(ProtoOutputStream proto)12042     public void dumpDebug(ProtoOutputStream proto) {
12043         // Same input parameters that toString() gives to toShortString().
12044         dumpDebugWithoutFieldId(proto, true, true, true, false);
12045     }
12046 
12047     /** @hide */
dumpDebug(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp, boolean extras, boolean clip)12048     public void dumpDebug(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
12049             boolean extras, boolean clip) {
12050         long token = proto.start(fieldId);
12051         dumpDebugWithoutFieldId(proto, secure, comp, extras, clip);
12052         proto.end(token);
12053     }
12054 
dumpDebugWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp, boolean extras, boolean clip)12055     private void dumpDebugWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp,
12056             boolean extras, boolean clip) {
12057         if (mAction != null) {
12058             proto.write(IntentProto.ACTION, mAction);
12059         }
12060         if (mCategories != null)  {
12061             for (String category : mCategories) {
12062                 proto.write(IntentProto.CATEGORIES, category);
12063             }
12064         }
12065         if (mData != null) {
12066             proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
12067         }
12068         if (mType != null) {
12069             proto.write(IntentProto.TYPE, mType);
12070         }
12071         if (mIdentifier != null) {
12072             proto.write(IntentProto.IDENTIFIER, mIdentifier);
12073         }
12074         if (mFlags != 0) {
12075             proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
12076         }
12077         if (mExtendedFlags != 0) {
12078             proto.write(IntentProto.EXTENDED_FLAG, "0x" + Integer.toHexString(mExtendedFlags));
12079         }
12080         if (mPackage != null) {
12081             proto.write(IntentProto.PACKAGE, mPackage);
12082         }
12083         if (comp && mComponent != null) {
12084             mComponent.dumpDebug(proto, IntentProto.COMPONENT);
12085         }
12086         if (mSourceBounds != null) {
12087             proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
12088         }
12089         if (mClipData != null) {
12090             StringBuilder b = new StringBuilder();
12091             mClipData.toShortString(b, !clip || secure);
12092             proto.write(IntentProto.CLIP_DATA, b.toString());
12093         }
12094         if (extras && mExtras != null) {
12095             proto.write(IntentProto.EXTRAS, mExtras.toShortString());
12096         }
12097         if (mContentUserHint != 0) {
12098             proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
12099         }
12100         if (mSelector != null) {
12101             proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
12102         }
12103     }
12104 
12105     /**
12106      * Call {@link #toUri} with 0 flags.
12107      * @deprecated Use {@link #toUri} instead.
12108      */
12109     @Deprecated
toURI()12110     public String toURI() {
12111         return toUri(0);
12112     }
12113 
12114     /**
12115      * Convert this Intent into a String holding a URI representation of it.
12116      * The returned URI string has been properly URI encoded, so it can be
12117      * used with {@link Uri#parse Uri.parse(String)}.  The URI contains the
12118      * Intent's data as the base URI, with an additional fragment describing
12119      * the action, categories, type, flags, package, component, and extras.
12120      *
12121      * <p>You can convert the returned string back to an Intent with
12122      * {@link #getIntent}.
12123      *
12124      * @param flags Additional operating flags.
12125      *
12126      * @return Returns a URI encoding URI string describing the entire contents
12127      * of the Intent.
12128      */
toUri(@riFlags int flags)12129     public String toUri(@UriFlags int flags) {
12130         StringBuilder uri = new StringBuilder(128);
12131         if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
12132             if (mPackage == null) {
12133                 throw new IllegalArgumentException(
12134                         "Intent must include an explicit package name to build an android-app: "
12135                         + this);
12136             }
12137             uri.append("android-app://");
12138             uri.append(Uri.encode(mPackage));
12139             String scheme = null;
12140             if (mData != null) {
12141                 // All values here must be wrapped with Uri#encodeIfNotEncoded because it is
12142                 // possible to exploit the Uri API to return a raw unencoded value, which will
12143                 // not deserialize properly and may cause the resulting Intent to be transformed
12144                 // to a malicious value.
12145                 scheme = Uri.encodeIfNotEncoded(mData.getScheme(), null);
12146                 if (scheme != null) {
12147                     uri.append('/');
12148                     uri.append(scheme);
12149                     String authority = Uri.encodeIfNotEncoded(mData.getEncodedAuthority(), null);
12150                     if (authority != null) {
12151                         uri.append('/');
12152                         uri.append(authority);
12153 
12154                         // Multiple path segments are allowed, don't encode the path / separator
12155                         String path = Uri.encodeIfNotEncoded(mData.getEncodedPath(), "/");
12156                         if (path != null) {
12157                             uri.append(path);
12158                         }
12159                         String queryParams = Uri.encodeIfNotEncoded(mData.getEncodedQuery(), null);
12160                         if (queryParams != null) {
12161                             uri.append('?');
12162                             uri.append(queryParams);
12163                         }
12164                         String fragment = Uri.encodeIfNotEncoded(mData.getEncodedFragment(), null);
12165                         if (fragment != null) {
12166                             uri.append('#');
12167                             uri.append(fragment);
12168                         }
12169                     }
12170                 }
12171             }
12172             toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
12173                     mPackage, flags);
12174             return uri.toString();
12175         }
12176         String scheme = null;
12177         if (mData != null) {
12178             String data = mData.toString();
12179             if ((flags&URI_INTENT_SCHEME) != 0) {
12180                 final int N = data.length();
12181                 for (int i=0; i<N; i++) {
12182                     char c = data.charAt(i);
12183                     if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
12184                             || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
12185                         continue;
12186                     }
12187                     if (c == ':' && i > 0) {
12188                         // Valid scheme.
12189                         scheme = data.substring(0, i);
12190                         uri.append("intent:");
12191                         data = data.substring(i+1);
12192                         break;
12193                     }
12194 
12195                     // No scheme.
12196                     break;
12197                 }
12198             }
12199             uri.append(data);
12200 
12201         } else if ((flags&URI_INTENT_SCHEME) != 0) {
12202             uri.append("intent:");
12203         }
12204 
12205         toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
12206 
12207         return uri.toString();
12208     }
12209 
toUriFragment(StringBuilder uri, String scheme, String defAction, String defPackage, int flags)12210     private void toUriFragment(StringBuilder uri, String scheme, String defAction,
12211             String defPackage, int flags) {
12212         StringBuilder frag = new StringBuilder(128);
12213 
12214         toUriInner(frag, scheme, defAction, defPackage, flags);
12215         if (mSelector != null) {
12216             frag.append("SEL;");
12217             // Note that for now we are not going to try to handle the
12218             // data part; not clear how to represent this as a URI, and
12219             // not much utility in it.
12220             mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
12221                     null, null, flags);
12222         }
12223 
12224         if (frag.length() > 0) {
12225             uri.append("#Intent;");
12226             uri.append(frag);
12227             uri.append("end");
12228         }
12229     }
12230 
toUriInner(StringBuilder uri, String scheme, String defAction, String defPackage, int flags)12231     private void toUriInner(StringBuilder uri, String scheme, String defAction,
12232             String defPackage, int flags) {
12233         if (scheme != null) {
12234             uri.append("scheme=").append(Uri.encode(scheme)).append(';');
12235         }
12236         if (mAction != null && !mAction.equals(defAction)) {
12237             uri.append("action=").append(Uri.encode(mAction)).append(';');
12238         }
12239         if (mCategories != null) {
12240             for (int i=0; i<mCategories.size(); i++) {
12241                 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
12242             }
12243         }
12244         if (mType != null) {
12245             uri.append("type=").append(Uri.encode(mType, "/")).append(';');
12246         }
12247         if (mIdentifier != null) {
12248             uri.append("identifier=").append(Uri.encode(mIdentifier, "/")).append(';');
12249         }
12250         if (mFlags != 0) {
12251             uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
12252         }
12253         if (mExtendedFlags != 0) {
12254             uri.append("extendedLaunchFlags=0x").append(Integer.toHexString(mExtendedFlags))
12255                     .append(';');
12256         }
12257         if (mPackage != null && !mPackage.equals(defPackage)) {
12258             uri.append("package=").append(Uri.encode(mPackage)).append(';');
12259         }
12260         if (mComponent != null) {
12261             uri.append("component=").append(Uri.encode(
12262                     mComponent.flattenToShortString(), "/")).append(';');
12263         }
12264         if (mSourceBounds != null) {
12265             uri.append("sourceBounds=")
12266                     .append(Uri.encode(mSourceBounds.flattenToString()))
12267                     .append(';');
12268         }
12269         if (mExtras != null) {
12270             for (String key : mExtras.keySet()) {
12271                 final Object value = mExtras.get(key);
12272                 char entryType =
12273                         value instanceof String    ? 'S' :
12274                         value instanceof Boolean   ? 'B' :
12275                         value instanceof Byte      ? 'b' :
12276                         value instanceof Character ? 'c' :
12277                         value instanceof Double    ? 'd' :
12278                         value instanceof Float     ? 'f' :
12279                         value instanceof Integer   ? 'i' :
12280                         value instanceof Long      ? 'l' :
12281                         value instanceof Short     ? 's' :
12282                         '\0';
12283 
12284                 if (entryType != '\0') {
12285                     uri.append(entryType);
12286                     uri.append('.');
12287                     uri.append(Uri.encode(key));
12288                     uri.append('=');
12289                     uri.append(Uri.encode(value.toString()));
12290                     uri.append(';');
12291                 }
12292             }
12293         }
12294     }
12295 
describeContents()12296     public int describeContents() {
12297         return (mExtras != null) ? mExtras.describeContents() : 0;
12298     }
12299 
12300     private static class CreatorTokenInfo {
12301         // Stores a creator token for an intent embedded as an extra intent in a top level intent,
12302         private IBinder mCreatorToken;
12303         // Stores all extra keys whose values are intents for a top level intent.
12304         private ArraySet<NestedIntentKey> mNestedIntentKeys;
12305     }
12306 
12307     /**
12308      * @hide
12309      */
12310     public static class NestedIntentKey {
12311         /** @hide */
12312         @IntDef(flag = true, prefix = {"NESTED_INTENT_KEY_TYPE"}, value = {
12313                 NESTED_INTENT_KEY_TYPE_EXTRA_PARCEL,
12314                 NESTED_INTENT_KEY_TYPE_EXTRA_PARCEL_ARRAY,
12315                 NESTED_INTENT_KEY_TYPE_EXTRA_PARCEL_LIST,
12316                 NESTED_INTENT_KEY_TYPE_CLIP_DATA,
12317         })
12318         @Retention(RetentionPolicy.SOURCE)
12319         private @interface NestedIntentKeyType {
12320         }
12321 
12322         /**
12323          * This flag indicates the key is for an extra parcel in mExtras.
12324          */
12325         private static final int NESTED_INTENT_KEY_TYPE_EXTRA_PARCEL = 1 << 0;
12326 
12327         /**
12328          * This flag indicates the key is for an extra parcel array in mExtras and the index is the
12329          * index of that array.
12330          */
12331         private static final int NESTED_INTENT_KEY_TYPE_EXTRA_PARCEL_ARRAY = 1 << 1;
12332 
12333         /**
12334          * This flag indicates the key is for an extra parcel list in mExtras and the index is the
12335          * index of that list.
12336          */
12337         private static final int NESTED_INTENT_KEY_TYPE_EXTRA_PARCEL_LIST = 1 << 2;
12338 
12339         /**
12340          * This flag indicates the key is for an extra parcel in mClipData.mItems.
12341          */
12342         private static final int NESTED_INTENT_KEY_TYPE_CLIP_DATA = 1 << 3;
12343 
12344         private final @NestedIntentKeyType int mType;
12345         private final String mKey;
12346         private final int mIndex;
12347 
NestedIntentKey(@estedIntentKeyType int type, String key, int index)12348         private NestedIntentKey(@NestedIntentKeyType int type, String key, int index) {
12349             this.mType = type;
12350             this.mKey = key;
12351             this.mIndex = index;
12352         }
12353 
12354         @Override
equals(Object o)12355         public boolean equals(Object o) {
12356             if (this == o) return true;
12357             if (o == null || getClass() != o.getClass()) return false;
12358             NestedIntentKey that = (NestedIntentKey) o;
12359             return mType == that.mType && mIndex == that.mIndex && Objects.equals(mKey, that.mKey);
12360         }
12361 
12362         @Override
hashCode()12363         public int hashCode() {
12364             return Objects.hash(mType, mKey, mIndex);
12365         }
12366 
12367     }
12368 
12369     private @Nullable CreatorTokenInfo mCreatorTokenInfo;
12370 
12371     /** @hide */
removeCreatorTokenInfo()12372     public void removeCreatorTokenInfo() {
12373         mCreatorTokenInfo = null;
12374     }
12375 
12376     /** @hide */
removeCreatorToken()12377     public void removeCreatorToken() {
12378         if (mCreatorTokenInfo != null) {
12379             mCreatorTokenInfo.mCreatorToken = null;
12380         }
12381     }
12382 
12383     /** @hide */
getCreatorToken()12384     public @Nullable IBinder getCreatorToken() {
12385         return mCreatorTokenInfo == null ? null : mCreatorTokenInfo.mCreatorToken;
12386     }
12387 
12388     /** @hide */
getExtraIntentKeys()12389     public Set<NestedIntentKey> getExtraIntentKeys() {
12390         return mCreatorTokenInfo == null ? null : mCreatorTokenInfo.mNestedIntentKeys;
12391     }
12392 
12393     /** @hide */
setCreatorToken(@onNull IBinder creatorToken)12394     public void setCreatorToken(@NonNull IBinder creatorToken) {
12395         if (mCreatorTokenInfo == null) {
12396             mCreatorTokenInfo = new CreatorTokenInfo();
12397         }
12398         mCreatorTokenInfo.mCreatorToken = creatorToken;
12399     }
12400 
12401     /**
12402      * Collects keys in the extra bundle whose value are intents.
12403      * With these keys collected on the client side, the system server would only unparcel values
12404      * of these keys and create IntentCreatorToken for them.
12405      * @hide
12406      */
collectExtraIntentKeys()12407     public void collectExtraIntentKeys() {
12408         collectExtraIntentKeys(false);
12409     }
12410 
12411     /**
12412      * Collects keys in the extra bundle whose value are intents.
12413      * With these keys collected on the client side, the system server would only unparcel values
12414      * of these keys and create IntentCreatorToken for them.
12415      * This method could also be called from the system server side as a catch all safty net in case
12416      * these keys are not collected on the client side. In that case, call it with forceUnparcel set
12417      * to true since everything is parceled on the system server side.
12418      *
12419      * @param forceUnparcel if it is true, unparcel everything to determine if an object is an
12420      *                      intent. Otherwise, do not unparcel anything.
12421      * @hide
12422      */
collectExtraIntentKeys(boolean forceUnparcel)12423     public void collectExtraIntentKeys(boolean forceUnparcel) {
12424         if (preventIntentRedirect()) {
12425             collectNestedIntentKeysRecur(new ArraySet<>(), forceUnparcel);
12426         }
12427     }
12428 
collectNestedIntentKeysRecur(Set<Intent> visited, boolean forceUnparcel)12429     private void collectNestedIntentKeysRecur(Set<Intent> visited, boolean forceUnparcel) {
12430         // if forceUnparcel is false, do not unparcel the mExtras bundle.
12431         // forceUnparcel will only be true when this method is called from system server.
12432         if (mExtras != null && (forceUnparcel || !mExtras.isParcelled()) && !mExtras.isEmpty()) {
12433             addExtendedFlags(EXTENDED_FLAG_NESTED_INTENT_KEYS_COLLECTED);
12434             for (String key : mExtras.keySet()) {
12435                 Object value;
12436                 try {
12437                     // Do not unparcel any Parcelable objects. It may cause issues for app who would
12438                     // change class loader before it reads a parceled value. b/382633789.
12439                     // It is okay to not collect a parceled intent since it would have been
12440                     // coming from another process and collected by its containing intent already
12441                     // in that process.
12442                     if (forceUnparcel || !mExtras.isValueParceled(key)) {
12443                         value = mExtras.get(key);
12444                     } else {
12445                         value = null;
12446                         removeExtendedFlags(EXTENDED_FLAG_NESTED_INTENT_KEYS_COLLECTED);
12447                     }
12448                 } catch (BadParcelableException e) {
12449                     // This may still happen if the keys are collected on the system server side, in
12450                     // which case, we will try to unparcel everything. If this happens, simply
12451                     // ignore it since it is not an intent anyway.
12452                     value = null;
12453                 }
12454                 if (value instanceof Intent intent) {
12455                     handleNestedIntent(intent, visited, new NestedIntentKey(
12456                                     NestedIntentKey.NESTED_INTENT_KEY_TYPE_EXTRA_PARCEL, key, 0),
12457                             forceUnparcel);
12458                 } else if (value instanceof Parcelable[] parcelables) {
12459                     handleParcelableArray(parcelables, key, visited, forceUnparcel);
12460                 } else if (value instanceof ArrayList<?> parcelables) {
12461                     handleParcelableList(parcelables, key, visited, forceUnparcel);
12462                 }
12463             }
12464         }
12465 
12466         // if there is no extras in the bundle, we also mark the intent as keys are collected.
12467         // isDefinitelyEmpty() will not unparceled the mExtras. This is the best we can do without
12468         // unparceling the extra bundle.
12469         if (mExtras == null ||  mExtras.isDefinitelyEmpty()) {
12470             addExtendedFlags(EXTENDED_FLAG_NESTED_INTENT_KEYS_COLLECTED);
12471         }
12472 
12473         if (mClipData != null) {
12474             for (int i = 0; i < mClipData.getItemCount(); i++) {
12475                 Intent intent = mClipData.getItemAt(i).mIntent;
12476                 if (intent != null && !visited.contains(intent)) {
12477                     handleNestedIntent(intent, visited, new NestedIntentKey(
12478                                     NestedIntentKey.NESTED_INTENT_KEY_TYPE_CLIP_DATA, null, i),
12479                             forceUnparcel);
12480                 }
12481             }
12482         }
12483     }
12484 
handleNestedIntent(Intent intent, Set<Intent> visited, NestedIntentKey key, boolean forceUnparcel)12485     private void handleNestedIntent(Intent intent, Set<Intent> visited, NestedIntentKey key,
12486             boolean forceUnparcel) {
12487         if (mCreatorTokenInfo == null) {
12488             mCreatorTokenInfo = new CreatorTokenInfo();
12489         }
12490         if (mCreatorTokenInfo.mNestedIntentKeys == null) {
12491             mCreatorTokenInfo.mNestedIntentKeys = new ArraySet<>();
12492         }
12493         mCreatorTokenInfo.mNestedIntentKeys.add(key);
12494         if (!visited.contains(intent)) {
12495             visited.add(intent);
12496             intent.collectNestedIntentKeysRecur(visited, forceUnparcel);
12497         }
12498     }
12499 
handleParcelableArray(Parcelable[] parcelables, String key, Set<Intent> visited, boolean forceUnparcel)12500     private void handleParcelableArray(Parcelable[] parcelables, String key, Set<Intent> visited,
12501             boolean forceUnparcel) {
12502         for (int i = 0; i < parcelables.length; i++) {
12503             if (parcelables[i] instanceof Intent intent && !visited.contains(intent)) {
12504                 handleNestedIntent(intent, visited, new NestedIntentKey(
12505                                 NestedIntentKey.NESTED_INTENT_KEY_TYPE_EXTRA_PARCEL_ARRAY, key, i),
12506                         forceUnparcel);
12507             }
12508         }
12509     }
12510 
handleParcelableList(ArrayList<?> parcelables, String key, Set<Intent> visited, boolean forceUnparcel)12511     private void handleParcelableList(ArrayList<?> parcelables, String key, Set<Intent> visited,
12512             boolean forceUnparcel) {
12513         for (int i = 0; i < parcelables.size(); i++) {
12514             if (parcelables.get(i) instanceof Intent intent && !visited.contains(intent)) {
12515                 handleNestedIntent(intent, visited, new NestedIntentKey(
12516                                 NestedIntentKey.NESTED_INTENT_KEY_TYPE_EXTRA_PARCEL_LIST, key, i),
12517                         forceUnparcel);
12518             }
12519         }
12520     }
12521 
12522     private static final Consumer<Intent> MARK_TRUSTED_TOKEN_PRESENT_ACTION = intent -> {
12523         intent.mLocalFlags |= LOCAL_FLAG_TRUSTED_CREATOR_TOKEN_PRESENT;
12524     };
12525 
12526     private static final Consumer<Intent> ENABLE_TOKEN_VERIFY_ACTION = intent -> {
12527         if (intent.mExtras != null) {
12528             intent.mExtras.enableTokenVerification();
12529         }
12530         if (intent.mClipData != null) {
12531             intent.mClipData.setTokenVerificationEnabled();
12532         }
12533     };
12534 
12535     /** @hide */
checkCreatorToken()12536     public void checkCreatorToken() {
12537         forEachNestedCreatorToken(MARK_TRUSTED_TOKEN_PRESENT_ACTION, ENABLE_TOKEN_VERIFY_ACTION);
12538         if (mExtras != null) {
12539             // mark the bundle as intent extras after calls to getParcelable.
12540             // otherwise, the logic to mark missing token would run before
12541             // mark trusted creator token present.
12542             mExtras.enableTokenVerification();
12543         }
12544         if (mClipData != null) {
12545             mClipData.setTokenVerificationEnabled();
12546         }
12547     }
12548 
12549     /** @hide */
forEachNestedCreatorToken(Consumer<? super Intent> action)12550     public void forEachNestedCreatorToken(Consumer<? super Intent> action) {
12551         forEachNestedCreatorToken(action, null);
12552     }
12553 
forEachNestedCreatorToken(Consumer<? super Intent> action, Consumer<? super Intent> postAction)12554     private void forEachNestedCreatorToken(Consumer<? super Intent> action,
12555             Consumer<? super Intent> postAction) {
12556         if (mExtras == null && mClipData == null) return;
12557 
12558         if (mCreatorTokenInfo != null && mCreatorTokenInfo.mNestedIntentKeys != null) {
12559             int N = mCreatorTokenInfo.mNestedIntentKeys.size();
12560             for (int i = 0; i < N; i++) {
12561                 NestedIntentKey key = mCreatorTokenInfo.mNestedIntentKeys.valueAt(i);
12562                 Intent extraIntent = extractIntentFromKey(key);
12563 
12564                 if (extraIntent != null) {
12565                     action.accept(extraIntent);
12566                     extraIntent.forEachNestedCreatorToken(action);
12567                     if (postAction != null) {
12568                         postAction.accept(extraIntent);
12569                     }
12570                 } else {
12571                     Log.w(TAG, getLogMessageForKey(key));
12572                 }
12573             }
12574         }
12575     }
12576 
extractIntentFromKey(NestedIntentKey key)12577     private Intent extractIntentFromKey(NestedIntentKey key) {
12578         switch (key.mType) {
12579             case NestedIntentKey.NESTED_INTENT_KEY_TYPE_EXTRA_PARCEL:
12580                 return mExtras == null ? null : mExtras.getParcelable(key.mKey, Intent.class);
12581             case NestedIntentKey.NESTED_INTENT_KEY_TYPE_EXTRA_PARCEL_ARRAY:
12582                 if (mExtras == null) return null;
12583                 Intent[] extraIntents = mExtras.getParcelableArray(key.mKey, Intent.class);
12584                 if (extraIntents != null && key.mIndex < extraIntents.length) {
12585                     return extraIntents[key.mIndex];
12586                 }
12587                 break;
12588             case NestedIntentKey.NESTED_INTENT_KEY_TYPE_EXTRA_PARCEL_LIST:
12589                 if (mExtras == null) return null;
12590                 ArrayList<Intent> extraIntentsList = mExtras.getParcelableArrayList(key.mKey,
12591                         Intent.class);
12592                 if (extraIntentsList != null && key.mIndex < extraIntentsList.size()) {
12593                     return extraIntentsList.get(key.mIndex);
12594                 }
12595                 break;
12596             case NestedIntentKey.NESTED_INTENT_KEY_TYPE_CLIP_DATA:
12597                 if (mClipData == null) return null;
12598                 if (key.mIndex < mClipData.getItemCount()) {
12599                     ClipData.Item item = mClipData.getItemAt(key.mIndex);
12600                     if (item != null) {
12601                         return item.mIntent;
12602                     }
12603                 }
12604                 break;
12605         }
12606         return null;
12607     }
12608 
getLogMessageForKey(NestedIntentKey key)12609     private String getLogMessageForKey(NestedIntentKey key) {
12610         switch (key.mType) {
12611             case NestedIntentKey.NESTED_INTENT_KEY_TYPE_EXTRA_PARCEL:
12612                 return "The key {" + key + "} does not correspond to an intent in the bundle.";
12613             case NestedIntentKey.NESTED_INTENT_KEY_TYPE_EXTRA_PARCEL_ARRAY:
12614                 if (mExtras.getParcelableArray(key.mKey, Intent.class) == null) {
12615                     return "The key {" + key
12616                             + "} does not correspond to a Parcelable[] in the bundle.";
12617                 } else {
12618                     return "Parcelable[" + key.mIndex + "] for key {" + key + "} is not an intent.";
12619                 }
12620             case NestedIntentKey.NESTED_INTENT_KEY_TYPE_EXTRA_PARCEL_LIST:
12621                 if (mExtras.getParcelableArrayList(key.mKey, Intent.class) == null) {
12622                     return "The key {" + key
12623                             + "} does not correspond to an ArrayList<Parcelable> in the bundle.";
12624                 } else {
12625                     return "List.get(" + key.mIndex + ") for key {" + key + "} is not an intent.";
12626                 }
12627             case NestedIntentKey.NESTED_INTENT_KEY_TYPE_CLIP_DATA:
12628                 if (key.mIndex >= mClipData.getItemCount()) {
12629                     return "Index out of range for clipData items. index: " + key.mIndex
12630                             + ". item counts: " + mClipData.getItemCount();
12631                 } else {
12632                     return "clipData items at index [" + key.mIndex
12633                             + "] is null or does not contain an intent.";
12634                 }
12635             default:
12636                 return "Unknown key type: " + key.mType;
12637         }
12638     }
12639 
12640     /**
12641      * When an intent comes from another app or component as an embedded extra intent, the system
12642      * creates a token to identify the creator of this foreign intent. If this token is missing or
12643      * invalid, the system will block the launch of this intent. If it contains a valid token, the
12644      * system will perform verification against the creator to block launching target it has no
12645      * permission to launch or block it from granting URI access to the tagert it cannot access.
12646      * This method provides a way to opt out this feature.
12647      */
12648     @FlaggedApi(FLAG_PREVENT_INTENT_REDIRECT)
removeLaunchSecurityProtection()12649     public void removeLaunchSecurityProtection() {
12650         mExtendedFlags &= ~EXTENDED_FLAG_MISSING_CREATOR_OR_INVALID_TOKEN;
12651         removeCreatorTokenInfo();
12652     }
12653 
writeToParcel(Parcel out, int flags)12654     public void writeToParcel(Parcel out, int flags) {
12655         out.writeString8(mAction);
12656         Uri.writeToParcel(out, mData);
12657         out.writeString8(mType);
12658         out.writeString8(mIdentifier);
12659         out.writeInt(mFlags);
12660         out.writeInt(mExtendedFlags);
12661         out.writeString8(mPackage);
12662         ComponentName.writeToParcel(mComponent, out);
12663 
12664         if (mSourceBounds != null) {
12665             out.writeInt(1);
12666             mSourceBounds.writeToParcel(out, flags);
12667         } else {
12668             out.writeInt(0);
12669         }
12670 
12671         if (mCategories != null) {
12672             final int N = mCategories.size();
12673             out.writeInt(N);
12674             for (int i=0; i<N; i++) {
12675                 out.writeString8(mCategories.valueAt(i));
12676             }
12677         } else {
12678             out.writeInt(0);
12679         }
12680 
12681         if (mSelector != null) {
12682             out.writeInt(1);
12683             mSelector.writeToParcel(out, flags);
12684         } else {
12685             out.writeInt(0);
12686         }
12687 
12688         if (mClipData != null) {
12689             out.writeInt(1);
12690             mClipData.writeToParcel(out, flags);
12691         } else {
12692             out.writeInt(0);
12693         }
12694         out.writeInt(mContentUserHint);
12695         out.writeBundle(mExtras);
12696 
12697         if (mOriginalIntent != null) {
12698             out.writeInt(1);
12699             mOriginalIntent.writeToParcel(out, flags);
12700         } else {
12701             out.writeInt(0);
12702         }
12703 
12704         if (preventIntentRedirect()) {
12705             if (mCreatorTokenInfo == null) {
12706                 out.writeInt(0);
12707             } else {
12708                 out.writeInt(1);
12709                 out.writeStrongBinder(mCreatorTokenInfo.mCreatorToken);
12710 
12711                 if (mCreatorTokenInfo.mNestedIntentKeys != null) {
12712                     final int N = mCreatorTokenInfo.mNestedIntentKeys.size();
12713                     out.writeInt(N);
12714                     for (int i = 0; i < N; i++) {
12715                         NestedIntentKey key = mCreatorTokenInfo.mNestedIntentKeys.valueAt(i);
12716                         out.writeInt(key.mType);
12717                         out.writeString8(key.mKey);
12718                         out.writeInt(key.mIndex);
12719                     }
12720                 } else {
12721                     out.writeInt(0);
12722                 }
12723             }
12724         }
12725     }
12726 
12727     public static final @android.annotation.NonNull Parcelable.Creator<Intent> CREATOR
12728             = new Parcelable.Creator<Intent>() {
12729         public Intent createFromParcel(Parcel in) {
12730             return new Intent(in);
12731         }
12732         public Intent[] newArray(int size) {
12733             return new Intent[size];
12734         }
12735     };
12736 
12737     /** @hide */
Intent(Parcel in)12738     protected Intent(Parcel in) {
12739         // Remember that we came from a remote process to help detect security
12740         // issues caused by later unsafe launches
12741         mLocalFlags = LOCAL_FLAG_FROM_PARCEL;
12742         readFromParcel(in);
12743     }
12744 
readFromParcel(Parcel in)12745     public void readFromParcel(Parcel in) {
12746         setAction(in.readString8());
12747         mData = Uri.CREATOR.createFromParcel(in);
12748         mType = in.readString8();
12749         mIdentifier = in.readString8();
12750         mFlags = in.readInt();
12751         mExtendedFlags = in.readInt();
12752         mPackage = in.readString8();
12753         mComponent = ComponentName.readFromParcel(in);
12754 
12755         if (in.readInt() != 0) {
12756             mSourceBounds = Rect.CREATOR.createFromParcel(in);
12757         }
12758 
12759         int N = in.readInt();
12760         if (N > 0) {
12761             mCategories = new ArraySet<String>();
12762             int i;
12763             for (i=0; i<N; i++) {
12764                 mCategories.add(in.readString8().intern());
12765             }
12766         } else {
12767             mCategories = null;
12768         }
12769 
12770         if (in.readInt() != 0) {
12771             mSelector = new Intent(in);
12772         }
12773 
12774         if (in.readInt() != 0) {
12775             mClipData = new ClipData(in);
12776         }
12777         mContentUserHint = in.readInt();
12778         mExtras = in.readBundle();
12779         if (in.readInt() != 0) {
12780             mOriginalIntent = new Intent(in);
12781         }
12782 
12783         if (preventIntentRedirect()) {
12784             if (in.readInt() != 0) {
12785                 mCreatorTokenInfo = new CreatorTokenInfo();
12786                 mCreatorTokenInfo.mCreatorToken = in.readStrongBinder();
12787 
12788                 N = in.readInt();
12789                 if (N > 0) {
12790                     mCreatorTokenInfo.mNestedIntentKeys = new ArraySet<>(N);
12791                     for (int i = 0; i < N; i++) {
12792                         int type = in.readInt();
12793                         String key = in.readString8();
12794                         int index = in.readInt();
12795                         mCreatorTokenInfo.mNestedIntentKeys.append(
12796                                 new NestedIntentKey(type, key, index));
12797                     }
12798                 }
12799             }
12800         }
12801     }
12802 
12803     /**
12804      * Parses the "intent" element (and its children) from XML and instantiates
12805      * an Intent object.  The given XML parser should be located at the tag
12806      * where parsing should start (often named "intent"), from which the
12807      * basic action, data, type, and package and class name will be
12808      * retrieved.  The function will then parse in to any child elements,
12809      * looking for <category android:name="xxx"> tags to add categories and
12810      * <extra android:name="xxx" android:value="yyy"> to attach extra data
12811      * to the intent.
12812      *
12813      * @param resources The Resources to use when inflating resources.
12814      * @param parser The XML parser pointing at an "intent" tag.
12815      * @param attrs The AttributeSet interface for retrieving extended
12816      * attribute data at the current <var>parser</var> location.
12817      * @return An Intent object matching the XML data.
12818      * @throws XmlPullParserException If there was an XML parsing error.
12819      * @throws IOException If there was an I/O error.
12820      */
parseIntent(@onNull Resources resources, @NonNull XmlPullParser parser, AttributeSet attrs)12821     public static @NonNull Intent parseIntent(@NonNull Resources resources,
12822             @NonNull XmlPullParser parser, AttributeSet attrs)
12823             throws XmlPullParserException, IOException {
12824         Intent intent = new Intent();
12825 
12826         TypedArray sa = resources.obtainAttributes(attrs,
12827                 com.android.internal.R.styleable.Intent);
12828 
12829         intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
12830 
12831         String data = sa.getString(com.android.internal.R.styleable.Intent_data);
12832         String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
12833         intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
12834 
12835         intent.setIdentifier(sa.getString(com.android.internal.R.styleable.Intent_identifier));
12836 
12837         String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
12838         String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
12839         if (packageName != null && className != null) {
12840             intent.setComponent(new ComponentName(packageName, className));
12841         }
12842 
12843         sa.recycle();
12844 
12845         int outerDepth = parser.getDepth();
12846         int type;
12847         while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
12848                && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
12849             if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
12850                 continue;
12851             }
12852 
12853             String nodeName = parser.getName();
12854             if (nodeName.equals(TAG_CATEGORIES)) {
12855                 sa = resources.obtainAttributes(attrs,
12856                         com.android.internal.R.styleable.IntentCategory);
12857                 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
12858                 sa.recycle();
12859 
12860                 if (cat != null) {
12861                     intent.addCategory(cat);
12862                 }
12863                 XmlUtils.skipCurrentTag(parser);
12864 
12865             } else if (nodeName.equals(TAG_EXTRA)) {
12866                 if (intent.mExtras == null) {
12867                     intent.mExtras = new Bundle();
12868                 }
12869                 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
12870                 XmlUtils.skipCurrentTag(parser);
12871 
12872             } else {
12873                 XmlUtils.skipCurrentTag(parser);
12874             }
12875         }
12876 
12877         return intent;
12878     }
12879 
12880     /** @hide */
saveToXml(XmlSerializer out)12881     public void saveToXml(XmlSerializer out) throws IOException {
12882         if (mAction != null) {
12883             out.attribute(null, ATTR_ACTION, mAction);
12884         }
12885         if (mData != null) {
12886             out.attribute(null, ATTR_DATA, mData.toString());
12887         }
12888         if (mType != null) {
12889             out.attribute(null, ATTR_TYPE, mType);
12890         }
12891         if (mIdentifier != null) {
12892             out.attribute(null, ATTR_IDENTIFIER, mIdentifier);
12893         }
12894         if (mComponent != null) {
12895             out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
12896         }
12897         if (android.content.flags.Flags.intentSaveToXmlPackage() && mPackage != null) {
12898             out.attribute(null, ATTR_PACKAGE, mPackage);
12899         }
12900         out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
12901 
12902         if (mCategories != null) {
12903             out.startTag(null, TAG_CATEGORIES);
12904             for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
12905                 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
12906             }
12907             out.endTag(null, TAG_CATEGORIES);
12908         }
12909     }
12910 
12911     /** @hide */
restoreFromXml(XmlPullParser in)12912     public static Intent restoreFromXml(XmlPullParser in) throws IOException,
12913             XmlPullParserException {
12914         Intent intent = new Intent();
12915         final int outerDepth = in.getDepth();
12916 
12917         int attrCount = in.getAttributeCount();
12918         for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
12919             final String attrName = in.getAttributeName(attrNdx);
12920             final String attrValue = in.getAttributeValue(attrNdx);
12921             if (ATTR_ACTION.equals(attrName)) {
12922                 intent.setAction(attrValue);
12923             } else if (ATTR_DATA.equals(attrName)) {
12924                 intent.setData(Uri.parse(attrValue));
12925             } else if (ATTR_TYPE.equals(attrName)) {
12926                 intent.setType(attrValue);
12927             } else if (ATTR_IDENTIFIER.equals(attrName)) {
12928                 intent.setIdentifier(attrValue);
12929             } else if (ATTR_COMPONENT.equals(attrName)) {
12930                 intent.setComponent(ComponentName.unflattenFromString(attrValue));
12931             } else if (ATTR_FLAGS.equals(attrName)) {
12932                 intent.setFlags(Integer.parseInt(attrValue, 16));
12933             } else if (android.content.flags.Flags.intentSaveToXmlPackage()
12934                     && ATTR_PACKAGE.equals(attrName)) {
12935                 intent.setPackage(attrValue);
12936             } else {
12937                 Log.e(TAG, "restoreFromXml: unknown attribute=" + attrName);
12938             }
12939         }
12940 
12941         int event;
12942         String name;
12943         while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
12944                 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
12945             if (event == XmlPullParser.START_TAG) {
12946                 name = in.getName();
12947                 if (TAG_CATEGORIES.equals(name)) {
12948                     attrCount = in.getAttributeCount();
12949                     for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
12950                         intent.addCategory(in.getAttributeValue(attrNdx));
12951                     }
12952                 } else {
12953                     Log.w(TAG, "restoreFromXml: unknown name=" + name);
12954                     XmlUtils.skipCurrentTag(in);
12955                 }
12956             }
12957         }
12958 
12959         return intent;
12960     }
12961 
12962     /**
12963      * Normalize a MIME data type.
12964      *
12965      * <p>A normalized MIME type has white-space trimmed,
12966      * content-type parameters removed, and is lower-case.
12967      * This aligns the type with Android best practices for
12968      * intent filtering.
12969      *
12970      * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
12971      * "text/x-vCard" becomes "text/x-vcard".
12972      *
12973      * <p>All MIME types received from outside Android (such as user input,
12974      * or external sources like Bluetooth, NFC, or the Internet) should
12975      * be normalized before they are used to create an Intent.
12976      *
12977      * @param type MIME data type to normalize
12978      * @return normalized MIME data type, or null if the input was null
12979      * @see #setType
12980      * @see #setTypeAndNormalize
12981      */
normalizeMimeType(@ullable String type)12982     public static @Nullable String normalizeMimeType(@Nullable String type) {
12983         if (type == null) {
12984             return null;
12985         }
12986 
12987         type = type.trim().toLowerCase(Locale.ROOT);
12988 
12989         final int semicolonIndex = type.indexOf(';');
12990         if (semicolonIndex != -1) {
12991             type = type.substring(0, semicolonIndex);
12992         }
12993         return type;
12994     }
12995 
12996     /**
12997      * Prepare this {@link Intent} to leave an app process.
12998      *
12999      * @hide
13000      */
13001     @android.ravenwood.annotation.RavenwoodThrow
13002     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
prepareToLeaveProcess(Context context)13003     public void prepareToLeaveProcess(Context context) {
13004         final boolean leavingPackage;
13005         if (mComponent != null) {
13006             leavingPackage = !Objects.equals(mComponent.getPackageName(), context.getPackageName());
13007         } else if (mPackage != null) {
13008             leavingPackage = !Objects.equals(mPackage, context.getPackageName());
13009         } else {
13010             // When no specific component or package has been defined, we have
13011             // to assume that we might be routed through an intent
13012             // disambiguation dialog which might leave our package
13013             leavingPackage = true;
13014         }
13015         prepareToLeaveProcess(leavingPackage);
13016     }
13017 
13018     /**
13019      * Prepare this {@link Intent} to leave an app process.
13020      *
13021      * @hide
13022      */
13023     @android.ravenwood.annotation.RavenwoodThrow
prepareToLeaveProcess(boolean leavingPackage)13024     public void prepareToLeaveProcess(boolean leavingPackage) {
13025         prepareToLeaveProcess(leavingPackage, true);
13026     }
13027 
13028     /**
13029      * @hide
13030      */
prepareToLeaveProcess(boolean leavingPackage, boolean isTopLevel)13031     void prepareToLeaveProcess(boolean leavingPackage, boolean isTopLevel) {
13032         setAllowFds(false);
13033 
13034         if (mSelector != null) {
13035             mSelector.prepareToLeaveProcess(leavingPackage, false);
13036         }
13037         if (mClipData != null) {
13038             mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
13039         }
13040         if (mOriginalIntent != null) {
13041             mOriginalIntent.prepareToLeaveProcess(leavingPackage, false);
13042         }
13043 
13044         if (mExtras != null && !mExtras.isParcelled()) {
13045             final Object intent = mExtras.get(Intent.EXTRA_INTENT);
13046             if (intent instanceof Intent) {
13047                 ((Intent) intent).prepareToLeaveProcess(leavingPackage, false);
13048             }
13049         }
13050 
13051         if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
13052                 && leavingPackage) {
13053             switch (mAction) {
13054                 case ACTION_MEDIA_REMOVED:
13055                 case ACTION_MEDIA_UNMOUNTED:
13056                 case ACTION_MEDIA_CHECKING:
13057                 case ACTION_MEDIA_NOFS:
13058                 case ACTION_MEDIA_MOUNTED:
13059                 case ACTION_MEDIA_SHARED:
13060                 case ACTION_MEDIA_UNSHARED:
13061                 case ACTION_MEDIA_BAD_REMOVAL:
13062                 case ACTION_MEDIA_UNMOUNTABLE:
13063                 case ACTION_MEDIA_EJECT:
13064                 case ACTION_MEDIA_SCANNER_STARTED:
13065                 case ACTION_MEDIA_SCANNER_FINISHED:
13066                 case ACTION_MEDIA_SCANNER_SCAN_FILE:
13067                 case ACTION_PACKAGE_NEEDS_VERIFICATION:
13068                 case ACTION_PACKAGE_NEEDS_INTEGRITY_VERIFICATION:
13069                 case ACTION_PACKAGE_VERIFIED:
13070                 case ACTION_PACKAGE_ENABLE_ROLLBACK:
13071                     // Ignore legacy actions
13072                     break;
13073                 default:
13074                     mData.checkFileUriExposed("Intent.getData()");
13075             }
13076         }
13077 
13078         if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
13079                 && leavingPackage) {
13080             switch (mAction) {
13081                 case ACTION_PROVIDER_CHANGED:
13082                 case QuickContact.ACTION_QUICK_CONTACT:
13083                     // Ignore actions that don't need to grant
13084                     break;
13085                 default:
13086                     mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
13087             }
13088         }
13089 
13090         // Translate raw filesystem paths out of storage sandbox
13091         if (ACTION_MEDIA_SCANNER_SCAN_FILE.equals(mAction) && mData != null
13092                 && ContentResolver.SCHEME_FILE.equals(mData.getScheme()) && leavingPackage) {
13093             final StorageManager sm = AppGlobals.getInitialApplication()
13094                     .getSystemService(StorageManager.class);
13095             final File before = new File(mData.getPath());
13096             final File after = sm.translateAppToSystem(before,
13097                     android.os.Process.myPid(), android.os.Process.myUid());
13098             if (!Objects.equals(before, after)) {
13099                 Log.v(TAG, "Translated " + before + " to " + after);
13100                 mData = Uri.fromFile(after);
13101             }
13102         }
13103 
13104         // Detect cases where we're about to launch a potentially unsafe intent
13105         if (StrictMode.vmUnsafeIntentLaunchEnabled()) {
13106             if ((mLocalFlags & LOCAL_FLAG_FROM_PARCEL) != 0
13107                     && (mLocalFlags
13108                     & (LOCAL_FLAG_FROM_PROTECTED_COMPONENT | LOCAL_FLAG_FROM_SYSTEM)) == 0) {
13109                 StrictMode.onUnsafeIntentLaunch(this);
13110             } else if ((mLocalFlags & LOCAL_FLAG_UNFILTERED_EXTRAS) != 0) {
13111                 StrictMode.onUnsafeIntentLaunch(this);
13112             } else if ((mLocalFlags & LOCAL_FLAG_FROM_URI) != 0
13113                     && !(mCategories != null && mCategories.contains(CATEGORY_BROWSABLE)
13114                     && mComponent == null)) {
13115                 // Since the docs for #URI_ALLOW_UNSAFE recommend setting the category to browsable
13116                 // for an implicit Intent parsed from a URI a violation should be reported if these
13117                 // conditions are not met.
13118                 StrictMode.onUnsafeIntentLaunch(this);
13119             }
13120         }
13121 
13122         if (isTopLevel) {
13123             collectExtraIntentKeys();
13124         }
13125     }
13126 
13127     /**
13128      * @hide
13129      */
13130     @android.ravenwood.annotation.RavenwoodThrow
prepareToEnterProcess(boolean fromProtectedComponent, AttributionSource source)13131     public void prepareToEnterProcess(boolean fromProtectedComponent, AttributionSource source) {
13132         if (fromProtectedComponent) {
13133             prepareToEnterProcess(LOCAL_FLAG_FROM_PROTECTED_COMPONENT, source);
13134         } else {
13135             prepareToEnterProcess(0, source);
13136         }
13137     }
13138 
13139     /**
13140      * @hide
13141      */
13142     @android.ravenwood.annotation.RavenwoodThrow
prepareToEnterProcess(int localFlags, AttributionSource source)13143     public void prepareToEnterProcess(int localFlags, AttributionSource source) {
13144         // We just entered destination process, so we should be able to read all
13145         // parcelables inside.
13146         setDefusable(true);
13147 
13148         if (mSelector != null) {
13149             // We can't recursively claim that this data is from a protected
13150             // component, since it may have been filled in by a malicious app
13151             mSelector.prepareToEnterProcess(0, source);
13152         }
13153         if (mClipData != null) {
13154             mClipData.prepareToEnterProcess(source);
13155         }
13156         if (mOriginalIntent != null) {
13157             // We can't recursively claim that this data is from a protected
13158             // component, since it may have been filled in by a malicious app
13159             mOriginalIntent.prepareToEnterProcess(0, source);
13160         }
13161 
13162         if (mContentUserHint != UserHandle.USER_CURRENT) {
13163             if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
13164                 fixUris(mContentUserHint);
13165                 mContentUserHint = UserHandle.USER_CURRENT;
13166             }
13167         }
13168 
13169         mLocalFlags |= localFlags;
13170         checkCreatorToken();
13171 
13172         // Special attribution fix-up logic for any BluetoothDevice extras
13173         // passed via Bluetooth intents
13174         if (mAction != null && mAction.startsWith("android.bluetooth.")
13175                 && hasExtra(BluetoothDevice.EXTRA_DEVICE)) {
13176             final BluetoothDevice device = getParcelableExtra(BluetoothDevice.EXTRA_DEVICE, BluetoothDevice.class);
13177             if (device != null) {
13178                 device.prepareToEnterProcess(source);
13179             }
13180         }
13181     }
13182 
13183     /** @hide */
hasWebURI()13184     public boolean hasWebURI() {
13185         if (getData() == null) {
13186             return false;
13187         }
13188         final String scheme = getScheme();
13189         if (TextUtils.isEmpty(scheme)) {
13190             return false;
13191         }
13192         return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS);
13193     }
13194 
13195     /** @hide */
isWebIntent()13196     public boolean isWebIntent() {
13197         return ACTION_VIEW.equals(mAction)
13198                 && hasWebURI();
13199     }
13200 
isImageCaptureIntent()13201     private boolean isImageCaptureIntent() {
13202         return (MediaStore.ACTION_IMAGE_CAPTURE.equals(mAction)
13203                 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(mAction)
13204                 || MediaStore.ACTION_MOTION_PHOTO_CAPTURE.equals(mAction)
13205                 || MediaStore.ACTION_MOTION_PHOTO_CAPTURE_SECURE.equals(mAction)
13206                 || MediaStore.ACTION_VIDEO_CAPTURE.equals(mAction));
13207     }
13208 
13209     /** @hide */
isImplicitImageCaptureIntent()13210     public boolean isImplicitImageCaptureIntent() {
13211         return mPackage == null && mComponent == null && isImageCaptureIntent();
13212     }
13213 
13214     /**
13215      * Whether the intent mismatches all intent filters declared in the receiving component.
13216      * <p>
13217      * When a component receives an intent, normally obtainable through the following methods:
13218      * <ul>
13219      *     <li> {@link BroadcastReceiver#onReceive(Context, Intent)}
13220      *     <li> {@link Activity#getIntent()}
13221      *     <li> {@link Activity#onNewIntent)}
13222      *     <li> {@link android.app.Service#onStartCommand(Intent, int, int)}
13223      *     <li> {@link android.app.Service#onBind(Intent)}
13224      * </ul>
13225      * The developer can call this method to check if this intent does not match any of its
13226      * declared intent filters. A non-matching intent can be delivered when the intent sender
13227      * explicitly set the component through {@link #setComponent} or {@link #setClassName}.
13228      * <p>
13229      * This method always returns {@code false} if the intent originated from within the same
13230      * application or the system, because these cases are always exempted from security checks.
13231      *
13232      * @return Returns true if the intent does not match any intent filters declared in the
13233      * receiving component.
13234      */
13235     @FlaggedApi(android.security.Flags.FLAG_ENFORCE_INTENT_FILTER_MATCH)
isMismatchingFilter()13236     public boolean isMismatchingFilter() {
13237         return (mExtendedFlags & EXTENDED_FLAG_FILTER_MISMATCH) != 0;
13238     }
13239 
13240     /**
13241      * @hide
13242      */
13243     @android.ravenwood.annotation.RavenwoodThrow
fixUris(int contentUserHint)13244      public void fixUris(int contentUserHint) {
13245         Uri data = getData();
13246         if (data != null) {
13247             mData = maybeAddUserId(data, contentUserHint);
13248         }
13249         if (mClipData != null) {
13250             mClipData.fixUris(contentUserHint);
13251         }
13252         String action = getAction();
13253         if (ACTION_SEND.equals(action)) {
13254             final Uri stream = getParcelableExtra(EXTRA_STREAM, Uri.class);
13255             if (stream != null) {
13256                 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
13257             }
13258         } else if (ACTION_SEND_MULTIPLE.equals(action)) {
13259             final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM, Uri.class);
13260             if (streams != null) {
13261                 ArrayList<Uri> newStreams = new ArrayList<Uri>();
13262                 for (int i = 0; i < streams.size(); i++) {
13263                     newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
13264                 }
13265                 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
13266             }
13267         } else if (isImageCaptureIntent()) {
13268             final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT, Uri.class);
13269             if (output != null) {
13270                 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
13271             }
13272         }
13273      }
13274 
13275     /**
13276      * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
13277      * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
13278      * intents in {@link #ACTION_CHOOSER}.
13279      *
13280      * @return Whether any contents were migrated.
13281      * @hide
13282      */
13283     @android.ravenwood.annotation.RavenwoodThrow
migrateExtraStreamToClipData()13284     public boolean migrateExtraStreamToClipData() {
13285         return migrateExtraStreamToClipData(AppGlobals.getInitialApplication());
13286     }
13287 
13288     /**
13289      * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
13290      * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
13291      * intents in {@link #ACTION_CHOOSER}.
13292      *
13293      * @param context app context
13294      * @return Whether any contents were migrated.
13295      * @hide
13296      */
13297     @android.ravenwood.annotation.RavenwoodThrow
migrateExtraStreamToClipData(Context context)13298     public boolean migrateExtraStreamToClipData(Context context) {
13299         // Refuse to touch if extras already parcelled
13300         if (mExtras != null && mExtras.isParcelled()) return false;
13301 
13302         // Bail when someone already gave us ClipData
13303         if (getClipData() != null) return false;
13304 
13305         final String action = getAction();
13306         if (ACTION_CHOOSER.equals(action)) {
13307             // Inspect contained intents to see if we need to migrate extras. We
13308             // don't promote ClipData to the parent, since ChooserActivity will
13309             // already start the picked item as the caller, and we can't combine
13310             // the flags in a safe way.
13311 
13312             boolean migrated = false;
13313             try {
13314                 final Intent intent = getParcelableExtra(EXTRA_INTENT, Intent.class);
13315                 if (intent != null) {
13316                     migrated |= intent.migrateExtraStreamToClipData(context);
13317                 }
13318             } catch (ClassCastException e) {
13319             }
13320             try {
13321                 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
13322                 if (intents != null) {
13323                     for (int i = 0; i < intents.length; i++) {
13324                         final Intent intent = (Intent) intents[i];
13325                         if (intent != null) {
13326                             migrated |= intent.migrateExtraStreamToClipData(context);
13327                         }
13328                     }
13329                 }
13330             } catch (ClassCastException e) {
13331             }
13332             return migrated;
13333 
13334         } else if (ACTION_SEND.equals(action)) {
13335             try {
13336                 final Uri stream = getParcelableExtra(EXTRA_STREAM, Uri.class);
13337                 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
13338                 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
13339                 if (stream != null || text != null || htmlText != null) {
13340                     final ClipData clipData = new ClipData(
13341                             null, new String[] { getType() },
13342                             new ClipData.Item(text, htmlText, null, stream));
13343                     setClipData(clipData);
13344                     if (stream != null) {
13345                         logCounterIfFlagsMissing(FLAG_GRANT_READ_URI_PERMISSION,
13346                                 "intents.value_explicit_uri_grant_for_send_action");
13347                         addFlags(FLAG_GRANT_READ_URI_PERMISSION);
13348                     }
13349                     return true;
13350                 }
13351             } catch (ClassCastException e) {
13352             }
13353 
13354         } else if (ACTION_SEND_MULTIPLE.equals(action)) {
13355             try {
13356                 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM, Uri.class);
13357                 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
13358                 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
13359                 int num = -1;
13360                 if (streams != null) {
13361                     num = streams.size();
13362                 }
13363                 if (texts != null) {
13364                     if (num >= 0 && num != texts.size()) {
13365                         // Wha...!  F- you.
13366                         return false;
13367                     }
13368                     num = texts.size();
13369                 }
13370                 if (htmlTexts != null) {
13371                     if (num >= 0 && num != htmlTexts.size()) {
13372                         // Wha...!  F- you.
13373                         return false;
13374                     }
13375                     num = htmlTexts.size();
13376                 }
13377                 if (num > 0) {
13378                     final ClipData clipData = new ClipData(
13379                             null, new String[] { getType() },
13380                             makeClipItem(streams, texts, htmlTexts, 0));
13381 
13382                     for (int i = 1; i < num; i++) {
13383                         clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
13384                     }
13385 
13386                     setClipData(clipData);
13387                     if (streams != null) {
13388                         logCounterIfFlagsMissing(FLAG_GRANT_READ_URI_PERMISSION,
13389                                 "intents.value_explicit_uri_grant_for_send_multiple_action");
13390                         addFlags(FLAG_GRANT_READ_URI_PERMISSION);
13391                     }
13392                     return true;
13393                 }
13394             } catch (ClassCastException e) {
13395             }
13396         } else if (isImageCaptureIntent()) {
13397             Uri output;
13398             try {
13399                 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT, Uri.class);
13400             } catch (ClassCastException e) {
13401                 return false;
13402             }
13403 
13404             if (output != null) {
13405                 output = maybeConvertFileToContentUri(context, output);
13406                 putExtra(MediaStore.EXTRA_OUTPUT, output);
13407 
13408                 setClipData(ClipData.newRawUri("", output));
13409 
13410                 logCounterIfFlagsMissing(
13411                         FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_READ_URI_PERMISSION,
13412                         "intents.value_explicit_uri_grant_for_image_capture_action");
13413                 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
13414                 return true;
13415             }
13416         }
13417 
13418         return false;
13419     }
13420 
logCounterIfFlagsMissing(int requiredFlags, String metricId)13421     private void logCounterIfFlagsMissing(int requiredFlags, String metricId) {
13422         if ((getFlags() & requiredFlags) != requiredFlags) {
13423             Counter.logIncrement(metricId);
13424         }
13425     }
13426 
13427     @android.ravenwood.annotation.RavenwoodThrow
maybeConvertFileToContentUri(Context context, Uri uri)13428     private Uri maybeConvertFileToContentUri(Context context, Uri uri) {
13429         if (ContentResolver.SCHEME_FILE.equals(uri.getScheme())
13430                 && context.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.R) {
13431             File file = new File(uri.getPath());
13432             try {
13433                 if (!file.exists()) file.createNewFile();
13434                 uri = MediaStore.scanFile(context.getContentResolver(), new File(uri.getPath()));
13435                 if (uri != null) {
13436                     return uri;
13437                 }
13438             } catch (IOException e) {
13439                 Log.e(TAG, "Ignoring failure to create file " + file, e);
13440             }
13441         }
13442         return uri;
13443     }
13444 
13445     /**
13446      * Convert the dock state to a human readable format.
13447      * @hide
13448      */
dockStateToString(int dock)13449     public static String dockStateToString(int dock) {
13450         switch (dock) {
13451             case EXTRA_DOCK_STATE_HE_DESK:
13452                 return "EXTRA_DOCK_STATE_HE_DESK";
13453             case EXTRA_DOCK_STATE_LE_DESK:
13454                 return "EXTRA_DOCK_STATE_LE_DESK";
13455             case EXTRA_DOCK_STATE_CAR:
13456                 return "EXTRA_DOCK_STATE_CAR";
13457             case EXTRA_DOCK_STATE_DESK:
13458                 return "EXTRA_DOCK_STATE_DESK";
13459             case EXTRA_DOCK_STATE_UNDOCKED:
13460                 return "EXTRA_DOCK_STATE_UNDOCKED";
13461             default:
13462                 return Integer.toString(dock);
13463         }
13464     }
13465 
makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts, ArrayList<String> htmlTexts, int which)13466     private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
13467             ArrayList<String> htmlTexts, int which) {
13468         Uri uri = streams != null ? streams.get(which) : null;
13469         CharSequence text = texts != null ? texts.get(which) : null;
13470         String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
13471         return new ClipData.Item(text, htmlText, null, uri);
13472     }
13473 
13474     /** @hide */
isDocument()13475     public boolean isDocument() {
13476         return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
13477     }
13478 }
13479