From 4f99b0dcac7ba8953fd66d6dd4185d28b4c06297 Mon Sep 17 00:00:00 2001 From: Jeff Chang Date: Fri, 27 Aug 2021 16:41:34 +0800 Subject: [PATCH] Don't show the embedded activities if visible needed activity without showWhenLocked MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While the host activity and the embedded activity are displayed side-by-side. Only the activity with showWhenLocked flag is shown when the lock-screen is displayed. This CL updates the logic for embedded activities policy if the visible needed activity without showWhenLocked flags. Don’t display the embedded activities while the lock-screen is shown. Bug: 197298936 Test: atest TaskFragmentOrganizerTest TaskFragmentOrganizerPolicyTest SplitActivityLifecycleTest Change-Id: I8e318c4b47f38ff3daf0713ab70cd980e7928000 --- .../com/android/server/wm/ActivityRecord.java | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 8ef973dbcfae5..731bd7716840e 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -4151,18 +4151,39 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * conditions a) above. * Multi-windowing mode will be exited if {@code true} is returned. */ - boolean canShowWhenLocked() { - if (!inPinnedWindowingMode() && (mShowWhenLocked || containsShowWhenLockedWindow())) { + private static boolean canShowWhenLocked(ActivityRecord r) { + if (r == null || r.getTaskFragment() == null) { + return false; + } + if (!r.inPinnedWindowingMode() && (r.mShowWhenLocked || r.containsShowWhenLockedWindow())) { return true; - } else if (mInheritShownWhenLocked) { - final ActivityRecord r = task.getActivityBelow(this); - return r != null && !r.inPinnedWindowingMode() && (r.mShowWhenLocked - || r.containsShowWhenLockedWindow()); + } else if (r.mInheritShownWhenLocked) { + final ActivityRecord activity = r.getTaskFragment().getActivityBelow(r); + return activity != null && !activity.inPinnedWindowingMode() + && (activity.mShowWhenLocked || activity.containsShowWhenLockedWindow()); } else { return false; } } + /** + * Determines if the activity can show while lock-screen is displayed. System displays + * activities while lock-screen is displayed only if all activities + * {@link #canShowWhenLocked(ActivityRecord)}. + * @see #canShowWhenLocked(ActivityRecord) + */ + boolean canShowWhenLocked() { + final TaskFragment taskFragment = getTaskFragment(); + if (taskFragment != null && taskFragment.getAdjacentTaskFragment() != null + && taskFragment.isEmbedded()) { + final TaskFragment adjacentTaskFragment = taskFragment.getAdjacentTaskFragment(); + final ActivityRecord r = adjacentTaskFragment.getTopNonFinishingActivity(); + return canShowWhenLocked(this) && canShowWhenLocked(r); + } else { + return canShowWhenLocked(this); + } + } + /** * @return Whether we are allowed to show non-starting windows at the moment. We disallow * showing windows during transitions in case we have windows that have wide-color-gamut