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

Commit 1b93f222 authored by Alison Cichowlas's avatar Alison Cichowlas Committed by Android (Google) Code Review
Browse files

Merge "Catch error when trying to Toast with unexpectedly missing context." into main

parents 10bd1cf8 85c5c950
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -117,7 +117,14 @@ public class ToastUI implements
            int displayId) {
        Runnable showToastRunnable = () -> {
            UserHandle userHandle = UserHandle.getUserHandleForUid(uid);
            Context context = mContext.createContextAsUser(userHandle, 0);
            Context context;
            try {
                context = mContext.createContextAsUser(userHandle, 0);
            } catch (IllegalStateException e) {
                // b/366533044 : Own package not found for systemui
                Log.e(TAG, "Cannot create toast because cannot create context", e);
                return;
            }

            DisplayManager mDisplayManager = mContext.getSystemService(DisplayManager.class);
            Display display = mDisplayManager.getDisplay(displayId);