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

Commit 68980c4d authored by Arif Hussain's avatar Arif Hussain Committed by Steve Kondik
Browse files

Wifi: Handle P2P-REMOVE-AND-REFORM-GROUP event in GroupNegotiationState

Framework does not handle P2P-REMOVE-AND-REFORM-GROUP event
if it is in GroupNegotiationState and p2p-GO will continue to operate
in unsafe channel till it gets next P2P-REMOVE-AND-REFORM-GROUP event.

This commit adds handling of above event in GroupNegotiationState.

Change-Id: I956bbcd0200ddc3acde8b989a6e0950bdeca269e
CRs-fixed: 714368
parent ff9ee917
Loading
Loading
Loading
Loading
+41 −13
Original line number Diff line number Diff line
@@ -445,6 +445,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
        });
        private final WifiP2pInfo mWifiP2pInfo = new WifiP2pInfo();
        private WifiP2pGroup mGroup;
        private boolean mPendingReformGroupIndication = false;

        // Saved WifiP2pConfig for an ongoing peer connection. This will never be null.
        // The deviceAddress will be an empty string when the device is inactive
@@ -1492,6 +1493,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
        @Override
        public void enter() {
            if (DBG) logd(getName());
            mPendingReformGroupIndication = false;
        }

        @Override
@@ -1504,6 +1506,13 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
                case WifiMonitor.P2P_GROUP_FORMATION_SUCCESS_EVENT:
                    if (DBG) logd(getName() + " go success");
                    break;
                // Action of removing and reforming group will be taken
                // when we enter in GroupCreatedState
                case WifiMonitor.P2P_REMOVE_AND_REFORM_GROUP_EVENT:
                    logd("P2P_REMOVE_AND_REFORM_GROUP_EVENT event received"
                         + " in GroupNegotiationState state");
                    mPendingReformGroupIndication = true;
                    break;
                case WifiMonitor.P2P_GROUP_STARTED_EVENT:
                    mGroup = (WifiP2pGroup) message.obj;
                    if (DBG) logd(getName() + " group started");
@@ -1708,7 +1717,25 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
    class GroupCreatedState extends State {
        @Override
        public void enter() {
            if (DBG) logd(getName());
            logd(getName() + "mPendingReformGroupIndication=" + mPendingReformGroupIndication);
            if (mPendingReformGroupIndication) {
                mPendingReformGroupIndication = false;
                if (mWifiNative.p2pGroupRemove(mGroup.getInterface())) {
                    Slog.d(TAG, "Removed P2P group successfully");
                    transitionTo(mOngoingGroupRemovalState);
                } else {
                    Slog.d(TAG, "Failed to remove the P2P group");
                    handleGroupRemoved();
                    transitionTo(mInactiveState);
                }
                if (mAutonomousGroup) {
                    Slog.d(TAG, "AutonomousGroup is set, reform P2P Group");
                    sendMessage(WifiP2pManager.CREATE_GROUP);
                } else {
                    Slog.d(TAG, "AutonomousGroup is not set, will not reform P2P Group");
                }
            } else {

                // Once connected, peer config details are invalid
                mSavedPeerConfig.invalidate();
                mNetworkInfo.setDetailedState(NetworkInfo.DetailedState.CONNECTED, null, null);
@@ -1726,6 +1753,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
                    sendP2pConnectionChangedBroadcast();
                }
            }
        }

        @Override
        public boolean processMessage(Message message) {