Skip to content

Commit 287c1e6

Browse files
author
The Android Automerger
committed
Revert "Merge "Avoid duplicate dialogs leading to NPE" into ics-mr0"
This reverts commit 7f00c22, reversing changes made to 451fa13.
1 parent b6b1176 commit 287c1e6

File tree

1 file changed

+14
-101
lines changed

1 file changed

+14
-101
lines changed

wifi/java/android/net/wifi/p2p/WifiP2pService.java

Lines changed: 14 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
*/
8282
public class WifiP2pService extends IWifiP2pManager.Stub {
8383
private static final String TAG = "WifiP2pService";
84-
private static final boolean DBG = false;
84+
private static final boolean DBG = true;
8585
private static final String NETWORKTYPE = "WIFI_P2P";
8686

8787
private Context mContext;
@@ -131,22 +131,12 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
131131
/* User rejected to disable Wi-Fi in order to enable p2p */
132132
private static final int WIFI_DISABLE_USER_REJECT = BASE + 5;
133133

134-
/* User accepted a group negotiation request */
135-
private static final int GROUP_NEGOTIATION_USER_ACCEPT = BASE + 6;
136-
/* User rejected a group negotiation request */
137-
private static final int GROUP_NEGOTIATION_USER_REJECT = BASE + 7;
138-
139-
/* User accepted a group invitation request */
140-
private static final int GROUP_INVITATION_USER_ACCEPT = BASE + 8;
141-
/* User rejected a group invitation request */
142-
private static final int GROUP_INVITATION_USER_REJECT = BASE + 9;
143-
144134
/* Airplane mode changed */
145-
private static final int AIRPLANE_MODE_CHANGED = BASE + 10;
135+
private static final int AIRPLANE_MODE_CHANGED = BASE + 6;
146136
/* Emergency callback mode */
147-
private static final int EMERGENCY_CALLBACK_MODE = BASE + 11;
148-
private static final int WPS_PBC = BASE + 12;
149-
private static final int WPS_PIN = BASE + 13;
137+
private static final int EMERGENCY_CALLBACK_MODE = BASE + 7;
138+
private static final int WPS_PBC = BASE + 8;
139+
private static final int WPS_PIN = BASE + 9;
150140

151141
private final boolean mP2pSupported;
152142

@@ -270,10 +260,6 @@ private class P2pStateMachine extends StateMachine {
270260
private P2pEnabledState mP2pEnabledState = new P2pEnabledState();
271261
// Inactive is when p2p is enabled with no connectivity
272262
private InactiveState mInactiveState = new InactiveState();
273-
private UserAuthorizingGroupNegotiationState mUserAuthorizingGroupNegotiationState
274-
= new UserAuthorizingGroupNegotiationState();
275-
private UserAuthorizingGroupInvitationState mUserAuthorizingGroupInvitationState
276-
= new UserAuthorizingGroupInvitationState();
277263
private GroupNegotiationState mGroupNegotiationState = new GroupNegotiationState();
278264
private GroupCreatedState mGroupCreatedState = new GroupCreatedState();
279265

@@ -304,8 +290,6 @@ private class P2pStateMachine extends StateMachine {
304290
addState(mP2pEnablingState, mDefaultState);
305291
addState(mP2pEnabledState, mDefaultState);
306292
addState(mInactiveState, mP2pEnabledState);
307-
addState(mUserAuthorizingGroupNegotiationState, mInactiveState);
308-
addState(mUserAuthorizingGroupInvitationState, mInactiveState);
309293
addState(mGroupNegotiationState, mP2pEnabledState);
310294
addState(mGroupCreatedState, mP2pEnabledState);
311295

@@ -395,10 +379,6 @@ public boolean processMessage(Message message) {
395379
// Ignore
396380
case WIFI_DISABLE_USER_ACCEPT:
397381
case WIFI_DISABLE_USER_REJECT:
398-
case GROUP_NEGOTIATION_USER_ACCEPT:
399-
case GROUP_NEGOTIATION_USER_REJECT:
400-
case GROUP_INVITATION_USER_ACCEPT:
401-
case GROUP_INVITATION_USER_REJECT:
402382
case GROUP_NEGOTIATION_TIMED_OUT:
403383
break;
404384
default:
@@ -767,7 +747,6 @@ public boolean processMessage(Message message) {
767747
case WifiMonitor.P2P_GO_NEGOTIATION_REQUEST_EVENT:
768748
mSavedGoNegotiationConfig = (WifiP2pConfig) message.obj;
769749
notifyP2pGoNegotationRequest(mSavedGoNegotiationConfig);
770-
transitionTo(mUserAuthorizingGroupNegotiationState);
771750
break;
772751
case WifiP2pManager.CREATE_GROUP:
773752
mPersistGroup = true;
@@ -782,37 +761,6 @@ public boolean processMessage(Message message) {
782761
case WifiMonitor.P2P_INVITATION_RECEIVED_EVENT:
783762
WifiP2pGroup group = (WifiP2pGroup) message.obj;
784763
notifyP2pInvitationReceived(group);
785-
transitionTo(mUserAuthorizingGroupInvitationState);
786-
break;
787-
default:
788-
return NOT_HANDLED;
789-
}
790-
return HANDLED;
791-
}
792-
}
793-
794-
class UserAuthorizingGroupNegotiationState extends State {
795-
@Override
796-
public void enter() {
797-
if (DBG) logd(getName());
798-
}
799-
800-
@Override
801-
public boolean processMessage(Message message) {
802-
if (DBG) logd(getName() + message.toString());
803-
switch (message.what) {
804-
case WifiMonitor.P2P_GO_NEGOTIATION_REQUEST_EVENT:
805-
case WifiMonitor.P2P_INVITATION_RECEIVED_EVENT:
806-
//Ignore additional connection requests
807-
break;
808-
case GROUP_NEGOTIATION_USER_ACCEPT:
809-
sendMessage(WifiP2pManager.CONNECT, mSavedGoNegotiationConfig);
810-
mSavedGoNegotiationConfig = null;
811-
break;
812-
case GROUP_NEGOTIATION_USER_REJECT:
813-
if (DBG) logd("User rejected incoming negotiation request");
814-
mSavedGoNegotiationConfig = null;
815-
transitionTo(mInactiveState);
816764
break;
817765
default:
818766
return NOT_HANDLED;
@@ -821,40 +769,6 @@ public boolean processMessage(Message message) {
821769
}
822770
}
823771

824-
class UserAuthorizingGroupInvitationState extends State {
825-
@Override
826-
public void enter() {
827-
if (DBG) logd(getName());
828-
}
829-
830-
@Override
831-
public boolean processMessage(Message message) {
832-
if (DBG) logd(getName() + message.toString());
833-
switch (message.what) {
834-
case WifiMonitor.P2P_GO_NEGOTIATION_REQUEST_EVENT:
835-
case WifiMonitor.P2P_INVITATION_RECEIVED_EVENT:
836-
//Ignore additional connection requests
837-
break;
838-
case GROUP_INVITATION_USER_ACCEPT:
839-
if (DBG) logd(getName() + " connect to invited group");
840-
WifiP2pConfig config = new WifiP2pConfig();
841-
config.deviceAddress = mSavedP2pGroup.getOwner().deviceAddress;
842-
sendMessage(WifiP2pManager.CONNECT, config);
843-
mSavedP2pGroup = null;
844-
break;
845-
case GROUP_INVITATION_USER_REJECT:
846-
if (DBG) logd("User rejected incoming invitation request");
847-
mSavedP2pGroup = null;
848-
transitionTo(mInactiveState);
849-
break;
850-
default:
851-
return NOT_HANDLED;
852-
}
853-
return HANDLED;
854-
}
855-
}
856-
857-
858772
class GroupNegotiationState extends State {
859773
@Override
860774
public void enter() {
@@ -1177,14 +1091,15 @@ public void onClick(DialogInterface dialog, int which) {
11771091
mSavedGoNegotiationConfig.wps.setup = WpsInfo.KEYPAD;
11781092
mSavedGoNegotiationConfig.wps.pin = pin.getText().toString();
11791093
}
1180-
sendMessage(GROUP_NEGOTIATION_USER_ACCEPT);
1094+
sendMessage(WifiP2pManager.CONNECT, mSavedGoNegotiationConfig);
1095+
mSavedGoNegotiationConfig = null;
11811096
}
11821097
})
11831098
.setNegativeButton(r.getString(R.string.cancel), new OnClickListener() {
11841099
@Override
11851100
public void onClick(DialogInterface dialog, int which) {
11861101
if (DBG) logd(getName() + " ignore connect");
1187-
sendMessage(GROUP_NEGOTIATION_USER_REJECT);
1102+
mSavedGoNegotiationConfig = null;
11881103
}
11891104
})
11901105
.create();
@@ -1265,16 +1180,14 @@ private void notifyP2pInvitationReceived(WifiP2pGroup group) {
12651180
.setView(textEntryView)
12661181
.setPositiveButton(r.getString(R.string.ok), new OnClickListener() {
12671182
public void onClick(DialogInterface dialog, int which) {
1268-
sendMessage(GROUP_INVITATION_USER_ACCEPT);
1269-
}
1270-
})
1271-
.setNegativeButton(r.getString(R.string.cancel), new OnClickListener() {
1272-
@Override
1273-
public void onClick(DialogInterface dialog, int which) {
1274-
if (DBG) logd(getName() + " ignore invite");
1275-
sendMessage(GROUP_INVITATION_USER_REJECT);
1183+
WifiP2pConfig config = new WifiP2pConfig();
1184+
config.deviceAddress = mSavedP2pGroup.getOwner().deviceAddress;
1185+
if (DBG) logd(getName() + " connect to invited group");
1186+
sendMessage(WifiP2pManager.CONNECT, config);
1187+
mSavedP2pGroup = null;
12761188
}
12771189
})
1190+
.setNegativeButton(r.getString(R.string.cancel), null)
12781191
.create();
12791192

12801193
pin.setVisibility(View.GONE);

0 commit comments

Comments
 (0)