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.
This commit is contained in:
parent
04fc90e9f7
commit
0d7156789e
1 changed files with 8 additions and 1 deletions
|
@ -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<AppStatusResult> = 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))
|
||||
|
|
Loading…
Reference in a new issue