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

Commit 6ff80dcf authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Fix #2377870 : NPE in Dock settings

If the Dock settings is launched after reboot but before it is docked,
the settings screen crashes because the dock status is not available.

This fixes the case where there was never a pending intent for dock status.
parent 0e2ab4f8
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -72,6 +72,9 @@ public class DockSettings extends PreferenceActivity {

    private void initDockSettings() {
        mAudioSettings = findPreference(KEY_AUDIO_SETTINGS);
        if (mAudioSettings != null) {
            mAudioSettings.setSummary(R.string.dock_audio_summary_none);
        }
    }

    private void handleDockChange(Intent intent) {
@@ -104,7 +107,9 @@ public class DockSettings extends PreferenceActivity {
    @Override
    public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
        if (preference == mAudioSettings) {
            int dockState = mDockIntent.getIntExtra(Intent.EXTRA_DOCK_STATE, 0);
            int dockState = mDockIntent != null
                    ? mDockIntent.getIntExtra(Intent.EXTRA_DOCK_STATE, 0)
                    : Intent.EXTRA_DOCK_STATE_UNDOCKED;
            if (dockState == Intent.EXTRA_DOCK_STATE_UNDOCKED) {
                showDialog(DIALOG_NOT_DOCKED);
            } else {