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

Commit d2794f5e authored by Craig Mautner's avatar Craig Mautner Committed by Android Git Automerger
Browse files

am 21c09e8a: am f0f45452: Merge "Reset deferred task removal when app token...

am 21c09e8a: am f0f45452: Merge "Reset deferred task removal when app token added." into klp-modular-dev

* commit '21c09e8a':
  Reset deferred task removal when app token added.
parents 5f652b9f 21c09e8a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1672,7 +1672,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            return view.getParent() != null ? view : null;
        } catch (WindowManager.BadTokenException e) {
            // ignore
            Log.w(TAG, appToken + " already running, starting window not displayed");
            Log.w(TAG, appToken + " already running, starting window not displayed. " +
                    e.getMessage());
        } catch (RuntimeException e) {
            // don't crash if something else bad happens, for example a
            // failure loading resources because we are loading from an app
+13 −5
Original line number Diff line number Diff line
@@ -16,11 +16,12 @@

package com.android.server.wm;

import static com.android.server.wm.WindowManagerService.TAG;

import android.util.EventLog;
import com.android.server.EventLogTags;
import android.util.Slog;

class Task {
//    private final String TAG = "TaskGroup";
    TaskStack mStack;
    final AppTokenList mAppTokens = new AppTokenList();
    final int taskId;
@@ -39,17 +40,24 @@ class Task {
    }

    void addAppToken(int addPos, AppWindowToken wtoken) {
        final int lastPos = mAppTokens.size();
        if (addPos > lastPos) {
            // We lost an app token. Don't crash though.
            Slog.e(TAG, "Task.addAppToken: Out of bounds attempt token=" + wtoken + " addPos="
                    + addPos + " lastPos=" + lastPos);
            addPos = lastPos;
        }
        mAppTokens.add(addPos, wtoken);
        mDeferRemoval = false;
    }

    boolean removeAppToken(AppWindowToken wtoken) {
        mAppTokens.remove(wtoken);
        boolean removed = mAppTokens.remove(wtoken);
        if (mAppTokens.size() == 0) {
            EventLog.writeEvent(com.android.server.EventLogTags.WM_TASK_REMOVED, taskId,
                    "removeAppToken: last token");
            return true;
        }
        return false;
        return removed;
    }

    @Override
+14 −21
Original line number Diff line number Diff line
@@ -3486,7 +3486,7 @@ public class WindowManagerService extends IWindowManager.Stub

            Task task = mTaskIdToTask.get(taskId);
            if (task == null) {
                task = createTask(taskId, stackId, userId, atoken);
                createTask(taskId, stackId, userId, atoken);
            } else {
                task.addAppToken(addPos, atoken);
            }
@@ -3839,27 +3839,23 @@ public class WindowManagerService extends IWindowManager.Stub
        }

        synchronized(mWindowMap) {
            boolean changed = false;
            final AppWindowToken newFocus;
            if (token == null) {
                if (DEBUG_FOCUS_LIGHT) Slog.v(TAG, "Clearing focused app, was " + mFocusedApp);
                changed = mFocusedApp != null;
                mFocusedApp = null;
                if (changed) {
                    mInputMonitor.setFocusedAppLw(null);
                }
                newFocus = null;
            } else {
                AppWindowToken newFocus = findAppWindowToken(token);
                newFocus = findAppWindowToken(token);
                if (newFocus == null) {
                    Slog.w(TAG, "Attempted to set focus to non-existing app token: " + token);
                    return;
                }
                changed = mFocusedApp != newFocus;
                if (DEBUG_FOCUS_LIGHT) Slog.v(TAG, "Set focused app to: " + newFocus
                        + " old focus=" + mFocusedApp + " moveFocusNow=" + moveFocusNow);
                mFocusedApp = newFocus;
                if (changed) {
                    mInputMonitor.setFocusedAppLw(newFocus);
            }

            final boolean changed = mFocusedApp != newFocus;
            if (changed) {
                mFocusedApp = newFocus;
                mInputMonitor.setFocusedAppLw(null);
            }

            if (moveFocusNow && changed) {
@@ -4543,11 +4539,9 @@ public class WindowManagerService extends IWindowManager.Stub
    void removeAppFromTaskLocked(AppWindowToken wtoken) {
        final Task task = mTaskIdToTask.get(wtoken.groupId);
        if (task != null) {
            task.removeAppToken(wtoken);
            // Remove after bug resolved.
            Slog.d(TAG, "removeAppFromTaskLocked: wtoken=" + wtoken
                    + " numTokens left=" + task.mAppTokens.size()
                    + " Callers=" + Debug.getCallers(5));
            if (!task.removeAppToken(wtoken)) {
                Slog.e(TAG, "removeAppFromTaskLocked: token=" + wtoken + " not found.");
            }
        }
    }

@@ -4583,6 +4577,8 @@ public class WindowManagerService extends IWindowManager.Stub
                        TAG, "Removing app " + wtoken + " delayed=" + delayed
                        + " animation=" + wtoken.mAppAnimator.animation
                        + " animating=" + wtoken.mAppAnimator.animating);
                if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, "removeAppToken: "
                        + wtoken + " delayed=" + delayed + " Callers=" + Debug.getCallers(4));
                final TaskStack stack = mTaskIdToTask.get(wtoken.groupId).mStack;
                if (delayed) {
                    // set the token aside because it has an active animation to be finished
@@ -4598,9 +4594,6 @@ public class WindowManagerService extends IWindowManager.Stub
                    wtoken.mAppAnimator.animating = false;
                    removeAppFromTaskLocked(wtoken);
                }
                if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG,
                        "removeAppToken: " + wtoken);


                wtoken.removed = true;
                if (wtoken.startingData != null) {