From a2baf58e26a6a152310ad9dfffaf1bd9a579ce7b Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Wed, 20 Nov 2019 14:40:30 -0800 Subject: [PATCH 1/3] Context: Rename Context.sendBroadcastMultiplePermissions Renaming based on API council feedback. Leaving the old API as @hide since there are other modules in platform using the old API. Bug: 144793100 Test: Compiles Change-Id: Id3fd01da3b4163d186cf9651a5b2b82c18859239 --- api/current.txt | 1 + api/system-current.txt | 1 - core/java/android/content/Context.java | 28 +++++++++++++++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/api/current.txt b/api/current.txt index 61013e81c473f..520be853e28bf 100644 --- a/api/current.txt +++ b/api/current.txt @@ -9895,6 +9895,7 @@ package android.content { method public abstract void sendBroadcast(@RequiresPermission android.content.Intent, @Nullable String); method @RequiresPermission("android.permission.INTERACT_ACROSS_USERS") public abstract void sendBroadcastAsUser(@RequiresPermission android.content.Intent, android.os.UserHandle); method @RequiresPermission("android.permission.INTERACT_ACROSS_USERS") public abstract void sendBroadcastAsUser(@RequiresPermission android.content.Intent, android.os.UserHandle, @Nullable String); + method public void sendBroadcastWithMultiplePermissions(@NonNull android.content.Intent, @NonNull String[]); method public abstract void sendOrderedBroadcast(@RequiresPermission android.content.Intent, @Nullable String); method public abstract void sendOrderedBroadcast(@NonNull @RequiresPermission android.content.Intent, @Nullable String, @Nullable android.content.BroadcastReceiver, @Nullable android.os.Handler, int, @Nullable String, @Nullable android.os.Bundle); method public void sendOrderedBroadcast(@NonNull @RequiresPermission android.content.Intent, @Nullable String, @Nullable String, @Nullable android.content.BroadcastReceiver, @Nullable android.os.Handler, int, @Nullable String, @Nullable android.os.Bundle); diff --git a/api/system-current.txt b/api/system-current.txt index aed13b7b0af20..95fdd5fecd525 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -1415,7 +1415,6 @@ package android.content { 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 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 void sendBroadcastMultiplePermissions(@NonNull android.content.Intent, @NonNull String[]); 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); method @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) public void startActivityAsUser(@NonNull @RequiresPermission android.content.Intent, @NonNull android.os.UserHandle); field public static final String APP_PREDICTION_SERVICE = "app_prediction"; diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 03b49136bde4f..d84199af4168a 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -2081,12 +2081,38 @@ public abstract class Context { * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) * @hide */ - @SystemApi public void sendBroadcastMultiplePermissions(@NonNull Intent intent, @NonNull String[] receiverPermissions) { throw new RuntimeException("Not implemented. Must override in a subclass."); } + /** + * Broadcast the given intent to all interested BroadcastReceivers, allowing + * an array of required permissions to be enforced. This call is asynchronous; it returns + * immediately, and you will continue executing while the receivers are run. No results are + * propagated from receivers and receivers can not abort the broadcast. If you want to allow + * receivers to propagate results or abort the broadcast, you must send an ordered broadcast + * using {@link #sendOrderedBroadcast(Intent, String)}. + * + *

See {@link BroadcastReceiver} for more information on Intent broadcasts. + * + * @param intent The Intent to broadcast; all receivers matching this + * Intent will receive the broadcast. + * @param receiverPermissions Array of names of permissions that a receiver must hold + * in order to receive your broadcast. + * If empty, no permissions are required. + * + * @see android.content.BroadcastReceiver + * @see #registerReceiver + * @see #sendBroadcast(Intent) + * @see #sendOrderedBroadcast(Intent, String) + * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) + */ + public void sendBroadcastWithMultiplePermissions(@NonNull Intent intent, + @NonNull String[] receiverPermissions) { + sendBroadcastMultiplePermissions(intent, receiverPermissions); + } + /** * Broadcast the given intent to all interested BroadcastReceivers, allowing * an array of required permissions to be enforced. This call is asynchronous; it returns From 866e9111c589923f12aa942e6b45a0fac7397282 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Wed, 20 Nov 2019 14:47:51 -0800 Subject: [PATCH 2/3] RemoteException: Add @throws documentation Bug: 144792553 Test: Compiles Change-Id: I5a7464c2fe786b8398c5abdf43f62479de62b133 --- core/java/android/os/RemoteException.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/java/android/os/RemoteException.java b/core/java/android/os/RemoteException.java index 10ef27952df40..98c66d1beaf47 100644 --- a/core/java/android/os/RemoteException.java +++ b/core/java/android/os/RemoteException.java @@ -44,6 +44,8 @@ public class RemoteException extends AndroidException { * state or making security decisions based on the perceived success or * failure of a call, or any default values returned. For this reason, we * want to strongly throw when there was trouble with the transaction. + * + * @throws RuntimeException */ @NonNull public RuntimeException rethrowAsRuntimeException() { @@ -60,6 +62,8 @@ public class RemoteException extends AndroidException { * state or making security decisions based on the perceived success or * failure of a call, or any default values returned. For this reason, we * want to strongly throw when there was trouble with the transaction. + * + * @throws RuntimeException */ @NonNull public RuntimeException rethrowFromSystemServer() { From 4241a2866cbf92a343aab42e0b668b373df9bae6 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Wed, 20 Nov 2019 14:48:34 -0800 Subject: [PATCH 3/3] AndroidKeyStoreProvider: Add @throws documentation Bug: 144791977 Test: Compiles Change-Id: I9f19e30d58b1b7d504f9e8f7e79dd71a38f81357 --- .../android/security/keystore/AndroidKeyStoreProvider.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/keystore/java/android/security/keystore/AndroidKeyStoreProvider.java b/keystore/java/android/security/keystore/AndroidKeyStoreProvider.java index 2cdd000492424..d03329445b18c 100644 --- a/keystore/java/android/security/keystore/AndroidKeyStoreProvider.java +++ b/keystore/java/android/security/keystore/AndroidKeyStoreProvider.java @@ -400,6 +400,12 @@ public class AndroidKeyStoreProvider extends Provider { * *

Note: the returned {@code KeyStore} is already initialized/loaded. Thus, there is * no need to invoke {@code load} on it. + * + * @param uid Uid for which the keystore provider is requested. + * @throws KeyStoreException if a KeyStoreSpi implementation for the specified type is not + * available from the specified provider. + * @throws NoSuchProviderException If the specified provider is not registered in the security + * provider list. * @hide */ @SystemApi