Merge "Stop app pinning if lock task is requested from allowedlisted app" into tm-qpr-dev

This commit is contained in:
Yanli Wan
2022-08-03 19:18:52 +00:00
committed by Android (Google) Code Review
3 changed files with 23 additions and 8 deletions

View File

@@ -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",

View File

@@ -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

View File

@@ -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);
}
}