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

Commit 8f7edfa1 authored by Doris Ling's avatar Doris Ling
Browse files

Fix NPE in InstantAppButtonsPreferenceController

- check for valid install options menu before trying to disable it.

Change-Id: Ibe644a506094e66b0f657092a25557f5096d4942
Fixes: 73767192
Test: make RunSettingsRoboTests
parent 38bfe2e4
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -112,11 +112,12 @@ public class InstantAppButtonsPreferenceController extends BasePreferenceControl
    @Override
    public void onPrepareOptionsMenu(Menu menu) {
        mInstallMenu = menu.findItem(AppInfoDashboardFragment.INSTALL_INSTANT_APP_MENU);
        final Intent appStoreIntent = AppStoreUtil.getAppStoreLink(mContext, mPackageName);
        if (appStoreIntent == null) {
        if (mInstallMenu != null) {
            if (AppStoreUtil.getAppStoreLink(mContext, mPackageName) == null) {
                mInstallMenu.setEnabled(false);
            }
        }
    }

    @Override
    public void onClick(DialogInterface dialog, int which) {
+9 −0
Original line number Diff line number Diff line
@@ -179,6 +179,15 @@ public class InstantAppButtonsPreferenceControllerTest {
        verify(menuItem, never()).setEnabled(false);
    }

    @Test
    public void onPrepareOptionsMenu_installMenuNotFound_shoulNotCrash() {
        final Menu menu = mock(Menu.class);

        mController.onPrepareOptionsMenu(menu);

        // no crash
    }

    @Test
    public void onOptionsItemSelected_shouldOpenAppStore() {
        final ResolveInfo resolveInfo = mock(ResolveInfo.class);