Merge "Document the limitation to a hundred callbacks." am: f60ed54d33 am: 363fb9fef9
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1313813 Change-Id: I84b1e39503feddc914b61d4e8bd35953e92ac270
This commit is contained in:
commit
1fa0eab021
1 changed files with 87 additions and 10 deletions
|
|
@ -3833,13 +3833,22 @@ public class ConnectivityManager {
|
|||
* or the ability to modify system settings as determined by
|
||||
* {@link android.provider.Settings.System#canWrite}.</p>
|
||||
*
|
||||
* <p>To avoid performance issues due to apps leaking callbacks, the system will limit the
|
||||
* number of outstanding requests to 100 per app (identified by their UID), shared with
|
||||
* all variants of this method, of {@link #registerNetworkCallback} as well as
|
||||
* {@link ConnectivityDiagnosticsManager#registerConnectivityDiagnosticsCallback}.
|
||||
* Requesting a network with this method will count toward this limit. If this limit is
|
||||
* exceeded, an exception will be thrown. To avoid hitting this issue and to conserve resources,
|
||||
* make sure to unregister the callbacks with
|
||||
* {@link #unregisterNetworkCallback(NetworkCallback)}.
|
||||
*
|
||||
* @param request {@link NetworkRequest} describing this request.
|
||||
* @param networkCallback The {@link NetworkCallback} to be utilized for this request. Note
|
||||
* the callback must not be shared - it uniquely specifies this request.
|
||||
* The callback is invoked on the default internal Handler.
|
||||
* @throws IllegalArgumentException if {@code request} contains invalid network capabilities.
|
||||
* @throws SecurityException if missing the appropriate permissions.
|
||||
* @throws RuntimeException if request limit per UID is exceeded.
|
||||
* @throws RuntimeException if the app already has too many callbacks registered.
|
||||
*/
|
||||
public void requestNetwork(@NonNull NetworkRequest request,
|
||||
@NonNull NetworkCallback networkCallback) {
|
||||
|
|
@ -3853,8 +3862,8 @@ public class ConnectivityManager {
|
|||
* but runs all the callbacks on the passed Handler.
|
||||
*
|
||||
* <p>This method has the same permission requirements as
|
||||
* {@link #requestNetwork(NetworkRequest, NetworkCallback)} and throws the same exceptions in
|
||||
* the same conditions.
|
||||
* {@link #requestNetwork(NetworkRequest, NetworkCallback)}, is subject to the same limitations,
|
||||
* and throws the same exceptions in the same conditions.
|
||||
*
|
||||
* @param request {@link NetworkRequest} describing this request.
|
||||
* @param networkCallback The {@link NetworkCallback} to be utilized for this request. Note
|
||||
|
|
@ -3885,8 +3894,8 @@ public class ConnectivityManager {
|
|||
* for that purpose. Calling this method will attempt to bring up the requested network.
|
||||
*
|
||||
* <p>This method has the same permission requirements as
|
||||
* {@link #requestNetwork(NetworkRequest, NetworkCallback)} and throws the same exceptions in
|
||||
* the same conditions.
|
||||
* {@link #requestNetwork(NetworkRequest, NetworkCallback)}, is subject to the same limitations,
|
||||
* and throws the same exceptions in the same conditions.
|
||||
*
|
||||
* @param request {@link NetworkRequest} describing this request.
|
||||
* @param networkCallback The {@link NetworkCallback} to be utilized for this request. Note
|
||||
|
|
@ -3912,8 +3921,8 @@ public class ConnectivityManager {
|
|||
* on the passed Handler.
|
||||
*
|
||||
* <p>This method has the same permission requirements as
|
||||
* {@link #requestNetwork(NetworkRequest, NetworkCallback, int)} and throws the same exceptions
|
||||
* in the same conditions.
|
||||
* {@link #requestNetwork(NetworkRequest, NetworkCallback)}, is subject to the same limitations,
|
||||
* and throws the same exceptions in the same conditions.
|
||||
*
|
||||
* @param request {@link NetworkRequest} describing this request.
|
||||
* @param networkCallback The {@link NetworkCallback} to be utilized for this request. Note
|
||||
|
|
@ -3982,6 +3991,15 @@ public class ConnectivityManager {
|
|||
* is unknown prior to bringing up the network so the framework does not
|
||||
* know how to go about satisfying a request with these capabilities.
|
||||
*
|
||||
* <p>To avoid performance issues due to apps leaking callbacks, the system will limit the
|
||||
* number of outstanding requests to 100 per app (identified by their UID), shared with
|
||||
* all variants of this method, of {@link #registerNetworkCallback} as well as
|
||||
* {@link ConnectivityDiagnosticsManager#registerConnectivityDiagnosticsCallback}.
|
||||
* Requesting a network with this method will count toward this limit. If this limit is
|
||||
* exceeded, an exception will be thrown. To avoid hitting this issue and to conserve resources,
|
||||
* make sure to unregister the callbacks with {@link #unregisterNetworkCallback(PendingIntent)}
|
||||
* or {@link #releaseNetworkRequest(PendingIntent)}.
|
||||
*
|
||||
* <p>This method requires the caller to hold either the
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE} permission
|
||||
* or the ability to modify system settings as determined by
|
||||
|
|
@ -3993,7 +4011,7 @@ public class ConnectivityManager {
|
|||
* comes from {@link PendingIntent#getBroadcast}. Cannot be null.
|
||||
* @throws IllegalArgumentException if {@code request} contains invalid network capabilities.
|
||||
* @throws SecurityException if missing the appropriate permissions.
|
||||
* @throws RuntimeException if request limit per UID is exceeded.
|
||||
* @throws RuntimeException if the app already has too many callbacks registered.
|
||||
*/
|
||||
public void requestNetwork(@NonNull NetworkRequest request,
|
||||
@NonNull PendingIntent operation) {
|
||||
|
|
@ -4050,10 +4068,20 @@ public class ConnectivityManager {
|
|||
* either the application exits or {@link #unregisterNetworkCallback(NetworkCallback)} is
|
||||
* called.
|
||||
*
|
||||
* <p>To avoid performance issues due to apps leaking callbacks, the system will limit the
|
||||
* number of outstanding requests to 100 per app (identified by their UID), shared with
|
||||
* all variants of this method, of {@link #requestNetwork} as well as
|
||||
* {@link ConnectivityDiagnosticsManager#registerConnectivityDiagnosticsCallback}.
|
||||
* Requesting a network with this method will count toward this limit. If this limit is
|
||||
* exceeded, an exception will be thrown. To avoid hitting this issue and to conserve resources,
|
||||
* make sure to unregister the callbacks with
|
||||
* {@link #unregisterNetworkCallback(NetworkCallback)}.
|
||||
*
|
||||
* @param request {@link NetworkRequest} describing this request.
|
||||
* @param networkCallback The {@link NetworkCallback} that the system will call as suitable
|
||||
* networks change state.
|
||||
* The callback is invoked on the default internal Handler.
|
||||
* @throws RuntimeException if the app already has too many callbacks registered.
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
||||
public void registerNetworkCallback(@NonNull NetworkRequest request,
|
||||
|
|
@ -4067,10 +4095,21 @@ public class ConnectivityManager {
|
|||
* either the application exits or {@link #unregisterNetworkCallback(NetworkCallback)} is
|
||||
* called.
|
||||
*
|
||||
* <p>To avoid performance issues due to apps leaking callbacks, the system will limit the
|
||||
* number of outstanding requests to 100 per app (identified by their UID), shared with
|
||||
* all variants of this method, of {@link #requestNetwork} as well as
|
||||
* {@link ConnectivityDiagnosticsManager#registerConnectivityDiagnosticsCallback}.
|
||||
* Requesting a network with this method will count toward this limit. If this limit is
|
||||
* exceeded, an exception will be thrown. To avoid hitting this issue and to conserve resources,
|
||||
* make sure to unregister the callbacks with
|
||||
* {@link #unregisterNetworkCallback(NetworkCallback)}.
|
||||
*
|
||||
*
|
||||
* @param request {@link NetworkRequest} describing this request.
|
||||
* @param networkCallback The {@link NetworkCallback} that the system will call as suitable
|
||||
* networks change state.
|
||||
* @param handler {@link Handler} to specify the thread upon which the callback will be invoked.
|
||||
* @throws RuntimeException if the app already has too many callbacks registered.
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
||||
public void registerNetworkCallback(@NonNull NetworkRequest request,
|
||||
|
|
@ -4104,10 +4143,21 @@ public class ConnectivityManager {
|
|||
* <p>
|
||||
* The request may be released normally by calling
|
||||
* {@link #unregisterNetworkCallback(android.app.PendingIntent)}.
|
||||
*
|
||||
* <p>To avoid performance issues due to apps leaking callbacks, the system will limit the
|
||||
* number of outstanding requests to 100 per app (identified by their UID), shared with
|
||||
* all variants of this method, of {@link #requestNetwork} as well as
|
||||
* {@link ConnectivityDiagnosticsManager#registerConnectivityDiagnosticsCallback}.
|
||||
* Requesting a network with this method will count toward this limit. If this limit is
|
||||
* exceeded, an exception will be thrown. To avoid hitting this issue and to conserve resources,
|
||||
* make sure to unregister the callbacks with {@link #unregisterNetworkCallback(PendingIntent)}
|
||||
* or {@link #releaseNetworkRequest(PendingIntent)}.
|
||||
*
|
||||
* @param request {@link NetworkRequest} describing this request.
|
||||
* @param operation Action to perform when the network is available (corresponds
|
||||
* to the {@link NetworkCallback#onAvailable} call. Typically
|
||||
* comes from {@link PendingIntent#getBroadcast}. Cannot be null.
|
||||
* @throws RuntimeException if the app already has too many callbacks registered.
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
||||
public void registerNetworkCallback(@NonNull NetworkRequest request,
|
||||
|
|
@ -4129,9 +4179,19 @@ public class ConnectivityManager {
|
|||
* will continue to be called until either the application exits or
|
||||
* {@link #unregisterNetworkCallback(NetworkCallback)} is called.
|
||||
*
|
||||
* <p>To avoid performance issues due to apps leaking callbacks, the system will limit the
|
||||
* number of outstanding requests to 100 per app (identified by their UID), shared with
|
||||
* all variants of this method, of {@link #requestNetwork} as well as
|
||||
* {@link ConnectivityDiagnosticsManager#registerConnectivityDiagnosticsCallback}.
|
||||
* Requesting a network with this method will count toward this limit. If this limit is
|
||||
* exceeded, an exception will be thrown. To avoid hitting this issue and to conserve resources,
|
||||
* make sure to unregister the callbacks with
|
||||
* {@link #unregisterNetworkCallback(NetworkCallback)}.
|
||||
*
|
||||
* @param networkCallback The {@link NetworkCallback} that the system will call as the
|
||||
* system default network changes.
|
||||
* The callback is invoked on the default internal Handler.
|
||||
* @throws RuntimeException if the app already has too many callbacks registered.
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
||||
public void registerDefaultNetworkCallback(@NonNull NetworkCallback networkCallback) {
|
||||
|
|
@ -4143,9 +4203,19 @@ public class ConnectivityManager {
|
|||
* will continue to be called until either the application exits or
|
||||
* {@link #unregisterNetworkCallback(NetworkCallback)} is called.
|
||||
*
|
||||
* <p>To avoid performance issues due to apps leaking callbacks, the system will limit the
|
||||
* number of outstanding requests to 100 per app (identified by their UID), shared with
|
||||
* all variants of this method, of {@link #requestNetwork} as well as
|
||||
* {@link ConnectivityDiagnosticsManager#registerConnectivityDiagnosticsCallback}.
|
||||
* Requesting a network with this method will count toward this limit. If this limit is
|
||||
* exceeded, an exception will be thrown. To avoid hitting this issue and to conserve resources,
|
||||
* make sure to unregister the callbacks with
|
||||
* {@link #unregisterNetworkCallback(NetworkCallback)}.
|
||||
*
|
||||
* @param networkCallback The {@link NetworkCallback} that the system will call as the
|
||||
* system default network changes.
|
||||
* @param handler {@link Handler} to specify the thread upon which the callback will be invoked.
|
||||
* @throws RuntimeException if the app already has too many callbacks registered.
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
||||
public void registerDefaultNetworkCallback(@NonNull NetworkCallback networkCallback,
|
||||
|
|
@ -4237,7 +4307,6 @@ public class ConnectivityManager {
|
|||
* Cannot be null.
|
||||
*/
|
||||
public void unregisterNetworkCallback(@NonNull PendingIntent operation) {
|
||||
checkPendingIntentNotNull(operation);
|
||||
releaseNetworkRequest(operation);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue