Don't remove main profile app if an app with the same package name has been uninstalled from work profile

This commit is contained in:
MM20 2022-04-17 13:51:08 +02:00
parent 8e4a4d8fb4
commit 68382d2746
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389

View File

@ -35,7 +35,7 @@ internal class AppRepositoryImpl(
private val launcherApps =
context.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
private val installedApps = MutableStateFlow<List<Application>>(emptyList())
private val installedApps = MutableStateFlow<List<LauncherApp>>(emptyList())
private val installations = MutableStateFlow<MutableList<AppInstallation>>(mutableListOf())
private val hiddenItems = hiddenItemsRepository.hiddenItemsKeys
private val suspendedPackages = MutableStateFlow<List<String>>(emptyList())
@ -85,7 +85,7 @@ internal class AppRepositoryImpl(
}
override fun onPackageRemoved(packageName: String, user: UserHandle) {
installedApps.value = installedApps.value.filter { packageName != (it.`package`) }
installedApps.value = installedApps.value.filter { packageName != (it.`package`) || it.getUser() != user }
}
override fun onShortcutsChanged(
@ -167,7 +167,7 @@ internal class AppRepositoryImpl(
return suspendedPackages
}
private fun getApplications(packageName: String): List<Application> {
private fun getApplications(packageName: String): List<LauncherApp> {
if (packageName == context.packageName) return emptyList()
return profiles.map { p ->
@ -179,7 +179,7 @@ internal class AppRepositoryImpl(
private fun getApplication(
launcherActivityInfo: LauncherActivityInfo,
profile: UserHandle
): Application? {
): LauncherApp? {
if (launcherActivityInfo.applicationInfo.packageName == context.packageName && !context.packageName.endsWith(
".debug"
)