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

Commit b7714540 authored by Beverly's avatar Beverly
Browse files

Add null check in displayPreference

Change-Id: I3afaa3f587dc5c9989d5e520f1c8a0b33e57ec7d
Fixes: 109740402
Test: ZenModeStarredContactsPreferenceControllerTest.java
parent e763ebcb
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -68,8 +68,11 @@ public class ZenModeStarredContactsPreferenceController extends
    public void displayPreference(PreferenceScreen screen) {
        super.displayPreference(screen);
        mPreference = screen.findPreference(KEY);

        if (mPreference != null) {
            mPreference.setOnPreferenceClickListener(this);
        }
    }

    @Override
    public String getPreferenceKey() {
+9 −0
Original line number Diff line number Diff line
@@ -190,4 +190,13 @@ public class ZenModeStarredContactsPreferenceControllerTest {
            assertThat(contacts.get(i)).isNotNull();
        }
    }

    @Test
    public void nullPreference_displayPreference() {
        when(mPreferenceScreen.findPreference(mMessagesController.getPreferenceKey()))
                .thenReturn(null);

        // should not throw a null pointer
        mMessagesController.displayPreference(mPreferenceScreen);
    }
}