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
This commit is contained in:
Winson
2016-01-25 17:16:58 -08:00
committed by Winson Chung
parent 6e6bd8776f
commit dcf4826c52
2 changed files with 32 additions and 4 deletions

View File

@@ -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;
}
/**

View File

@@ -5349,9 +5349,31 @@ 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 */
boolean isCurrentProfileLocked(int userId) {
if (userId == mCurrentUserId) return true;