1828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale/*
2828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale * Copyright (C) 2017 The Android Open Source Project
3828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale *
4828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale * Licensed under the Apache License, Version 2.0 (the "License");
5828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale * you may not use this file except in compliance with the License.
6828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale * You may obtain a copy of the License at
7828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale *
8828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale *      http://www.apache.org/licenses/LICENSE-2.0
9828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale *
10828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale * Unless required by applicable law or agreed to in writing, software
11828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale * distributed under the License is distributed on an "AS IS" BASIS,
12828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale * See the License for the specific language governing permissions and
14e99bc0501a288735d337f2ff64f8fa47f766a59bAdrian Roos * limitations under the License.
15828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale */
16828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
17e99bc0501a288735d337f2ff64f8fa47f766a59bAdrian Roospackage com.android.server.wm;
18828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
19828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwaleimport static android.view.Surface.ROTATION_180;
20828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwaleimport static android.view.Surface.ROTATION_270;
21828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwaleimport static android.view.Surface.ROTATION_90;
226c6e9cab42bccb44ebb4b30e7eab7394c0dbb759Yi Jinimport static com.android.server.wm.DisplayFramesProto.STABLE_BOUNDS;
23828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
245c6b6223281e0669e674df3cb489d8544c20fb84Adrian Roosimport android.annotation.NonNull;
25828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwaleimport android.graphics.Rect;
26828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwaleimport android.util.proto.ProtoOutputStream;
275c6b6223281e0669e674df3cb489d8544c20fb84Adrian Roosimport android.view.DisplayCutout;
28e99bc0501a288735d337f2ff64f8fa47f766a59bAdrian Roosimport android.view.DisplayInfo;
29828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
306a4fa0ec183e20c32e7816f5475e72fa9126356cAdrian Roosimport com.android.server.wm.utils.WmDisplayCutout;
316a4fa0ec183e20c32e7816f5475e72fa9126356cAdrian Roos
32828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwaleimport java.io.PrintWriter;
33828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
34828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale/**
35828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale * Container class for all the display frames that affect how we do window layout on a display.
36828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale * @hide
37828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale */
38828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwalepublic class DisplayFrames {
39828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    public final int mDisplayId;
40828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
41828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    /**
42828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     * The current size of the screen; really; extends into the overscan area of the screen and
43828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     * doesn't account for any system elements like the status bar.
44828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     */
45828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    public final Rect mOverscan = new Rect();
46828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
47828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    /**
48828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     * The current visible size of the screen; really; (ir)regardless of whether the status bar can
49828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     * be hidden but not extending into the overscan area.
50828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     */
51828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    public final Rect mUnrestricted = new Rect();
52828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
53828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    /** Like mOverscan*, but allowed to move into the overscan region where appropriate. */
54828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    public final Rect mRestrictedOverscan = new Rect();
55828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
56828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    /**
57828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     * The current size of the screen; these may be different than (0,0)-(dw,dh) if the status bar
58828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     * can't be hidden; in that case it effectively carves out that area of the display from all
59828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     * other windows.
60828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     */
61828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    public final Rect mRestricted = new Rect();
62828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
63828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    /**
64828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     * During layout, the current screen borders accounting for any currently visible system UI
65828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     * elements.
66828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     */
67828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    public final Rect mSystem = new Rect();
68828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
69828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    /** For applications requesting stable content insets, these are them. */
70828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    public final Rect mStable = new Rect();
71828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
72828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    /**
73828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     * For applications requesting stable content insets but have also set the fullscreen window
74828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     * flag, these are the stable dimensions without the status bar.
75828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     */
76828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    public final Rect mStableFullscreen = new Rect();
77828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
78828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    /**
79828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     * During layout, the current screen borders with all outer decoration (status bar, input method
80828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     * dock) accounted for.
81828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     */
82828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    public final Rect mCurrent = new Rect();
83828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
84828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    /**
85828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     * During layout, the frame in which content should be displayed to the user, accounting for all
86828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     * screen decoration except for any space they deem as available for other content. This is
87828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     * usually the same as mCurrent*, but may be larger if the screen decor has supplied content
88828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     * insets.
89828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     */
90828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    public final Rect mContent = new Rect();
91828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
92828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    /**
93828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     * During layout, the frame in which voice content should be displayed to the user, accounting
94828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     * for all screen decoration except for any space they deem as available for other content.
95828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale     */
96828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    public final Rect mVoiceContent = new Rect();
97828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
98828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    /** During layout, the current screen borders along which input method windows are placed. */
99828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    public final Rect mDock = new Rect();
100828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
10130f5321310bbf7d5fdda21d336afd9f76aecbdfcAdrian Roos    /** The display cutout used for layout (after rotation) */
1026a4fa0ec183e20c32e7816f5475e72fa9126356cAdrian Roos    @NonNull public WmDisplayCutout mDisplayCutout = WmDisplayCutout.NO_CUTOUT;
1035c6b6223281e0669e674df3cb489d8544c20fb84Adrian Roos
1041cf585059cf44d817f28b072b5f64e6ef616b59cAdrian Roos    /** The cutout as supplied by display info */
1056a4fa0ec183e20c32e7816f5475e72fa9126356cAdrian Roos    @NonNull public WmDisplayCutout mDisplayInfoCutout = WmDisplayCutout.NO_CUTOUT;
1061cf585059cf44d817f28b072b5f64e6ef616b59cAdrian Roos
1075c6b6223281e0669e674df3cb489d8544c20fb84Adrian Roos    /**
1085c6b6223281e0669e674df3cb489d8544c20fb84Adrian Roos     * During layout, the frame that is display-cutout safe, i.e. that does not intersect with it.
1095c6b6223281e0669e674df3cb489d8544c20fb84Adrian Roos     */
1105c6b6223281e0669e674df3cb489d8544c20fb84Adrian Roos    public final Rect mDisplayCutoutSafe = new Rect();
1115c6b6223281e0669e674df3cb489d8544c20fb84Adrian Roos
112828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    private final Rect mDisplayInfoOverscan = new Rect();
113828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    private final Rect mRotatedDisplayInfoOverscan = new Rect();
114828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    public int mDisplayWidth;
115828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    public int mDisplayHeight;
116828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
117828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    public int mRotation;
118828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
1196a4fa0ec183e20c32e7816f5475e72fa9126356cAdrian Roos    public DisplayFrames(int displayId, DisplayInfo info, WmDisplayCutout displayCutout) {
120828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        mDisplayId = displayId;
1216a4fa0ec183e20c32e7816f5475e72fa9126356cAdrian Roos        onDisplayInfoUpdated(info, displayCutout);
122828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    }
123828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
1246a4fa0ec183e20c32e7816f5475e72fa9126356cAdrian Roos    public void onDisplayInfoUpdated(DisplayInfo info, WmDisplayCutout displayCutout) {
125828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        mDisplayWidth = info.logicalWidth;
126828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        mDisplayHeight = info.logicalHeight;
127828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        mRotation = info.rotation;
128828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        mDisplayInfoOverscan.set(
129828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale                info.overscanLeft, info.overscanTop, info.overscanRight, info.overscanBottom);
1306a4fa0ec183e20c32e7816f5475e72fa9126356cAdrian Roos        mDisplayInfoCutout = displayCutout != null ? displayCutout : WmDisplayCutout.NO_CUTOUT;
131828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    }
132828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
13330f5321310bbf7d5fdda21d336afd9f76aecbdfcAdrian Roos    public void onBeginLayout() {
134828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        switch (mRotation) {
135828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale            case ROTATION_90:
136828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale                mRotatedDisplayInfoOverscan.left = mDisplayInfoOverscan.top;
137828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale                mRotatedDisplayInfoOverscan.top = mDisplayInfoOverscan.right;
138828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale                mRotatedDisplayInfoOverscan.right = mDisplayInfoOverscan.bottom;
139828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale                mRotatedDisplayInfoOverscan.bottom = mDisplayInfoOverscan.left;
140828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale                break;
141828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale            case ROTATION_180:
142828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale                mRotatedDisplayInfoOverscan.left = mDisplayInfoOverscan.right;
143828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale                mRotatedDisplayInfoOverscan.top = mDisplayInfoOverscan.bottom;
144828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale                mRotatedDisplayInfoOverscan.right = mDisplayInfoOverscan.left;
145828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale                mRotatedDisplayInfoOverscan.bottom = mDisplayInfoOverscan.top;
146828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale                break;
147828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale            case ROTATION_270:
148828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale                mRotatedDisplayInfoOverscan.left = mDisplayInfoOverscan.bottom;
149828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale                mRotatedDisplayInfoOverscan.top = mDisplayInfoOverscan.left;
150828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale                mRotatedDisplayInfoOverscan.right = mDisplayInfoOverscan.top;
151828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale                mRotatedDisplayInfoOverscan.bottom = mDisplayInfoOverscan.right;
152828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale                break;
153828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale            default:
154828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale                mRotatedDisplayInfoOverscan.set(mDisplayInfoOverscan);
155828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale                break;
156828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        }
157828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
158828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        mRestrictedOverscan.set(0, 0, mDisplayWidth, mDisplayHeight);
159828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        mOverscan.set(mRestrictedOverscan);
160828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        mSystem.set(mRestrictedOverscan);
161828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        mUnrestricted.set(mRotatedDisplayInfoOverscan);
162828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        mUnrestricted.right = mDisplayWidth - mUnrestricted.right;
163828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        mUnrestricted.bottom = mDisplayHeight - mUnrestricted.bottom;
164828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        mRestricted.set(mUnrestricted);
165828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        mDock.set(mUnrestricted);
166828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        mContent.set(mUnrestricted);
167828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        mVoiceContent.set(mUnrestricted);
168828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        mStable.set(mUnrestricted);
169828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        mStableFullscreen.set(mUnrestricted);
170828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        mCurrent.set(mUnrestricted);
1711cf585059cf44d817f28b072b5f64e6ef616b59cAdrian Roos
172242642146dbd762ccd43f8634476f3be9303b863Adrian Roos        mDisplayCutout = mDisplayInfoCutout;
1731cf585059cf44d817f28b072b5f64e6ef616b59cAdrian Roos        mDisplayCutoutSafe.set(Integer.MIN_VALUE, Integer.MIN_VALUE,
1741cf585059cf44d817f28b072b5f64e6ef616b59cAdrian Roos                Integer.MAX_VALUE, Integer.MAX_VALUE);
1756a4fa0ec183e20c32e7816f5475e72fa9126356cAdrian Roos        if (!mDisplayCutout.getDisplayCutout().isEmpty()) {
1766a4fa0ec183e20c32e7816f5475e72fa9126356cAdrian Roos            final DisplayCutout c = mDisplayCutout.getDisplayCutout();
1771cf585059cf44d817f28b072b5f64e6ef616b59cAdrian Roos            if (c.getSafeInsetLeft() > 0) {
1781cf585059cf44d817f28b072b5f64e6ef616b59cAdrian Roos                mDisplayCutoutSafe.left = mRestrictedOverscan.left + c.getSafeInsetLeft();
1791cf585059cf44d817f28b072b5f64e6ef616b59cAdrian Roos            }
1801cf585059cf44d817f28b072b5f64e6ef616b59cAdrian Roos            if (c.getSafeInsetTop() > 0) {
1811cf585059cf44d817f28b072b5f64e6ef616b59cAdrian Roos                mDisplayCutoutSafe.top = mRestrictedOverscan.top + c.getSafeInsetTop();
1821cf585059cf44d817f28b072b5f64e6ef616b59cAdrian Roos            }
1831cf585059cf44d817f28b072b5f64e6ef616b59cAdrian Roos            if (c.getSafeInsetRight() > 0) {
1841cf585059cf44d817f28b072b5f64e6ef616b59cAdrian Roos                mDisplayCutoutSafe.right = mRestrictedOverscan.right - c.getSafeInsetRight();
1851cf585059cf44d817f28b072b5f64e6ef616b59cAdrian Roos            }
1861cf585059cf44d817f28b072b5f64e6ef616b59cAdrian Roos            if (c.getSafeInsetBottom() > 0) {
1871cf585059cf44d817f28b072b5f64e6ef616b59cAdrian Roos                mDisplayCutoutSafe.bottom = mRestrictedOverscan.bottom - c.getSafeInsetBottom();
1881cf585059cf44d817f28b072b5f64e6ef616b59cAdrian Roos            }
1891cf585059cf44d817f28b072b5f64e6ef616b59cAdrian Roos        }
190828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    }
191828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
192828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    public int getInputMethodWindowVisibleHeight() {
193828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        return mDock.bottom - mCurrent.bottom;
194828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    }
195828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
196828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    public void writeToProto(ProtoOutputStream proto, long fieldId) {
197828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        final long token = proto.start(fieldId);
198828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        mStable.writeToProto(proto, STABLE_BOUNDS);
199828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        proto.end(token);
200828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    }
201828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
202828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    public void dump(String prefix, PrintWriter pw) {
203828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        pw.println(prefix + "DisplayFrames w=" + mDisplayWidth + " h=" + mDisplayHeight
204828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale                + " r=" + mRotation);
205828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        final String myPrefix = prefix + "  ";
206828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        dumpFrame(mStable, "mStable", myPrefix, pw);
207828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        dumpFrame(mStableFullscreen, "mStableFullscreen", myPrefix, pw);
208828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        dumpFrame(mDock, "mDock", myPrefix, pw);
209828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        dumpFrame(mCurrent, "mCurrent", myPrefix, pw);
210828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        dumpFrame(mSystem, "mSystem", myPrefix, pw);
211828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        dumpFrame(mContent, "mContent", myPrefix, pw);
212828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        dumpFrame(mVoiceContent, "mVoiceContent", myPrefix, pw);
213828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        dumpFrame(mOverscan, "mOverscan", myPrefix, pw);
214828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        dumpFrame(mRestrictedOverscan, "mRestrictedOverscan", myPrefix, pw);
215828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        dumpFrame(mRestricted, "mRestricted", myPrefix, pw);
216828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        dumpFrame(mUnrestricted, "mUnrestricted", myPrefix, pw);
217828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        dumpFrame(mDisplayInfoOverscan, "mDisplayInfoOverscan", myPrefix, pw);
218828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        dumpFrame(mRotatedDisplayInfoOverscan, "mRotatedDisplayInfoOverscan", myPrefix, pw);
2195c6b6223281e0669e674df3cb489d8544c20fb84Adrian Roos        pw.println(myPrefix + "mDisplayCutout=" + mDisplayCutout);
220828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    }
221828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale
222828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    private void dumpFrame(Rect frame, String name, String prefix, PrintWriter pw) {
223828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale        pw.print(prefix + name + "="); frame.printShortString(pw); pw.println();
224828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale    }
225828ff7e3ef032f3c3b149be9961fa39a979d2fd2Wale Ogunwale}
226