diff options
author | Jacky Kao <jackykao@google.com> | 2021-10-05 02:08:29 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-10-05 02:08:29 +0000 |
commit | 1a894180c96ec128278a295cc818f7b00d0293a6 (patch) | |
tree | f82e5eecb0e7bab4a3e2dc2212a4d0b1cd2f0759 | |
parent | 7e5da1ee2e9f29689113324f438b4e1002b5a3c0 (diff) | |
parent | 98ff8ecdaa5be2426d09c557ff70f234a1369fb0 (diff) | |
download | base-1a894180c96ec128278a295cc818f7b00d0293a6.tar.gz |
Merge "Revert "Cherrypicking flags and override methods for allowing dy..."" am: 98ff8ecdaa
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1842721
Change-Id: Ieaed4fcc2fa97db551a70f4a3076b4237acfb8ab
-rw-r--r-- | core/api/current.txt | 2 | ||||
-rw-r--r-- | core/api/system-current.txt | 1 | ||||
-rw-r--r-- | core/java/android/app/ContextImpl.java | 14 | ||||
-rw-r--r-- | core/java/android/content/Context.java | 103 | ||||
-rw-r--r-- | core/java/android/content/ContextWrapper.java | 26 | ||||
-rw-r--r-- | test-mock/src/android/test/mock/MockContext.java | 15 |
6 files changed, 9 insertions, 152 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index 1cd3a60a8a9b..09f10aa95834 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -10687,8 +10687,6 @@ package android.content { field public static final String PERFORMANCE_HINT_SERVICE = "performance_hint"; field public static final String POWER_SERVICE = "power"; field public static final String PRINT_SERVICE = "print"; - field public static final int RECEIVER_EXPORTED = 2; // 0x2 - field public static final int RECEIVER_NOT_EXPORTED = 4; // 0x4 field public static final int RECEIVER_VISIBLE_TO_INSTANT_APPS = 1; // 0x1 field public static final String RESTRICTIONS_SERVICE = "restrictions"; field public static final String ROLE_SERVICE = "role"; diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 4a732e544722..35e169ba2953 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -2340,7 +2340,6 @@ package android.content { method @Nullable public abstract java.io.File getPreloadsFileCache(); method public abstract boolean isCredentialProtectedStorage(); method @Nullable @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) public android.content.Intent registerReceiverForAllUsers(@Nullable android.content.BroadcastReceiver, @NonNull android.content.IntentFilter, @Nullable String, @Nullable android.os.Handler); - method @Nullable @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) public android.content.Intent registerReceiverForAllUsers(@Nullable android.content.BroadcastReceiver, @NonNull android.content.IntentFilter, @Nullable String, @Nullable android.os.Handler, int); method public abstract void sendBroadcast(android.content.Intent, @Nullable String, @Nullable android.os.Bundle); method @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) public abstract void sendBroadcastAsUser(@RequiresPermission android.content.Intent, android.os.UserHandle, @Nullable String, @Nullable android.os.Bundle); method public abstract void sendOrderedBroadcast(@NonNull android.content.Intent, @Nullable String, @Nullable android.os.Bundle, @Nullable android.content.BroadcastReceiver, @Nullable android.os.Handler, int, @Nullable String, @Nullable android.os.Bundle); diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index c36b585d3183..4db1f71e8256 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -1739,26 +1739,12 @@ class ContextImpl extends Context { } @Override - public Intent registerReceiverForAllUsers(BroadcastReceiver receiver, - IntentFilter filter, String broadcastPermission, Handler scheduler, int flags) { - return registerReceiverAsUser(receiver, UserHandle.ALL, - filter, broadcastPermission, scheduler, flags); - } - - @Override public Intent registerReceiverAsUser(BroadcastReceiver receiver, UserHandle user, IntentFilter filter, String broadcastPermission, Handler scheduler) { return registerReceiverInternal(receiver, user.getIdentifier(), filter, broadcastPermission, scheduler, getOuterContext(), 0); } - @Override - public Intent registerReceiverAsUser(BroadcastReceiver receiver, UserHandle user, - IntentFilter filter, String broadcastPermission, Handler scheduler, int flags) { - return registerReceiverInternal(receiver, user.getIdentifier(), - filter, broadcastPermission, scheduler, getOuterContext(), flags); - } - private Intent registerReceiverInternal(BroadcastReceiver receiver, int userId, IntentFilter filter, String broadcastPermission, Handler scheduler, Context context, int flags) { diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 2aec066dd3d7..27027721109d 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -534,8 +534,8 @@ public abstract class Context { | Context.BIND_NOT_PERCEPTIBLE | Context.BIND_NOT_VISIBLE; /** @hide */ - @IntDef(flag = true, prefix = { "RECEIVER_VISIBLE" }, value = { - RECEIVER_VISIBLE_TO_INSTANT_APPS, RECEIVER_EXPORTED, RECEIVER_NOT_EXPORTED + @IntDef(flag = true, prefix = { "RECEIVER_VISIBLE_" }, value = { + RECEIVER_VISIBLE_TO_INSTANT_APPS }) @Retention(RetentionPolicy.SOURCE) public @interface RegisterReceiverFlags {} @@ -546,18 +546,6 @@ public abstract class Context { public static final int RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x1; /** - * Flag for {@link #registerReceiver}: The receiver can receive broadcasts from other Apps. - * Has the same behavior as marking a statically registered receiver with "exported=true" - */ - public static final int RECEIVER_EXPORTED = 0x2; - - /** - * Flag for {@link #registerReceiver}: The receiver cannot receive broadcasts from other Apps. - * Has the same behavior as marking a statically registered receiver with "exported=false" - */ - public static final int RECEIVER_NOT_EXPORTED = 0x4; - - /** * Returns an AssetManager instance for the application's package. * <p> * <strong>Note:</strong> Implementations of this method should return @@ -3001,12 +2989,8 @@ public abstract class Context { * * @param receiver The BroadcastReceiver to handle the broadcast. * @param filter Selects the Intent broadcasts to be received. - * @param flags Additional options for the receiver. As of - * {@link android.os.Build.VERSION_CODES#TIRAMISU}, either {@link #RECEIVER_EXPORTED} or - * {@link #RECEIVER_NOT_EXPORTED} must be specified if the receiver isn't being registered - * for protected broadcasts, and may additionally specify - * {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS} if {@link #RECEIVER_EXPORTED} is - * specified. + * @param flags Additional options for the receiver. May be 0 or + * {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. * * @return The first sticky intent found that matches <var>filter</var>, * or null if there are none. @@ -3078,12 +3062,8 @@ public abstract class Context { * no permission is required. * @param scheduler Handler identifying the thread that will receive * the Intent. If null, the main thread of the process will be used. - * @param flags Additional options for the receiver. As of - * {@link android.os.Build.VERSION_CODES#TIRAMISU}, either {@link #RECEIVER_EXPORTED} or - * {@link #RECEIVER_NOT_EXPORTED} must be specified if the receiver isn't being registered - * for protected broadcasts, and may additionally specify - * {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS} if {@link #RECEIVER_EXPORTED} is - * specified. + * @param flags Additional options for the receiver. May be 0 or + * {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. * * @return The first sticky intent found that matches <var>filter</var>, * or null if there are none. @@ -3130,42 +3110,6 @@ public abstract class Context { } /** - * Same as {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler, int)} - * but this receiver will receive broadcasts that are sent to all users. The receiver can - * use {@link BroadcastReceiver#getSendingUser} to determine on which user the broadcast - * was sent. - * - * @param receiver The BroadcastReceiver to handle the broadcast. - * @param filter Selects the Intent broadcasts to be received. - * @param broadcastPermission String naming a permissions that a - * broadcaster must hold in order to send an Intent to you. If {@code null}, - * no permission is required. - * @param scheduler Handler identifying the thread that will receive - * the Intent. If {@code null}, the main thread of the process will be used. - * @param flags Additional options for the receiver. As of - * {@link android.os.Build.VERSION_CODES#TIRAMISU}, either {@link #RECEIVER_EXPORTED} or - * {@link #RECEIVER_NOT_EXPORTED} must be specified if the receiver isn't being - * registered for protected broadcasts - * - * @return The first sticky intent found that matches <var>filter</var>, - * or {@code null} if there are none. - * - * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler, int) - * @see #sendBroadcast - * @see #unregisterReceiver - * @hide - */ - @SuppressLint("IntentBuilderName") - @Nullable - @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) - @SystemApi - public Intent registerReceiverForAllUsers(@Nullable BroadcastReceiver receiver, - @NonNull IntentFilter filter, @Nullable String broadcastPermission, - @Nullable Handler scheduler, @RegisterReceiverFlags int flags) { - throw new RuntimeException("Not implemented. Must override in a subclass."); - } - - /** * @hide * Same as {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) * but for a specific user. This receiver will receiver broadcasts that @@ -3196,41 +3140,6 @@ public abstract class Context { @Nullable Handler scheduler); /** - * @hide - * Same as {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler, int) - * but for a specific user. This receiver will receiver broadcasts that - * are sent to the requested user. - * - * @param receiver The BroadcastReceiver to handle the broadcast. - * @param user UserHandle to send the intent to. - * @param filter Selects the Intent broadcasts to be received. - * @param broadcastPermission String naming a permissions that a - * broadcaster must hold in order to send an Intent to you. If null, - * no permission is required. - * @param scheduler Handler identifying the thread that will receive - * the Intent. If null, the main thread of the process will be used. - * @param flags Additional options for the receiver. As of - * {@link android.os.Build.VERSION_CODES#TIRAMISU}, either {@link #RECEIVER_EXPORTED} or - * {@link #RECEIVER_NOT_EXPORTED} must be specified if the receiver isn't being - * registered for protected broadcasts - * - * @return The first sticky intent found that matches <var>filter</var>, - * or null if there are none. - * - * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler, int) - * @see #sendBroadcast - * @see #unregisterReceiver - */ - @SuppressWarnings("HiddenAbstractMethod") - @SuppressLint("IntentBuilderName") - @Nullable - @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) - @UnsupportedAppUsage - public abstract Intent registerReceiverAsUser(BroadcastReceiver receiver, - UserHandle user, IntentFilter filter, @Nullable String broadcastPermission, - @Nullable Handler scheduler, @RegisterReceiverFlags int flags); - - /** * Unregister a previously registered BroadcastReceiver. <em>All</em> * filters that have been registered for this BroadcastReceiver will be * removed. diff --git a/core/java/android/content/ContextWrapper.java b/core/java/android/content/ContextWrapper.java index 3a02004edb1f..0e5f66cc68d5 100644 --- a/core/java/android/content/ContextWrapper.java +++ b/core/java/android/content/ContextWrapper.java @@ -756,34 +756,14 @@ public class ContextWrapper extends Context { /** @hide */ @Override - @Nullable - public Intent registerReceiverForAllUsers(@Nullable BroadcastReceiver receiver, - @NonNull IntentFilter filter, @Nullable String broadcastPermission, - @Nullable Handler scheduler, int flags) { - return mBase.registerReceiverForAllUsers(receiver, filter, broadcastPermission, - scheduler, flags); - } - - /** @hide */ - @Override @UnsupportedAppUsage - public Intent registerReceiverAsUser(@Nullable BroadcastReceiver receiver, UserHandle user, - IntentFilter filter, @Nullable String broadcastPermission, - @Nullable Handler scheduler) { + public Intent registerReceiverAsUser( + BroadcastReceiver receiver, UserHandle user, IntentFilter filter, + String broadcastPermission, Handler scheduler) { return mBase.registerReceiverAsUser(receiver, user, filter, broadcastPermission, scheduler); } - /** @hide */ - @Override - @UnsupportedAppUsage - public Intent registerReceiverAsUser(@Nullable BroadcastReceiver receiver, UserHandle user, - IntentFilter filter, @Nullable String broadcastPermission, - @Nullable Handler scheduler, int flags) { - return mBase.registerReceiverAsUser(receiver, user, filter, broadcastPermission, - scheduler, flags); - } - @Override public void unregisterReceiver(BroadcastReceiver receiver) { mBase.unregisterReceiver(receiver); diff --git a/test-mock/src/android/test/mock/MockContext.java b/test-mock/src/android/test/mock/MockContext.java index 49daad324bd1..7a1dda37de70 100644 --- a/test-mock/src/android/test/mock/MockContext.java +++ b/test-mock/src/android/test/mock/MockContext.java @@ -573,26 +573,11 @@ public class MockContext extends Context { /** @hide */ @Override - @SystemApi - public Intent registerReceiverForAllUsers(BroadcastReceiver receiver, - IntentFilter filter, String broadcastPermission, Handler scheduler, int flags) { - throw new UnsupportedOperationException(); - } - - /** @hide */ - @Override public Intent registerReceiverAsUser(BroadcastReceiver receiver, UserHandle user, IntentFilter filter, String broadcastPermission, Handler scheduler) { throw new UnsupportedOperationException(); } - /** @hide */ - @Override - public Intent registerReceiverAsUser(BroadcastReceiver receiver, UserHandle user, - IntentFilter filter, String broadcastPermission, Handler scheduler, int flags) { - throw new UnsupportedOperationException(); - } - @Override public void unregisterReceiver(BroadcastReceiver receiver) { throw new UnsupportedOperationException(); |