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

Commit dcf4826c authored by Winson's avatar Winson Committed by Winson Chung
Browse files

Fixing notification of the docked stack state for the current user.

- When there are multiple users, ensure that we check that there are
  tasks in the docked stack for each user (instead of just the presence
  of the docked stack) and re-notify listeners of the state of the
  docked stack when the user is switched.

Change-Id: I911c4a32db187f9cd29d462309bd0cf7febb1993
parent 6e6bd877
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -378,13 +378,19 @@ public class SystemServicesProxy {
        ActivityManager.StackInfo stackInfo = null;
        try {
            stackInfo = mIam.getStackInfo(DOCKED_STACK_ID);
            if (stackInfo != null && stackInfo.userId != getCurrentUser()) {
                return false;
            }
        } catch (RemoteException e) {
            e.printStackTrace();
        }
        return stackInfo != null;

        if (stackInfo != null) {
            int userId = getCurrentUser();
            boolean hasUserTask = false;
            for (int i = stackInfo.taskUserIds.length - 1; i >= 0 && !hasUserTask; i--) {
                hasUserTask = (stackInfo.taskUserIds[i] == userId);
            }
            return hasUserTask;
        }
        return false;
    }

    /**
+22 −0
Original line number Diff line number Diff line
@@ -5349,7 +5349,29 @@ public class WindowManagerService extends IWindowManager.Stub
                rebuildAppWindowListLocked(displayContent);
            }
            mWindowPlacerLocked.performSurfacePlacement();

            // Notify whether the docked stack exists for the current user
            getDefaultDisplayContentLocked().mDividerControllerLocked
                    .notifyDockedStackExistsChanged(hasDockedTasksForUser(newUserId));
        }
    }

    /**
     * Returns whether there is a docked task for the current user.
     */
    boolean hasDockedTasksForUser(int userId) {
        final TaskStack stack = mStackIdToStack.get(DOCKED_STACK_ID);
        if (stack == null) {
            return false;
        }

        final ArrayList<Task> tasks = stack.getTasks();
        boolean hasUserTask = false;
        for (int i = tasks.size() - 1; i >= 0 && !hasUserTask; i--) {
            final Task task = tasks.get(i);
            hasUserTask = (task.mUserId == userId);
        }
        return hasUserTask;
    }

    /* Called by WindowState */