[VCN13] Implement tracking best matching network

This is done by:
  1. In requestNetwork, provide a basic permission check.
  2. rematchNetworksAndRequests: no change, since non listen
     requests will be automatically processed to track
     best satisfying network.
  3. applyNetworkReassignment: no change, since non-request
     will not be sent to factories.

Test: atest ConnectivityServiceTest#testRegisterBestMatchingNetworkCallback_noIssueToFactory
Test: atest ConnectivityServiceTest#testRegisterBestMatchingNetworkCallback_trackBestNetwork
Bug: 175662146
Change-Id: I8cf4ab334df6812d84cdda160e9b72b6f54062af
This commit is contained in:
junyulai
2021-03-12 20:05:08 +08:00
parent 4fe7ff8d1f
commit 7664f62d37
2 changed files with 12 additions and 3 deletions

View File

@@ -18,8 +18,8 @@ package android.net;
import static android.annotation.SystemApi.Client.MODULE_LIBRARIES; import static android.annotation.SystemApi.Client.MODULE_LIBRARIES;
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.LISTEN_FOR_BEST;
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;
@@ -4249,7 +4249,7 @@ public class ConnectivityManager {
@NonNull NetworkCallback networkCallback, @NonNull Handler handler) { @NonNull NetworkCallback networkCallback, @NonNull Handler handler) {
final NetworkCapabilities nc = request.networkCapabilities; final NetworkCapabilities nc = request.networkCapabilities;
final CallbackHandler cbHandler = new CallbackHandler(handler); final CallbackHandler cbHandler = new CallbackHandler(handler);
sendRequestForNetwork(nc, networkCallback, 0, TRACK_BEST, TYPE_NONE, cbHandler); sendRequestForNetwork(nc, networkCallback, 0, LISTEN_FOR_BEST, TYPE_NONE, cbHandler);
} }
/** /**

View File

@@ -140,7 +140,7 @@ public class NetworkRequest implements Parcelable {
REQUEST, REQUEST,
BACKGROUND_REQUEST, BACKGROUND_REQUEST,
TRACK_SYSTEM_DEFAULT, TRACK_SYSTEM_DEFAULT,
TRACK_BEST, LISTEN_FOR_BEST,
}; };
/** /**
@@ -513,6 +513,15 @@ public class NetworkRequest implements Parcelable {
return type == Type.LISTEN; return type == Type.LISTEN;
} }
/**
* Returns true iff. this NetworkRequest is of type LISTEN_FOR_BEST.
*
* @hide
*/
public boolean isListenForBest() {
return type == Type.LISTEN_FOR_BEST;
}
/** /**
* Returns true iff. the contained NetworkRequest is one that: * Returns true iff. the contained NetworkRequest is one that:
* *