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

Commit bcc880d6 authored by Svet Ganov's avatar Svet Ganov Committed by android-build-merger
Browse files

[DO NOT MERGE] Allow multiple toasts for the focused app

am: 296a60ac

Change-Id: If076e3af0033447eb074ba45721205974cb763a4
parents 41313f60 296a60ac
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -719,16 +719,21 @@ class DisplayContent {

    boolean canAddToastWindowForUid(int uid) {
        // We allow one toast window per UID being shown at a time.
        WindowList windows = getWindowList();
        final int windowCount = windows.size();
        // Also if the app is focused adding more than one toast at
        // a time for better backwards compatibility.
        boolean alreadyHasToastWindow = false;
        final int windowCount = mWindows.size();
        for (int i = 0; i < windowCount; i++) {
            WindowState window = windows.get(i);
            if (window.mAttrs.type == TYPE_TOAST && window.mOwnerUid == uid
            final WindowState window = mWindows.get(i);
            if (window.isFocused() && window.getOwningUid() == uid) {
                return true;
            }
            if (window.mAttrs.type == TYPE_TOAST && window.getOwningUid() == uid
                    && !window.isRemovedOrHidden()) {
                return false;
                alreadyHasToastWindow = true;
            }
        }
        return true;
        return !alreadyHasToastWindow;
    }

    void scheduleToastWindowsTimeoutIfNeededLocked(WindowState oldFocus,