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

Commit 85c5c950 authored by Alison Cichowlas's avatar Alison Cichowlas
Browse files

Catch error when trying to Toast with unexpectedly missing context.

We think this happens rarely, when user is changed mid-toast, and
only in test scenarios.

Fixes: 366533044

Test: atest SystemUITests
Flag: EXEMPT bugfix

Change-Id: Ifb50c94dd4757779f27c3e1bdbe7628c675a8e34
parent 94e623b4
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);