1 /*
2  * Copyright (C) 2021 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.IntDef;
20 import android.annotation.NonNull;
21 import android.annotation.Nullable;
22 import android.graphics.Rect;
23 import android.os.Parcel;
24 import android.os.Parcelable;
25 import android.view.SurfaceControl;
26 
27 import java.lang.annotation.Retention;
28 import java.lang.annotation.RetentionPolicy;
29 
30 /**
31  * Information when removing a starting window of a particular task.
32  * @hide
33  */
34 public final class StartingWindowRemovalInfo implements Parcelable {
35 
36     /**
37      * The identifier of a task.
38      * @hide
39      */
40     public int taskId;
41 
42     /**
43      * The animation container layer of the top activity.
44      * @hide
45      */
46     @Nullable
47     public SurfaceControl windowAnimationLeash;
48 
49     /**
50      * The main window frame for the window of the top activity.
51      * @hide
52      */
53     @Nullable
54     public Rect mainFrame;
55 
56     /**
57      * Whether need to play reveal animation.
58      * @hide
59      */
60     public boolean playRevealAnimation;
61 
62     /** The mode is no need to defer removing the starting window for IME */
63     public static final int DEFER_MODE_NONE = 0;
64 
65     /** The mode to defer removing the starting window until IME has drawn */
66     public static final int DEFER_MODE_NORMAL = 1;
67 
68     /** The mode to defer the starting window removal until IME drawn and finished the rotation */
69     public static final int DEFER_MODE_ROTATION = 2;
70 
71     @IntDef(prefix = { "DEFER_MODE_" }, value = {
72             DEFER_MODE_NONE,
73             DEFER_MODE_NORMAL,
74             DEFER_MODE_ROTATION,
75     })
76     @Retention(RetentionPolicy.SOURCE)
77     public @interface DeferMode {}
78 
79     /**
80      * Whether need to defer removing the starting window for IME.
81      * @hide
82      */
83     public @DeferMode int deferRemoveForImeMode;
84 
85     /**
86      * The rounded corner radius
87      * @hide
88      */
89     public float roundedCornerRadius;
90 
91     /**
92      * Remove windowless surface.
93      */
94     public boolean windowlessSurface;
95 
96     /**
97      * Remove immediately.
98      */
99     public boolean removeImmediately;
100 
StartingWindowRemovalInfo()101     public StartingWindowRemovalInfo() {
102 
103     }
104 
StartingWindowRemovalInfo(@onNull Parcel source)105     private StartingWindowRemovalInfo(@NonNull Parcel source) {
106         readFromParcel(source);
107     }
108 
109     @Override
describeContents()110     public int describeContents() {
111         return 0;
112     }
113 
readFromParcel(@onNull Parcel source)114     void readFromParcel(@NonNull Parcel source) {
115         taskId = source.readInt();
116         windowAnimationLeash = source.readTypedObject(SurfaceControl.CREATOR);
117         mainFrame = source.readTypedObject(Rect.CREATOR);
118         playRevealAnimation = source.readBoolean();
119         deferRemoveForImeMode = source.readInt();
120         roundedCornerRadius = source.readFloat();
121         windowlessSurface = source.readBoolean();
122         removeImmediately = source.readBoolean();
123     }
124 
125     @Override
writeToParcel(@onNull Parcel dest, int flags)126     public void writeToParcel(@NonNull Parcel dest, int flags) {
127         dest.writeInt(taskId);
128         dest.writeTypedObject(windowAnimationLeash, flags);
129         dest.writeTypedObject(mainFrame, flags);
130         dest.writeBoolean(playRevealAnimation);
131         dest.writeInt(deferRemoveForImeMode);
132         dest.writeFloat(roundedCornerRadius);
133         dest.writeBoolean(windowlessSurface);
134         dest.writeBoolean(removeImmediately);
135     }
136 
137     @Override
toString()138     public String toString() {
139         return "StartingWindowRemovalInfo{taskId=" + taskId
140                 + " frame=" + mainFrame
141                 + " playRevealAnimation=" + playRevealAnimation
142                 + " roundedCornerRadius=" + roundedCornerRadius
143                 + " deferRemoveForImeMode=" + deferRemoveForImeMode
144                 + " windowlessSurface=" + windowlessSurface
145                 + " removeImmediately=" + removeImmediately + "}";
146     }
147 
148     public static final @android.annotation.NonNull Creator<StartingWindowRemovalInfo> CREATOR =
149             new Creator<StartingWindowRemovalInfo>() {
150                 public StartingWindowRemovalInfo createFromParcel(@NonNull Parcel source) {
151                     return new StartingWindowRemovalInfo(source);
152                 }
153                 public StartingWindowRemovalInfo[] newArray(int size) {
154                     return new StartingWindowRemovalInfo[size];
155                 }
156             };
157 }
158