Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2b80ab7d authored by Daniel Nishi's avatar Daniel Nishi
Browse files

Don't crash in background after app uninstall.

It's possible for an app to be uninstalled during a
LOAD_SIZES phase of the ApplicationsState measurement. By
catching the IllegalStateException which is thrown, we can
continue without crashing.

Change-Id: I9aae8928dc7205c52f61d09345d5226e7bd07f49
Fixes: 36845611
Test: Manual
parent eabb5621
Loading
Loading
Loading
Loading
+19 −10
Original line number Diff line number Diff line
@@ -984,6 +984,7 @@ public class ApplicationsState {
                                    mCurComputingSizeUserId = UserHandle.getUserId(entry.info.uid);

                                    mBackgroundHandler.post(() -> {
                                        try {
                                            final StorageStats stats = mStats.queryStatsForPackage(
                                                    mCurComputingSizeUuid, mCurComputingSizePkg,
                                                    UserHandle.of(mCurComputingSizeUserId));
@@ -996,6 +997,14 @@ public class ApplicationsState {
                                                mStatsObserver.onGetStatsCompleted(legacyStats, true);
                                            } catch (RemoteException ignored) {
                                            }
                                        } catch (IllegalStateException e) {
                                            Log.e(TAG,"An exception occurred while fetching app size", e);
                                            try {
                                                mStatsObserver.onGetStatsCompleted(null, false);
                                            } catch (RemoteException ignored) {
                                            }
                                        }

                                    });
                                }
                                if (DEBUG_LOCKING) Log.v(TAG, "MSG_LOAD_SIZES releasing: now computing");