Merge "[VCN14] Expose registerBestMatchingNetworkCallback" am: 29908cf3c4

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1635047

Change-Id: I4d475e1a681473c244afe4d3eaaabbcfaa9af9d6
This commit is contained in:
Junyu Lai
2021-03-16 23:43:07 +00:00
committed by Automerger Merge Worker
2 changed files with 21 additions and 2 deletions

View File

@@ -87,6 +87,7 @@ package android.net {
method @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) public boolean isActiveNetworkMetered();
method public boolean isDefaultNetworkActive();
method @Deprecated public static boolean isNetworkTypeValid(int);
method public void registerBestMatchingNetworkCallback(@NonNull android.net.NetworkRequest, @NonNull android.net.ConnectivityManager.NetworkCallback, @NonNull android.os.Handler);
method @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) public void registerDefaultNetworkCallback(@NonNull android.net.ConnectivityManager.NetworkCallback);
method @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) public void registerDefaultNetworkCallback(@NonNull android.net.ConnectivityManager.NetworkCallback, @NonNull android.os.Handler);
method @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) public void registerNetworkCallback(@NonNull android.net.NetworkRequest, @NonNull android.net.ConnectivityManager.NetworkCallback);

View File

@@ -4241,9 +4241,27 @@ public class ConnectivityManager {
}
/**
* @hide
* Registers to receive notifications about the best matching network which satisfy the given
* {@link NetworkRequest}. The callbacks 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
* {@link #registerNetworkCallback} and its variants and {@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.
*/
// TODO: Make it public api.
@SuppressLint("ExecutorRegistration")
public void registerBestMatchingNetworkCallback(@NonNull NetworkRequest request,
@NonNull NetworkCallback networkCallback, @NonNull Handler handler) {