From eb6343516fb91c3f7651e5979e047306aaf04554 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Tue, 6 Jun 2017 14:51:19 -0700 Subject: WifiConfigurationUtil: Ignore masked passwords This is the case of apps retrieving WifiConfiguration from WifiManager API's and passing it back to use for a network update. This is already ignored in WifiConfigManager's update handling. Bug: 62385845 Test: Unit tests Test: Able to force connection to existing saved PSK network. Change-Id: I0277dcca401335db21ad0f360f044e9634956829 --- service/java/com/android/server/wifi/WifiConfigurationUtil.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'service') diff --git a/service/java/com/android/server/wifi/WifiConfigurationUtil.java b/service/java/com/android/server/wifi/WifiConfigurationUtil.java index 5b20fd0b1..3ff4d73fd 100644 --- a/service/java/com/android/server/wifi/WifiConfigurationUtil.java +++ b/service/java/com/android/server/wifi/WifiConfigurationUtil.java @@ -55,6 +55,8 @@ public class WifiConfigurationUtil { private static final int PSK_ASCII_MIN_LEN = 8 + ENCLOSING_QUTOES_LEN; private static final int PSK_ASCII_MAX_LEN = 63 + ENCLOSING_QUTOES_LEN; private static final int PSK_HEX_LEN = 128; + @VisibleForTesting + public static final String PASSWORD_MASK = "*"; /** * Check whether a network configuration is visible to a user or any of its managed profiles. @@ -300,6 +302,10 @@ public class WifiConfigurationUtil { Log.e(TAG, "validatePsk failed: empty string"); return false; } + // The app returned back the masked password, let it thru. WifiConfigManager will handle it. + if (psk.equals(PASSWORD_MASK)) { + return true; + } if (psk.startsWith("\"")) { // ASCII PSK string if (psk.length() < PSK_ASCII_MIN_LEN) { -- cgit v1.2.3