summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWale Ogunwale <ogunwale@google.com>2015-04-07 03:06:19 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-04-07 03:06:23 +0000
commitb9223015261afdec7e8686b732b298b809bf87dc (patch)
tree8d22708db2217b52ace48f53fce7797d69b83ddb
parent33c375ff9268fda513bebc67ec3e01dcdc56837e (diff)
parent3fcb4a89750d6df42f850021cd754500fc084086 (diff)
downloadframeworks_base-b9223015261afdec7e8686b732b298b809bf87dc.zip
frameworks_base-b9223015261afdec7e8686b732b298b809bf87dc.tar.gz
frameworks_base-b9223015261afdec7e8686b732b298b809bf87dc.tar.bz2
Merge "Fixed bug with ActivityInfo.FLAG_SHOW_ON_LOCK_SCREEN not working"
-rw-r--r--services/core/java/com/android/server/am/ActivityStack.java40
-rw-r--r--services/core/java/com/android/server/wm/Task.java5
-rw-r--r--services/core/java/com/android/server/wm/TaskStack.java16
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java2
4 files changed, 44 insertions, 19 deletions
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 1108391..1fee1ae 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -16,6 +16,8 @@
package com.android.server.am;
+import static android.content.pm.ActivityInfo.FLAG_SHOW_ON_LOCK_SCREEN;
+
import static com.android.server.am.ActivityManagerDebugConfig.*;
import static com.android.server.am.ActivityRecord.HOME_ACTIVITY_TYPE;
@@ -373,8 +375,7 @@ final class ActivityStack {
}
boolean okToShowLocked(ActivityRecord r) {
- return isCurrentProfileLocked(r.userId)
- || (r.info.flags & ActivityInfo.FLAG_SHOW_ON_LOCK_SCREEN) != 0;
+ return isCurrentProfileLocked(r.userId) || (r.info.flags & FLAG_SHOW_ON_LOCK_SCREEN) != 0;
}
final ActivityRecord topRunningActivityLocked(ActivityRecord notTop) {
@@ -617,13 +618,15 @@ final class ActivityStack {
final int userId = UserHandle.getUserId(info.applicationInfo.uid);
for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
- TaskRecord task = mTaskHistory.get(taskNdx);
- if (!isCurrentProfileLocked(task.userId)) {
- return null;
- }
+ final TaskRecord task = mTaskHistory.get(taskNdx);
+ final boolean notCurrentUserTask = !isCurrentProfileLocked(task.userId);
final ArrayList<ActivityRecord> activities = task.mActivities;
+
for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
ActivityRecord r = activities.get(activityNdx);
+ if (notCurrentUserTask && (r.info.flags & FLAG_SHOW_ON_LOCK_SCREEN) == 0) {
+ return null;
+ }
if (!r.finishing && r.intent.getComponent().equals(cls) && r.userId == userId) {
//Slog.i(TAG, "Found matching class!");
//dump();
@@ -648,8 +651,12 @@ final class ActivityStack {
// Move userId's tasks to the top.
int index = mTaskHistory.size();
for (int i = 0; i < index; ) {
- TaskRecord task = mTaskHistory.get(i);
- if (isCurrentProfileLocked(task.userId)) {
+ final TaskRecord task = mTaskHistory.get(i);
+
+ // NOTE: If {@link TaskRecord#topRunningActivityLocked} return is not null then it is
+ // okay to show the activity when locked.
+ if (isCurrentProfileLocked(task.userId)
+ || task.topRunningActivityLocked(null) != null) {
if (DEBUG_TASKS) Slog.d(TAG_TASKS, "switchUserLocked: stack=" + getStackId() +
" moving " + task + " to top");
mTaskHistory.remove(i);
@@ -1981,7 +1988,7 @@ final class ActivityStack {
return null;
}
- private void insertTaskAtTop(TaskRecord task) {
+ private void insertTaskAtTop(TaskRecord task, ActivityRecord newActivity) {
// If the moving task is over home stack, transfer its return type to next task
if (task.isOverHomeStack()) {
final TaskRecord nextTask = getNextTask(task);
@@ -2009,10 +2016,15 @@ final class ActivityStack {
mTaskHistory.remove(task);
// Now put task at top.
int taskNdx = mTaskHistory.size();
- if (!isCurrentProfileLocked(task.userId)) {
+ final boolean notShownWhenLocked =
+ (newActivity != null && (newActivity.info.flags & FLAG_SHOW_ON_LOCK_SCREEN) == 0)
+ || (newActivity == null && task.topRunningActivityLocked(null) == null);
+ if (!isCurrentProfileLocked(task.userId) && notShownWhenLocked) {
// Put non-current user tasks below current user tasks.
while (--taskNdx >= 0) {
- if (!isCurrentProfileLocked(mTaskHistory.get(taskNdx).userId)) {
+ final TaskRecord tmpTask = mTaskHistory.get(taskNdx);
+ if (!isCurrentProfileLocked(tmpTask.userId)
+ || tmpTask.topRunningActivityLocked(null) == null) {
break;
}
}
@@ -2031,7 +2043,7 @@ final class ActivityStack {
// Last activity in task had been removed or ActivityManagerService is reusing task.
// Insert or replace.
// Might not even be in.
- insertTaskAtTop(rTask);
+ insertTaskAtTop(rTask, r);
mWindowManager.moveTaskToTop(taskId);
}
TaskRecord task = null;
@@ -3611,7 +3623,7 @@ final class ActivityStack {
// Shift all activities with this task up to the top
// of the stack, keeping them in the same internal order.
- insertTaskAtTop(tr);
+ insertTaskAtTop(tr, null);
// Set focus to the top running activity of this stack.
ActivityRecord r = topRunningActivityLocked(null);
@@ -4288,7 +4300,7 @@ final class ActivityStack {
void addTask(final TaskRecord task, final boolean toTop, boolean moving) {
task.stack = this;
if (toTop) {
- insertTaskAtTop(task);
+ insertTaskAtTop(task, null);
} else {
mTaskHistory.add(0, task);
updateTaskMovement(task, false);
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 98ac5ef..34120a0 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -107,6 +107,11 @@ class Task {
}
}
+ boolean showWhenLocked() {
+ final int tokensCount = mAppTokens.size();
+ return (tokensCount != 0) && mAppTokens.get(tokensCount - 1).showWhenLocked;
+ }
+
@Override
public String toString() {
return "{taskId=" + mTaskId + " appTokens=" + mAppTokens + " mdr=" + mDeferRemoval + "}";
diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java
index b61a6f7..e845f83 100644
--- a/services/core/java/com/android/server/wm/TaskStack.java
+++ b/services/core/java/com/android/server/wm/TaskStack.java
@@ -275,21 +275,29 @@ public class TaskStack {
return false;
}
+ void addTask(Task task, boolean toTop) {
+ addTask(task, toTop, task.showWhenLocked());
+ }
+
/**
* Put a Task in this stack. Used for adding and moving.
* @param task The task to add.
* @param toTop Whether to add it to the top or bottom.
+ * @param showWhenLocked Whether to show the task when the device is locked
+ * regardless of the current user.
*/
- void addTask(Task task, boolean toTop) {
+ void addTask(Task task, boolean toTop, boolean showWhenLocked) {
int stackNdx;
if (!toTop) {
stackNdx = 0;
} else {
stackNdx = mTasks.size();
- if (!mService.isCurrentProfileLocked(task.mUserId)) {
+ if (!showWhenLocked && !mService.isCurrentProfileLocked(task.mUserId)) {
// Place the task below all current user tasks.
while (--stackNdx >= 0) {
- if (!mService.isCurrentProfileLocked(mTasks.get(stackNdx).mUserId)) {
+ final Task tmpTask = mTasks.get(stackNdx);
+ if (!tmpTask.showWhenLocked()
+ || !mService.isCurrentProfileLocked(tmpTask.mUserId)) {
break;
}
}
@@ -490,7 +498,7 @@ public class TaskStack {
int top = mTasks.size();
for (int taskNdx = 0; taskNdx < top; ++taskNdx) {
Task task = mTasks.get(taskNdx);
- if (mService.isCurrentProfileLocked(task.mUserId)) {
+ if (mService.isCurrentProfileLocked(task.mUserId) || task.showWhenLocked()) {
mTasks.remove(taskNdx);
mTasks.add(task);
--top;
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 796868c..0188e98 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -3620,7 +3620,7 @@ public class WindowManagerService extends IWindowManager.Stub
EventLog.writeEvent(EventLogTags.WM_TASK_CREATED, taskId, stackId);
Task task = new Task(taskId, stack, userId, this);
mTaskIdToTask.put(taskId, task);
- stack.addTask(task, !atoken.mLaunchTaskBehind /* toTop */);
+ stack.addTask(task, !atoken.mLaunchTaskBehind /* toTop */, atoken.showWhenLocked);
return task;
}