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

Commit b2165509 authored by Daniel Nishi's avatar Daniel Nishi
Browse files

Don't allow a zero-length device name to work.

Technically, if a device has a zero-length device name, the bug will
resurface. The EditText validator doesn't trigger on opening -- only
when the text is edited. A zero-length device name is flagged as being
invalid, but that fails if the text box starts empty.

By pre-filling it with the previous device name, we can ensure that, as
long as a zero-length device name is never set, it can never be set.

Change-Id: I0d28aaae09f99b7d697b753835ba39c0c06644a1
Fixes: 73127912
Test: Robotest
parent 6d3511c9
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -54,7 +54,9 @@ public class DeviceNamePreferenceController extends BasePreferenceController
    public void displayPreference(PreferenceScreen screen) {
        super.displayPreference(screen);
        mPreference = (ValidatedEditTextPreference) screen.findPreference(PREF_KEY);
        mPreference.setSummary(getSummary());
        final CharSequence deviceName = getSummary();
        mPreference.setSummary(deviceName);
        mPreference.setText(deviceName.toString());
        mPreference.setValidator(this);
    }

+8 −0
Original line number Diff line number Diff line
@@ -123,4 +123,12 @@ public class DeviceNamePreferenceControllerTest {
        verify(mWifiManager).setWifiApConfiguration(captor.capture());
        assertThat(captor.getValue().SSID).isEqualTo(TESTING_STRING);
    }

    @Test
    public void displayPreference_defaultDeviceNameIsModelNameOnPreference() {
        mController.displayPreference(mScreen);

        assertThat(mPreference.getText()).isEqualTo(Build.MODEL);
    }

}