• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.window;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.graphics.Rect;
22 import android.os.Parcel;
23 import android.os.Parcelable;
24 
25 /**
26  * The window frame container class used by client side for layout.
27  * @hide
28  */
29 public class ClientWindowFrames implements Parcelable {
30     /** The actual window bounds. */
31     public final @NonNull Rect frame = new Rect();
32 
33     /**
34      * The container frame that is usually the same as display size. It may exclude the area of
35      * insets if the window layout parameter has specified fit-insets-sides.
36      */
37     public final @NonNull Rect displayFrame = new Rect();
38 
39     /**
40      * The frame to be referenced while applying gravity and MATCH_PARENT.
41      */
42     public final @NonNull Rect parentFrame = new Rect();
43 
44     /**
45      * The frame this window attaches to. If this is not null, this is the frame of the parent
46      * window.
47      */
48     public @Nullable Rect attachedFrame;
49 
50     public boolean isParentFrameClippedByDisplayCutout;
51 
52     public float compatScale = 1f;
53 
ClientWindowFrames()54     public ClientWindowFrames() {
55     }
56 
ClientWindowFrames(ClientWindowFrames other)57     public ClientWindowFrames(ClientWindowFrames other) {
58         frame.set(other.frame);
59         displayFrame.set(other.displayFrame);
60         parentFrame.set(other.parentFrame);
61         if (other.attachedFrame != null) {
62             attachedFrame = new Rect(other.attachedFrame);
63         }
64         isParentFrameClippedByDisplayCutout = other.isParentFrameClippedByDisplayCutout;
65         compatScale = other.compatScale;
66     }
67 
ClientWindowFrames(Parcel in)68     private ClientWindowFrames(Parcel in) {
69         readFromParcel(in);
70     }
71 
72     /** Needed for AIDL out parameters. */
readFromParcel(Parcel in)73     public void readFromParcel(Parcel in) {
74         frame.readFromParcel(in);
75         displayFrame.readFromParcel(in);
76         parentFrame.readFromParcel(in);
77         attachedFrame = in.readTypedObject(Rect.CREATOR);
78         isParentFrameClippedByDisplayCutout = in.readBoolean();
79         compatScale = in.readFloat();
80     }
81 
82     @Override
writeToParcel(Parcel dest, int flags)83     public void writeToParcel(Parcel dest, int flags) {
84         frame.writeToParcel(dest, flags);
85         displayFrame.writeToParcel(dest, flags);
86         parentFrame.writeToParcel(dest, flags);
87         dest.writeTypedObject(attachedFrame, flags);
88         dest.writeBoolean(isParentFrameClippedByDisplayCutout);
89         dest.writeFloat(compatScale);
90     }
91 
92     @Override
toString()93     public String toString() {
94         final StringBuilder sb = new StringBuilder(32);
95         return "ClientWindowFrames{frame=" + frame.toShortString(sb)
96                 + " display=" + displayFrame.toShortString(sb)
97                 + " parentFrame=" + parentFrame.toShortString(sb)
98                 + (attachedFrame != null ? " attachedFrame=" + attachedFrame.toShortString() : "")
99                 + (isParentFrameClippedByDisplayCutout ? " parentClippedByDisplayCutout" : "")
100                 + (compatScale != 1f ? " sizeCompatScale=" + compatScale : "") +  "}";
101     }
102 
103     @Override
describeContents()104     public int describeContents() {
105         return 0;
106     }
107 
108     public static final Creator<ClientWindowFrames> CREATOR = new Creator<ClientWindowFrames>() {
109         public ClientWindowFrames createFromParcel(Parcel in) {
110             return new ClientWindowFrames(in);
111         }
112 
113         public ClientWindowFrames[] newArray(int size) {
114             return new ClientWindowFrames[size];
115         }
116     };
117 }
118