diff options
-rw-r--r-- | api/current.txt | 3 | ||||
-rw-r--r-- | api/system-current.txt | 3 | ||||
-rw-r--r-- | core/java/android/content/pm/ActivityInfo.java | 7 | ||||
-rw-r--r-- | core/java/android/content/pm/PackageParser.java | 5 | ||||
-rw-r--r-- | core/res/res/values/attrs_manifest.xml | 11 | ||||
-rw-r--r-- | core/res/res/values/public.xml | 2 | ||||
-rw-r--r-- | services/core/java/com/android/server/am/ActivityStack.java | 14 | ||||
-rw-r--r-- | services/core/java/com/android/server/am/ActivityStackSupervisor.java | 2 | ||||
-rw-r--r-- | services/core/java/com/android/server/wm/AppWindowToken.java | 2 | ||||
-rw-r--r-- | services/core/java/com/android/server/wm/Task.java | 4 | ||||
-rw-r--r-- | services/core/java/com/android/server/wm/TaskStack.java | 13 | ||||
-rw-r--r-- | services/core/java/com/android/server/wm/WindowManagerService.java | 6 | ||||
-rw-r--r-- | services/core/java/com/android/server/wm/WindowState.java | 9 |
13 files changed, 51 insertions, 30 deletions
diff --git a/api/current.txt b/api/current.txt index d73b9f9..da39063 100644 --- a/api/current.txt +++ b/api/current.txt @@ -1098,7 +1098,8 @@ package android { field public static final int showAsAction = 16843481; // 0x10102d9 field public static final int showDefault = 16843258; // 0x10101fa field public static final int showDividers = 16843561; // 0x1010329 - field public static final int showOnLockScreen = 16843721; // 0x10103c9 + field public static final int showForAllUsers = 16844018; // 0x10104f2 + field public static final deprecated int showOnLockScreen = 16843721; // 0x10103c9 field public static final int showSilent = 16843259; // 0x10101fb field public static final int showText = 16843949; // 0x10104ad field public static final deprecated int showWeekNumber = 16843582; // 0x101033e diff --git a/api/system-current.txt b/api/system-current.txt index f98e15f..a1980f0 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -1175,7 +1175,8 @@ package android { field public static final int showAsAction = 16843481; // 0x10102d9 field public static final int showDefault = 16843258; // 0x10101fa field public static final int showDividers = 16843561; // 0x1010329 - field public static final int showOnLockScreen = 16843721; // 0x10103c9 + field public static final int showForAllUsers = 16844018; // 0x10104f2 + field public static final deprecated int showOnLockScreen = 16843721; // 0x10103c9 field public static final int showSilent = 16843259; // 0x10101fb field public static final int showText = 16843949; // 0x10104ad field public static final deprecated int showWeekNumber = 16843582; // 0x101033e diff --git a/core/java/android/content/pm/ActivityInfo.java b/core/java/android/content/pm/ActivityInfo.java index 8d82aa2..16f6b1e 100644 --- a/core/java/android/content/pm/ActivityInfo.java +++ b/core/java/android/content/pm/ActivityInfo.java @@ -223,11 +223,12 @@ public class ActivityInfo extends ComponentInfo */ public static final int FLAG_HARDWARE_ACCELERATED = 0x0200; /** - * Value for {@link #flags}: true when the application can be displayed over the lockscreen - * and consequently over all users' windows. + * Value for {@link #flags}: true when the application can be displayed for all users + * regardless of if the user of the application is the current user. Set from the + * {@link android.R.attr#showForAllUsers} attribute. * @hide */ - public static final int FLAG_SHOW_ON_LOCK_SCREEN = 0x0400; + public static final int FLAG_SHOW_FOR_ALL_USERS = 0x0400; /** * Bit in {@link #flags} corresponding to an immersive activity * that wishes not to be interrupted by notifications. diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index 40f4e8f..fed9261 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -3099,8 +3099,9 @@ public class PackageParser { a.info.flags |= ActivityInfo.FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS; } - if (sa.getBoolean(R.styleable.AndroidManifestActivity_showOnLockScreen, false)) { - a.info.flags |= ActivityInfo.FLAG_SHOW_ON_LOCK_SCREEN; + if (sa.getBoolean(R.styleable.AndroidManifestActivity_showOnLockScreen, false) + || sa.getBoolean(R.styleable.AndroidManifestActivity_showForAllUsers, false)) { + a.info.flags |= ActivityInfo.FLAG_SHOW_FOR_ALL_USERS; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_immersive, false)) { diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml index 0ac366d..12d7e60 100644 --- a/core/res/res/values/attrs_manifest.xml +++ b/core/res/res/values/attrs_manifest.xml @@ -501,9 +501,16 @@ <attr name="excludeFromRecents" format="boolean" /> <!-- Specify that an Activity should be shown over the lock screen and, - in a multiuser environment, across all users' windows --> + in a multiuser environment, across all users' windows. + @deprecated use {@link android.R.attr#showForAllUsers} instead. --> <attr name="showOnLockScreen" format="boolean" /> + <!-- Specify that an Activity should be shown even if the current/foreground user + is different from the user of the Activity. This will also force the + <code>android.view.LayoutParams.FLAG_SHOW_WHEN_LOCKED</code> flag + to be set for all windows of this activity --> + <attr name="showForAllUsers" format="boolean" /> + <!-- Specify the authorities under which this content provider can be found. Multiple authorities may be supplied by separating them with a semicolon. Authority names should use a Java-style naming @@ -1761,6 +1768,7 @@ <attr name="alwaysRetainTaskState" /> <attr name="stateNotNeeded" /> <attr name="excludeFromRecents" /> + <!-- @deprecated use {@link android.R.attr#showForAllUsers} instead. --> <attr name="showOnLockScreen" /> <!-- Specify whether the activity is enabled or not (that is, can be instantiated by the system). It can also be specified for an application as a whole, in which case a value of "false" @@ -1789,6 +1797,7 @@ <attr name="resumeWhilePausing" /> <attr name="resizeableActivity" /> <attr name="lockTaskMode" /> + <attr name="showForAllUsers" /> </declare-styleable> <!-- The <code>activity-alias</code> tag declares a new diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 282c80b..261efd0 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -2668,4 +2668,6 @@ <public type="attr" name="leftIndents" /> <public type="attr" name="rightIndents" /> + + <public type="attr" name="showForAllUsers" /> </resources> diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java index 6210d60..162270c 100644 --- a/services/core/java/com/android/server/am/ActivityStack.java +++ b/services/core/java/com/android/server/am/ActivityStack.java @@ -16,7 +16,7 @@ package com.android.server.am; -import static android.content.pm.ActivityInfo.FLAG_SHOW_ON_LOCK_SCREEN; +import static android.content.pm.ActivityInfo.FLAG_SHOW_FOR_ALL_USERS; import static com.android.server.am.ActivityManagerDebugConfig.*; @@ -375,7 +375,7 @@ final class ActivityStack { } boolean okToShowLocked(ActivityRecord r) { - return isCurrentProfileLocked(r.userId) || (r.info.flags & FLAG_SHOW_ON_LOCK_SCREEN) != 0; + return isCurrentProfileLocked(r.userId) || (r.info.flags & FLAG_SHOW_FOR_ALL_USERS) != 0; } final ActivityRecord topRunningActivityLocked(ActivityRecord notTop) { @@ -624,7 +624,7 @@ final class ActivityStack { 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) { + if (notCurrentUserTask && (r.info.flags & FLAG_SHOW_FOR_ALL_USERS) == 0) { return null; } if (!r.finishing && r.intent.getComponent().equals(cls) && r.userId == userId) { @@ -2024,7 +2024,7 @@ final class ActivityStack { // Now put task at top. int taskNdx = mTaskHistory.size(); final boolean notShownWhenLocked = - (newActivity != null && (newActivity.info.flags & FLAG_SHOW_ON_LOCK_SCREEN) == 0) + (newActivity != null && (newActivity.info.flags & FLAG_SHOW_FOR_ALL_USERS) == 0) || (newActivity == null && task.topRunningActivityLocked(null) == null); if (!isCurrentProfileLocked(task.userId) && notShownWhenLocked) { // Put non-current user tasks below current user tasks. @@ -2074,7 +2074,7 @@ final class ActivityStack { r.putInHistory(); mWindowManager.addAppToken(task.mActivities.indexOf(r), r.appToken, r.task.taskId, mStackId, r.info.screenOrientation, r.fullscreen, - (r.info.flags & ActivityInfo.FLAG_SHOW_ON_LOCK_SCREEN) != 0, + (r.info.flags & ActivityInfo.FLAG_SHOW_FOR_ALL_USERS) != 0, r.userId, r.info.configChanges, task.voiceSession != null, r.mLaunchTaskBehind); if (VALIDATE_TOKENS) { @@ -2138,7 +2138,7 @@ final class ActivityStack { } mWindowManager.addAppToken(task.mActivities.indexOf(r), r.appToken, r.task.taskId, mStackId, r.info.screenOrientation, r.fullscreen, - (r.info.flags & ActivityInfo.FLAG_SHOW_ON_LOCK_SCREEN) != 0, r.userId, + (r.info.flags & ActivityInfo.FLAG_SHOW_FOR_ALL_USERS) != 0, r.userId, r.info.configChanges, task.voiceSession != null, r.mLaunchTaskBehind); boolean doShow = true; if (newTask) { @@ -2190,7 +2190,7 @@ final class ActivityStack { // because there is nothing for it to animate on top of. mWindowManager.addAppToken(task.mActivities.indexOf(r), r.appToken, r.task.taskId, mStackId, r.info.screenOrientation, r.fullscreen, - (r.info.flags & ActivityInfo.FLAG_SHOW_ON_LOCK_SCREEN) != 0, r.userId, + (r.info.flags & ActivityInfo.FLAG_SHOW_FOR_ALL_USERS) != 0, r.userId, r.info.configChanges, task.voiceSession != null, r.mLaunchTaskBehind); ActivityOptions.abort(options); options = null; diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java index 6908483..58bdc28 100644 --- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java @@ -2826,7 +2826,7 @@ public final class ActivityStackSupervisor implements DisplayListener { final ActivityRecord r = activities.get(activityNdx); mWindowManager.addAppToken(0, r.appToken, task.taskId, stack.mStackId, r.info.screenOrientation, r.fullscreen, - (r.info.flags & ActivityInfo.FLAG_SHOW_ON_LOCK_SCREEN) != 0, + (r.info.flags & ActivityInfo.FLAG_SHOW_FOR_ALL_USERS) != 0, r.userId, r.info.configChanges, task.voiceSession != null, r.mLaunchTaskBehind); } diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java index a04f6cb..e914cd4 100644 --- a/services/core/java/com/android/server/wm/AppWindowToken.java +++ b/services/core/java/com/android/server/wm/AppWindowToken.java @@ -56,7 +56,7 @@ class AppWindowToken extends WindowToken { boolean appFullscreen; int requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; boolean layoutConfigChanges; - boolean showWhenLocked; + boolean showForAllUsers; // The input dispatching timeout for this application token in nanoseconds. long inputDispatchingTimeoutNanos; diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 34120a0..0c3cf65 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -107,9 +107,9 @@ class Task { } } - boolean showWhenLocked() { + boolean showForAllUsers() { final int tokensCount = mAppTokens.size(); - return (tokensCount != 0) && mAppTokens.get(tokensCount - 1).showWhenLocked; + return (tokensCount != 0) && mAppTokens.get(tokensCount - 1).showForAllUsers; } @Override diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java index e845f83..7cdf8b2 100644 --- a/services/core/java/com/android/server/wm/TaskStack.java +++ b/services/core/java/com/android/server/wm/TaskStack.java @@ -276,27 +276,26 @@ public class TaskStack { } void addTask(Task task, boolean toTop) { - addTask(task, toTop, task.showWhenLocked()); + addTask(task, toTop, task.showForAllUsers()); } /** * 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. + * @param showForAllUsers Whether to show the task regardless of the current user. */ - void addTask(Task task, boolean toTop, boolean showWhenLocked) { + void addTask(Task task, boolean toTop, boolean showForAllUsers) { int stackNdx; if (!toTop) { stackNdx = 0; } else { stackNdx = mTasks.size(); - if (!showWhenLocked && !mService.isCurrentProfileLocked(task.mUserId)) { + if (!showForAllUsers && !mService.isCurrentProfileLocked(task.mUserId)) { // Place the task below all current user tasks. while (--stackNdx >= 0) { final Task tmpTask = mTasks.get(stackNdx); - if (!tmpTask.showWhenLocked() + if (!tmpTask.showForAllUsers() || !mService.isCurrentProfileLocked(tmpTask.mUserId)) { break; } @@ -498,7 +497,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) || task.showWhenLocked()) { + if (mService.isCurrentProfileLocked(task.mUserId) || task.showForAllUsers()) { 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 e790fb0..dbcafc8 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -3620,13 +3620,13 @@ 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 */, atoken.showWhenLocked); + stack.addTask(task, !atoken.mLaunchTaskBehind /* toTop */, atoken.showForAllUsers); return task; } @Override public void addAppToken(int addPos, IApplicationToken token, int taskId, int stackId, - int requestedOrientation, boolean fullscreen, boolean showWhenLocked, int userId, + int requestedOrientation, boolean fullscreen, boolean showForAllUsers, int userId, int configChanges, boolean voiceInteraction, boolean launchTaskBehind) { if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS, "addAppToken()")) { @@ -3656,7 +3656,7 @@ public class WindowManagerService extends IWindowManager.Stub atoken = new AppWindowToken(this, token, voiceInteraction); atoken.inputDispatchingTimeoutNanos = inputDispatchingTimeoutNanos; atoken.appFullscreen = fullscreen; - atoken.showWhenLocked = showWhenLocked; + atoken.showForAllUsers = showForAllUsers; atoken.requestedOrientation = requestedOrientation; atoken.layoutConfigChanges = (configChanges & (ActivityInfo.CONFIG_SCREEN_SIZE | ActivityInfo.CONFIG_ORIENTATION)) != 0; diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index db3268d..4f795a6 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -17,6 +17,7 @@ package com.android.server.wm; import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW; +import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION; @@ -478,6 +479,12 @@ final class WindowState implements WindowManagerPolicy.WindowState { if (mAppToken != null) { final DisplayContent appDisplay = getDisplayContent(); mNotOnAppsDisplay = displayContent != appDisplay; + + if (mAppToken.showForAllUsers) { + // Windows for apps that can show for all users should also show when the + // device is locked. + mAttrs.flags |= FLAG_SHOW_WHEN_LOCKED; + } } mWinAnimator = new WindowStateAnimator(this); @@ -1353,7 +1360,7 @@ final class WindowState implements WindowManagerPolicy.WindowState { win = win.mAttachedWindow; } if (win.mAttrs.type < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW - && win.mAppToken != null && win.mAppToken.showWhenLocked) { + && win.mAppToken != null && win.mAppToken.showForAllUsers) { // Save some cycles by not calling getDisplayInfo unless it is an application // window intended for all users. final DisplayContent displayContent = win.getDisplayContent(); |