diff options
author | Rebecca Silberstein <silberst@google.com> | 2017-04-15 21:52:54 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-04-15 21:52:54 +0000 |
commit | 11df4062d7a5a7ed192a0de8f7fd19817048e9b1 (patch) | |
tree | cfa0b5cb0d381c0a79958b92c35e04d3cf7ec71e /service | |
parent | 6fbe976501c2c4501a22986ba35f9e91dffce1ad (diff) | |
parent | 021255a7c135ae7ee1680e9c72301dfc55151fd7 (diff) |
WifiApConfigStore: create temp sharing AP config am: 1e5c1abdeb am: 7fa3919c94 am: b487bcbf34
am: 021255a7c1
Change-Id: I1547dd3026c0b10c3448418df53a0e160e43035b
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiApConfigStore.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/WifiApConfigStore.java b/service/java/com/android/server/wifi/WifiApConfigStore.java index 4233f5834..850c5aebe 100644 --- a/service/java/com/android/server/wifi/WifiApConfigStore.java +++ b/service/java/com/android/server/wifi/WifiApConfigStore.java @@ -203,8 +203,24 @@ public class WifiApConfigStore { return config; } - private int getRandomIntForDefaultSsid() { + private static int getRandomIntForDefaultSsid() { Random random = new Random(); return random.nextInt((RAND_SSID_INT_MAX - RAND_SSID_INT_MIN) + 1) + RAND_SSID_INT_MIN; } + + /** + * Generate a temporary WPA2 based configuration for use by the local only hotspot. + * This config is not persisted and will not be stored by the WifiApConfigStore. + */ + public static WifiConfiguration generateLocalOnlyHotspotConfig(Context context) { + WifiConfiguration config = new WifiConfiguration(); + config.SSID = context.getResources().getString( + R.string.wifi_localhotspot_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; + } } |