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

Commit 8dd26b23 authored by shawnlin's avatar shawnlin
Browse files

Support hide display cutout with display area

- Added a new DisplayArea feature for hide display cutout
- Added a new config for enable/disable hide display cutout
- Resize and shift display areas to exclude the cutout areas.
- Force dark status bar when there is a cutout area at top
- Update bounds & offsets for different rotations.

Bug: 157388722
Test: atest HideDisplayCutoutControllerTest
      atest HideDisplayCutoutOrganizerTest
      atest WMShellTest
Change-Id: Iad2c8b1eff1ea4523f8a7e362c9e851d8594141c
parent f24001ca
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -77,6 +77,12 @@ public class DisplayAreaOrganizer extends WindowOrganizer {
     */
    public static final int FEATURE_FULLSCREEN_MAGNIFICATION = FEATURE_SYSTEM_FIRST + 5;

    /**
     * Display area for hiding display cutout feature
     * @hide
     */
    public static final int FEATURE_HIDE_DISPLAY_CUTOUT = FEATURE_SYSTEM_FIRST + 6;

    /**
     * The last boundary of display area for system features
     */
+3 −0
Original line number Diff line number Diff line
@@ -4510,4 +4510,7 @@
         activity-level letterboxing (size-compat mode). Therefore this override can control the
         maximum screen area that can be occupied by the app in the letterbox mode. -->
    <item name="config_taskLetterboxAspectRatio" format="float" type="dimen">0.0</item>

    <!-- If true, hide the display cutout with display area -->
    <bool name="config_hideDisplayCutoutWithDisplayArea">false</bool>
</resources>
+2 −0
Original line number Diff line number Diff line
@@ -4095,4 +4095,6 @@
  <java-symbol type="dimen" name="controls_thumbnail_image_max_width" />

  <java-symbol type="dimen" name="config_taskLetterboxAspectRatio" />

  <java-symbol type="bool" name="config_hideDisplayCutoutWithDisplayArea" />
</resources>
+6 −3
Original line number Diff line number Diff line
@@ -16,8 +16,7 @@

package com.android.wm.shell;

import com.android.wm.shell.common.DisplayImeController;
import com.android.wm.shell.draganddrop.DragAndDropController;
import com.android.wm.shell.hidedisplaycutout.HideDisplayCutout;
import com.android.wm.shell.onehanded.OneHanded;
import com.android.wm.shell.pip.Pip;
import com.android.wm.shell.splitscreen.SplitScreen;
@@ -33,16 +32,19 @@ public class ShellDump {
    private final Optional<SplitScreen> mSplitScreenOptional;
    private final Optional<Pip> mPipOptional;
    private final Optional<OneHanded> mOneHandedOptional;
    private final Optional<HideDisplayCutout> mHideDisplayCutout;
    private final ShellTaskOrganizer mShellTaskOrganizer;

    public ShellDump(ShellTaskOrganizer shellTaskOrganizer,
            Optional<SplitScreen> splitScreenOptional,
            Optional<Pip> pipOptional,
            Optional<OneHanded> oneHandedOptional) {
            Optional<OneHanded> oneHandedOptional,
            Optional<HideDisplayCutout> hideDisplayCutout) {
        mShellTaskOrganizer = shellTaskOrganizer;
        mSplitScreenOptional = splitScreenOptional;
        mPipOptional = pipOptional;
        mOneHandedOptional = oneHandedOptional;
        mHideDisplayCutout = hideDisplayCutout;
    }

    public void dump(PrintWriter pw) {
@@ -52,5 +54,6 @@ public class ShellDump {
        mPipOptional.ifPresent(pip -> pip.dump(pw));
        mSplitScreenOptional.ifPresent(splitScreen -> splitScreen.dump(pw));
        mOneHandedOptional.ifPresent(oneHanded -> oneHanded.dump(pw));
        mHideDisplayCutout.ifPresent(hideDisplayCutout -> hideDisplayCutout.dump(pw));
    }
}
+39 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.wm.shell.hidedisplaycutout;

import android.content.res.Configuration;

import androidx.annotation.NonNull;

import java.io.PrintWriter;

/**
 * Interface to engage hide display cutout feature.
 */
public interface HideDisplayCutout {
    /**
     * Notifies {@link Configuration} changed.
     * @param newConfig
     */
    void onConfigurationChanged(Configuration newConfig);

    /**
     * Dumps hide display cutout status.
     */
    void dump(@NonNull PrintWriter pw);
}
Loading