Update preference to set password field
The preference for the wifi tether password was having the input type set incorrectly. This could lead to strange keyboard behavior and the password being remembered by the keyboard which is bad. This CL sets the appropriate field where needed. Test: robotests Bug: 77853620 Change-Id: I2a72fc863cd3779aed98a0df95500b652bb51cc8
This commit is contained in:
@@ -74,7 +74,7 @@ public class ValidatedEditTextPreference extends CustomEditTextPreference {
|
|||||||
editText.removeTextChangedListener(mTextWatcher);
|
editText.removeTextChangedListener(mTextWatcher);
|
||||||
if (mIsPassword) {
|
if (mIsPassword) {
|
||||||
editText.setInputType(
|
editText.setInputType(
|
||||||
InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
|
||||||
editText.setMaxLines(1);
|
editText.setMaxLines(1);
|
||||||
}
|
}
|
||||||
editText.addTextChangedListener(mTextWatcher);
|
editText.addTextChangedListener(mTextWatcher);
|
||||||
|
@@ -55,6 +55,7 @@ public class WifiTetherPasswordPreferenceController extends WifiTetherBasePrefer
|
|||||||
mPassword = generateRandomPassword();
|
mPassword = generateRandomPassword();
|
||||||
}
|
}
|
||||||
((ValidatedEditTextPreference) mPreference).setValidator(this);
|
((ValidatedEditTextPreference) mPreference).setValidator(this);
|
||||||
|
((ValidatedEditTextPreference) mPreference).setIsPassword(true);
|
||||||
((ValidatedEditTextPreference) mPreference).setIsSummaryPassword(true);
|
((ValidatedEditTextPreference) mPreference).setIsSummaryPassword(true);
|
||||||
updatePasswordDisplay((EditTextPreference) mPreference);
|
updatePasswordDisplay((EditTextPreference) mPreference);
|
||||||
}
|
}
|
||||||
|
@@ -116,7 +116,7 @@ public class ValidatedEditTextPreferenceTest {
|
|||||||
mPreference.onBindDialogView(mView);
|
mPreference.onBindDialogView(mView);
|
||||||
|
|
||||||
assertThat(editText.getInputType()
|
assertThat(editText.getInputType()
|
||||||
& (InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_CLASS_TEXT))
|
& (InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_CLASS_TEXT))
|
||||||
.isNotEqualTo(0);
|
.isNotEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -145,4 +145,21 @@ public class WifiTetherPasswordPreferenceControllerTest {
|
|||||||
assertThat(mController.getSecuritySettingForPassword())
|
assertThat(mController.getSecuritySettingForPassword())
|
||||||
.isEqualTo(WifiConfiguration.KeyMgmt.WPA2_PSK);
|
.isEqualTo(WifiConfiguration.KeyMgmt.WPA2_PSK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateDisplay_shouldSetInputType() {
|
||||||
|
// Set controller password to anything and verify is set.
|
||||||
|
mController.displayPreference(mScreen);
|
||||||
|
mController.onPreferenceChange(mPreference, "1");
|
||||||
|
assertThat(mController.getPassword()).isEqualTo("1");
|
||||||
|
|
||||||
|
// Create a new config using different password
|
||||||
|
final WifiConfiguration config = new WifiConfiguration();
|
||||||
|
config.preSharedKey = "test_1234";
|
||||||
|
when(mWifiManager.getWifiApConfiguration()).thenReturn(config);
|
||||||
|
|
||||||
|
// Call updateDisplay and verify it's changed.
|
||||||
|
mController.updateDisplay();
|
||||||
|
assertThat(mPreference.isPassword()).isTrue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user