Loading services/java/com/android/server/NetworkManagementService.java +16 −6 Original line number Diff line number Diff line Loading @@ -612,8 +612,7 @@ class NetworkManagementService extends INetworkManagementService.Stub { */ String str = String.format("softap set " + wlanIface + " " + softapIface + " %s %s %s", convertQuotedString(wifiConfig.SSID), wifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ? "wpa2-psk" : "open", getSecurityType(wifiConfig), convertQuotedString(wifiConfig.preSharedKey)); mConnector.doCommand(str); } Loading @@ -631,6 +630,17 @@ class NetworkManagementService extends INetworkManagementService.Stub { return '"' + s.replaceAll("\\\\","\\\\\\\\").replaceAll("\"","\\\\\"") + '"'; } private String getSecurityType(WifiConfiguration wifiConfig) { switch (wifiConfig.getAuthType()) { case KeyMgmt.WPA_PSK: return "wpa-psk"; case KeyMgmt.WPA2_PSK: return "wpa2-psk"; default: return "open"; } } public void stopAccessPoint() throws IllegalStateException { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.CHANGE_NETWORK_STATE, "NetworkManagementService"); Loading @@ -656,7 +666,7 @@ class NetworkManagementService extends INetworkManagementService.Stub { } else { String str = String.format("softap set " + wlanIface + " " + softapIface + " %s %s %s", convertQuotedString(wifiConfig.SSID), wifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ? "wpa2-psk" : "open", getSecurityType(wifiConfig), convertQuotedString(wifiConfig.preSharedKey)); mConnector.doCommand(str); } Loading services/java/com/android/server/WifiService.java +3 −6 Original line number Diff line number Diff line Loading @@ -501,15 +501,12 @@ public class WifiService extends IWifiManager.Stub { public synchronized void setWifiApConfiguration(WifiConfiguration wifiConfig) { enforceChangePermission(); final ContentResolver cr = mContext.getContentResolver(); boolean isWpa; if (wifiConfig == null) return; int authType = wifiConfig.getAuthType(); Settings.Secure.putString(cr, Settings.Secure.WIFI_AP_SSID, wifiConfig.SSID); isWpa = wifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK); Settings.Secure.putInt(cr, Settings.Secure.WIFI_AP_SECURITY, isWpa ? KeyMgmt.WPA_PSK : KeyMgmt.NONE); if (isWpa) Settings.Secure.putInt(cr, Settings.Secure.WIFI_AP_SECURITY, authType); if (authType != KeyMgmt.NONE) Settings.Secure.putString(cr, Settings.Secure.WIFI_AP_PASSWD, wifiConfig.preSharedKey); } Loading wifi/java/android/net/wifi/WifiConfiguration.java +22 −1 Original line number Diff line number Diff line Loading @@ -107,9 +107,16 @@ public class WifiConfiguration implements Parcelable { * generated WEP keys. */ public static final int IEEE8021X = 3; /** WPA2 pre-shared key for use with soft access point * (requires {@code preSharedKey} to be specified). * @hide */ public static final int WPA2_PSK = 4; public static final String varName = "key_mgmt"; public static final String[] strings = { "NONE", "WPA_PSK", "WPA_EAP", "IEEE8021X" }; public static final String[] strings = { "NONE", "WPA_PSK", "WPA_EAP", "IEEE8021X", "WPA2_PSK" }; } /** Loading Loading @@ -480,6 +487,20 @@ public class WifiConfiguration implements Parcelable { dest.writeInt(nextSetBit); } /** @hide */ public int getAuthType() { if (allowedKeyManagement.get(KeyMgmt.WPA_PSK)) { return KeyMgmt.WPA_PSK; } else if (allowedKeyManagement.get(KeyMgmt.WPA2_PSK)) { return KeyMgmt.WPA2_PSK; } else if (allowedKeyManagement.get(KeyMgmt.WPA_EAP)) { return KeyMgmt.WPA_EAP; } else if (allowedKeyManagement.get(KeyMgmt.IEEE8021X)) { return KeyMgmt.IEEE8021X; } return KeyMgmt.NONE; } /** Implement the Parcelable interface {@hide} */ public int describeContents() { return 0; Loading Loading
services/java/com/android/server/NetworkManagementService.java +16 −6 Original line number Diff line number Diff line Loading @@ -612,8 +612,7 @@ class NetworkManagementService extends INetworkManagementService.Stub { */ String str = String.format("softap set " + wlanIface + " " + softapIface + " %s %s %s", convertQuotedString(wifiConfig.SSID), wifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ? "wpa2-psk" : "open", getSecurityType(wifiConfig), convertQuotedString(wifiConfig.preSharedKey)); mConnector.doCommand(str); } Loading @@ -631,6 +630,17 @@ class NetworkManagementService extends INetworkManagementService.Stub { return '"' + s.replaceAll("\\\\","\\\\\\\\").replaceAll("\"","\\\\\"") + '"'; } private String getSecurityType(WifiConfiguration wifiConfig) { switch (wifiConfig.getAuthType()) { case KeyMgmt.WPA_PSK: return "wpa-psk"; case KeyMgmt.WPA2_PSK: return "wpa2-psk"; default: return "open"; } } public void stopAccessPoint() throws IllegalStateException { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.CHANGE_NETWORK_STATE, "NetworkManagementService"); Loading @@ -656,7 +666,7 @@ class NetworkManagementService extends INetworkManagementService.Stub { } else { String str = String.format("softap set " + wlanIface + " " + softapIface + " %s %s %s", convertQuotedString(wifiConfig.SSID), wifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ? "wpa2-psk" : "open", getSecurityType(wifiConfig), convertQuotedString(wifiConfig.preSharedKey)); mConnector.doCommand(str); } Loading
services/java/com/android/server/WifiService.java +3 −6 Original line number Diff line number Diff line Loading @@ -501,15 +501,12 @@ public class WifiService extends IWifiManager.Stub { public synchronized void setWifiApConfiguration(WifiConfiguration wifiConfig) { enforceChangePermission(); final ContentResolver cr = mContext.getContentResolver(); boolean isWpa; if (wifiConfig == null) return; int authType = wifiConfig.getAuthType(); Settings.Secure.putString(cr, Settings.Secure.WIFI_AP_SSID, wifiConfig.SSID); isWpa = wifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK); Settings.Secure.putInt(cr, Settings.Secure.WIFI_AP_SECURITY, isWpa ? KeyMgmt.WPA_PSK : KeyMgmt.NONE); if (isWpa) Settings.Secure.putInt(cr, Settings.Secure.WIFI_AP_SECURITY, authType); if (authType != KeyMgmt.NONE) Settings.Secure.putString(cr, Settings.Secure.WIFI_AP_PASSWD, wifiConfig.preSharedKey); } Loading
wifi/java/android/net/wifi/WifiConfiguration.java +22 −1 Original line number Diff line number Diff line Loading @@ -107,9 +107,16 @@ public class WifiConfiguration implements Parcelable { * generated WEP keys. */ public static final int IEEE8021X = 3; /** WPA2 pre-shared key for use with soft access point * (requires {@code preSharedKey} to be specified). * @hide */ public static final int WPA2_PSK = 4; public static final String varName = "key_mgmt"; public static final String[] strings = { "NONE", "WPA_PSK", "WPA_EAP", "IEEE8021X" }; public static final String[] strings = { "NONE", "WPA_PSK", "WPA_EAP", "IEEE8021X", "WPA2_PSK" }; } /** Loading Loading @@ -480,6 +487,20 @@ public class WifiConfiguration implements Parcelable { dest.writeInt(nextSetBit); } /** @hide */ public int getAuthType() { if (allowedKeyManagement.get(KeyMgmt.WPA_PSK)) { return KeyMgmt.WPA_PSK; } else if (allowedKeyManagement.get(KeyMgmt.WPA2_PSK)) { return KeyMgmt.WPA2_PSK; } else if (allowedKeyManagement.get(KeyMgmt.WPA_EAP)) { return KeyMgmt.WPA_EAP; } else if (allowedKeyManagement.get(KeyMgmt.IEEE8021X)) { return KeyMgmt.IEEE8021X; } return KeyMgmt.NONE; } /** Implement the Parcelable interface {@hide} */ public int describeContents() { return 0; Loading