Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f2dd033a authored by Garfield Tan's avatar Garfield Tan
Browse files

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
parent 564ef6e7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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<DisplayArea> {
class RootDisplayArea extends DisplayArea.Dimmable {

    /** {@link Feature} that are supported in this {@link DisplayArea} hierarchy. */
    List<DisplayAreaPolicyBuilder.Feature> mFeatures;
+11 −0
Original line number Diff line number Diff line
@@ -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();