From f5052f9bf722eab618cb9e4a1202d9eb8c5fd445 Mon Sep 17 00:00:00 2001 From: MM20 <15646950+MM2-0@users.noreply.github.com> Date: Sat, 22 Oct 2022 13:31:06 +0200 Subject: [PATCH] Fix apps and shortcuts incorrectly deserialized if their profile has been removed --- .../main/java/de/mm20/launcher2/search/data/AppSerialization.kt | 2 +- .../de/mm20/launcher2/appshortcuts/AppShortcutSerialization.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/src/main/java/de/mm20/launcher2/search/data/AppSerialization.kt b/applications/src/main/java/de/mm20/launcher2/search/data/AppSerialization.kt index feb77fbd..a2643ac5 100644 --- a/applications/src/main/java/de/mm20/launcher2/search/data/AppSerialization.kt +++ b/applications/src/main/java/de/mm20/launcher2/search/data/AppSerialization.kt @@ -32,7 +32,7 @@ class LauncherAppDeserializer(val context: Context) : SearchableDeserializer { val launcherApps = context.getSystemService()!! val userManager = context.getSystemService()!! val userSerial = json.optLong("user") - val user = userManager.getUserForSerialNumber(userSerial) ?: Process.myUserHandle() + val user = userManager.getUserForSerialNumber(userSerial) ?: return null val pkg = json.getString("package") val intent = Intent().also { it.component = ComponentName(pkg, json.getString("activity")) diff --git a/appshortcuts/src/main/java/de/mm20/launcher2/appshortcuts/AppShortcutSerialization.kt b/appshortcuts/src/main/java/de/mm20/launcher2/appshortcuts/AppShortcutSerialization.kt index 7b118101..5a516dd1 100644 --- a/appshortcuts/src/main/java/de/mm20/launcher2/appshortcuts/AppShortcutSerialization.kt +++ b/appshortcuts/src/main/java/de/mm20/launcher2/appshortcuts/AppShortcutSerialization.kt @@ -55,7 +55,7 @@ class LauncherShortcutDeserializer( ) query.setShortcutIds(mutableListOf(id)) val userManager = context.getSystemService()!! - val user = userManager.getUserForSerialNumber(userSerial) ?: Process.myUserHandle() + val user = userManager.getUserForSerialNumber(userSerial) ?: return null val shortcuts = try { launcherApps.getShortcuts(query, user) } catch (e: IllegalStateException) {