@@ -494,15 +494,20 @@ public void startAccessPoint(WifiConfiguration wifiConfig, String wlanIface, Str
494494 * argv8 - Max SCB
495495 */
496496 String str = String .format ("softap set " + wlanIface + " " + softapIface +
497- " \" %s \" %s %s" , wifiConfig .SSID ,
497+ " %s %s %s" , convertQuotedString ( wifiConfig .SSID ) ,
498498 wifiConfig .allowedKeyManagement .get (KeyMgmt .WPA_PSK ) ?
499499 "wpa2-psk" : "open" ,
500- wifiConfig .preSharedKey );
500+ convertQuotedString ( wifiConfig .preSharedKey ) );
501501 mConnector .doCommand (str );
502502 }
503503 mConnector .doCommand (String .format ("softap startap" ));
504504 }
505505
506+ private String convertQuotedString (String s ) {
507+ /* Replace \ with \\, then " with \" and add quotes at end */
508+ return '"' + s .replaceAll ("\\ \\ " ,"\\ \\ \\ \\ " ).replaceAll ("\" " ,"\\ \\ \" " ) + '"' ;
509+ }
510+
506511 public void stopAccessPoint () throws IllegalStateException {
507512 mContext .enforceCallingOrSelfPermission (
508513 android .Manifest .permission .CHANGE_NETWORK_STATE , "NetworkManagementService" );
@@ -521,10 +526,10 @@ public void setAccessPoint(WifiConfiguration wifiConfig, String wlanIface, Strin
521526 mConnector .doCommand (String .format ("softap set " + wlanIface + " " + softapIface ));
522527 } else {
523528 String str = String .format ("softap set " + wlanIface + " " + softapIface +
524- " \" %s \" %s %s" , wifiConfig .SSID ,
529+ " %s %s %s" , convertQuotedString ( wifiConfig .SSID ) ,
525530 wifiConfig .allowedKeyManagement .get (KeyMgmt .WPA_PSK ) ?
526531 "wpa2-psk" : "open" ,
527- wifiConfig .preSharedKey );
532+ convertQuotedString ( wifiConfig .preSharedKey ) );
528533 mConnector .doCommand (str );
529534 }
530535 }
0 commit comments