Skip to content

Commit

Permalink
Don't remove main profile app if an app with the same package name ha…
Browse files Browse the repository at this point in the history
…s been uninstalled from work profile
  • Loading branch information
MM2-0 committed Apr 17, 2022
1 parent 8e4a4d8 commit 68382d2
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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 ->
Expand All @@ -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"
)
Expand Down

0 comments on commit 68382d2

Please sign in to comment.