Don't show uninstall for all users
when the only profiles that have the package are hidden in quiet mode Fix: 334041279 Test: atest AppInfoSettingsMoreOptionsTest Test: manual Change-Id: Ic8e594eb1db5bed926783a244a24e24c4435f04e
This commit is contained in:
@@ -175,6 +175,7 @@ private fun ApplicationInfo.isOtherUserHasInstallPackage(
|
||||
packageManagers: IPackageManagers,
|
||||
): Boolean = userManager.aliveUsers
|
||||
.filter { it.id != userId }
|
||||
.filter { !Utils.shouldHideUser(it.userHandle, userManager) }
|
||||
.any { packageManagers.isPackageInstalledAsUser(packageName, it.id) }
|
||||
|
||||
private fun ApplicationInfo.shouldShowAccessRestrictedSettings(context: Context): Boolean {
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.content.Context
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.pm.UserInfo
|
||||
import android.os.UserHandle
|
||||
import android.os.UserManager
|
||||
import android.platform.test.annotations.RequiresFlagsDisabled
|
||||
import android.platform.test.annotations.RequiresFlagsEnabled
|
||||
@@ -170,6 +171,44 @@ class AppInfoSettingsMoreOptionsTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun uninstallForAllUsers_appHiddenNotInQuietModeAndPrimaryUser_displayed() {
|
||||
val app = ApplicationInfo().apply {
|
||||
packageName = PACKAGE_NAME
|
||||
uid = UID
|
||||
}
|
||||
whenever(userManager.aliveUsers).thenReturn(listOf(OTHER_USER))
|
||||
whenever(packageManagers
|
||||
.isPackageInstalledAsUser(PACKAGE_NAME, OTHER_USER_ID))
|
||||
.thenReturn(true)
|
||||
whenever(Utils.shouldHideUser(UserHandle.of(OTHER_USER_ID), userManager)).thenReturn(false)
|
||||
|
||||
setContent(app)
|
||||
composeTestRule.onRoot().performClick()
|
||||
|
||||
composeTestRule.waitUntilExists(
|
||||
hasText(context.getString(R.string.uninstall_all_users_text))
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
fun uninstallForAllUsers_appHiddenInQuietModeAndPrimaryUser_notDisplayed() {
|
||||
val app = ApplicationInfo().apply {
|
||||
packageName = PACKAGE_NAME
|
||||
uid = UID
|
||||
}
|
||||
whenever(userManager.aliveUsers).thenReturn(listOf(OTHER_USER))
|
||||
whenever(packageManagers
|
||||
.isPackageInstalledAsUser(PACKAGE_NAME, OTHER_USER_ID))
|
||||
.thenReturn(true)
|
||||
whenever(Utils.shouldHideUser(UserHandle.of(OTHER_USER_ID), userManager)).thenReturn(true)
|
||||
|
||||
setContent(ApplicationInfo())
|
||||
|
||||
composeTestRule.onRoot().assertIsNotDisplayed()
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(android.security.Flags.FLAG_EXTEND_ECM_TO_ALL_SETTINGS,
|
||||
android.permission.flags.Flags.FLAG_ENHANCED_CONFIRMATION_MODE_APIS_ENABLED)
|
||||
|
||||
Reference in New Issue
Block a user