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

Commit 10ec7712 authored by Stanley Wang's avatar Stanley Wang
Browse files

Fix the 'Google play system update' button is not actionable.

If the ResolveInfo of the update intent is not null, set preference
to selectable.

Fixes: 147616097
Test: manual & robotest
Change-Id: If6086b113fc1c782b47966f7a30eddfdac195ce0
parent cf4e12bb
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@
        android:key="module_version"
        android:title="@string/module_version"
        android:summary="@string/summary_placeholder"
        android:selectable="false"
        settings:enableCopying="true"
        settings:controller="com.android.settings.deviceinfo.firmwareversion.MainlineModuleVersionPreferenceController"/>

+3 −0
Original line number Diff line number Diff line
@@ -86,8 +86,11 @@ public class MainlineModuleVersionPreferenceController extends BasePreferenceCon
                mPackageManager.resolveActivity(MODULE_UPDATE_INTENT, 0 /* flags */);
        if (resolved != null) {
            preference.setIntent(MODULE_UPDATE_INTENT);
            preference.setSelectable(true);
        } else {
            Log.d(TAG, "The ResolveInfo of the update intent is null.");
            preference.setIntent(null);
            preference.setSelectable(false);
        }
    }

+14 −0
Original line number Diff line number Diff line
@@ -110,6 +110,20 @@ public class MainlineModuleVersionPreferenceControllerTest {
        assertThat(mPreference.getIntent()).isEqualTo(MODULE_UPDATE_INTENT);
    }

    @Test
    public void updateStates_canHandleIntent_preferenceShouldBeSelectable() throws Exception {
        setupModulePackage("test version 123");
        when(mPackageManager.resolveActivity(MODULE_UPDATE_INTENT, 0))
                .thenReturn(new ResolveInfo());

        final MainlineModuleVersionPreferenceController controller =
                new MainlineModuleVersionPreferenceController(mContext, "key");

        controller.updateState(mPreference);

        assertThat(mPreference.isSelectable()).isTrue();
    }

    @Test
    public void updateStates_cannotHandleIntent_setNullToPreference() throws Exception {
        setupModulePackage("test version 123");