Search in sources :

Example 56 with Network

use of android.net.Network in project platform_frameworks_base by android.

the class OSUManager method wnmRemediate.

// !!! Consistently check passpoint match.
// !!! Convert to a one-thread thread-pool
public void wnmRemediate(long bssid, String url, PasspointMatch match) throws IOException, SAXException {
    WifiConfiguration config = mWifiNetworkAdapter.getActiveWifiConfig();
    HomeSP homeSP = MOManager.buildSP(config.getMoTree());
    if (homeSP == null) {
        throw new IOException("Remediation request for unidentified Passpoint network " + config.networkId);
    }
    Network network = mWifiNetworkAdapter.getCurrentNetwork();
    if (network == null) {
        throw new IOException("Failed to determine current network");
    }
    WifiInfo wifiInfo = mWifiNetworkAdapter.getConnectionInfo();
    if (wifiInfo == null || Utils.parseMac(wifiInfo.getBSSID()) != bssid) {
        throw new IOException("Mismatching BSSID");
    }
    Log.d(TAG, "WNM Remediation on " + network.netId + " FQDN " + homeSP.getFQDN());
    doRemediate(url, network, homeSP, false);
}
Also used : HomeSP(com.android.hotspot2.pps.HomeSP) WifiConfiguration(android.net.wifi.WifiConfiguration) Network(android.net.Network) IOException(java.io.IOException) WifiInfo(android.net.wifi.WifiInfo)

Example 57 with Network

use of android.net.Network in project platform_frameworks_base by android.

the class AccessPoint method getSummary.

public static String getSummary(Context context, String ssid, DetailedState state, boolean isEphemeral, String passpointProvider) {
    if (state == DetailedState.CONNECTED && ssid == null) {
        if (TextUtils.isEmpty(passpointProvider) == false) {
            // Special case for connected + passpoint networks.
            String format = context.getString(R.string.connected_via_passpoint);
            return String.format(format, passpointProvider);
        } else if (isEphemeral) {
            // Special case for connected + ephemeral networks.
            return context.getString(R.string.connected_via_wfa);
        }
    }
    // Case when there is wifi connected without internet connectivity.
    final ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    if (state == DetailedState.CONNECTED) {
        IWifiManager wifiManager = IWifiManager.Stub.asInterface(ServiceManager.getService(Context.WIFI_SERVICE));
        Network nw;
        try {
            nw = wifiManager.getCurrentNetwork();
        } catch (RemoteException e) {
            nw = null;
        }
        NetworkCapabilities nc = cm.getNetworkCapabilities(nw);
        if (nc != null && !nc.hasCapability(nc.NET_CAPABILITY_VALIDATED)) {
            return context.getString(R.string.wifi_connected_no_internet);
        }
    }
    String[] formats = context.getResources().getStringArray((ssid == null) ? R.array.wifi_status : R.array.wifi_status_with_ssid);
    int index = state.ordinal();
    if (index >= formats.length || formats[index].length() == 0) {
        return "";
    }
    return String.format(formats[index], ssid);
}
Also used : ConnectivityManager(android.net.ConnectivityManager) Network(android.net.Network) SpannableString(android.text.SpannableString) RemoteException(android.os.RemoteException) NetworkCapabilities(android.net.NetworkCapabilities) IWifiManager(android.net.wifi.IWifiManager)

Example 58 with Network

use of android.net.Network in project platform_frameworks_base by android.

the class NetworkTest method testZeroIsObviousForDebugging.

@SmallTest
public void testZeroIsObviousForDebugging() {
    Network zero = new Network(0);
    assertEquals(0, zero.hashCode());
    assertEquals(0, zero.getNetworkHandle());
    assertEquals("0", zero.toString());
}
Also used : Network(android.net.Network) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 59 with Network

use of android.net.Network in project platform_frameworks_base by android.

the class ConnectivityService method createVpnInfo.

/**
     * @return VPN information for accounting, or null if we can't retrieve all required
     *         information, e.g primary underlying iface.
     */
@Nullable
private VpnInfo createVpnInfo(Vpn vpn) {
    VpnInfo info = vpn.getVpnInfo();
    if (info == null) {
        return null;
    }
    Network[] underlyingNetworks = vpn.getUnderlyingNetworks();
    // the underlyingNetworks list.
    if (underlyingNetworks == null) {
        NetworkAgentInfo defaultNetwork = getDefaultNetwork();
        if (defaultNetwork != null && defaultNetwork.linkProperties != null) {
            info.primaryUnderlyingIface = getDefaultNetwork().linkProperties.getInterfaceName();
        }
    } else if (underlyingNetworks.length > 0) {
        LinkProperties linkProperties = getLinkProperties(underlyingNetworks[0]);
        if (linkProperties != null) {
            info.primaryUnderlyingIface = linkProperties.getInterfaceName();
        }
    }
    return info.primaryUnderlyingIface == null ? null : info;
}
Also used : LegacyVpnInfo(com.android.internal.net.LegacyVpnInfo) VpnInfo(com.android.internal.net.VpnInfo) NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo) Network(android.net.Network) LinkProperties(android.net.LinkProperties) Nullable(android.annotation.Nullable)

Example 60 with Network

use of android.net.Network in project platform_frameworks_base by android.

the class ConnectivityService method registerNetworkAgent.

public int registerNetworkAgent(Messenger messenger, NetworkInfo networkInfo, LinkProperties linkProperties, NetworkCapabilities networkCapabilities, int currentScore, NetworkMisc networkMisc) {
    enforceConnectivityInternalPermission();
    // TODO: Instead of passing mDefaultRequest, provide an API to determine whether a Network
    // satisfies mDefaultRequest.
    final NetworkAgentInfo nai = new NetworkAgentInfo(messenger, new AsyncChannel(), new Network(reserveNetId()), new NetworkInfo(networkInfo), new LinkProperties(linkProperties), new NetworkCapabilities(networkCapabilities), currentScore, mContext, mTrackerHandler, new NetworkMisc(networkMisc), mDefaultRequest, this);
    synchronized (this) {
        nai.networkMonitor.systemReady = mSystemReady;
    }
    addValidationLogs(nai.networkMonitor.getValidationLogs(), nai.network, networkInfo.getExtraInfo());
    if (DBG)
        log("registerNetworkAgent " + nai);
    mHandler.sendMessage(mHandler.obtainMessage(EVENT_REGISTER_NETWORK_AGENT, nai));
    return nai.network.netId;
}
Also used : NetworkMisc(android.net.NetworkMisc) NetworkInfo(android.net.NetworkInfo) NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo) Network(android.net.Network) AsyncChannel(com.android.internal.util.AsyncChannel) LinkProperties(android.net.LinkProperties) NetworkCapabilities(android.net.NetworkCapabilities)

Aggregations

Network (android.net.Network)92 SmallTest (android.test.suitebuilder.annotation.SmallTest)28 NetworkAgentInfo (com.android.server.connectivity.NetworkAgentInfo)25 NetworkCapabilities (android.net.NetworkCapabilities)22 NetworkRequest (android.net.NetworkRequest)18 NetworkInfo (android.net.NetworkInfo)17 LinkProperties (android.net.LinkProperties)16 ConnectivityManager (android.net.ConnectivityManager)11 NetworkCallback (android.net.ConnectivityManager.NetworkCallback)11 Test (org.junit.Test)7 InetAddress (java.net.InetAddress)6 Nullable (android.annotation.Nullable)5 NetworkMisc (android.net.NetworkMisc)5 NetworkState (android.net.NetworkState)5 WifiConfiguration (android.net.wifi.WifiConfiguration)5 WifiInfo (android.net.wifi.WifiInfo)5 ConditionVariable (android.os.ConditionVariable)5 WebSettings (android.webkit.WebSettings)5 HomeSP (com.android.hotspot2.pps.HomeSP)5 LegacyVpnInfo (com.android.internal.net.LegacyVpnInfo)5