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
This commit is contained in:
Stanley Wang
2020-02-06 17:26:07 +08:00
parent cf4e12bbd9
commit 10ec77121c
3 changed files with 17 additions and 1 deletions

View File

@@ -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");