Loading packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/data/repository/InstalledTilesComponentRepositoryImplTest.kt +27 −0 Original line number Diff line number Diff line Loading @@ -245,6 +245,33 @@ class InstalledTilesComponentRepositoryImplTest : SysuiTestCase() { assertThat(flowForUser2).isNotEqualTo(flowForUser1) } // Tests that a ServiceInfo that is returned by queryIntentServicesAsUser but shortly // after uninstalled, doesn't crash SystemUI. @Test fun packageUninstalledAfterQuery_noCrash_noComponent() = testScope.runTest { val userId = 0 val resolveInfo = ResolveInfo(TEST_COMPONENT, hasPermission = true, defaultEnabled = true) val componentNames by collectLastValue(underTest.getInstalledTilesComponents(userId)) whenever( packageManager.queryIntentServicesAsUser( matchIntent(), matchFlags(), eq(userId) ) ) .thenReturn(listOf(resolveInfo)) whenever(packageManager.getComponentEnabledSetting(TEST_COMPONENT)) .thenThrow(IllegalArgumentException()) kosmos.fakePackageChangeRepository.notifyChange(PackageChangeModel.Empty) runCurrent() assertThat(componentNames).isEmpty() } companion object { private val INTENT = Intent(TileService.ACTION_QS_TILE) private val FLAGS = Loading packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/InstalledTilesComponentRepository.kt +9 −1 Original line number Diff line number Diff line Loading @@ -91,7 +91,15 @@ constructor( .queryIntentServicesAsUser(INTENT, FLAGS, userId) .mapNotNull { it.serviceInfo } .filter { it.permission == BIND_QUICK_SETTINGS_TILE } .filter { packageManager.isComponentActuallyEnabled(it) } .filter { try { packageManager.isComponentActuallyEnabled(it) } catch (e: IllegalArgumentException) { // If the package is not found, it means it was uninstalled between query // and now. So it's clearly not enabled. false } } .mapTo(mutableSetOf()) { it.componentName } } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/data/repository/InstalledTilesComponentRepositoryImplTest.kt +27 −0 Original line number Diff line number Diff line Loading @@ -245,6 +245,33 @@ class InstalledTilesComponentRepositoryImplTest : SysuiTestCase() { assertThat(flowForUser2).isNotEqualTo(flowForUser1) } // Tests that a ServiceInfo that is returned by queryIntentServicesAsUser but shortly // after uninstalled, doesn't crash SystemUI. @Test fun packageUninstalledAfterQuery_noCrash_noComponent() = testScope.runTest { val userId = 0 val resolveInfo = ResolveInfo(TEST_COMPONENT, hasPermission = true, defaultEnabled = true) val componentNames by collectLastValue(underTest.getInstalledTilesComponents(userId)) whenever( packageManager.queryIntentServicesAsUser( matchIntent(), matchFlags(), eq(userId) ) ) .thenReturn(listOf(resolveInfo)) whenever(packageManager.getComponentEnabledSetting(TEST_COMPONENT)) .thenThrow(IllegalArgumentException()) kosmos.fakePackageChangeRepository.notifyChange(PackageChangeModel.Empty) runCurrent() assertThat(componentNames).isEmpty() } companion object { private val INTENT = Intent(TileService.ACTION_QS_TILE) private val FLAGS = Loading
packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/InstalledTilesComponentRepository.kt +9 −1 Original line number Diff line number Diff line Loading @@ -91,7 +91,15 @@ constructor( .queryIntentServicesAsUser(INTENT, FLAGS, userId) .mapNotNull { it.serviceInfo } .filter { it.permission == BIND_QUICK_SETTINGS_TILE } .filter { packageManager.isComponentActuallyEnabled(it) } .filter { try { packageManager.isComponentActuallyEnabled(it) } catch (e: IllegalArgumentException) { // If the package is not found, it means it was uninstalled between query // and now. So it's clearly not enabled. false } } .mapTo(mutableSetOf()) { it.componentName } } Loading