@@ -1500,8 +1500,7 @@ private boolean updateSupplicantServiceRequest() {
15001500 int key ;
15011501 WifiP2pServiceRequest req ;
15021502 for (int i =0 ; i < c .mReqList .size (); i ++) {
1503- key = c .mReqList .keyAt (i );
1504- req = c .mReqList .get (key );
1503+ req = c .mReqList .valueAt (i );
15051504 if (req != null ) {
15061505 sb .append (req .getSupplicantQuery ());
15071506 }
@@ -1539,7 +1538,10 @@ private boolean addServiceRequest(Messenger m, WifiP2pServiceRequest req) {
15391538 return false ;
15401539 }
15411540
1542- req .setTransactionId (++mServiceTransactionId );
1541+ ++mServiceTransactionId ;
1542+ //The Wi-Fi p2p spec says transaction id should be non-zero
1543+ if (mServiceTransactionId == 0 ) ++mServiceTransactionId ;
1544+ req .setTransactionId (mServiceTransactionId );
15431545 clientInfo .mReqList .put (mServiceTransactionId , req );
15441546
15451547 if (mServiceDiscReqId == null ) {
@@ -1550,13 +1552,23 @@ private boolean addServiceRequest(Messenger m, WifiP2pServiceRequest req) {
15501552 }
15511553
15521554 private void removeServiceRequest (Messenger m , WifiP2pServiceRequest req ) {
1553-
15541555 ClientInfo clientInfo = getClientInfo (m , false );
15551556 if (clientInfo == null ) {
15561557 return ;
15571558 }
15581559
1559- clientInfo .mReqList .remove (req .getTransactionId ());
1560+ //Application does not have transaction id information
1561+ //go through stored requests to remove
1562+ boolean removed = false ;
1563+ for (int i =0 ; i < clientInfo .mReqList .size (); i ++) {
1564+ if (req .equals (clientInfo .mReqList .valueAt (i ))) {
1565+ removed = true ;
1566+ clientInfo .mReqList .removeAt (i );
1567+ break ;
1568+ }
1569+ }
1570+
1571+ if (!removed ) return ;
15601572
15611573 if (clientInfo .mReqList .size () == 0 && clientInfo .mServList .size () == 0 ) {
15621574 if (DBG ) logd ("remove client information from framework" );
@@ -1670,6 +1682,7 @@ private void sendServiceResponse(WifiP2pServiceResponse resp) {
16701682 } catch (RemoteException e ) {
16711683 if (DBG ) logd ("detect dead channel" );
16721684 clearClientInfo (c .mMessenger );
1685+ return ;
16731686 }
16741687 }
16751688 }
@@ -1683,6 +1696,8 @@ private void sendServiceResponse(WifiP2pServiceResponse resp) {
16831696 * TODO: This can be done better with full async channels.
16841697 */
16851698 private void clearClientDeadChannels () {
1699+ ArrayList <Messenger > deadClients = new ArrayList <Messenger >();
1700+
16861701 for (ClientInfo c : mClientInfoList .values ()) {
16871702 Message msg = Message .obtain ();
16881703 msg .what = WifiP2pManager .PING ;
@@ -1693,9 +1708,13 @@ private void clearClientDeadChannels() {
16931708 c .mMessenger .send (msg );
16941709 } catch (RemoteException e ) {
16951710 if (DBG ) logd ("detect dead channel" );
1696- clearClientInfo (c .mMessenger );
1711+ deadClients . add (c .mMessenger );
16971712 }
16981713 }
1714+
1715+ for (Messenger m : deadClients ) {
1716+ clearClientInfo (m );
1717+ }
16991718 }
17001719
17011720 /**
0 commit comments