Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c088282a authored by Marcos Marado's avatar Marcos Marado Committed by Gerrit Code Review
Browse files

Revert 'base: Add P2P interface "p2p0" to tethering support list'

* fixes p2p issues

Change-Id: I12249f4f633c5b317d04da9f433ee58bb21f4681
parent 41220928
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -249,14 +249,6 @@
    <string-array translatable="false" name="config_tether_wifi_regexs">
    </string-array>

    <!-- List of regexpressions describing the interface (if any) that represent tetherable
         p2p Go interfaces.  If the device doesn't want to support tethering over P2p this
         should be empty. -->
    <string-array translatable="false" name="config_tether_p2p_regexs">
        <item>"p2p0"</item>
    </string-array>


    <!-- List of regexpressions describing the interface (if any) that represent tetherable
         WiMAX interfaces.  If the device doesn't want to support tethering over Wifi this
         should be empty.  An example would be "softap.*" -->
+0 −1
Original line number Diff line number Diff line
@@ -1476,7 +1476,6 @@
  <java-symbol type="array" name="config_tether_upstream_types" />
  <java-symbol type="array" name="config_tether_usb_regexs" />
  <java-symbol type="array" name="config_tether_wifi_regexs" />
  <java-symbol type="array" name="config_tether_p2p_regexs" />
  <java-symbol type="array" name="config_usbHostBlacklist" />
  <java-symbol type="array" name="config_serialPorts" />
  <java-symbol type="array" name="radioAttributes" />
+2 −28
Original line number Diff line number Diff line
@@ -116,7 +116,6 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
    // TODO - remove both of these - should be part of interface inspection/selection stuff
    private String[] mTetherableUsbRegexs;
    private String[] mTetherableWifiRegexs;
    private String[] mTetherableP2pRegexs;
    private String[] mTetherableBluetoothRegexs;
    private Collection<Integer> mUpstreamIfaceTypes;

@@ -151,12 +150,11 @@ public class Tethering extends INetworkManagementEventObserver.Stub {

    private String[] mDhcpRange;
    private static final int TETHER_RETRY_UPSTREAM_LIMIT = 5;
    // P2p GO is 192.168.49.1 and 255.255.255.0
    private static final String[] DHCP_DEFAULT_RANGE = {
        "192.168.42.2", "192.168.42.254", "192.168.43.2", "192.168.43.254",
        "192.168.44.2", "192.168.44.254", "192.168.45.2", "192.168.45.254",
        "192.168.46.2", "192.168.46.254", "192.168.47.2", "192.168.47.254",
        "192.168.48.2", "192.168.48.254", "192.168.49.2", "192.168.49.254"
        "192.168.48.2", "192.168.48.254",
    };

    private String[] mDefaultDnsServers;
@@ -233,8 +231,6 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
                com.android.internal.R.array.config_tether_usb_regexs);
        String[] tetherableWifiRegexs = mContext.getResources().getStringArray(
                com.android.internal.R.array.config_tether_wifi_regexs);
        String[] tetherableP2pRegexs = mContext.getResources().getStringArray(
                com.android.internal.R.array.config_tether_p2p_regexs);
        String[] tetherableBluetoothRegexs = mContext.getResources().getStringArray(
                com.android.internal.R.array.config_tether_bluetooth_regexs);

@@ -273,7 +269,6 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
        synchronized (mPublicSync) {
            mTetherableUsbRegexs = tetherableUsbRegexs;
            mTetherableWifiRegexs = tetherableWifiRegexs;
            mTetherableP2pRegexs = tetherableP2pRegexs;
            mTetherableBluetoothRegexs = tetherableBluetoothRegexs;
            mUpstreamIfaceTypes = upstreamIfaceTypes;
        }
@@ -289,8 +284,6 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
        synchronized (mPublicSync) {
            if (isWifi(iface)) {
                found = true;
            } else if (isP2p(iface)) {
                found = true;
            } else if (isUsb(iface)) {
                found = true;
                usb = true;
@@ -342,15 +335,6 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
        }
    }

    public boolean isP2p(String iface) {
        synchronized (mPublicSync) {
            for (String regex : mTetherableP2pRegexs) {
                if (iface.matches(regex)) return true;
            }
            return false;
        }
    }

    public boolean isBluetooth(String iface) {
        synchronized (mPublicSync) {
            for (String regex : mTetherableBluetoothRegexs) {
@@ -368,9 +352,6 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
            if (isWifi(iface)) {
                found = true;
            }
            if (isP2p(iface)) {
                found = true;
            }
            if (isUsb(iface)) {
                found = true;
                usb = true;
@@ -480,7 +461,6 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
        ArrayList<String> erroredList = new ArrayList<String>();

        boolean wifiTethered = false;
        boolean p2pTethered = false;
        boolean usbTethered = false;
        boolean bluetoothTethered = false;

@@ -498,8 +478,6 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
                            usbTethered = true;
                        } else if (isWifi((String)iface)) {
                            wifiTethered = true;
                        } else if (isP2p((String)iface)) {
                            p2pTethered = true;
                      } else if (isBluetooth((String)iface)) {
                            bluetoothTethered = true;
                        }
@@ -784,10 +762,6 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
        return mTetherableWifiRegexs;
    }

    public String[] getTetherableP2pRegexs() {
        return mTetherableP2pRegexs;
    }

    public String[] getTetherableBluetoothRegexs() {
        return mTetherableBluetoothRegexs;
    }
+10 −25
Original line number Diff line number Diff line
@@ -109,7 +109,6 @@ public class WifiP2pService extends IWifiP2pManager.Stub {

    INetworkManagementService mNwService;
    private DhcpStateMachine mDhcpStateMachine;
    private ConnectivityManager mCm;

    private P2pStateMachine mP2pStateMachine;
    private AsyncChannel mReplyChannel = new AsyncChannel();
@@ -230,7 +229,9 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
    /* clients(application) information list. */
    private HashMap<Messenger, ClientInfo> mClientInfoList = new HashMap<Messenger, ClientInfo>();

    /* The range defined in Tethering.java include range for P2P group*/
    /* Is chosen as a unique range to avoid conflict with
       the range defined in Tethering.java */
    private static final String[] DHCP_RANGE = {"192.168.49.2", "192.168.49.254"};
    private static final String SERVER_ADDRESS = "192.168.49.1";

    /**
@@ -2136,29 +2137,16 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
        mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
    }

    private void checkAndSetConnectivityInstance() {
        if (mCm == null) {
            mCm = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
        }
    }

    private void startDhcpServer(String intf) {
        InterfaceConfiguration ifcg = null;

        checkAndSetConnectivityInstance();

        try {
            ifcg = mNwService.getInterfaceConfig(intf);
            if (ifcg != null) {
            ifcg.setLinkAddress(new LinkAddress(NetworkUtils.numericToInetAddress(
                        SERVER_ADDRESS), 24));
            ifcg.setInterfaceUp();
            mNwService.setInterfaceConfig(intf, ifcg);
                if (mCm.tether(intf) != ConnectivityManager.TETHER_ERROR_NO_ERROR) {
                    loge("Error tethering on " + intf);
                     return;
                }
             }
            /* This starts the dnsmasq server */
            mNwService.startTethering(DHCP_RANGE);
        } catch (Exception e) {
            loge("Error configuring interface " + intf + ", :" + e);
            return;
@@ -2168,11 +2156,8 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
   }

    private void stopDhcpServer(String intf) {
        checkAndSetConnectivityInstance();
        try {
            if (mCm.untether(intf) != ConnectivityManager.TETHER_ERROR_NO_ERROR) {
                loge("Error Untether on " + intf);
            }
            mNwService.stopTethering();
        } catch (Exception e) {
            loge("Error stopping Dhcp server" + e);
            return;