diff options
author | Rebecca Silberstein <silberst@google.com> | 2017-01-09 18:46:56 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-01-09 18:46:56 +0000 |
commit | 83418537b8188242e94c11e33298a51ea2606edd (patch) | |
tree | eebc5a0787fd9a39d3c38aeb28c6ac0d0f1463f9 /service | |
parent | 5bd75487ad81dc7a01768def4d0417931cdabff9 (diff) | |
parent | c4d0de0346332a43155580c28097c3bdc9976875 (diff) |
Merge "WifiApConfigStore: randomize default soft ap SSID"
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiApConfigStore.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/WifiApConfigStore.java b/service/java/com/android/server/wifi/WifiApConfigStore.java index bcd8d03e9..4233f5834 100644 --- a/service/java/com/android/server/wifi/WifiApConfigStore.java +++ b/service/java/com/android/server/wifi/WifiApConfigStore.java @@ -32,6 +32,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; +import java.util.Random; import java.util.UUID; /** @@ -46,6 +47,9 @@ public class WifiApConfigStore { private static final int AP_CONFIG_FILE_VERSION = 2; + private static final int RAND_SSID_INT_MIN = 1000; + private static final int RAND_SSID_INT_MAX = 9999; + private WifiConfiguration mWifiApConfig = null; private ArrayList<Integer> mAllowed2GChannel = null; @@ -191,11 +195,16 @@ public class WifiApConfigStore { private WifiConfiguration getDefaultApConfiguration() { WifiConfiguration config = new WifiConfiguration(); config.SSID = mContext.getResources().getString( - R.string.wifi_tether_configure_ssid_default); + R.string.wifi_tether_configure_ssid_default) + "_" + getRandomIntForDefaultSsid(); config.allowedKeyManagement.set(KeyMgmt.WPA2_PSK); String randomUUID = UUID.randomUUID().toString(); //first 12 chars from xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx config.preSharedKey = randomUUID.substring(0, 8) + randomUUID.substring(9, 13); return config; } + + private int getRandomIntForDefaultSsid() { + Random random = new Random(); + return random.nextInt((RAND_SSID_INT_MAX - RAND_SSID_INT_MIN) + 1) + RAND_SSID_INT_MIN; + } } |