use of android.net.NetworkRequest in project android_frameworks_base by DirtyUnicorns.
the class GnssLocationProvider method handleRequestSuplConnection.
private void handleRequestSuplConnection(InetAddress address) {
if (DEBUG) {
String message = String.format("requestSuplConnection, state=%s, address=%s", agpsDataConnStateAsString(), address);
Log.d(TAG, message);
}
if (mAGpsDataConnectionState != AGPS_DATA_CONNECTION_CLOSED) {
return;
}
mAGpsDataConnectionIpAddr = address;
mAGpsDataConnectionState = AGPS_DATA_CONNECTION_OPENING;
NetworkRequest.Builder requestBuilder = new NetworkRequest.Builder();
requestBuilder.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
requestBuilder.addCapability(NetworkCapabilities.NET_CAPABILITY_SUPL);
NetworkRequest request = requestBuilder.build();
mConnMgr.requestNetwork(request, mSuplConnectivityCallback, ConnectivityManager.MAX_NETWORK_REQUEST_TIMEOUT_MS);
}
use of android.net.NetworkRequest in project android_frameworks_base by AOSPA.
the class NetworkAgentInfo method addRequest.
/**
* Add {@code networkRequest} to this network as it's satisfied by this network.
* @return true if {@code networkRequest} was added or false if {@code networkRequest} was
* already present.
*/
public boolean addRequest(NetworkRequest networkRequest) {
NetworkRequest existing = mNetworkRequests.get(networkRequest.requestId);
if (existing == networkRequest)
return false;
if (existing != null) {
// Should only happen if the requestId wraps. If that happens lots of other things will
// be broken as well.
Log.wtf(TAG, String.format("Duplicate requestId for %s and %s on %s", networkRequest, existing, name()));
updateRequestCounts(REMOVE, existing);
}
mNetworkRequests.put(networkRequest.requestId, networkRequest);
updateRequestCounts(ADD, networkRequest);
return true;
}
use of android.net.NetworkRequest in project android_frameworks_base by AOSPA.
the class NetworkAgentInfo method removeRequest.
/**
* Remove the specified request from this network.
*/
public void removeRequest(int requestId) {
NetworkRequest existing = mNetworkRequests.get(requestId);
if (existing == null)
return;
updateRequestCounts(REMOVE, existing);
mNetworkRequests.remove(requestId);
if (existing.isRequest()) {
unlingerRequest(existing);
}
}
use of android.net.NetworkRequest in project android_frameworks_base by crdroidandroid.
the class ConnectivityService method listenForNetwork.
@Override
public NetworkRequest listenForNetwork(NetworkCapabilities networkCapabilities, Messenger messenger, IBinder binder) {
if (!hasWifiNetworkListenPermission(networkCapabilities)) {
enforceAccessPermission();
}
NetworkCapabilities nc = new NetworkCapabilities(networkCapabilities);
if (!ConnectivityManager.checkChangePermission(mContext)) {
// Apps without the CHANGE_NETWORK_STATE permission can't use background networks, so
// make all their listens include NET_CAPABILITY_FOREGROUND. That way, they will get
// onLost and onAvailable callbacks when networks move in and out of the background.
// There is no need to do this for requests because an app without CHANGE_NETWORK_STATE
// can't request networks.
nc.addCapability(NET_CAPABILITY_FOREGROUND);
}
NetworkRequest networkRequest = new NetworkRequest(nc, TYPE_NONE, nextNetworkRequestId(), NetworkRequest.Type.LISTEN);
NetworkRequestInfo nri = new NetworkRequestInfo(messenger, networkRequest, binder);
if (VDBG)
log("listenForNetwork for " + nri);
mHandler.sendMessage(mHandler.obtainMessage(EVENT_REGISTER_NETWORK_LISTENER, nri));
return networkRequest;
}
use of android.net.NetworkRequest in project android_frameworks_base by crdroidandroid.
the class ConnectivityService method processListenRequests.
private void processListenRequests(NetworkAgentInfo nai, boolean capabilitiesChanged) {
// For consistency with previous behaviour, send onLost callbacks before onAvailable.
for (NetworkRequestInfo nri : mNetworkRequests.values()) {
NetworkRequest nr = nri.request;
if (!nr.isListen())
continue;
if (nai.isSatisfyingRequest(nr.requestId) && !nai.satisfies(nr)) {
nai.removeRequest(nri.request.requestId);
callCallbackForRequest(nri, nai, ConnectivityManager.CALLBACK_LOST, 0);
}
}
if (capabilitiesChanged) {
notifyNetworkCallbacks(nai, ConnectivityManager.CALLBACK_CAP_CHANGED);
}
for (NetworkRequestInfo nri : mNetworkRequests.values()) {
NetworkRequest nr = nri.request;
if (!nr.isListen())
continue;
if (nai.satisfies(nr) && !nai.isSatisfyingRequest(nr.requestId)) {
nai.addRequest(nr);
notifyNetworkCallback(nai, nri);
}
}
}
Aggregations