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

Commit 859e7de2 authored by Irfan Sheriff's avatar Irfan Sheriff
Browse files

Fix connection notification for group owner

Bug: 5002384
Change-Id: I099d6907787a0becf9363c3709efd8d4ec2a97af
parent ea5b16ac
Loading
Loading
Loading
Loading
+14 −11
Original line number Diff line number Diff line
@@ -129,6 +129,11 @@ public class WifiP2pService extends IWifiP2pManager.Stub {

    private NetworkInfo mNetworkInfo;

    /* 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";

    public WifiP2pService(Context context) {
        mContext = context;

@@ -739,6 +744,12 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
        public void enter() {
            if (DBG) logd(getName());
            mNetworkInfo.setDetailedState(NetworkInfo.DetailedState.CONNECTED, null, null);

            //DHCP server has already been started if I am a group owner
            if (mGroup.isGroupOwner()) {
                setWifiP2pInfoOnGroupFormation(SERVER_ADDRESS);
                sendP2pConnectionChangedBroadcast();
            }
        }

        @Override
@@ -895,29 +906,21 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
    }

    private void startDhcpServer(String intf) {
        /* Is chosen as a unique range to avoid conflict with
           the range defined in Tethering.java */
        String[] dhcp_range = {"192.168.49.2", "192.168.49.254"};
        String serverAddress = "192.168.49.1";

        InterfaceConfiguration ifcg = null;
        try {
            ifcg = mNwService.getInterfaceConfig(intf);
            ifcg.addr = new LinkAddress(NetworkUtils.numericToInetAddress(
                        serverAddress), 24);
                        SERVER_ADDRESS), 24);
            ifcg.interfaceFlags = "[up]";
            mNwService.setInterfaceConfig(intf, ifcg);
            /* This starts the dnsmasq server */
            mNwService.startTethering(dhcp_range);
            mNwService.startTethering(DHCP_RANGE);
        } catch (Exception e) {
            loge("Error configuring interface " + intf + ", :" + e);
            return;
        }

        logd("Started Dhcp server on " + intf);

        setWifiP2pInfoOnGroupFormation(serverAddress);
        sendP2pConnectionChangedBroadcast();
   }

    private void stopDhcpServer() {