Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 24a505c4 authored by lesl's avatar lesl
Browse files

softap: Use set/getPassphrase to replace set/getWpa2Passphrase

Bug: 142752869
Test: Manual, on/off/setting change for hotspot function
Test: make RunSettingsRoboTests ROBOTEST_FILTER=CodeInspectionTest
Change-Id: I22c89f15a6ef1c5366394431cc5aa7031a573d45
parent a09d1a73
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -349,7 +349,7 @@ public class WifiDppUtils {
        // When the value of this key is read, the actual key is not returned, just a "*".
        // Call privileged system API to obtain actual key.
        final String preSharedKey = removeFirstAndLastDoubleQuotes(
                softApConfiguration.getWpa2Passphrase());
                softApConfiguration.getPassphrase());

        if (!TextUtils.isEmpty(ssid)) {
            intent.putExtra(EXTRA_WIFI_SSID, ssid);
+2 −2
Original line number Diff line number Diff line
@@ -51,10 +51,10 @@ public class WifiTetherPasswordPreferenceController extends WifiTetherBasePrefer
        final SoftApConfiguration config = mWifiManager.getSoftApConfiguration();
        if (config == null
                || (config.getSecurityType() == SoftApConfiguration.SECURITY_TYPE_WPA2_PSK
                && TextUtils.isEmpty(config.getWpa2Passphrase()))) {
                && TextUtils.isEmpty(config.getPassphrase()))) {
            mPassword = generateRandomPassword();
        } else {
            mPassword = config.getWpa2Passphrase();
            mPassword = config.getPassphrase();
        }
        ((ValidatedEditTextPreference) mPreference).setValidator(this);
        ((ValidatedEditTextPreference) mPreference).setIsPassword(true);
+3 −2
Original line number Diff line number Diff line
@@ -214,8 +214,9 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
        final int securityType = mSecurityPreferenceController.getSecurityType();
        configBuilder.setSsid(mSSIDPreferenceController.getSSID());
        if (securityType == SoftApConfiguration.SECURITY_TYPE_WPA2_PSK) {
            configBuilder.setWpa2Passphrase(
                    mPasswordPreferenceController.getPasswordValidated(securityType));
            configBuilder.setPassphrase(
                    mPasswordPreferenceController.getPasswordValidated(securityType),
                    SoftApConfiguration.SECURITY_TYPE_WPA2_PSK);
        }
        configBuilder.setBand(mApBandPreferenceController.getBandIndex());
        return configBuilder.build();
+7 −7
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ public class WifiTetherPasswordPreferenceControllerTest {
        MockitoAnnotations.initMocks(this);
        mPreference = new ValidatedEditTextPreference(RuntimeEnvironment.application);
        mConfig = new SoftApConfiguration.Builder().setSsid("test_1234")
                .setWpa2Passphrase("test_password").build();
                .setPassphrase("test_password", SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();

        when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
        when(mWifiManager.getSoftApConfiguration()).thenReturn(mConfig);
@@ -83,8 +83,8 @@ public class WifiTetherPasswordPreferenceControllerTest {
    public void displayPreference_shouldStylePreference() {
        mController.displayPreference(mScreen);

        assertThat(mPreference.getText()).isEqualTo(mConfig.getWpa2Passphrase());
        assertThat(mPreference.getSummary()).isEqualTo(mConfig.getWpa2Passphrase());
        assertThat(mPreference.getText()).isEqualTo(mConfig.getPassphrase());
        assertThat(mPreference.getSummary()).isEqualTo(mConfig.getPassphrase());
    }

    @Test
@@ -111,14 +111,14 @@ public class WifiTetherPasswordPreferenceControllerTest {

        // Create a new config using different password
        final SoftApConfiguration config = new SoftApConfiguration.Builder()
                .setWpa2Passphrase(VALID_PASS2).build();
                .setPassphrase(VALID_PASS2, SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
        when(mWifiManager.getSoftApConfiguration()).thenReturn(config);

        // Call updateDisplay and verify it's changed.
        mController.updateDisplay();
        assertThat(mController.getPasswordValidated(SoftApConfiguration.SECURITY_TYPE_WPA2_PSK))
                .isEqualTo(config.getWpa2Passphrase());
        assertThat(mPreference.getSummary()).isEqualTo(config.getWpa2Passphrase());
                .isEqualTo(config.getPassphrase());
        assertThat(mPreference.getSummary()).isEqualTo(config.getPassphrase());
    }

    @Test
@@ -131,7 +131,7 @@ public class WifiTetherPasswordPreferenceControllerTest {

        // Create a new config using different password
        final SoftApConfiguration config = new SoftApConfiguration.Builder()
                .setWpa2Passphrase(VALID_PASS2).build();
                .setPassphrase(VALID_PASS2, SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
        when(mWifiManager.getSoftApConfiguration()).thenReturn(config);

        // Call updateDisplay and verify it's changed.
+4 −2
Original line number Diff line number Diff line
@@ -124,7 +124,8 @@ public class WifiTetherSSIDPreferenceControllerTest {
    public void displayPreference_wifiApDisabled_shouldHideQrCodeIcon() {
        when(mWifiManager.isWifiApEnabled()).thenReturn(false);
        final SoftApConfiguration config = new SoftApConfiguration.Builder()
                .setSsid("test_1234").setWpa2Passphrase("test_password").build();
                .setSsid("test_1234").setPassphrase("test_password",
                SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
        when(mWifiManager.getSoftApConfiguration()).thenReturn(config);

        mController.displayPreference(mScreen);
@@ -135,7 +136,8 @@ public class WifiTetherSSIDPreferenceControllerTest {
    public void displayPreference_wifiApEnabled_shouldShowQrCodeIcon() {
        when(mWifiManager.isWifiApEnabled()).thenReturn(true);
        final SoftApConfiguration config = new SoftApConfiguration.Builder()
                .setSsid("test_1234").setWpa2Passphrase("test_password").build();
                .setSsid("test_1234").setPassphrase("test_password",
                SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
        when(mWifiManager.getSoftApConfiguration()).thenReturn(config);

        mController.displayPreference(mScreen);
Loading