From 0d7156789e9abe6aa9e675e07a40a92d34e4049d Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Wed, 21 Feb 2024 17:25:13 -0300 Subject: [PATCH] Guard against BadParcelableException when getting app list hopefully something rare, but it just happened to me while testing. It seems it happens when there are many apps installed (>500) and the app list is open while a backup happens. Then, we keep reloading the list and hammer the package manager hard which it seems can't handle it. It does recover on its own though. --- .../stevesoltys/seedvault/settings/SettingsViewModel.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt index eda7c4f7..1fefc982 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt @@ -11,6 +11,7 @@ import android.net.Network import android.net.NetworkCapabilities import android.net.NetworkRequest import android.net.Uri +import android.os.BadParcelableException import android.os.Process.myUid import android.provider.Settings import android.util.Log @@ -196,7 +197,13 @@ internal class SettingsViewModel( } private fun getAppStatusResult(): LiveData = liveData(Dispatchers.Default) { - val list = appListRetriever.getAppList() + val list = try { + Log.i(TAG, "Loading app list...") + appListRetriever.getAppList() + } catch (e: BadParcelableException) { + Log.e(TAG, "Error getting app list: ", e) + emptyList() + } val oldList = mAppStatusList.value?.appStatusList ?: emptyList() val diff = calculateDiff(AppStatusDiff(oldList, list)) emit(AppStatusResult(list, diff))