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

Commit b617f84b authored by Fan Zhang's avatar Fan Zhang
Browse files

Fix a NPE from incorrect assumption of operation pecedence.

Change-Id: I13d01c39bd3afcfbc7b680b96e0c7eb341fbc584
Fixes: 123709444
Test: robotest
parent f508a57a
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -128,8 +128,10 @@ public class LegacySuggestionContextualCardController implements ContextualCardC
                return;
            }
            final List<Suggestion> suggestions = mSuggestionController.getSuggestions();
            Log.d(TAG, "Loaded suggests: "
                    + suggestions == null ? "null" : String.valueOf(suggestions.size()));
            final String suggestionCount = suggestions == null
                    ? "null"
                    : String.valueOf(suggestions.size());
            Log.d(TAG, "Loaded suggests: " + suggestionCount);

            final List<ContextualCard> cards = new ArrayList<>();
            if (suggestions != null) {
+3 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.settings.homepage.contextualcards.legacysuggestion;
import static com.google.common.truth.Truth.assertThat;

import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.content.Context;

@@ -84,8 +85,10 @@ public class LegacySuggestionContextualCardControllerTest {

    @Test
    public void onServiceConnected_shouldLoadSuggestion() {
        when(mSuggestionController.getSuggestions()).thenReturn(null);
        mController.mSuggestionController = mSuggestionController;
        mController.setCardUpdateListener(mCardUpdateListener);

        mController.onServiceConnected();

        verify(mSuggestionController).getSuggestions();