File tree Expand file tree Collapse file tree 3 files changed +39
-2
lines changed
wifi/java/android/net/wifi Expand file tree Collapse file tree 3 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -640,6 +640,27 @@ public String p2pGetDeviceAddress() {
640640 return "" ;
641641 }
642642
643+ public int getGroupCapability (String deviceAddress ) {
644+ int gc = 0 ;
645+ if (TextUtils .isEmpty (deviceAddress )) return gc ;
646+ String peerInfo = p2pPeer (deviceAddress );
647+ if (TextUtils .isEmpty (peerInfo )) return gc ;
648+
649+ String [] tokens = peerInfo .split ("\n " );
650+ for (String token : tokens ) {
651+ if (token .startsWith ("group_capab=" )) {
652+ String [] nameValue = token .split ("=" );
653+ if (nameValue .length != 2 ) break ;
654+ try {
655+ return Integer .decode (nameValue [1 ]);
656+ } catch (NumberFormatException e ) {
657+ return gc ;
658+ }
659+ }
660+ }
661+ return gc ;
662+ }
663+
643664 public String p2pPeer (String deviceAddress ) {
644665 return doStringCommand ("P2P_PEER " + deviceAddress );
645666 }
Original file line number Diff line number Diff line change 1919import android .os .Parcelable ;
2020import android .os .Parcel ;
2121import android .net .wifi .p2p .WifiP2pDevice ;
22+ import android .text .TextUtils ;
2223import android .util .Log ;
2324
2425import java .util .ArrayList ;
@@ -83,11 +84,22 @@ public void update(WifiP2pDevice device) {
8384 mDevices .put (device .deviceAddress , device );
8485 }
8586
87+ /** @hide */
88+ public void updateGroupCapability (String deviceAddress , int groupCapab ) {
89+ if (TextUtils .isEmpty (deviceAddress )) return ;
90+ WifiP2pDevice d = mDevices .get (deviceAddress );
91+ if (d != null ) {
92+ d .groupCapability = groupCapab ;
93+ }
94+ }
95+
8696 /** @hide */
8797 public void updateStatus (String deviceAddress , int status ) {
88- if (deviceAddress == null ) return ;
98+ if (TextUtils . isEmpty ( deviceAddress ) ) return ;
8999 WifiP2pDevice d = mDevices .get (deviceAddress );
90- d .status = status ;
100+ if (d != null ) {
101+ d .status = status ;
102+ }
91103 }
92104
93105 /** @hide */
Original file line number Diff line number Diff line change @@ -764,6 +764,10 @@ public boolean processMessage(Message message) {
764764 WifiP2pConfig config = (WifiP2pConfig ) message .obj ;
765765 mAutonomousGroup = false ;
766766
767+ /* Update group capability before connect */
768+ int gc = mWifiNative .getGroupCapability (config .deviceAddress );
769+ mPeers .updateGroupCapability (config .deviceAddress , gc );
770+
767771 if (mSavedPeerConfig != null && config .deviceAddress .equals (
768772 mSavedPeerConfig .deviceAddress )) {
769773 mSavedPeerConfig = config ;
You can’t perform that action at this time.
0 commit comments