Revert "Merge "Avoid duplicate dialogs leading to NPE" into ics-mr0"

This reverts commit 7f00c22b7f, reversing
changes made to 451fa13e82.
This commit is contained in:
The Android Automerger
2011-11-02 21:08:38 -07:00
parent b6b117624b
commit 287c1e66fe

View File

@@ -81,7 +81,7 @@ import java.util.Collection;
*/
public class WifiP2pService extends IWifiP2pManager.Stub {
private static final String TAG = "WifiP2pService";
private static final boolean DBG = false;
private static final boolean DBG = true;
private static final String NETWORKTYPE = "WIFI_P2P";
private Context mContext;
@@ -131,22 +131,12 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
/* User rejected to disable Wi-Fi in order to enable p2p */
private static final int WIFI_DISABLE_USER_REJECT = BASE + 5;
/* User accepted a group negotiation request */
private static final int GROUP_NEGOTIATION_USER_ACCEPT = BASE + 6;
/* User rejected a group negotiation request */
private static final int GROUP_NEGOTIATION_USER_REJECT = BASE + 7;
/* User accepted a group invitation request */
private static final int GROUP_INVITATION_USER_ACCEPT = BASE + 8;
/* User rejected a group invitation request */
private static final int GROUP_INVITATION_USER_REJECT = BASE + 9;
/* Airplane mode changed */
private static final int AIRPLANE_MODE_CHANGED = BASE + 10;
private static final int AIRPLANE_MODE_CHANGED = BASE + 6;
/* Emergency callback mode */
private static final int EMERGENCY_CALLBACK_MODE = BASE + 11;
private static final int WPS_PBC = BASE + 12;
private static final int WPS_PIN = BASE + 13;
private static final int EMERGENCY_CALLBACK_MODE = BASE + 7;
private static final int WPS_PBC = BASE + 8;
private static final int WPS_PIN = BASE + 9;
private final boolean mP2pSupported;
@@ -270,10 +260,6 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
private P2pEnabledState mP2pEnabledState = new P2pEnabledState();
// Inactive is when p2p is enabled with no connectivity
private InactiveState mInactiveState = new InactiveState();
private UserAuthorizingGroupNegotiationState mUserAuthorizingGroupNegotiationState
= new UserAuthorizingGroupNegotiationState();
private UserAuthorizingGroupInvitationState mUserAuthorizingGroupInvitationState
= new UserAuthorizingGroupInvitationState();
private GroupNegotiationState mGroupNegotiationState = new GroupNegotiationState();
private GroupCreatedState mGroupCreatedState = new GroupCreatedState();
@@ -304,8 +290,6 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
addState(mP2pEnablingState, mDefaultState);
addState(mP2pEnabledState, mDefaultState);
addState(mInactiveState, mP2pEnabledState);
addState(mUserAuthorizingGroupNegotiationState, mInactiveState);
addState(mUserAuthorizingGroupInvitationState, mInactiveState);
addState(mGroupNegotiationState, mP2pEnabledState);
addState(mGroupCreatedState, mP2pEnabledState);
@@ -395,10 +379,6 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
// Ignore
case WIFI_DISABLE_USER_ACCEPT:
case WIFI_DISABLE_USER_REJECT:
case GROUP_NEGOTIATION_USER_ACCEPT:
case GROUP_NEGOTIATION_USER_REJECT:
case GROUP_INVITATION_USER_ACCEPT:
case GROUP_INVITATION_USER_REJECT:
case GROUP_NEGOTIATION_TIMED_OUT:
break;
default:
@@ -767,7 +747,6 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
case WifiMonitor.P2P_GO_NEGOTIATION_REQUEST_EVENT:
mSavedGoNegotiationConfig = (WifiP2pConfig) message.obj;
notifyP2pGoNegotationRequest(mSavedGoNegotiationConfig);
transitionTo(mUserAuthorizingGroupNegotiationState);
break;
case WifiP2pManager.CREATE_GROUP:
mPersistGroup = true;
@@ -782,7 +761,6 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
case WifiMonitor.P2P_INVITATION_RECEIVED_EVENT:
WifiP2pGroup group = (WifiP2pGroup) message.obj;
notifyP2pInvitationReceived(group);
transitionTo(mUserAuthorizingGroupInvitationState);
break;
default:
return NOT_HANDLED;
@@ -791,70 +769,6 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
}
}
class UserAuthorizingGroupNegotiationState extends State {
@Override
public void enter() {
if (DBG) logd(getName());
}
@Override
public boolean processMessage(Message message) {
if (DBG) logd(getName() + message.toString());
switch (message.what) {
case WifiMonitor.P2P_GO_NEGOTIATION_REQUEST_EVENT:
case WifiMonitor.P2P_INVITATION_RECEIVED_EVENT:
//Ignore additional connection requests
break;
case GROUP_NEGOTIATION_USER_ACCEPT:
sendMessage(WifiP2pManager.CONNECT, mSavedGoNegotiationConfig);
mSavedGoNegotiationConfig = null;
break;
case GROUP_NEGOTIATION_USER_REJECT:
if (DBG) logd("User rejected incoming negotiation request");
mSavedGoNegotiationConfig = null;
transitionTo(mInactiveState);
break;
default:
return NOT_HANDLED;
}
return HANDLED;
}
}
class UserAuthorizingGroupInvitationState extends State {
@Override
public void enter() {
if (DBG) logd(getName());
}
@Override
public boolean processMessage(Message message) {
if (DBG) logd(getName() + message.toString());
switch (message.what) {
case WifiMonitor.P2P_GO_NEGOTIATION_REQUEST_EVENT:
case WifiMonitor.P2P_INVITATION_RECEIVED_EVENT:
//Ignore additional connection requests
break;
case GROUP_INVITATION_USER_ACCEPT:
if (DBG) logd(getName() + " connect to invited group");
WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress = mSavedP2pGroup.getOwner().deviceAddress;
sendMessage(WifiP2pManager.CONNECT, config);
mSavedP2pGroup = null;
break;
case GROUP_INVITATION_USER_REJECT:
if (DBG) logd("User rejected incoming invitation request");
mSavedP2pGroup = null;
transitionTo(mInactiveState);
break;
default:
return NOT_HANDLED;
}
return HANDLED;
}
}
class GroupNegotiationState extends State {
@Override
public void enter() {
@@ -1177,14 +1091,15 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
mSavedGoNegotiationConfig.wps.setup = WpsInfo.KEYPAD;
mSavedGoNegotiationConfig.wps.pin = pin.getText().toString();
}
sendMessage(GROUP_NEGOTIATION_USER_ACCEPT);
sendMessage(WifiP2pManager.CONNECT, mSavedGoNegotiationConfig);
mSavedGoNegotiationConfig = null;
}
})
.setNegativeButton(r.getString(R.string.cancel), new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (DBG) logd(getName() + " ignore connect");
sendMessage(GROUP_NEGOTIATION_USER_REJECT);
mSavedGoNegotiationConfig = null;
}
})
.create();
@@ -1265,16 +1180,14 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
.setView(textEntryView)
.setPositiveButton(r.getString(R.string.ok), new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
sendMessage(GROUP_INVITATION_USER_ACCEPT);
}
})
.setNegativeButton(r.getString(R.string.cancel), new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (DBG) logd(getName() + " ignore invite");
sendMessage(GROUP_INVITATION_USER_REJECT);
WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress = mSavedP2pGroup.getOwner().deviceAddress;
if (DBG) logd(getName() + " connect to invited group");
sendMessage(WifiP2pManager.CONNECT, config);
mSavedP2pGroup = null;
}
})
.setNegativeButton(r.getString(R.string.cancel), null)
.create();
pin.setVisibility(View.GONE);