From f2dd033aad4ffd8c0f8ec1541f68214585093f95 Mon Sep 17 00:00:00 2001 From: Garfield Tan Date: Tue, 27 Apr 2021 16:54:58 -0700 Subject: [PATCH] Add Dimmer to RootDisplayArea There are 2 reasons that led to this change. Right now on trusted displays Dimmer is offered on windowed magnification display area, but no one offers it on untrusted displays. There is no guarantee that windowed manification display area always exists either on all OEM. In Task#getDimmer() if the task is fullscreen but is translucent it asks for a dimmer from one of its ancestors, and WindowState#applyDims() uses Dimmer as if it always can get one. There can also be system dialogs (e.g. ANR dialogs) that don't belong to any TaskDisplayArea that also needs a Dimmer. Therefore add a dimmer to RootDisplayArea. Bug: 186436456 Test: atest TaskTests Change-Id: I284b60124e27496352c27f446a2742e3e4756ec9 --- .../java/com/android/server/wm/RootDisplayArea.java | 2 +- .../wmtests/src/com/android/server/wm/TaskTests.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/RootDisplayArea.java b/services/core/java/com/android/server/wm/RootDisplayArea.java index cd20c8242d81b..1cda8d56ddc72 100644 --- a/services/core/java/com/android/server/wm/RootDisplayArea.java +++ b/services/core/java/com/android/server/wm/RootDisplayArea.java @@ -37,7 +37,7 @@ import java.util.Map; * of the whole logical display, or a {@link DisplayAreaGroup} as the root of a partition of the * logical display. */ -class RootDisplayArea extends DisplayArea { +class RootDisplayArea extends DisplayArea.Dimmable { /** {@link Feature} that are supported in this {@link DisplayArea} hierarchy. */ List mFeatures; diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java index 2389d2d6e8d64..13ef9982494eb 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java @@ -80,6 +80,7 @@ import android.util.DisplayMetrics; import android.util.TypedXmlPullParser; import android.util.TypedXmlSerializer; import android.util.Xml; +import android.view.Display; import android.view.DisplayInfo; import androidx.test.filters.MediumTest; @@ -1338,6 +1339,16 @@ public class TaskTests extends WindowTestsBase { verify(display).onDescendantOrientationChanged(same(task)); } + @Test + public void testGetNonNullDimmerOnUntrustedDisplays() { + final DisplayInfo untrustedDisplayInfo = new DisplayInfo(mDisplayInfo); + untrustedDisplayInfo.flags &= ~Display.FLAG_TRUSTED; + final DisplayContent untrustedDisplay = createNewDisplay(untrustedDisplayInfo); + final ActivityRecord activity = createActivityRecord(untrustedDisplay); + activity.setOccludesParent(false); + assertNotNull(activity.getTask().getDimmer()); + } + private Task getTestTask() { final Task task = new TaskBuilder(mSupervisor).setCreateActivity(true).build(); return task.getBottomMostTask();