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 static android.window.DisplayAreaOrganizer.FEATURE_UNDEFINED;
20 
21 import android.annotation.NonNull;
22 import android.annotation.TestApi;
23 import android.content.res.Configuration;
24 import android.os.Parcel;
25 import android.os.Parcelable;
26 
27 /**
28  * Stores information about a particular {@link com.android.server.wm.DisplayArea}. This object will
29  * be sent to registered {@link DisplayAreaOrganizer} to provide information when the DisplayArea
30  * is added, removed, or changed.
31  *
32  * @hide
33  */
34 @TestApi
35 public final class DisplayAreaInfo implements Parcelable {
36 
37     @NonNull
38     public final WindowContainerToken token;
39 
40     @NonNull
41     public final Configuration configuration = new Configuration();
42 
43     /**
44      * The id of the display this display area is associated with.
45      */
46     public final int displayId;
47 
48     /**
49      * The feature id of this display area.
50      */
51     public final int featureId;
52 
53     /**
54      * The feature id of the root display area this display area is associated with.
55      * @hide
56      */
57     public int rootDisplayAreaId = FEATURE_UNDEFINED;
58 
DisplayAreaInfo(@onNull WindowContainerToken token, int displayId, int featureId)59     public DisplayAreaInfo(@NonNull WindowContainerToken token, int displayId, int featureId) {
60         this.token = token;
61         this.displayId = displayId;
62         this.featureId = featureId;
63     }
64 
DisplayAreaInfo(Parcel in)65     private DisplayAreaInfo(Parcel in) {
66         token = WindowContainerToken.CREATOR.createFromParcel(in);
67         configuration.readFromParcel(in);
68         displayId = in.readInt();
69         featureId = in.readInt();
70         rootDisplayAreaId = in.readInt();
71     }
72 
73     @Override
writeToParcel(@onNull Parcel dest, int flags)74     public void writeToParcel(@NonNull Parcel dest, int flags) {
75         token.writeToParcel(dest, flags);
76         configuration.writeToParcel(dest, flags);
77         dest.writeInt(displayId);
78         dest.writeInt(featureId);
79         dest.writeInt(rootDisplayAreaId);
80     }
81 
82     @NonNull
83     public static final Creator<DisplayAreaInfo> CREATOR = new Creator<DisplayAreaInfo>() {
84         @Override
85         public DisplayAreaInfo createFromParcel(Parcel in) {
86             return new DisplayAreaInfo(in);
87         }
88 
89         @Override
90         public DisplayAreaInfo[] newArray(int size) {
91             return new DisplayAreaInfo[size];
92         }
93     };
94 
95     @Override
toString()96     public String toString() {
97         return "DisplayAreaInfo{token=" + token
98                 + " config=" + configuration + "}";
99     }
100 
101     @Override
describeContents()102     public int describeContents() {
103         return 0;
104     }
105 }
106