diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 014c4eee39248..46c49ce4acb87 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -783,13 +783,19 @@ package android.app { } public class BroadcastOptions { + method public void clearDeliveryGroupMatchingFilter(); + method public void clearDeliveryGroupMatchingKey(); method public void clearDeliveryGroupPolicy(); method public void clearRequireCompatChange(); + method @Nullable public android.content.IntentFilter getDeliveryGroupMatchingFilter(); + method @Nullable public String getDeliveryGroupMatchingKey(); method public int getDeliveryGroupPolicy(); method public boolean isPendingIntentBackgroundActivityLaunchAllowed(); method public static android.app.BroadcastOptions makeBasic(); method @RequiresPermission(android.Manifest.permission.ACCESS_BROADCAST_RESPONSE_STATS) public void recordResponseEventWhileInBackground(@IntRange(from=0) long); method @RequiresPermission(android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND) public void setBackgroundActivityStartsAllowed(boolean); + method public void setDeliveryGroupMatchingFilter(@NonNull android.content.IntentFilter); + method public void setDeliveryGroupMatchingKey(@NonNull String, @NonNull String); method public void setDeliveryGroupPolicy(int); method public void setDontSendToRestrictedApps(boolean); method public void setPendingIntentBackgroundActivityLaunchAllowed(boolean); @@ -3218,7 +3224,9 @@ package android.content { } public class IntentFilter implements android.os.Parcelable { + method @NonNull public final android.os.PersistableBundle getExtras(); method public final int getOrder(); + method public final void setExtras(@NonNull android.os.PersistableBundle); method public final void setOrder(int); } diff --git a/core/java/android/app/BroadcastOptions.java b/core/java/android/app/BroadcastOptions.java index 1777f37202c2b..f25e639a9c806 100644 --- a/core/java/android/app/BroadcastOptions.java +++ b/core/java/android/app/BroadcastOptions.java @@ -66,8 +66,9 @@ public class BroadcastOptions extends ComponentOptions { private long mIdForResponseEvent; private @Nullable IntentFilter mRemoveMatchingFilter; private @DeliveryGroupPolicy int mDeliveryGroupPolicy; - private @Nullable String mDeliveryGroupKey; + private @Nullable String mDeliveryGroupMatchingKey; private @Nullable BundleMerger mDeliveryGroupExtrasMerger; + private @Nullable IntentFilter mDeliveryGroupMatchingFilter; /** * Change ID which is invalid. @@ -206,10 +207,10 @@ public class BroadcastOptions extends ComponentOptions { "android:broadcast.deliveryGroupPolicy"; /** - * Corresponds to {@link #setDeliveryGroupKey(String, String)}. + * Corresponds to {@link #setDeliveryGroupMatchingKey(String, String)}. */ private static final String KEY_DELIVERY_GROUP_KEY = - "android:broadcast.deliveryGroupKey"; + "android:broadcast.deliveryGroupMatchingKey"; /** * Corresponds to {@link #setDeliveryGroupExtrasMerger(BundleMerger)}. @@ -217,6 +218,12 @@ public class BroadcastOptions extends ComponentOptions { private static final String KEY_DELIVERY_GROUP_EXTRAS_MERGER = "android:broadcast.deliveryGroupExtrasMerger"; + /** + * Corresponds to {@link #setDeliveryGroupMatchingFilter(IntentFilter)}. + */ + private static final String KEY_DELIVERY_GROUP_MATCHING_FILTER = + "android:broadcast.deliveryGroupMatchingFilter"; + /** * The list of delivery group policies which specify how multiple broadcasts belonging to * the same delivery group has to be handled. @@ -304,9 +311,11 @@ public class BroadcastOptions extends ComponentOptions { IntentFilter.class); mDeliveryGroupPolicy = opts.getInt(KEY_DELIVERY_GROUP_POLICY, DELIVERY_GROUP_POLICY_ALL); - mDeliveryGroupKey = opts.getString(KEY_DELIVERY_GROUP_KEY); + mDeliveryGroupMatchingKey = opts.getString(KEY_DELIVERY_GROUP_KEY); mDeliveryGroupExtrasMerger = opts.getParcelable(KEY_DELIVERY_GROUP_EXTRAS_MERGER, BundleMerger.class); + mDeliveryGroupMatchingFilter = opts.getParcelable(KEY_DELIVERY_GROUP_MATCHING_FILTER, + IntentFilter.class); } /** @@ -733,7 +742,7 @@ public class BroadcastOptions extends ComponentOptions { /** * Clears any previously set delivery group policies using - * {@link #setDeliveryGroupKey(String, String)} and resets the delivery group policy to + * {@link #setDeliveryGroupMatchingKey(String, String)} and resets the delivery group policy to * the default value ({@link #DELIVERY_GROUP_POLICY_ALL}). * * @hide @@ -745,22 +754,92 @@ public class BroadcastOptions extends ComponentOptions { /** * Set namespace and key to identify the delivery group that this broadcast belongs to. - * If no namespace and key is set, then by default {@link Intent#filterEquals(Intent)} will be - * used to identify the delivery group. + * + *
If {@code namespace} and {@code key} are specified, then another broadcast will be + * considered to be in the same delivery group as this iff it has the same {@code namespace} + * and {@code key}. + * + *
If neither matching key using this API nor matching filter using + * {@link #setDeliveryGroupMatchingFilter(IntentFilter)} is specified, then by default + * {@link Intent#filterEquals(Intent)} will be used to identify the delivery group. * * @hide */ - public void setDeliveryGroupKey(@NonNull String namespace, @NonNull String key) { + @SystemApi + public void setDeliveryGroupMatchingKey(@NonNull String namespace, @NonNull String key) { Preconditions.checkArgument(!namespace.contains("/"), "namespace should not contain '/'"); Preconditions.checkArgument(!key.contains("/"), "key should not contain '/'"); - mDeliveryGroupKey = namespace + "/" + key; + mDeliveryGroupMatchingKey = namespace + "/" + key; } - /** @hide */ - public String getDeliveryGroupKey() { - return mDeliveryGroupKey; + /** + * Return the namespace and key that is used to identify the delivery group that this + * broadcast belongs to. + * + * @return the delivery group namespace and key that was previously set using + * {@link #setDeliveryGroupMatchingKey(String, String)}, concatenated with a {@code /}. + * @hide + */ + @SystemApi + @Nullable + public String getDeliveryGroupMatchingKey() { + return mDeliveryGroupMatchingKey; + } + + /** + * Clears the namespace and key that was previously set using + * {@link #setDeliveryGroupMatchingKey(String, String)}. + * + * @hide + */ + @SystemApi + public void clearDeliveryGroupMatchingKey() { + mDeliveryGroupMatchingKey = null; + } + + /** + * Set the {@link IntentFilter} object to identify the delivery group that this broadcast + * belongs to. + * + *
If a {@code matchingFilter} is specified, then another broadcast will be considered + * to be in the same delivery group as this iff the {@code matchingFilter} matches it's intent. + * + *
If neither matching key using {@link #setDeliveryGroupMatchingKey(String, String)} nor
+ * matching filter using this API is specified, then by default
+ * {@link Intent#filterEquals(Intent)} will be used to identify the delivery group.
+ *
+ * @hide
+ */
+ @SystemApi
+ public void setDeliveryGroupMatchingFilter(@NonNull IntentFilter matchingFilter) {
+ mDeliveryGroupMatchingFilter = Objects.requireNonNull(matchingFilter);
+ }
+
+ /**
+ * Return the {@link IntentFilter} object that is used to identify the delivery group
+ * that this broadcast belongs to.
+ *
+ * @return the {@link IntentFilter} object that was previously set using
+ * {@link #setDeliveryGroupMatchingFilter(IntentFilter)}.
+ * @hide
+ */
+ @SystemApi
+ @Nullable
+ public IntentFilter getDeliveryGroupMatchingFilter() {
+ return mDeliveryGroupMatchingFilter;
+ }
+
+ /**
+ * Clears the {@link IntentFilter} object that was previously set using
+ * {@link #setDeliveryGroupMatchingFilter(IntentFilter)}.
+ *
+ * @hide
+ */
+ @SystemApi
+ public void clearDeliveryGroupMatchingFilter() {
+ mDeliveryGroupMatchingFilter = null;
}
/**
@@ -773,15 +852,32 @@ public class BroadcastOptions extends ComponentOptions {
* @hide
*/
public void setDeliveryGroupExtrasMerger(@NonNull BundleMerger extrasMerger) {
- Preconditions.checkNotNull(extrasMerger);
- mDeliveryGroupExtrasMerger = extrasMerger;
+ mDeliveryGroupExtrasMerger = Objects.requireNonNull(extrasMerger);
}
- /** @hide */
- public @Nullable BundleMerger getDeliveryGroupExtrasMerger() {
+ /**
+ * Return the {@link BundleMerger} that specifies how to merge the extras data from
+ * broadcasts in a delivery group.
+ *
+ * @return the {@link BundleMerger} object that was previously set using
+ * {@link #setDeliveryGroupExtrasMerger(BundleMerger)}.
+ * @hide
+ */
+ @Nullable
+ public BundleMerger getDeliveryGroupExtrasMerger() {
return mDeliveryGroupExtrasMerger;
}
+ /**
+ * Clear the {@link BundleMerger} object that was previously set using
+ * {@link #setDeliveryGroupExtrasMerger(BundleMerger)}.
+ *
+ * @hide
+ */
+ public void clearDeliveryGroupExtrasMerger() {
+ mDeliveryGroupExtrasMerger = null;
+ }
+
/**
* Returns the created options as a Bundle, which can be passed to
* {@link android.content.Context#sendBroadcast(android.content.Intent)
@@ -837,8 +933,8 @@ public class BroadcastOptions extends ComponentOptions {
if (mDeliveryGroupPolicy != DELIVERY_GROUP_POLICY_ALL) {
b.putInt(KEY_DELIVERY_GROUP_POLICY, mDeliveryGroupPolicy);
}
- if (mDeliveryGroupKey != null) {
- b.putString(KEY_DELIVERY_GROUP_KEY, mDeliveryGroupKey);
+ if (mDeliveryGroupMatchingKey != null) {
+ b.putString(KEY_DELIVERY_GROUP_KEY, mDeliveryGroupMatchingKey);
}
if (mDeliveryGroupPolicy == DELIVERY_GROUP_POLICY_MERGED) {
if (mDeliveryGroupExtrasMerger != null) {
@@ -849,6 +945,9 @@ public class BroadcastOptions extends ComponentOptions {
+ "when delivery group policy is 'MERGED'");
}
}
+ if (mDeliveryGroupMatchingFilter != null) {
+ b.putParcelable(KEY_DELIVERY_GROUP_MATCHING_FILTER, mDeliveryGroupMatchingFilter);
+ }
return b.isEmpty() ? null : b;
}
}
diff --git a/core/java/android/content/IntentFilter.java b/core/java/android/content/IntentFilter.java
index 8b6c4dd8497b1..bff27d35cc239 100644
--- a/core/java/android/content/IntentFilter.java
+++ b/core/java/android/content/IntentFilter.java
@@ -23,9 +23,11 @@ import android.annotation.SystemApi;
import android.compat.annotation.UnsupportedAppUsage;
import android.net.Uri;
import android.os.Build;
+import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.PatternMatcher;
+import android.os.PersistableBundle;
import android.text.TextUtils;
import android.util.AndroidException;
import android.util.ArraySet;
@@ -171,6 +173,13 @@ public class IntentFilter implements Parcelable {
private static final String NAME_STR = "name";
private static final String ACTION_STR = "action";
private static final String AUTO_VERIFY_STR = "autoVerify";
+ private static final String EXTRAS_STR = "extras";
+
+ private static final int[] EMPTY_INT_ARRAY = new int[0];
+ private static final long[] EMPTY_LONG_ARRAY = new long[0];
+ private static final double[] EMPTY_DOUBLE_ARRAY = new double[0];
+ private static final String[] EMPTY_STRING_ARRAY = new String[0];
+ private static final boolean[] EMPTY_BOOLEAN_ARRAY = new boolean[0];
/**
* The filter {@link #setPriority} value at which system high-priority
@@ -267,6 +276,11 @@ public class IntentFilter implements Parcelable {
* that were not in the Intent.
*/
public static final int NO_MATCH_CATEGORY = -4;
+ /**
+ * That filter didn't match due to different extras data.
+ * @hide
+ */
+ public static final int NO_MATCH_EXTRAS = -5;
/**
* HTTP scheme.
@@ -314,6 +328,7 @@ public class IntentFilter implements Parcelable {
private ArrayList An intent con have other extras in addition to those specified
+ * by the filter and it would not affect whether the match succeeds or not.
+ *
+ * @param extras The extras included in the intent, as returned by
+ * Intent.getExtras().
+ *
+ * @return If all extras match (success), null; else the name of the
+ * first extra that didn't match.
+ *
+ * @hide
+ */
+ private String matchExtras(@Nullable Bundle extras) {
+ if (mExtras == null) {
+ return null;
+ }
+ final Set Subsequent calls to this method with the same {@code name} will override any previously
+ * set {@code value}.
+ *
+ * @param name the name of the extra to match against.
+ * @param value the value of the extra to match against.
+ *
+ * @hide
+ */
+ public final void addExtra(@NonNull String name, int value) {
+ Objects.requireNonNull(name);
+ if (mExtras == null) {
+ mExtras = new PersistableBundle();
+ }
+ mExtras.putInt(name, value);
+ }
+
+ /**
+ * Return the value of the extra with {@code name} included in the filter.
+ *
+ * @return the value that was previously set using {@link #addExtra(String, int)} or
+ * {@code 0} if no value has been set.
+ * @hide
+ */
+ public final int getIntExtra(@NonNull String name) {
+ Objects.requireNonNull(name);
+ return mExtras == null ? 0 : mExtras.getInt(name);
+ }
+
+ /**
+ * Add a new extra name and value to match against. If an extra is included in the filter,
+ * then an Intent must have an extra with the same {@code name} and {@code value} for it to
+ * match.
+ *
+ * Subsequent calls to this method with the same {@code name} will override any previously
+ * set {@code value}.
+ *
+ * @param name the name of the extra to match against.
+ * @param value the value of the extra to match against.
+ *
+ * @hide
+ */
+ public final void addExtra(@NonNull String name, @NonNull int[] value) {
+ Objects.requireNonNull(name);
+ Objects.requireNonNull(value);
+ if (mExtras == null) {
+ mExtras = new PersistableBundle();
+ }
+ mExtras.putIntArray(name, value);
+ }
+
+ /**
+ * Return the value of the extra with {@code name} included in the filter.
+ *
+ * @return the value that was previously set using {@link #addExtra(String, int[])} or
+ * an empty int array if no value has been set.
+ * @hide
+ */
+ @NonNull
+ public final int[] getIntArrayExtra(@NonNull String name) {
+ Objects.requireNonNull(name);
+ return mExtras == null ? EMPTY_INT_ARRAY : mExtras.getIntArray(name);
+ }
+
+ /**
+ * Add a new extra name and value to match against. If an extra is included in the filter,
+ * then an Intent must have an extra with the same {@code name} and {@code value} for it to
+ * match.
+ *
+ * Subsequent calls to this method with the same {@code name} will override any previously
+ * set {@code value}.
+ *
+ * @param name the name of the extra to match against.
+ * @param value the value of the extra to match against.
+ *
+ * @hide
+ */
+ public final void addExtra(@NonNull String name, long value) {
+ Objects.requireNonNull(name);
+ if (mExtras == null) {
+ mExtras = new PersistableBundle();
+ }
+ mExtras.putLong(name, value);
+ }
+
+ /**
+ * Return the value of the extra with {@code name} included in the filter.
+ *
+ * @return the value that was previously set using {@link #addExtra(String, long)} or
+ * {@code 0L} if no value has been set.
+ * @hide
+ */
+ public final long getLongExtra(@NonNull String name) {
+ Objects.requireNonNull(name);
+ return mExtras == null ? 0L : mExtras.getLong(name);
+ }
+
+ /**
+ * Add a new extra name and value to match against. If an extra is included in the filter,
+ * then an Intent must have an extra with the same {@code name} and {@code value} for it to
+ * match.
+ *
+ * Subsequent calls to this method with the same {@code name} will override any previously
+ * set {@code value}.
+ *
+ * @param name the name of the extra to match against.
+ * @param value the value of the extra to match against.
+ *
+ * @hide
+ */
+ public final void addExtra(@NonNull String name, @NonNull long[] value) {
+ Objects.requireNonNull(name);
+ Objects.requireNonNull(value);
+ if (mExtras == null) {
+ mExtras = new PersistableBundle();
+ }
+ mExtras.putLongArray(name, value);
+ }
+
+ /**
+ * Return the value of the extra with {@code name} included in the filter.
+ *
+ * @return the value that was previously set using {@link #addExtra(String, long[])} or
+ * an empty long array if no value has been set.
+ * @hide
+ */
+ @NonNull
+ public final long[] getLongArrayExtra(@NonNull String name) {
+ Objects.requireNonNull(name);
+ return mExtras == null ? EMPTY_LONG_ARRAY : mExtras.getLongArray(name);
+ }
+
+ /**
+ * Add a new extra name and value to match against. If an extra is included in the filter,
+ * then an Intent must have an extra with the same {@code name} and {@code value} for it to
+ * match.
+ *
+ * Subsequent calls to this method with the same {@code name} will override any previously
+ * set {@code value}.
+ *
+ * @param name the name of the extra to match against.
+ * @param value the value of the extra to match against.
+ *
+ * @hide
+ */
+ public final void addExtra(@NonNull String name, double value) {
+ Objects.requireNonNull(name);
+ if (mExtras == null) {
+ mExtras = new PersistableBundle();
+ }
+ mExtras.putDouble(name, value);
+ }
+
+ /**
+ * Return the value of the extra with {@code name} included in the filter.
+ *
+ * @return the value that was previously set using {@link #addExtra(String, double)} or
+ * {@code 0.0} if no value has been set.
+ * @hide
+ */
+ @NonNull
+ public final double getDoubleExtra(@NonNull String name) {
+ Objects.requireNonNull(name);
+ return mExtras == null ? 0.0 : mExtras.getDouble(name);
+ }
+
+ /**
+ * Add a new extra name and value to match against. If an extra is included in the filter,
+ * then an Intent must have an extra with the same {@code name} and {@code value} for it to
+ * match.
+ *
+ * Subsequent calls to this method with the same {@code name} will override any previously
+ * set {@code value}.
+ *
+ * @param name the name of the extra to match against.
+ * @param value the value of the extra to match against.
+ *
+ * @hide
+ */
+ public final void addExtra(@NonNull String name, @NonNull double[] value) {
+ Objects.requireNonNull(name);
+ Objects.requireNonNull(value);
+ if (mExtras == null) {
+ mExtras = new PersistableBundle();
+ }
+ mExtras.putDoubleArray(name, value);
+ }
+
+ /**
+ * Return the value of the extra with {@code name} included in the filter.
+ *
+ * @return the value that was previously set using {@link #addExtra(String, double[])} or
+ * an empty double array if no value has been set.
+ * @hide
+ */
+ @NonNull
+ public final double[] getDoubleArrayExtra(@NonNull String name) {
+ Objects.requireNonNull(name);
+ return mExtras == null ? EMPTY_DOUBLE_ARRAY : mExtras.getDoubleArray(name);
+ }
+
+ /**
+ * Add a new extra name and value to match against. If an extra is included in the filter,
+ * then an Intent must have an extra with the same {@code name} and {@code value} for it to
+ * match.
+ *
+ * Subsequent calls to this method with the same {@code name} will override any previously
+ * set {@code value}.
+ *
+ * @param name the name of the extra to match against.
+ * @param value the value of the extra to match against.
+ *
+ * @hide
+ */
+ public final void addExtra(@NonNull String name, @NonNull String value) {
+ Objects.requireNonNull(name);
+ Objects.requireNonNull(value);
+ if (mExtras == null) {
+ mExtras = new PersistableBundle();
+ }
+ mExtras.putString(name, value);
+ }
+
+ /**
+ * Return the value of the extra with {@code name} included in the filter.
+ *
+ * @return the value that was previously set using {@link #addExtra(String, String)} or a
+ * {@code null} if no value has been set.
+ * @hide
+ */
+ @Nullable
+ public final String getStringExtra(@NonNull String name) {
+ Objects.requireNonNull(name);
+ return mExtras == null ? null : mExtras.getString(name);
+ }
+
+ /**
+ * Add a new extra name and value to match against. If an extra is included in the filter,
+ * then an Intent must have an extra with the same {@code name} and {@code value} for it to
+ * match.
+ *
+ * Subsequent calls to this method with the same {@code name} will override any previously
+ * set {@code value}.
+ *
+ * @param name the name of the extra to match against.
+ * @param value the value of the extra to match against.
+ *
+ * @hide
+ */
+ public final void addExtra(@NonNull String name, @NonNull String[] value) {
+ Objects.requireNonNull(name);
+ Objects.requireNonNull(value);
+ if (mExtras == null) {
+ mExtras = new PersistableBundle();
+ }
+ mExtras.putStringArray(name, value);
+ }
+
+ /**
+ * Return the value of the extra with {@code name} included in the filter.
+ *
+ * @return the value that was previously set using {@link #addExtra(String, String[])} or
+ * an empty string array if no value has been set.
+ * @hide
+ */
+ @NonNull
+ public final String[] getStringArrayExtra(@NonNull String name) {
+ Objects.requireNonNull(name);
+ return mExtras == null ? EMPTY_STRING_ARRAY : mExtras.getStringArray(name);
+ }
+
+ /**
+ * Add a new extra name and value to match against. If an extra is included in the filter,
+ * then an Intent must have an extra with the same {@code name} and {@code value} for it to
+ * match.
+ *
+ * Subsequent calls to this method with the same {@code name} will override any previously
+ * set {@code value}.
+ *
+ * @param name the name of the extra to match against.
+ * @param value the value of the extra to match against.
+ *
+ * @hide
+ */
+ public final void addExtra(@NonNull String name, boolean value) {
+ Objects.requireNonNull(name);
+ if (mExtras == null) {
+ mExtras = new PersistableBundle();
+ }
+ mExtras.putBoolean(name, value);
+ }
+
+ /**
+ * Return the value of the extra with {@code name} included in the filter.
+ *
+ * @return the value that was previously set using {@link #addExtra(String, boolean)} or
+ * {@code false} if no value has been set.
+ * @hide
+ */
+ public final boolean getBooleanExtra(@NonNull String name) {
+ Objects.requireNonNull(name);
+ return mExtras == null ? false : mExtras.getBoolean(name);
+ }
+
+ /**
+ * Add a new extra name and value to match against. If an extra is included in the filter,
+ * then an Intent must have an extra with the same {@code name} and {@code value} for it to
+ * match.
+ *
+ * Subsequent calls to this method with the same {@code name} will override any previously
+ * set {@code value}.
+ *
+ * @param name the name of the extra to match against.
+ * @param value the value of the extra to match against.
+ *
+ * @hide
+ */
+ public final void addExtra(@NonNull String name, @NonNull boolean[] value) {
+ Objects.requireNonNull(name);
+ Objects.requireNonNull(value);
+ if (mExtras == null) {
+ mExtras = new PersistableBundle();
+ }
+ mExtras.putBooleanArray(name, value);
+ }
+
+ /**
+ * Return the value of the extra with {@code name} included in the filter.
+ *
+ * @return the value that was previously set using {@link #addExtra(String, boolean[])} or
+ * an empty boolean array if no value has been set.
+ * @hide
+ */
+ @NonNull
+ public final boolean[] getBooleanArrayExtra(@NonNull String name) {
+ Objects.requireNonNull(name);
+ return mExtras == null ? EMPTY_BOOLEAN_ARRAY : mExtras.getBooleanArray(name);
+ }
+
+ /**
+ * Returns whether or not an extra with {@code name} is included in the filter.
+ *
+ * @return {@code true} if an extra with {@code name} is included in the filter.
+ * Otherwise {@code false}.
+ * @hide
+ */
+ public final boolean hasExtra(@NonNull String name) {
+ Objects.requireNonNull(name);
+ return mExtras == null ? false : mExtras.containsKey(name);
+ }
+
+ /**
+ * Set the intent extras to match against. For this filter to match an
+ * intent, it must contain all the {@code extras} set.
+ *
+ * Subsequent calls to this method will override any previously set extras.
+ *
+ * @param extras The intent extras to match against.
+ * @hide
+ */
+ @SystemApi
+ public final void setExtras(@NonNull PersistableBundle extras) {
+ mExtras = extras;
+ }
+
+ /**
+ * Return the intent extras included in this filter.
+ *
+ * @return the extras that were previously set using {@link #setExtras(PersistableBundle)} or
+ * an empty {@link PersistableBundle} object if no extras were set.
+ * @hide
+ */
+ @SystemApi
+ @NonNull
+ public final PersistableBundle getExtras() {
+ return mExtras == null ? new PersistableBundle() : mExtras;
+ }
+
/**
* Return a {@link Predicate} which tests whether this filter matches the
* given intent.
@@ -1818,7 +2253,9 @@ public class IntentFilter implements Parcelable {
boolean resolve, String logTag) {
String type = resolve ? intent.resolveType(resolver) : intent.getType();
return match(intent.getAction(), type, intent.getScheme(),
- intent.getData(), intent.getCategories(), logTag);
+ intent.getData(), intent.getCategories(), logTag,
+ false /* supportWildcards */, null /* ignoreActions */,
+ intent.getExtras());
}
/**
@@ -1868,6 +2305,19 @@ public class IntentFilter implements Parcelable {
public final int match(String action, String type, String scheme,
Uri data, Set