[Wi-Fi] Fix crash after editing invalid hotspot password

From Android 11, Wi-Fi framework only supports ASCII encoding
for hotspot password, APP should check if password character is
valid.

This change checks if SoftApConfiguration accepts the password
and disable the OK button if the password is invalid.

Bug: 163353576
Test: make RunSettingsRoboTests ROBOTEST_FILTER=WifiUtilsTest
Change-Id: Ief3c6c1f08f8fcdf128768cde3ab8eef91f19fbe
This commit is contained in:
Arc Wang
2020-08-12 13:57:05 +08:00
parent 502c4207f0
commit ae79c41cd7
3 changed files with 17 additions and 13 deletions

View File

@@ -45,11 +45,12 @@ public class WifiUtilsTest {
public void testPassword() {
final String longPassword = "123456789012345678901234567890"
+ "1234567890123456789012345678901234567890";
assertThat(WifiUtils.isHotspotPasswordValid("123")).isFalse();
assertThat(WifiUtils.isHotspotPasswordValid("12345678")).isTrue();
assertThat(WifiUtils.isHotspotPasswordValid("1234567890")).isTrue();
assertThat(WifiUtils.isHotspotPasswordValid(longPassword)).isFalse();
assertThat(WifiUtils.isHotspotPasswordValid("")).isFalse();
assertThat(WifiUtils.isHotspotWpa2PasswordValid("123")).isFalse();
assertThat(WifiUtils.isHotspotWpa2PasswordValid("12345678")).isTrue();
assertThat(WifiUtils.isHotspotWpa2PasswordValid("1234567890")).isTrue();
assertThat(WifiUtils.isHotspotWpa2PasswordValid(longPassword)).isFalse();
assertThat(WifiUtils.isHotspotWpa2PasswordValid("")).isFalse();
assertThat(WifiUtils.isHotspotWpa2PasswordValid("€¥£")).isFalse();
}
@Test