use of com.android.server.connectivity.NetworkAgentInfo in project platform_frameworks_base by android.
the class ConnectivityService method getAllNetworkState.
@Override
public NetworkState[] getAllNetworkState() {
// Require internal since we're handing out IMSI details
enforceConnectivityInternalPermission();
final ArrayList<NetworkState> result = Lists.newArrayList();
for (Network network : getAllNetworks()) {
final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
if (nai != null) {
result.add(nai.getNetworkState());
}
}
return result.toArray(new NetworkState[result.size()]);
}
use of com.android.server.connectivity.NetworkAgentInfo in project platform_frameworks_base by android.
the class ConnectivityService method getFilteredNetworkState.
private NetworkState getFilteredNetworkState(int networkType, int uid, boolean ignoreBlocked) {
if (mLegacyTypeTracker.isTypeSupported(networkType)) {
final NetworkAgentInfo nai = mLegacyTypeTracker.getNetworkForType(networkType);
final NetworkState state;
if (nai != null) {
state = nai.getNetworkState();
state.networkInfo.setType(networkType);
} else {
final NetworkInfo info = new NetworkInfo(networkType, 0, getNetworkTypeName(networkType), "");
info.setDetailedState(NetworkInfo.DetailedState.DISCONNECTED, null, null);
info.setIsAvailable(true);
state = new NetworkState(info, new LinkProperties(), new NetworkCapabilities(), null, null, null);
}
filterNetworkStateForUid(state, uid, ignoreBlocked);
return state;
} else {
return NetworkState.EMPTY;
}
}
use of com.android.server.connectivity.NetworkAgentInfo in project platform_frameworks_base by android.
the class ConnectivityService method getProxyForNetwork.
@Override
public ProxyInfo getProxyForNetwork(Network network) {
if (network == null)
return getDefaultProxy();
final ProxyInfo globalProxy = getGlobalProxy();
if (globalProxy != null)
return globalProxy;
if (!NetworkUtils.queryUserAccess(Binder.getCallingUid(), network.netId))
return null;
// Don't call getLinkProperties() as it requires ACCESS_NETWORK_STATE permission, which
// caller may not have.
final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
if (nai == null)
return null;
synchronized (nai) {
final ProxyInfo proxyInfo = nai.linkProperties.getHttpProxy();
if (proxyInfo == null)
return null;
return new ProxyInfo(proxyInfo);
}
}
use of com.android.server.connectivity.NetworkAgentInfo in project platform_frameworks_base by android.
the class ConnectivityService method isLiveNetworkAgent.
private boolean isLiveNetworkAgent(NetworkAgentInfo nai, int what) {
if (nai.network == null)
return false;
final NetworkAgentInfo officialNai = getNetworkAgentInfoForNetwork(nai.network);
if (officialNai != null && officialNai.equals(nai))
return true;
if (officialNai != null || VDBG) {
final String msg = sMagicDecoderRing.get(what, Integer.toString(what));
loge(msg + " - isLiveNetworkAgent found mismatched netId: " + officialNai + " - " + nai);
}
return false;
}
use of com.android.server.connectivity.NetworkAgentInfo in project platform_frameworks_base by android.
the class ConnectivityService method handleAsyncChannelHalfConnect.
private void handleAsyncChannelHalfConnect(Message msg) {
AsyncChannel ac = (AsyncChannel) msg.obj;
if (mNetworkFactoryInfos.containsKey(msg.replyTo)) {
if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL) {
if (VDBG)
log("NetworkFactory connected");
// A network factory has connected. Send it all current NetworkRequests.
for (NetworkRequestInfo nri : mNetworkRequests.values()) {
if (nri.request.isListen())
continue;
NetworkAgentInfo nai = mNetworkForRequestId.get(nri.request.requestId);
ac.sendMessage(android.net.NetworkFactory.CMD_REQUEST_NETWORK, (nai != null ? nai.getCurrentScore() : 0), 0, nri.request);
}
} else {
loge("Error connecting NetworkFactory");
mNetworkFactoryInfos.remove(msg.obj);
}
} else if (mNetworkAgentInfos.containsKey(msg.replyTo)) {
if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL) {
if (VDBG)
log("NetworkAgent connected");
// A network agent has requested a connection. Establish the connection.
mNetworkAgentInfos.get(msg.replyTo).asyncChannel.sendMessage(AsyncChannel.CMD_CHANNEL_FULL_CONNECTION);
} else {
loge("Error connecting NetworkAgent");
NetworkAgentInfo nai = mNetworkAgentInfos.remove(msg.replyTo);
if (nai != null) {
final boolean wasDefault = isDefaultNetwork(nai);
synchronized (mNetworkForNetId) {
mNetworkForNetId.remove(nai.network.netId);
mNetIdInUse.delete(nai.network.netId);
}
// Just in case.
mLegacyTypeTracker.remove(nai, wasDefault);
}
}
}
}
Aggregations