[VCN10] Add new API to listen for highest score network

Test: atest ConnectivityServiceTest#testRegisterBestMatchingNetworkCallback
Bug: 175662146
Change-Id: Ifa411c7b53da789c74fff7e1a95f9c9ebf5bd05c
This commit is contained in:
junyulai
2021-03-05 15:51:17 +08:00
parent 91fccfe42f
commit 6b0a6a22a3
4 changed files with 29 additions and 1 deletions

View File

@@ -20,6 +20,7 @@ import static android.net.IpSecManager.INVALID_RESOURCE_ID;
import static android.net.NetworkRequest.Type.BACKGROUND_REQUEST;
import static android.net.NetworkRequest.Type.LISTEN;
import static android.net.NetworkRequest.Type.REQUEST;
import static android.net.NetworkRequest.Type.TRACK_BEST;
import static android.net.NetworkRequest.Type.TRACK_DEFAULT;
import static android.net.NetworkRequest.Type.TRACK_SYSTEM_DEFAULT;
import static android.net.QosCallback.QosCallbackRegistrationException;
@@ -4189,6 +4190,18 @@ public class ConnectivityManager {
TRACK_SYSTEM_DEFAULT, TYPE_NONE, cbHandler);
}
/**
* @hide
*/
// TODO: Make it public api.
@SuppressLint("ExecutorRegistration")
public void registerBestMatchingNetworkCallback(@NonNull NetworkRequest request,
@NonNull NetworkCallback networkCallback, @NonNull Handler handler) {
final NetworkCapabilities nc = request.networkCapabilities;
final CallbackHandler cbHandler = new CallbackHandler(handler);
sendRequestForNetwork(nc, networkCallback, 0, TRACK_BEST, TYPE_NONE, cbHandler);
}
/**
* Requests bandwidth update for a given {@link Network} and returns whether the update request
* is accepted by ConnectivityService. Once accepted, ConnectivityService will poll underlying