Search in sources :

Example 26 with InterfaceConfiguration

use of android.net.InterfaceConfiguration in project android_frameworks_base by AOSPA.

the class NetworkManagementService method setInterfaceUp.

@Override
public void setInterfaceUp(String iface) {
    mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
    final InterfaceConfiguration ifcg = getInterfaceConfig(iface);
    ifcg.setInterfaceUp();
    setInterfaceConfig(iface, ifcg);
}
Also used : InterfaceConfiguration(android.net.InterfaceConfiguration)

Example 27 with InterfaceConfiguration

use of android.net.InterfaceConfiguration in project android_frameworks_base by ParanoidAndroid.

the class WifiStateMachine method startTethering.

private boolean startTethering(ArrayList<String> available) {
    boolean wifiAvailable = false;
    checkAndSetConnectivityInstance();
    String[] wifiRegexs = mCm.getTetherableWifiRegexs();
    for (String intf : available) {
        for (String regex : wifiRegexs) {
            if (intf.matches(regex)) {
                InterfaceConfiguration ifcg = null;
                try {
                    ifcg = mNwService.getInterfaceConfig(intf);
                    if (ifcg != null) {
                        /* IP/netmask: 192.168.43.1/255.255.255.0 */
                        ifcg.setLinkAddress(new LinkAddress(NetworkUtils.numericToInetAddress("192.168.43.1"), 24));
                        ifcg.setInterfaceUp();
                        mNwService.setInterfaceConfig(intf, ifcg);
                    }
                } catch (Exception e) {
                    loge("Error configuring interface " + intf + ", :" + e);
                    return false;
                }
                if (mCm.tether(intf) != ConnectivityManager.TETHER_ERROR_NO_ERROR) {
                    loge("Error tethering on " + intf);
                    return false;
                }
                mTetherInterfaceName = intf;
                return true;
            }
        }
    }
    // We found no interfaces to tether
    return false;
}
Also used : LinkAddress(android.net.LinkAddress) InterfaceConfiguration(android.net.InterfaceConfiguration) RemoteException(android.os.RemoteException)

Example 28 with InterfaceConfiguration

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

the class NetworkManagementService method setInterfaceDown.

@Override
public void setInterfaceDown(String iface) {
    mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
    final InterfaceConfiguration ifcg = getInterfaceConfig(iface);
    ifcg.setInterfaceDown();
    setInterfaceConfig(iface, ifcg);
}
Also used : InterfaceConfiguration(android.net.InterfaceConfiguration)

Example 29 with InterfaceConfiguration

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

the class NetworkManagementService method setInterfaceUp.

@Override
public void setInterfaceUp(String iface) {
    mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
    final InterfaceConfiguration ifcg = getInterfaceConfig(iface);
    ifcg.setInterfaceUp();
    setInterfaceConfig(iface, ifcg);
}
Also used : InterfaceConfiguration(android.net.InterfaceConfiguration)

Example 30 with InterfaceConfiguration

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

the class IpManager method setIPv4Address.

private boolean setIPv4Address(LinkAddress address) {
    final InterfaceConfiguration ifcg = new InterfaceConfiguration();
    ifcg.setLinkAddress(address);
    try {
        mNwService.setInterfaceConfig(mInterfaceName, ifcg);
        if (VDBG)
            Log.d(mTag, "IPv4 configuration succeeded");
    } catch (IllegalStateException | RemoteException e) {
        logError("IPv4 configuration failed: %s", e);
        return false;
    }
    return true;
}
Also used : RemoteException(android.os.RemoteException) InterfaceConfiguration(android.net.InterfaceConfiguration)

Aggregations

InterfaceConfiguration (android.net.InterfaceConfiguration)44 LinkAddress (android.net.LinkAddress)22 RemoteException (android.os.RemoteException)20 InetAddress (java.net.InetAddress)13 NoSuchElementException (java.util.NoSuchElementException)6 StringTokenizer (java.util.StringTokenizer)6 NotFoundException (android.content.res.Resources.NotFoundException)1 ConnectivityManager (android.net.ConnectivityManager)1 RouteInfo (android.net.RouteInfo)1 IBinder (android.os.IBinder)1 INetworkManagementService (android.os.INetworkManagementService)1 Message (android.os.Message)1