[VCN10] Add new API to listen for highest score network
Test: atest ConnectivityServiceTest#testRegisterBestMatchingNetworkCallback Bug: 175662146 Change-Id: Ifa411c7b53da789c74fff7e1a95f9c9ebf5bd05c
This commit is contained in:
@@ -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.BACKGROUND_REQUEST;
|
||||||
import static android.net.NetworkRequest.Type.LISTEN;
|
import static android.net.NetworkRequest.Type.LISTEN;
|
||||||
import static android.net.NetworkRequest.Type.REQUEST;
|
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_DEFAULT;
|
||||||
import static android.net.NetworkRequest.Type.TRACK_SYSTEM_DEFAULT;
|
import static android.net.NetworkRequest.Type.TRACK_SYSTEM_DEFAULT;
|
||||||
import static android.net.QosCallback.QosCallbackRegistrationException;
|
import static android.net.QosCallback.QosCallbackRegistrationException;
|
||||||
@@ -4189,6 +4190,18 @@ public class ConnectivityManager {
|
|||||||
TRACK_SYSTEM_DEFAULT, TYPE_NONE, cbHandler);
|
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
|
* Requests bandwidth update for a given {@link Network} and returns whether the update request
|
||||||
* is accepted by ConnectivityService. Once accepted, ConnectivityService will poll underlying
|
* is accepted by ConnectivityService. Once accepted, ConnectivityService will poll underlying
|
||||||
|
|||||||
@@ -113,6 +113,10 @@ public class NetworkRequest implements Parcelable {
|
|||||||
* for the network (if any) that satisfies the default Internet
|
* for the network (if any) that satisfies the default Internet
|
||||||
* request.
|
* request.
|
||||||
*
|
*
|
||||||
|
* - TRACK_BEST, which causes the framework to send callbacks about
|
||||||
|
* the single, highest scoring current network (if any) that matches
|
||||||
|
* the specified NetworkCapabilities.
|
||||||
|
*
|
||||||
* - BACKGROUND_REQUEST, like REQUEST but does not cause any networks
|
* - BACKGROUND_REQUEST, like REQUEST but does not cause any networks
|
||||||
* to retain the NET_CAPABILITY_FOREGROUND capability. A network with
|
* to retain the NET_CAPABILITY_FOREGROUND capability. A network with
|
||||||
* no foreground requests is in the background. A network that has
|
* no foreground requests is in the background. A network that has
|
||||||
@@ -135,6 +139,7 @@ public class NetworkRequest implements Parcelable {
|
|||||||
REQUEST,
|
REQUEST,
|
||||||
BACKGROUND_REQUEST,
|
BACKGROUND_REQUEST,
|
||||||
TRACK_SYSTEM_DEFAULT,
|
TRACK_SYSTEM_DEFAULT,
|
||||||
|
TRACK_BEST,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user