From 9eef8ebc44d1d70f0cb9f8b34bdb1ff885227f68 Mon Sep 17 00:00:00 2001 From: Jeff Chang Date: Thu, 8 Dec 2022 23:13:13 +0800 Subject: [PATCH] Check lock-task mode if task_on_home is applied MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit d41841f469f3a9e13, always checks whether the home task is violated with lock-task mode while moving the task to the front. That result in the pinned toast was shown even applications don’t not request to have task_on_home behavior. This CL checks the home task violation with lock-task mode after the task-on-home flag is applyed. Bug: 261383209 Test: atest TaskTests#testReturnsToHomeRootTask atest ActivityVisibilityTests#testLaunchTaskOnHome Change-Id: Iccc7e595b043a712c5959d28ba14f54825bcadd6 --- services/core/java/com/android/server/wm/Task.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 84e30142f9835..476ffc65f99a6 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -1119,11 +1119,12 @@ class Task extends TaskFragment { if (inMultiWindowMode() || !hasChild()) return false; if (intent != null) { final int returnHomeFlags = FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_TASK_ON_HOME; + if ((intent.getFlags() & returnHomeFlags) != returnHomeFlags) { + return false; + } final Task task = getDisplayArea() != null ? getDisplayArea().getRootHomeTask() : null; - final boolean isLockTaskModeViolation = task != null - && mAtmService.getLockTaskController().isLockTaskModeViolation(task); - return (intent.getFlags() & returnHomeFlags) == returnHomeFlags - && !isLockTaskModeViolation; + return !(task != null + && mAtmService.getLockTaskController().isLockTaskModeViolation(task)); } final Task bottomTask = getBottomMostTask(); return bottomTask != this && bottomTask.returnsToHomeRootTask();