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

Commit 5f6c80a2 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Guard against a NPE when disconnecting suggestion service."

parents 146997a6 f6073fb9
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -97,7 +97,10 @@ public class SuggestionControllerMixin implements SuggestionController.ServiceCo
        if (DEBUG) {
            Log.d(TAG, "SuggestionService disconnected");
        }
        mHost.getLoaderManager().destroyLoader(SuggestionLoader.LOADER_ID_SUGGESTIONS);
        final LoaderManager loaderManager = mHost.getLoaderManager();
        if (loaderManager != null) {
            loaderManager.destroyLoader(SuggestionLoader.LOADER_ID_SUGGESTIONS);
        }
    }

    @Override
+10 −0
Original line number Diff line number Diff line
@@ -97,4 +97,14 @@ public class SuggestionControllerMixinTest {

        verify(mHost).getLoaderManager();
    }

    @Test
    public void onServiceDisconnected_hostNotAttached_shouldDoNothing() {
        when(mHost.getLoaderManager()).thenReturn(null);

        mMixin = new SuggestionControllerMixin(mContext, mHost, mLifecycle);
        mMixin.onServiceDisconnected();

        verify(mHost).getLoaderManager();
    }
}