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

Commit 80a5314a authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

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

parents 486117bf dcf4826c
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 */