From 79563030fb9e7e6a65a2053f3ce362859946c635 Mon Sep 17 00:00:00 2001 From: Wes Okuhara Date: Fri, 28 Feb 2025 11:26:23 -0800 Subject: [PATCH] Settings: Do not show install info for Play Store app Clicking the "App details" row in the info subpage for the Play Store app results in a crash. It appears that this app is not considered a mainline module and has an installer label, but this app is a special case. Hide the row for the Play Store app. Bug: 302093631 Test: atest com.android.settings.spa.app.appinfo.AppInstallerInfoPreferenceTest Flag: EXEMPT bugfix Change-Id: I291ee3e5dec2075381cb52d041982583cdd04323 --- .../app/appinfo/AppInstallerInfoPreference.kt | 13 +++++++++---- .../appinfo/AppInstallerInfoPreferenceTest.kt | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/com/android/settings/spa/app/appinfo/AppInstallerInfoPreference.kt b/src/com/android/settings/spa/app/appinfo/AppInstallerInfoPreference.kt index 7e160960efa..9bb3051efab 100644 --- a/src/com/android/settings/spa/app/appinfo/AppInstallerInfoPreference.kt +++ b/src/com/android/settings/spa/app/appinfo/AppInstallerInfoPreference.kt @@ -91,10 +91,15 @@ private class AppInstallerInfoPresenter( } }.sharedFlow() - val isAvailableFlow = installerLabelFlow.map { installerLabel -> - withContext(Dispatchers.IO) { - !AppUtils.isMainlineModule(packageManager, app.packageName) && - installerLabel != null + val isAvailableFlow = installerLabelFlow.map() { installerLabel -> + // Do not show the install info for the special case of the Play Store app. + if (app.packageName == context.getString(R.string.config_mainline_module_update_package)) { + false + } else { + withContext(Dispatchers.IO) { + val isMainlineModule = AppUtils.isMainlineModule(packageManager, app.packageName) + !isMainlineModule && installerLabel != null + } } } diff --git a/tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppInstallerInfoPreferenceTest.kt b/tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppInstallerInfoPreferenceTest.kt index 6297c62a015..52ee077c4d2 100644 --- a/tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppInstallerInfoPreferenceTest.kt +++ b/tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppInstallerInfoPreferenceTest.kt @@ -121,6 +121,25 @@ class AppInstallerInfoPreferenceTest { composeTestRule.onRoot().assertIsNotDisplayed() } + @Test + fun whenIsPlayStoreApp_notDisplayed() { + val playStorePackageName = "com.android.vending" + whenever( + AppStoreUtil.getInstallerPackageNameAndInstallSourceInfo( + any(), + eq(playStorePackageName) + ) + ) + .thenReturn(Pair(INSTALLER_PACKAGE_NAME, INSTALL_SOURCE_INFO)) + val playStoreApp = ApplicationInfo().apply { + packageName = playStorePackageName + uid = UID + } + setContent(playStoreApp) + + composeTestRule.onRoot().assertIsNotDisplayed() + } + @Test fun whenStoreLinkIsNull_disabled() { whenever(AppStoreUtil.getAppStoreLink(context, INSTALLER_PACKAGE_NAME, PACKAGE_NAME))