summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/etc/services.core.protolog.json6
-rw-r--r--services/core/java/com/android/server/wm/ActivityTaskManagerService.java3
-rw-r--r--services/core/java/com/android/server/wm/LockTaskController.java22
3 files changed, 23 insertions, 8 deletions
diff --git a/data/etc/services.core.protolog.json b/data/etc/services.core.protolog.json
index c6d9ebab297d..f9bfd5872187 100644
--- a/data/etc/services.core.protolog.json
+++ b/data/etc/services.core.protolog.json
@@ -1069,6 +1069,12 @@
"group": "WM_DEBUG_ORIENTATION",
"at": "com\/android\/server\/wm\/WindowManagerService.java"
},
+ "-1075136930": {
+ "message": "startLockTaskMode: Can't lock due to auth",
+ "level": "WARN",
+ "group": "WM_DEBUG_LOCKTASK",
+ "at": "com\/android\/server\/wm\/LockTaskController.java"
+ },
"-1069336896": {
"message": "onRootTaskOrderChanged(): rootTask=%s",
"level": "DEBUG",
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index c8fcee67a383..2591a36a7f0e 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -2568,6 +2568,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
}
task = r.getTask();
}
+ // If {@code isSystemCaller} is {@code true}, it means the user intends to stop
+ // pinned mode through UI; otherwise, it's called by an app and we need to stop
+ // locked or pinned mode, subject to checks.
getLockTaskController().stopLockTaskMode(task, isSystemCaller, callingUid);
}
// Launch in-call UI if a call is ongoing. This is necessary to allow stopping the lock
diff --git a/services/core/java/com/android/server/wm/LockTaskController.java b/services/core/java/com/android/server/wm/LockTaskController.java
index 7a055d2948ad..f11c2a7da840 100644
--- a/services/core/java/com/android/server/wm/LockTaskController.java
+++ b/services/core/java/com/android/server/wm/LockTaskController.java
@@ -481,27 +481,24 @@ public class LockTaskController {
*
* @param task the task that requested the end of lock task mode ({@code null} for quitting app
* pinning mode)
- * @param isSystemCaller indicates whether this request comes from the system via
- * {@link ActivityTaskManagerService#stopSystemLockTaskMode()}. If
- * {@code true}, it means the user intends to stop pinned mode through UI;
- * otherwise, it's called by an app and we need to stop locked or pinned
- * mode, subject to checks.
+ * @param stopAppPinning indicates whether to stop app pinning mode or to stop a task from
+ * being locked.
* @param callingUid the caller that requested the end of lock task mode.
* @throws IllegalArgumentException if the calling task is invalid (e.g., {@code null} or not in
* foreground)
* @throws SecurityException if the caller is not authorized to stop the lock task mode, i.e. if
* they differ from the one that launched lock task mode.
*/
- void stopLockTaskMode(@Nullable Task task, boolean isSystemCaller, int callingUid) {
+ void stopLockTaskMode(@Nullable Task task, boolean stopAppPinning, int callingUid) {
if (mLockTaskModeState == LOCK_TASK_MODE_NONE) {
return;
}
- if (isSystemCaller) {
+ if (stopAppPinning) {
if (mLockTaskModeState == LOCK_TASK_MODE_PINNED) {
clearLockedTasks("stopAppPinning");
} else {
- Slog.e(TAG_LOCKTASK, "Attempted to stop LockTask with isSystemCaller=true");
+ Slog.e(TAG_LOCKTASK, "Attempted to stop app pinning while fully locked");
showLockTaskToast();
}
@@ -642,6 +639,10 @@ public class LockTaskController {
* @param callingUid the caller that requested the launch of lock task mode.
*/
void startLockTaskMode(@NonNull Task task, boolean isSystemCaller, int callingUid) {
+ if (task.mLockTaskAuth == LOCK_TASK_AUTH_DONT_LOCK) {
+ ProtoLog.w(WM_DEBUG_LOCKTASK, "startLockTaskMode: Can't lock due to auth");
+ return;
+ }
if (!isSystemCaller) {
task.mLockTaskUid = callingUid;
if (task.mLockTaskAuth == LOCK_TASK_AUTH_PINNABLE) {
@@ -654,6 +655,11 @@ public class LockTaskController {
statusBarManager.showScreenPinningRequest(task.mTaskId);
}
return;
+ } else if (mLockTaskModeState == LOCK_TASK_MODE_PINNED) {
+ // startLockTask() called by app, and app is part of lock task allowlist.
+ // Deactivate the currently pinned task before doing so.
+ Slog.i(TAG, "Stop app pinning before entering full lock task mode");
+ stopLockTaskMode(/* task= */ null, /* stopAppPinning= */ true, callingUid);
}
}