summaryrefslogtreecommitdiff
path: root/core/java/android/content
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2017-04-24 11:18:03 -0600
committerJeff Sharkey <jsharkey@android.com>2017-04-24 13:20:46 -0600
commit30e06bb668f2e4b024c4ebc2a131de91c96de5eb (patch)
tree23912af279b2c4c54de4b213712eb8528dfd34c3 /core/java/android/content
parent4d23f258d4c15df9329d9c66ee902afa78cebca7 (diff)
Even more auto-doc work.
Update docs based on what new lint detector found. Add new @IntDef to parameters or methods returning constants or flags, and add @RequiresPermission to methods mentioning permissions. Test: make -j32 offline-sdk-docs Bug: 37526420 Change-Id: I7f640f7883fcb66b911a52ae93b83f77306571ec
Diffstat (limited to 'core/java/android/content')
-rw-r--r--core/java/android/content/ComponentName.java22
-rw-r--r--core/java/android/content/Context.java119
-rw-r--r--core/java/android/content/Intent.java368
-rw-r--r--core/java/android/content/pm/PackageManager.java108
4 files changed, 337 insertions, 280 deletions
diff --git a/core/java/android/content/ComponentName.java b/core/java/android/content/ComponentName.java
index 8aeb22dddd1e..ea6b7690b431 100644
--- a/core/java/android/content/ComponentName.java
+++ b/core/java/android/content/ComponentName.java
@@ -16,6 +16,8 @@
package android.content;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
@@ -52,7 +54,7 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
* the component
* @return the new ComponentName
*/
- public static ComponentName createRelative(String pkg, String cls) {
+ public static @NonNull ComponentName createRelative(@NonNull String pkg, @NonNull String cls) {
if (TextUtils.isEmpty(cls)) {
throw new IllegalArgumentException("class name cannot be empty");
}
@@ -83,7 +85,7 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
* the component
* @return the new ComponentName
*/
- public static ComponentName createRelative(Context pkg, String cls) {
+ public static @NonNull ComponentName createRelative(@NonNull Context pkg, @NonNull String cls) {
return createRelative(pkg.getPackageName(), cls);
}
@@ -95,7 +97,7 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
* @param cls The name of the class inside of <var>pkg</var> that
* implements the component. Can not be null.
*/
- public ComponentName(String pkg, String cls) {
+ public ComponentName(@NonNull String pkg, @NonNull String cls) {
if (pkg == null) throw new NullPointerException("package name is null");
if (cls == null) throw new NullPointerException("class name is null");
mPackage = pkg;
@@ -110,7 +112,7 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
* @param cls The name of the class inside of <var>pkg</var> that
* implements the component.
*/
- public ComponentName(Context pkg, String cls) {
+ public ComponentName(@NonNull Context pkg, @NonNull String cls) {
if (cls == null) throw new NullPointerException("class name is null");
mPackage = pkg.getPackageName();
mClass = cls;
@@ -124,7 +126,7 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
* @param cls The Class object of the desired component, from which the
* actual class name will be retrieved.
*/
- public ComponentName(Context pkg, Class<?> cls) {
+ public ComponentName(@NonNull Context pkg, @NonNull Class<?> cls) {
mPackage = pkg.getPackageName();
mClass = cls.getName();
}
@@ -136,14 +138,14 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
/**
* Return the package name of this component.
*/
- public String getPackageName() {
+ public @NonNull String getPackageName() {
return mPackage;
}
/**
* Return the class name of this component.
*/
- public String getClassName() {
+ public @NonNull String getClassName() {
return mClass;
}
@@ -200,7 +202,7 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
*
* @see #unflattenFromString(String)
*/
- public String flattenToString() {
+ public @NonNull String flattenToString() {
return mPackage + "/" + mClass;
}
@@ -215,7 +217,7 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
*
* @see #unflattenFromString(String)
*/
- public String flattenToShortString() {
+ public @NonNull String flattenToShortString() {
StringBuilder sb = new StringBuilder(mPackage.length() + mClass.length());
appendShortString(sb, mPackage, mClass);
return sb.toString();
@@ -255,7 +257,7 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
*
* @see #flattenToString()
*/
- public static ComponentName unflattenFromString(String str) {
+ public static @Nullable ComponentName unflattenFromString(@NonNull String str) {
int sep = str.indexOf('/');
if (sep < 0 || (sep+1) >= str.length()) {
return null;
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 1585d2164cd1..42ef871ef3ba 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -85,6 +85,37 @@ import java.lang.annotation.RetentionPolicy;
* broadcasting and receiving intents, etc.
*/
public abstract class Context {
+ /** @hide */
+ @IntDef(flag = true, prefix = { "MODE_" }, value = {
+ MODE_PRIVATE,
+ MODE_WORLD_READABLE,
+ MODE_WORLD_WRITEABLE,
+ MODE_APPEND,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface FileMode {}
+
+ /** @hide */
+ @IntDef(flag = true, prefix = { "MODE_" }, value = {
+ MODE_PRIVATE,
+ MODE_WORLD_READABLE,
+ MODE_WORLD_WRITEABLE,
+ MODE_MULTI_PROCESS,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface PreferencesMode {}
+
+ /** @hide */
+ @IntDef(flag = true, prefix = { "MODE_" }, value = {
+ MODE_PRIVATE,
+ MODE_WORLD_READABLE,
+ MODE_WORLD_WRITEABLE,
+ MODE_ENABLE_WRITE_AHEAD_LOGGING,
+ MODE_NO_LOCALIZED_COLLATORS,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface DatabaseMode {}
+
/**
* File creation mode: the default mode, where the created file can only
* be accessed by the calling application (or all applications sharing the
@@ -720,15 +751,14 @@ public abstract class Context {
* @param name Desired preferences file. If a preferences file by this name
* does not exist, it will be created when you retrieve an
* editor (SharedPreferences.edit()) and then commit changes (Editor.commit()).
- * @param mode Operating mode. Use 0 or {@link #MODE_PRIVATE} for the
- * default operation.
+ * @param mode Operating mode.
*
* @return The single {@link SharedPreferences} instance that can be used
* to retrieve and modify the preference values.
*
* @see #MODE_PRIVATE
*/
- public abstract SharedPreferences getSharedPreferences(String name, int mode);
+ public abstract SharedPreferences getSharedPreferences(String name, @PreferencesMode int mode);
/**
* Retrieve and hold the contents of the preferences file, returning
@@ -740,8 +770,7 @@ public abstract class Context {
* @param file Desired preferences file. If a preferences file by this name
* does not exist, it will be created when you retrieve an
* editor (SharedPreferences.edit()) and then commit changes (Editor.commit()).
- * @param mode Operating mode. Use 0 or {@link #MODE_PRIVATE} for the
- * default operation.
+ * @param mode Operating mode.
*
* @return The single {@link SharedPreferences} instance that can be used
* to retrieve and modify the preference values.
@@ -750,7 +779,7 @@ public abstract class Context {
* @see #MODE_PRIVATE
* @removed
*/
- public abstract SharedPreferences getSharedPreferences(File file, int mode);
+ public abstract SharedPreferences getSharedPreferences(File file, @PreferencesMode int mode);
/**
* Move an existing shared preferences file from the given source storage
@@ -805,9 +834,7 @@ public abstract class Context {
*
* @param name The name of the file to open; can not contain path
* separators.
- * @param mode Operating mode. Use 0 or {@link #MODE_PRIVATE} for the
- * default operation. Use {@link #MODE_APPEND} to append to an
- * existing file.
+ * @param mode Operating mode.
* @return The resulting {@link FileOutputStream}.
* @see #MODE_APPEND
* @see #MODE_PRIVATE
@@ -816,7 +843,7 @@ public abstract class Context {
* @see #deleteFile
* @see java.io.FileOutputStream#FileOutputStream(String)
*/
- public abstract FileOutputStream openFileOutput(String name, int mode)
+ public abstract FileOutputStream openFileOutput(String name, @FileMode int mode)
throws FileNotFoundException;
/**
@@ -1413,26 +1440,21 @@ public abstract class Context {
*
* @param name Name of the directory to retrieve. This is a directory
* that is created as part of your application data.
- * @param mode Operating mode. Use 0 or {@link #MODE_PRIVATE} for the
- * default operation.
+ * @param mode Operating mode.
*
* @return A {@link File} object for the requested directory. The directory
* will have been created if it does not already exist.
*
* @see #openFileOutput(String, int)
*/
- public abstract File getDir(String name, int mode);
+ public abstract File getDir(String name, @FileMode int mode);
/**
* Open a new private SQLiteDatabase associated with this Context's
* application package. Create the database file if it doesn't exist.
*
* @param name The name (unique in the application package) of the database.
- * @param mode Operating mode. Use 0 or {@link #MODE_PRIVATE} for the
- * default operation. Use
- * {@link #MODE_ENABLE_WRITE_AHEAD_LOGGING} to enable write-ahead
- * logging by default. Use {@link #MODE_NO_LOCALIZED_COLLATORS}
- * to disable localized collators.
+ * @param mode Operating mode.
* @param factory An optional factory class that is called to instantiate a
* cursor when query is called.
* @return The contents of a newly created database with the given name.
@@ -1444,7 +1466,7 @@ public abstract class Context {
* @see #deleteDatabase
*/
public abstract SQLiteDatabase openOrCreateDatabase(String name,
- int mode, CursorFactory factory);
+ @DatabaseMode int mode, CursorFactory factory);
/**
* Open a new private SQLiteDatabase associated with this Context's
@@ -1455,11 +1477,7 @@ public abstract class Context {
* </p>
*
* @param name The name (unique in the application package) of the database.
- * @param mode Operating mode. Use 0 or {@link #MODE_PRIVATE} for the
- * default operation. Use
- * {@link #MODE_ENABLE_WRITE_AHEAD_LOGGING} to enable write-ahead
- * logging by default. Use {@link #MODE_NO_LOCALIZED_COLLATORS}
- * to disable localized collators.
+ * @param mode Operating mode.
* @param factory An optional factory class that is called to instantiate a
* cursor when query is called.
* @param errorHandler the {@link DatabaseErrorHandler} to be used when
@@ -1475,7 +1493,7 @@ public abstract class Context {
* @see #deleteDatabase
*/
public abstract SQLiteDatabase openOrCreateDatabase(String name,
- int mode, CursorFactory factory,
+ @DatabaseMode int mode, CursorFactory factory,
@Nullable DatabaseErrorHandler errorHandler);
/**
@@ -1777,9 +1795,9 @@ public abstract class Context {
* @see #startActivity(Intent)
* @see #startIntentSender(IntentSender, Intent, int, int, int, Bundle)
*/
- public abstract void startIntentSender(IntentSender intent,
- Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
- throws IntentSender.SendIntentException;
+ public abstract void startIntentSender(IntentSender intent, @Nullable Intent fillInIntent,
+ @Intent.MutableFlags int flagsMask, @Intent.MutableFlags int flagsValues,
+ int extraFlags) throws IntentSender.SendIntentException;
/**
* Like {@link #startActivity(Intent, Bundle)}, but taking a IntentSender
@@ -1806,9 +1824,9 @@ public abstract class Context {
* @see #startActivity(Intent, Bundle)
* @see #startIntentSender(IntentSender, Intent, int, int, int)
*/
- public abstract void startIntentSender(IntentSender intent,
- @Nullable Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags,
- Bundle options) throws IntentSender.SendIntentException;
+ public abstract void startIntentSender(IntentSender intent, @Nullable Intent fillInIntent,
+ @Intent.MutableFlags int flagsMask, @Intent.MutableFlags int flagsValues,
+ int extraFlags, @Nullable Bundle options) throws IntentSender.SendIntentException;
/**
* Broadcast the given intent to all interested BroadcastReceivers. This
@@ -2192,10 +2210,6 @@ public abstract class Context {
* all other ways, this behaves the same as
* {@link #sendBroadcast(Intent)}.
*
- * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY}
- * permission in order to use this API. If you do not hold that
- * permission, {@link SecurityException} will be thrown.
- *
* @deprecated Sticky broadcasts should not be used. They provide no security (anyone
* can access them), no protection (anyone can modify them), and many other problems.
* The recommended pattern is to use a non-sticky broadcast to report that <em>something</em>
@@ -2210,6 +2224,7 @@ public abstract class Context {
* @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)
*/
@Deprecated
+ @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY)
public abstract void sendStickyBroadcast(@RequiresPermission Intent intent);
/**
@@ -2259,6 +2274,7 @@ public abstract class Context {
* @see android.app.Activity#RESULT_OK
*/
@Deprecated
+ @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY)
public abstract void sendStickyOrderedBroadcast(@RequiresPermission Intent intent,
BroadcastReceiver resultReceiver,
@Nullable Handler scheduler, int initialCode, @Nullable String initialData,
@@ -2268,10 +2284,6 @@ public abstract class Context {
* <p>Remove the data previously sent with {@link #sendStickyBroadcast},
* so that it is as if the sticky broadcast had never happened.
*
- * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY}
- * permission in order to use this API. If you do not hold that
- * permission, {@link SecurityException} will be thrown.
- *
* @deprecated Sticky broadcasts should not be used. They provide no security (anyone
* can access them), no protection (anyone can modify them), and many other problems.
* The recommended pattern is to use a non-sticky broadcast to report that <em>something</em>
@@ -2283,6 +2295,7 @@ public abstract class Context {
* @see #sendStickyBroadcast
*/
@Deprecated
+ @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY)
public abstract void removeStickyBroadcast(@RequiresPermission Intent intent);
/**
@@ -3048,7 +3061,7 @@ public abstract class Context {
* @see android.os.HardwarePropertiesManager
* @see #HARDWARE_PROPERTIES_SERVICE
*/
- public abstract Object getSystemService(@ServiceName @NonNull String name);
+ public abstract @Nullable Object getSystemService(@ServiceName @NonNull String name);
/**
* Return the handle to a system-level service by class.
@@ -3078,7 +3091,7 @@ public abstract class Context {
* @return The service or null if the class is not a supported system service.
*/
@SuppressWarnings("unchecked")
- public final <T> T getSystemService(Class<T> serviceClass) {
+ public final @Nullable <T> T getSystemService(@NonNull Class<T> serviceClass) {
// Because subclasses may override getSystemService(String) we cannot
// perform a lookup by class alone. We must first map the class to its
// service name then invoke the string-based method.
@@ -3092,7 +3105,7 @@ public abstract class Context {
* @param serviceClass The class of the desired service.
* @return The service name or null if the class is not a supported system service.
*/
- public abstract String getSystemServiceName(Class<?> serviceClass);
+ public abstract @Nullable String getSystemServiceName(@NonNull Class<?> serviceClass);
/**
* Use with {@link #getSystemService} to retrieve a
@@ -4181,10 +4194,12 @@ public abstract class Context {
* @see #checkCallingUriPermission
*/
@CheckResult(suggest="#enforceUriPermission(Uri,int,int,String)")
+ @PackageManager.PermissionResult
public abstract int checkUriPermission(Uri uri, int pid, int uid,
@Intent.AccessUriMode int modeFlags);
/** @hide */
+ @PackageManager.PermissionResult
public abstract int checkUriPermission(Uri uri, int pid, int uid,
@Intent.AccessUriMode int modeFlags, IBinder callerToken);
@@ -4208,6 +4223,7 @@ public abstract class Context {
* @see #checkUriPermission(Uri, int, int, int)
*/
@CheckResult(suggest="#enforceCallingUriPermission(Uri,int,String)")
+ @PackageManager.PermissionResult
public abstract int checkCallingUriPermission(Uri uri, @Intent.AccessUriMode int modeFlags);
/**
@@ -4226,6 +4242,7 @@ public abstract class Context {
* @see #checkCallingUriPermission
*/
@CheckResult(suggest="#enforceCallingOrSelfUriPermission(Uri,int,String)")
+ @PackageManager.PermissionResult
public abstract int checkCallingOrSelfUriPermission(Uri uri,
@Intent.AccessUriMode int modeFlags);
@@ -4250,6 +4267,7 @@ public abstract class Context {
* {@link PackageManager#PERMISSION_DENIED} if it is not.
*/
@CheckResult(suggest="#enforceUriPermission(Uri,String,String,int,int,int,String)")
+ @PackageManager.PermissionResult
public abstract int checkUriPermission(@Nullable Uri uri, @Nullable String readPermission,
@Nullable String writePermission, int pid, int uid,
@Intent.AccessUriMode int modeFlags);
@@ -4336,8 +4354,14 @@ public abstract class Context {
@Nullable String message);
/** @hide */
- @IntDef(flag = true,
- value = {CONTEXT_INCLUDE_CODE, CONTEXT_IGNORE_SECURITY, CONTEXT_RESTRICTED})
+ @IntDef(flag = true, prefix = { "CONTEXT_" }, value = {
+ CONTEXT_INCLUDE_CODE,
+ CONTEXT_IGNORE_SECURITY,
+ CONTEXT_RESTRICTED,
+ CONTEXT_DEVICE_PROTECTED_STORAGE,
+ CONTEXT_CREDENTIAL_PROTECTED_STORAGE,
+ CONTEXT_REGISTER_PACKAGE,
+ })
@Retention(RetentionPolicy.SOURCE)
public @interface CreatePackageOptions {}
@@ -4409,8 +4433,7 @@ public abstract class Context {
* {@link #CONTEXT_INCLUDE_CODE} for more information}.
*
* @param packageName Name of the application's package.
- * @param flags Option flags, one of {@link #CONTEXT_INCLUDE_CODE}
- * or {@link #CONTEXT_IGNORE_SECURITY}.
+ * @param flags Option flags.
*
* @return A {@link Context} for the application.
*
@@ -4429,7 +4452,7 @@ public abstract class Context {
* @hide
*/
public abstract Context createPackageContextAsUser(
- String packageName, int flags, UserHandle user)
+ String packageName, @CreatePackageOptions int flags, UserHandle user)
throws PackageManager.NameNotFoundException;
/**
@@ -4438,7 +4461,7 @@ public abstract class Context {
* @hide
*/
public abstract Context createApplicationContext(ApplicationInfo application,
- int flags) throws PackageManager.NameNotFoundException;
+ @CreatePackageOptions int flags) throws PackageManager.NameNotFoundException;
/**
* Return a new Context object for the given split name. The new Context has a ClassLoader and
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index b6f9ac97e727..9c87ff27caaf 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -19,6 +19,8 @@ package android.content;
import android.annotation.AnyRes;
import android.annotation.BroadcastBehavior;
import android.annotation.IntDef;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
@@ -4903,6 +4905,96 @@ public class Intent implements Parcelable, Cloneable {
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
}
+ /** @hide */
+ @IntDef(flag = true, prefix = { "FLAG_" }, value = {
+ FLAG_GRANT_READ_URI_PERMISSION,
+ FLAG_GRANT_WRITE_URI_PERMISSION,
+ FLAG_FROM_BACKGROUND,
+ FLAG_DEBUG_LOG_RESOLUTION,
+ FLAG_EXCLUDE_STOPPED_PACKAGES,
+ FLAG_INCLUDE_STOPPED_PACKAGES,
+ FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
+ FLAG_GRANT_PREFIX_URI_PERMISSION,
+ FLAG_DEBUG_TRIAGED_MISSING,
+ FLAG_IGNORE_EPHEMERAL,
+ FLAG_ACTIVITY_NO_HISTORY,
+ FLAG_ACTIVITY_SINGLE_TOP,
+ FLAG_ACTIVITY_NEW_TASK,
+ FLAG_ACTIVITY_MULTIPLE_TASK,
+ FLAG_ACTIVITY_CLEAR_TOP,
+ FLAG_ACTIVITY_FORWARD_RESULT,
+ FLAG_ACTIVITY_PREVIOUS_IS_TOP,
+ FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
+ FLAG_ACTIVITY_BROUGHT_TO_FRONT,
+ FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
+ FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
+ FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
+ FLAG_ACTIVITY_NEW_DOCUMENT,
+ FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
+ FLAG_ACTIVITY_NO_USER_ACTION,
+ FLAG_ACTIVITY_REORDER_TO_FRONT,
+ FLAG_ACTIVITY_NO_ANIMATION,
+ FLAG_ACTIVITY_CLEAR_TASK,
+ FLAG_ACTIVITY_TASK_ON_HOME,
+ FLAG_ACTIVITY_RETAIN_IN_RECENTS,
+ FLAG_ACTIVITY_LAUNCH_ADJACENT,
+ FLAG_RECEIVER_REGISTERED_ONLY,
+ FLAG_RECEIVER_REPLACE_PENDING,
+ FLAG_RECEIVER_FOREGROUND,
+ FLAG_RECEIVER_NO_ABORT,
+ FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
+ FLAG_RECEIVER_BOOT_UPGRADE,
+ FLAG_RECEIVER_INCLUDE_BACKGROUND,
+ FLAG_RECEIVER_EXCLUDE_BACKGROUND,
+ FLAG_RECEIVER_FROM_SHELL,
+ FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface Flags {}
+
+ /** @hide */
+ @IntDef(flag = true, prefix = { "FLAG_" }, value = {
+ FLAG_FROM_BACKGROUND,
+ FLAG_DEBUG_LOG_RESOLUTION,
+ FLAG_EXCLUDE_STOPPED_PACKAGES,
+ FLAG_INCLUDE_STOPPED_PACKAGES,
+ FLAG_DEBUG_TRIAGED_MISSING,
+ FLAG_IGNORE_EPHEMERAL,
+ FLAG_ACTIVITY_NO_HISTORY,
+ FLAG_ACTIVITY_SINGLE_TOP,
+ FLAG_ACTIVITY_NEW_TASK,
+ FLAG_ACTIVITY_MULTIPLE_TASK,
+ FLAG_ACTIVITY_CLEAR_TOP,
+ FLAG_ACTIVITY_FORWARD_RESULT,
+ FLAG_ACTIVITY_PREVIOUS_IS_TOP,
+ FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
+ FLAG_ACTIVITY_BROUGHT_TO_FRONT,
+ FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
+ FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
+ FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
+ FLAG_ACTIVITY_NEW_DOCUMENT,
+ FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
+ FLAG_ACTIVITY_NO_USER_ACTION,
+ FLAG_ACTIVITY_REORDER_TO_FRONT,
+ FLAG_ACTIVITY_NO_ANIMATION,
+ FLAG_ACTIVITY_CLEAR_TASK,
+ FLAG_ACTIVITY_TASK_ON_HOME,
+ FLAG_ACTIVITY_RETAIN_IN_RECENTS,
+ FLAG_ACTIVITY_LAUNCH_ADJACENT,
+ FLAG_RECEIVER_REGISTERED_ONLY,
+ FLAG_RECEIVER_REPLACE_PENDING,
+ FLAG_RECEIVER_FOREGROUND,
+ FLAG_RECEIVER_NO_ABORT,
+ FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
+ FLAG_RECEIVER_BOOT_UPGRADE,
+ FLAG_RECEIVER_INCLUDE_BACKGROUND,
+ FLAG_RECEIVER_EXCLUDE_BACKGROUND,
+ FLAG_RECEIVER_FROM_SHELL,
+ FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface MutableFlags {}
+
/**
* If set, the recipient of this Intent will be granted permission to
* perform read operations on the URI in the Intent's data and any URIs
@@ -5369,6 +5461,15 @@ public class Intent implements Parcelable, Cloneable {
// ---------------------------------------------------------------------
// toUri() and parseUri() options.
+ /** @hide */
+ @IntDef(flag = true, prefix = { "URI_" }, value = {
+ URI_ALLOW_UNSAFE,
+ URI_ANDROID_APP_SCHEME,
+ URI_INTENT_SCHEME,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface UriFlags {}
+
/**
* Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
* always has the "intent:" scheme. This syntax can be used when you want
@@ -5538,7 +5639,7 @@ public class Intent implements Parcelable, Cloneable {
* Make a clone of only the parts of the Intent that are relevant for
* filter matching: the action, data, type, component, and categories.
*/
- public Intent cloneFilter() {
+ public @NonNull Intent cloneFilter() {
return new Intent(this, false);
}
@@ -5727,8 +5828,7 @@ public class Intent implements Parcelable, Cloneable {
* the scheme and full path.
*
* @param uri The URI to turn into an Intent.
- * @param flags Additional processing flags. Either 0,
- * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
+ * @param flags Additional processing flags.
*
* @return Intent The newly created Intent object.
*
@@ -5738,7 +5838,7 @@ public class Intent implements Parcelable, Cloneable {
*
* @see #toUri
*/
- public static Intent parseUri(String uri, int flags) throws URISyntaxException {
+ public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
int i = 0;
try {
final boolean androidApp = uri.startsWith("android-app:");
@@ -6568,7 +6668,7 @@ public class Intent implements Parcelable, Cloneable {
*
* @see #setAction
*/
- public String getAction() {
+ public @Nullable String getAction() {
return mAction;
}
@@ -6583,7 +6683,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #getScheme
* @see #setData
*/
- public Uri getData() {
+ public @Nullable Uri getData() {
return mData;
}
@@ -6591,7 +6691,7 @@ public class Intent implements Parcelable, Cloneable {
* The same as {@link #getData()}, but returns the URI as an encoded
* String.
*/
- public String getDataString() {
+ public @Nullable String getDataString() {
return mData != null ? mData.toString() : null;
}
@@ -6607,7 +6707,7 @@ public class Intent implements Parcelable, Cloneable {
*
* @see #getData
*/
- public String getScheme() {
+ public @Nullable String getScheme() {
return mData != null ? mData.getScheme() : null;
}
@@ -6621,7 +6721,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #resolveType(ContentResolver)
* @see #setType
*/
- public String getType() {
+ public @Nullable String getType() {
return mType;
}
@@ -6636,7 +6736,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #getType
* @see #resolveType(ContentResolver)
*/
- public String resolveType(Context context) {
+ public @Nullable String resolveType(@NonNull Context context) {
return resolveType(context.getContentResolver());
}
@@ -6654,7 +6754,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #getType
* @see #resolveType(Context)
*/
- public String resolveType(ContentResolver resolver) {
+ public @Nullable String resolveType(@NonNull ContentResolver resolver) {
if (mType != null) {
return mType;
}
@@ -6678,7 +6778,7 @@ public class Intent implements Parcelable, Cloneable {
* @return The MIME type of this intent, or null if it is unknown or not
* needed.
*/
- public String resolveTypeIfNeeded(ContentResolver resolver) {
+ public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
if (mComponent != null) {
return mType;
}
@@ -6718,7 +6818,7 @@ public class Intent implements Parcelable, Cloneable {
*
* @see #setSelector
*/
- public Intent getSelector() {
+ public @Nullable Intent getSelector() {
return mSelector;
}
@@ -6728,7 +6828,7 @@ public class Intent implements Parcelable, Cloneable {
*
* @see #setClipData
*/
- public ClipData getClipData() {
+ public @Nullable ClipData getClipData() {
return mClipData;
}
@@ -6754,7 +6854,7 @@ public class Intent implements Parcelable, Cloneable {
* @param loader a ClassLoader, or null to use the default loader
* at the time of unmarshalling.
*/
- public void setExtrasClassLoader(ClassLoader loader) {
+ public void setExtrasClassLoader(@Nullable ClassLoader loader) {
if (mExtras != null) {
mExtras.setClassLoader(loader);
}
@@ -7275,7 +7375,7 @@ public class Intent implements Parcelable, Cloneable {
* @return the map of all extras previously added with putExtra(),
* or null if none have been added.
*/
- public Bundle getExtras() {
+ public @Nullable Bundle getExtras() {
return (mExtras != null)
? new Bundle(mExtras)
: null;
@@ -7296,11 +7396,12 @@ public class Intent implements Parcelable, Cloneable {
* normally just set them with {@link #setFlags} and let the system
* take the appropriate action with them.
*
- * @return int The currently set flags.
- *
+ * @return The currently set flags.
* @see #setFlags
+ * @see #addFlags
+ * @see #removeFlags
*/
- public int getFlags() {
+ public @Flags int getFlags() {
return mFlags;
}
@@ -7320,7 +7421,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #resolveActivity
* @see #setPackage
*/
- public String getPackage() {
+ public @Nullable String getPackage() {
return mPackage;
}
@@ -7335,7 +7436,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #resolveActivity
* @see #setComponent
*/
- public ComponentName getComponent() {
+ public @Nullable ComponentName getComponent() {
return mComponent;
}
@@ -7344,7 +7445,7 @@ public class Intent implements Parcelable, Cloneable {
* used as a hint to the receiver for animations and the like. Null means that there
* is no source bounds.
*/
- public Rect getSourceBounds() {
+ public @Nullable Rect getSourceBounds() {
return mSourceBounds;
}
@@ -7395,7 +7496,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #getComponent
* @see #resolveActivityInfo
*/
- public ComponentName resolveActivity(PackageManager pm) {
+ public ComponentName resolveActivity(@NonNull PackageManager pm) {
if (mComponent != null) {
return mComponent;
}
@@ -7427,7 +7528,8 @@ public class Intent implements Parcelable, Cloneable {
*
* @see #resolveActivity
*/
- public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
+ public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
+ @PackageManager.ComponentInfoFlags int flags) {
ActivityInfo ai = null;
if (mComponent != null) {
try {
@@ -7453,7 +7555,8 @@ public class Intent implements Parcelable, Cloneable {
* there are no matches.
* @hide
*/
- public ComponentName resolveSystemService(PackageManager pm, int flags) {
+ public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
+ @PackageManager.ComponentInfoFlags int flags) {
if (mComponent != null) {
return mComponent;
}
@@ -7490,7 +7593,7 @@ public class Intent implements Parcelable, Cloneable {
*
* @see #getAction
*/
- public Intent setAction(String action) {
+ public @NonNull Intent setAction(@Nullable String action) {
mAction = action != null ? action.intern() : null;
return this;
}
@@ -7516,7 +7619,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #setDataAndNormalize
* @see android.net.Uri#normalizeScheme()
*/
- public Intent setData(Uri data) {
+ public @NonNull Intent setData(@Nullable Uri data) {
mData = data;
mType = null;
return this;
@@ -7544,7 +7647,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #setType
* @see android.net.Uri#normalizeScheme
*/
- public Intent setDataAndNormalize(Uri data) {
+ public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
return setData(data.normalizeScheme());
}
@@ -7573,7 +7676,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #setDataAndType
* @see #normalizeMimeType
*/
- public Intent setType(String type) {
+ public @NonNull Intent setType(@Nullable String type) {
mData = null;
mType = type;
return this;
@@ -7604,7 +7707,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #setData
* @see #normalizeMimeType
*/
- public Intent setTypeAndNormalize(String type) {
+ public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
return setType(normalizeMimeType(type));
}
@@ -7633,7 +7736,7 @@ public class Intent implements Parcelable, Cloneable {
* @see android.net.Uri#normalizeScheme
* @see #setDataAndTypeAndNormalize
*/
- public Intent setDataAndType(Uri data, String type) {
+ public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
mData = data;
mType = type;
return this;
@@ -7664,7 +7767,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #normalizeMimeType
* @see android.net.Uri#normalizeScheme
*/
- public Intent setDataAndTypeAndNormalize(Uri data, String type) {
+ public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
}
@@ -7684,7 +7787,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #hasCategory
* @see #removeCategory
*/
- public Intent addCategory(String category) {
+ public @NonNull Intent addCategory(String category) {
if (mCategories == null) {
mCategories = new ArraySet<String>();
}
@@ -7739,7 +7842,7 @@ public class Intent implements Parcelable, Cloneable {
* @param selector The desired selector Intent; set to null to not use
* a special selector.
*/
- public void setSelector(Intent selector) {
+ public void setSelector(@Nullable Intent selector) {
if (selector == this) {
throw new IllegalArgumentException(
"Intent being set as a selector of itself");
@@ -7778,7 +7881,7 @@ public class Intent implements Parcelable, Cloneable {
*
* @param clip The new clip to set. May be null to clear the current clip.
*/
- public void setClipData(ClipData clip) {
+ public void setClipData(@Nullable ClipData clip) {
mClipData = clip;
}
@@ -7811,7 +7914,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getBooleanExtra(String, boolean)
*/
- public Intent putExtra(String name, boolean value) {
+ public @NonNull Intent putExtra(String name, boolean value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -7834,7 +7937,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getByteExtra(String, byte)
*/
- public Intent putExtra(String name, byte value) {
+ public @NonNull Intent putExtra(String name, byte value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -7857,7 +7960,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getCharExtra(String, char)
*/
- public Intent putExtra(String name, char value) {
+ public @NonNull Intent putExtra(String name, char value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -7880,7 +7983,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getShortExtra(String, short)
*/
- public Intent putExtra(String name, short value) {
+ public @NonNull Intent putExtra(String name, short value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -7903,7 +8006,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getIntExtra(String, int)
*/
- public Intent putExtra(String name, int value) {
+ public @NonNull Intent putExtra(String name, int value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -7926,7 +8029,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getLongExtra(String, long)
*/
- public Intent putExtra(String name, long value) {
+ public @NonNull Intent putExtra(String name, long value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -7949,7 +8052,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getFloatExtra(String, float)
*/
- public Intent putExtra(String name, float value) {
+ public @NonNull Intent putExtra(String name, float value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -7972,7 +8075,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getDoubleExtra(String, double)
*/
- public Intent putExtra(String name, double value) {
+ public @NonNull Intent putExtra(String name, double value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -7995,7 +8098,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getStringExtra(String)
*/
- public Intent putExtra(String name, String value) {
+ public @NonNull Intent putExtra(String name, String value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -8018,7 +8121,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getCharSequenceExtra(String)
*/
- public Intent putExtra(String name, CharSequence value) {
+ public @NonNull Intent putExtra(String name, CharSequence value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -8041,7 +8144,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getParcelableExtra(String)
*/
- public Intent putExtra(String name, Parcelable value) {
+ public @NonNull Intent putExtra(String name, Parcelable value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -8064,7 +8167,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getParcelableArrayExtra(String)
*/
- public Intent putExtra(String name, Parcelable[] value) {
+ public @NonNull Intent putExtra(String name, Parcelable[] value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -8087,7 +8190,8 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getParcelableArrayListExtra(String)
*/
- public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
+ public @NonNull Intent putParcelableArrayListExtra(String name,
+ ArrayList<? extends Parcelable> value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -8110,7 +8214,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getIntegerArrayListExtra(String)
*/
- public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
+ public @NonNull Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -8133,7 +8237,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getStringArrayListExtra(String)
*/
- public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
+ public @NonNull Intent putStringArrayListExtra(String name, ArrayList<String> value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -8156,7 +8260,8 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getCharSequenceArrayListExtra(String)
*/
- public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
+ public @NonNull Intent putCharSequenceArrayListExtra(String name,
+ ArrayList<CharSequence> value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -8179,7 +8284,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getSerializableExtra(String)
*/
- public Intent putExtra(String name, Serializable value) {
+ public @NonNull Intent putExtra(String name, Serializable value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -8202,7 +8307,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getBooleanArrayExtra(String)
*/
- public Intent putExtra(String name, boolean[] value) {
+ public @NonNull Intent putExtra(String name, boolean[] value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -8225,7 +8330,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getByteArrayExtra(String)
*/
- public Intent putExtra(String name, byte[] value) {
+ public @NonNull Intent putExtra(String name, byte[] value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -8248,7 +8353,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getShortArrayExtra(String)
*/
- public Intent putExtra(String name, short[] value) {
+ public @NonNull Intent putExtra(String name, short[] value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -8271,7 +8376,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getCharArrayExtra(String)
*/
- public Intent putExtra(String name, char[] value) {
+ public @NonNull Intent putExtra(String name, char[] value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -8294,7 +8399,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getIntArrayExtra(String)
*/
- public Intent putExtra(String name, int[] value) {
+ public @NonNull Intent putExtra(String name, int[] value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -8317,7 +8422,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getLongArrayExtra(String)
*/
- public Intent putExtra(String name, long[] value) {
+ public @NonNull Intent putExtra(String name, long[] value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -8340,7 +8445,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getFloatArrayExtra(String)
*/
- public Intent putExtra(String name, float[] value) {
+ public @NonNull Intent putExtra(String name, float[] value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -8363,7 +8468,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getDoubleArrayExtra(String)
*/
- public Intent putExtra(String name, double[] value) {
+ public @NonNull Intent putExtra(String name, double[] value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -8386,7 +8491,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getStringArrayExtra(String)
*/
- public Intent putExtra(String name, String[] value) {
+ public @NonNull Intent putExtra(String name, String[] value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -8409,7 +8514,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getCharSequenceArrayExtra(String)
*/
- public Intent putExtra(String name, CharSequence[] value) {
+ public @NonNull Intent putExtra(String name, CharSequence[] value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -8432,7 +8537,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #removeExtra
* @see #getBundleExtra(String)
*/
- public Intent putExtra(String name, Bundle value) {
+ public @NonNull Intent putExtra(String name, Bundle value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -8459,7 +8564,7 @@ public class Intent implements Parcelable, Cloneable {
* @hide
*/
@Deprecated
- public Intent putExtra(String name, IBinder value) {
+ public @NonNull Intent putExtra(String name, IBinder value) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -8474,7 +8579,7 @@ public class Intent implements Parcelable, Cloneable {
*
* @see #putExtra
*/
- public Intent putExtras(Intent src) {
+ public @NonNull Intent putExtras(@NonNull Intent src) {
if (src.mExtras != null) {
if (mExtras == null) {
mExtras = new Bundle(src.mExtras);
@@ -8495,7 +8600,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #putExtra
* @see #removeExtra
*/
- public Intent putExtras(Bundle extras) {
+ public @NonNull Intent putExtras(@NonNull Bundle extras) {
if (mExtras == null) {
mExtras = new Bundle();
}
@@ -8510,7 +8615,7 @@ public class Intent implements Parcelable, Cloneable {
* @param src The exact extras contained in this Intent are copied
* into the target intent, replacing any that were previously there.
*/
- public Intent replaceExtras(Intent src) {
+ public @NonNull Intent replaceExtras(@NonNull Intent src) {
mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
return this;
}
@@ -8522,7 +8627,7 @@ public class Intent implements Parcelable, Cloneable {
* @param extras The new set of extras in the Intent, or null to erase
* all extras.
*/
- public Intent replaceExtras(Bundle extras) {
+ public @NonNull Intent replaceExtras(@NonNull Bundle extras) {
mExtras = extras != null ? new Bundle(extras) : null;
return this;
}
@@ -8555,41 +8660,13 @@ public class Intent implements Parcelable, Cloneable {
* the behavior of your application.
*
* @param flags The desired flags.
- *
* @return Returns the same Intent object, for chaining multiple calls
* into a single statement.
- *
* @see #getFlags
* @see #addFlags
* @see #removeFlags
- *
- * @see #FLAG_GRANT_READ_URI_PERMISSION
- * @see #FLAG_GRANT_WRITE_URI_PERMISSION
- * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
- * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
- * @see #FLAG_DEBUG_LOG_RESOLUTION
- * @see #FLAG_FROM_BACKGROUND
- * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
- * @see #FLAG_ACTIVITY_CLEAR_TASK
- * @see #FLAG_ACTIVITY_CLEAR_TOP
- * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
- * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
- * @see #FLAG_ACTIVITY_FORWARD_RESULT
- * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
- * @see #FLAG_ACTIVITY_MULTIPLE_TASK
- * @see #FLAG_ACTIVITY_NEW_DOCUMENT
- * @see #FLAG_ACTIVITY_NEW_TASK
- * @see #FLAG_ACTIVITY_NO_ANIMATION
- * @see #FLAG_ACTIVITY_NO_HISTORY
- * @see #FLAG_ACTIVITY_NO_USER_ACTION
- * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
- * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
- * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
- * @see #FLAG_ACTIVITY_SINGLE_TOP
- * @see #FLAG_ACTIVITY_TASK_ON_HOME
- * @see #FLAG_RECEIVER_REGISTERED_ONLY
- */
- public Intent setFlags(int flags) {
+ */
+ public @NonNull Intent setFlags(@Flags int flags) {
mFlags = flags;
return this;
}
@@ -8600,36 +8677,11 @@ public class Intent implements Parcelable, Cloneable {
* @param flags The new flags to set.
* @return Returns the same Intent object, for chaining multiple calls into
* a single statement.
- * @see #setFlags(int)
- * @see #removeFlags(int)
- *
- * @see #FLAG_GRANT_READ_URI_PERMISSION
- * @see #FLAG_GRANT_WRITE_URI_PERMISSION
- * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
- * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
- * @see #FLAG_DEBUG_LOG_RESOLUTION
- * @see #FLAG_FROM_BACKGROUND
- * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
- * @see #FLAG_ACTIVITY_CLEAR_TASK
- * @see #FLAG_ACTIVITY_CLEAR_TOP
- * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
- * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
- * @see #FLAG_ACTIVITY_FORWARD_RESULT
- * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
- * @see #FLAG_ACTIVITY_MULTIPLE_TASK
- * @see #FLAG_ACTIVITY_NEW_DOCUMENT
- * @see #FLAG_ACTIVITY_NEW_TASK
- * @see #FLAG_ACTIVITY_NO_ANIMATION
- * @see #FLAG_ACTIVITY_NO_HISTORY
- * @see #FLAG_ACTIVITY_NO_USER_ACTION
- * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
- * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
- * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
- * @see #FLAG_ACTIVITY_SINGLE_TOP
- * @see #FLAG_ACTIVITY_TASK_ON_HOME
- * @see #FLAG_RECEIVER_REGISTERED_ONLY
- */
- public Intent addFlags(int flags) {
+ * @see #setFlags
+ * @see #getFlags
+ * @see #removeFlags
+ */
+ public @NonNull Intent addFlags(@Flags int flags) {
mFlags |= flags;
return this;
}
@@ -8638,36 +8690,11 @@ public class Intent implements Parcelable, Cloneable {
* Remove these flags from the intent.
*
* @param flags The flags to remove.
- * @see #setFlags(int)
- * @see #addFlags(int)
- *
- * @see #FLAG_GRANT_READ_URI_PERMISSION
- * @see #FLAG_GRANT_WRITE_URI_PERMISSION
- * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
- * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
- * @see #FLAG_DEBUG_LOG_RESOLUTION
- * @see #FLAG_FROM_BACKGROUND
- * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
- * @see #FLAG_ACTIVITY_CLEAR_TASK
- * @see #FLAG_ACTIVITY_CLEAR_TOP
- * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
- * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
- * @see #FLAG_ACTIVITY_FORWARD_RESULT
- * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
- * @see #FLAG_ACTIVITY_MULTIPLE_TASK
- * @see #FLAG_ACTIVITY_NEW_DOCUMENT
- * @see #FLAG_ACTIVITY_NEW_TASK
- * @see #FLAG_ACTIVITY_NO_ANIMATION
- * @see #FLAG_ACTIVITY_NO_HISTORY
- * @see #FLAG_ACTIVITY_NO_USER_ACTION
- * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
- * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
- * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
- * @see #FLAG_ACTIVITY_SINGLE_TOP
- * @see #FLAG_ACTIVITY_TASK_ON_HOME
- * @see #FLAG_RECEIVER_REGISTERED_ONLY
- */
- public void removeFlags(int flags) {
+ * @see #setFlags
+ * @see #getFlags
+ * @see #addFlags
+ */
+ public void removeFlags(@Flags int flags) {
mFlags &= ~flags;
}
@@ -8687,7 +8714,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #getPackage
* @see #resolveActivity
*/
- public Intent setPackage(String packageName) {
+ public @NonNull Intent setPackage(@Nullable String packageName) {
if (packageName != null && mSelector != null) {
throw new IllegalArgumentException(
"Can't set package name when selector is already set");
@@ -8719,7 +8746,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #getComponent
* @see #resolveActivity
*/
- public Intent setComponent(ComponentName component) {
+ public @NonNull Intent setComponent(@Nullable ComponentName component) {
mComponent = component;
return this;
}
@@ -8739,7 +8766,8 @@ public class Intent implements Parcelable, Cloneable {
* @see #setComponent
* @see #setClass
*/
- public Intent setClassName(Context packageContext, String className) {
+ public @NonNull Intent setClassName(@NonNull Context packageContext,
+ @NonNull String className) {
mComponent = new ComponentName(packageContext, className);
return this;
}
@@ -8759,7 +8787,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #setComponent
* @see #setClass
*/
- public Intent setClassName(String packageName, String className) {
+ public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
mComponent = new ComponentName(packageName, className);
return this;
}
@@ -8778,7 +8806,7 @@ public class Intent implements Parcelable, Cloneable {
*
* @see #setComponent
*/
- public Intent setClass(Context packageContext, Class<?> cls) {
+ public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
mComponent = new ComponentName(packageContext, cls);
return this;
}
@@ -8788,7 +8816,7 @@ public class Intent implements Parcelable, Cloneable {
* used as a hint to the receiver for animations and the like. Null means that there
* is no source bounds.
*/
- public void setSourceBounds(Rect r) {
+ public void setSourceBounds(@Nullable Rect r) {
if (r != null) {
mSourceBounds = new Rect(r);
} else {
@@ -8909,7 +8937,7 @@ public class Intent implements Parcelable, Cloneable {
* changed.
*/
@FillInFlags
- public int fillIn(Intent other, @FillInFlags int flags) {
+ public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
int changes = 0;
boolean mayHaveCopiedUris = false;
if (other.mAction != null
@@ -9257,13 +9285,12 @@ public class Intent implements Parcelable, Cloneable {
* <p>You can convert the returned string back to an Intent with
* {@link #getIntent}.
*
- * @param flags Additional operating flags. Either 0,
- * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
+ * @param flags Additional operating flags.
*
* @return Returns a URI encoding URI string describing the entire contents
* of the Intent.
*/
- public String toUri(int flags) {
+ public String toUri(@UriFlags int flags) {
StringBuilder uri = new StringBuilder(128);
if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
if (mPackage == null) {
@@ -9530,7 +9557,8 @@ public class Intent implements Parcelable, Cloneable {
* @throws XmlPullParserException If there was an XML parsing error.
* @throws IOException If there was an I/O error.
*/
- public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
+ public static @NonNull Intent parseIntent(@NonNull Resources resources,
+ @NonNull XmlPullParser parser, AttributeSet attrs)
throws XmlPullParserException, IOException {
Intent intent = new Intent();
@@ -9677,7 +9705,7 @@ public class Intent implements Parcelable, Cloneable {
* @see #setType
* @see #setTypeAndNormalize
*/
- public static String normalizeMimeType(String type) {
+ public static @Nullable String normalizeMimeType(@Nullable String type) {
if (type == null) {
return null;
}
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 47d79cfba40c..ecaf7ebe07d2 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -522,6 +522,18 @@ public abstract class PackageManager {
*/
public static final int PERMISSION_DENIED = -1;
+ /** @hide */
+ @IntDef(prefix = { "SIGNATURE_" }, value = {
+ SIGNATURE_MATCH,
+ SIGNATURE_NEITHER_SIGNED,
+ SIGNATURE_FIRST_NOT_SIGNED,
+ SIGNATURE_SECOND_NOT_SIGNED,
+ SIGNATURE_NO_MATCH,
+ SIGNATURE_UNKNOWN_PACKAGE,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface SignatureResult {}
+
/**
* Signature check result: this is returned by {@link #checkSignatures}
* if all signatures on the two packages match.
@@ -558,11 +570,25 @@ public abstract class PackageManager {
*/
public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
+ /** @hide */
+ @IntDef(prefix = { "COMPONENT_ENABLED_STATE_" }, value = {
+ COMPONENT_ENABLED_STATE_DEFAULT,
+ COMPONENT_ENABLED_STATE_ENABLED,
+ COMPONENT_ENABLED_STATE_DISABLED,
+ COMPONENT_ENABLED_STATE_DISABLED_USER,
+ COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface EnabledState {}
+
/**
- * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
- * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
- * component or application is in its default enabled state (as specified
- * in its manifest).
+ * Flag for {@link #setApplicationEnabledSetting(String, int, int)} and
+ * {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
+ * component or application is in its default enabled state (as specified in
+ * its manifest).
+ * <p>
+ * Explicitly setting the component state to this value restores it's
+ * enabled state to whatever is set in the manifest.
*/
public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
@@ -764,6 +790,13 @@ public abstract class PackageManager {
*/
public static final int INSTALL_ALLOCATE_AGGRESSIVE = 0x00008000;
+ /** @hide */
+ @IntDef(flag = true, prefix = { "DONT_KILL_APP" }, value = {
+ DONT_KILL_APP
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface EnabledFlags {}
+
/**
* Flag parameter for
* {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
@@ -2871,7 +2904,7 @@ public abstract class PackageManager {
* does not contain such an activity, or if <em>packageName</em> is not
* recognized.
*/
- public abstract Intent getLaunchIntentForPackage(String packageName);
+ public abstract @Nullable Intent getLaunchIntentForPackage(@NonNull String packageName);
/**
* Return a "good" intent to launch a front-door Leanback activity in a
@@ -2885,7 +2918,7 @@ public abstract class PackageManager {
* the main Leanback activity in the package, or null if the package
* does not contain such an activity.
*/
- public abstract Intent getLeanbackLaunchIntentForPackage(String packageName);
+ public abstract @Nullable Intent getLeanbackLaunchIntentForPackage(@NonNull String packageName);
/**
* Return an array of all of the POSIX secondary group IDs that have been
@@ -2901,7 +2934,7 @@ public abstract class PackageManager {
* @throws NameNotFoundException if a package with the given name cannot be
* found on the system.
*/
- public abstract int[] getPackageGids(String packageName)
+ public abstract int[] getPackageGids(@NonNull String packageName)
throws NameNotFoundException;
/**
@@ -3189,7 +3222,7 @@ public abstract class PackageManager {
* @see #PERMISSION_DENIED
*/
@CheckResult
- public abstract int checkPermission(String permName, String pkgName);
+ public abstract @PermissionResult int checkPermission(String permName, String pkgName);
/**
* Checks whether a particular permissions has been revoked for a
@@ -3419,12 +3452,9 @@ public abstract class PackageManager {
* #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
*
* @see #checkSignatures(int, int)
- * @see #SIGNATURE_MATCH
- * @see #SIGNATURE_NO_MATCH
- * @see #SIGNATURE_UNKNOWN_PACKAGE
*/
@CheckResult
- public abstract int checkSignatures(String pkg1, String pkg2);
+ public abstract @SignatureResult int checkSignatures(String pkg1, String pkg2);
/**
* Like {@link #checkSignatures(String, String)}, but takes UIDs of
@@ -3442,12 +3472,9 @@ public abstract class PackageManager {
* #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
*
* @see #checkSignatures(String, String)
- * @see #SIGNATURE_MATCH
- * @see #SIGNATURE_NO_MATCH
- * @see #SIGNATURE_UNKNOWN_PACKAGE
*/
@CheckResult
- public abstract int checkSignatures(int uid1, int uid2);
+ public abstract @SignatureResult int checkSignatures(int uid1, int uid2);
/**
* Retrieve the names of all packages that are associated with a particular
@@ -3881,8 +3908,8 @@ public abstract class PackageManager {
* included by one of the <var>specifics</var> intents. If there are
* no matching activities, an empty list is returned.
*/
- public abstract List<ResolveInfo> queryIntentActivityOptions(
- ComponentName caller, Intent[] specifics, Intent intent, @ResolveInfoFlags int flags);
+ public abstract List<ResolveInfo> queryIntentActivityOptions(@Nullable ComponentName caller,
+ @Nullable Intent[] specifics, Intent intent, @ResolveInfoFlags int flags);
/**
* Retrieve all receivers that can handle a broadcast of the given intent.
@@ -5136,18 +5163,11 @@ public abstract class PackageManager {
* manifest.
*
* @param componentName The component to enable
- * @param newState The new enabled state for the component. The legal values for this state
- * are:
- * {@link #COMPONENT_ENABLED_STATE_ENABLED},
- * {@link #COMPONENT_ENABLED_STATE_DISABLED}
- * and
- * {@link #COMPONENT_ENABLED_STATE_DEFAULT}
- * The last one removes the setting, thereby restoring the component's state to
- * whatever was set in it's manifest (or enabled, by default).
- * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
+ * @param newState The new enabled state for the component.
+ * @param flags Optional behavior flags.
*/
public abstract void setComponentEnabledSetting(ComponentName componentName,
- int newState, int flags);
+ @EnabledState int newState, @EnabledFlags int flags);
/**
* Return the enabled setting for a package component (activity,
@@ -5157,14 +5177,10 @@ public abstract class PackageManager {
* the value originally specified in the manifest has not been modified.
*
* @param componentName The component to retrieve.
- * @return Returns the current enabled state for the component. May
- * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
- * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
- * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the
- * component's enabled state is based on the original information in
- * the manifest as found in {@link ComponentInfo}.
+ * @return Returns the current enabled state for the component.
*/
- public abstract int getComponentEnabledSetting(ComponentName componentName);
+ public abstract @EnabledState int getComponentEnabledSetting(
+ ComponentName componentName);
/**
* Set the enabled setting for an application
@@ -5174,18 +5190,11 @@ public abstract class PackageManager {
* {@link #setComponentEnabledSetting} for any of the application's components.
*
* @param packageName The package name of the application to enable
- * @param newState The new enabled state for the component. The legal values for this state
- * are:
- * {@link #COMPONENT_ENABLED_STATE_ENABLED},
- * {@link #COMPONENT_ENABLED_STATE_DISABLED}
- * and
- * {@link #COMPONENT_ENABLED_STATE_DEFAULT}
- * The last one removes the setting, thereby restoring the applications's state to
- * whatever was set in its manifest (or enabled, by default).
- * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
+ * @param newState The new enabled state for the application.
+ * @param flags Optional behavior flags.
*/
public abstract void setApplicationEnabledSetting(String packageName,
- int newState, int flags);
+ @EnabledState int newState, @EnabledFlags int flags);
/**
* Return the enabled setting for an application. This returns
@@ -5195,15 +5204,10 @@ public abstract class PackageManager {
* the value originally specified in the manifest has not been modified.
*
* @param packageName The package name of the application to retrieve.
- * @return Returns the current enabled state for the application. May
- * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
- * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
- * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the
- * application's enabled state is based on the original information in
- * the manifest as found in {@link ApplicationInfo}.
+ * @return Returns the current enabled state for the application.
* @throws IllegalArgumentException if the named package does not exist.
*/
- public abstract int getApplicationEnabledSetting(String packageName);
+ public abstract @EnabledState int getApplicationEnabledSetting(String packageName);
/**
* Flush the package restrictions for a given user to disk. This forces the package restrictions