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 default defer removing the snapshot starting window. */ 63 public static final int DEFER_MODE_DEFAULT = 0; 64 65 /** The mode to defer removing the snapshot starting window until IME has drawn. */ 66 public static final int DEFER_MODE_NORMAL = 1; 67 68 /** 69 * The mode to defer the snapshot starting window removal until IME drawn and finished the 70 * rotation. 71 */ 72 public static final int DEFER_MODE_ROTATION = 2; 73 74 /** The mode is no need to defer removing the snapshot starting window. */ 75 public static final int DEFER_MODE_NONE = 3; 76 77 @IntDef(prefix = { "DEFER_MODE_" }, value = { 78 DEFER_MODE_DEFAULT, 79 DEFER_MODE_NORMAL, 80 DEFER_MODE_ROTATION, 81 DEFER_MODE_NONE, 82 }) 83 @Retention(RetentionPolicy.SOURCE) 84 public @interface DeferMode {} 85 86 /** 87 * Whether need to defer removing the snapshot starting window. 88 * @hide 89 */ 90 public @DeferMode int deferRemoveMode; 91 92 /** 93 * The rounded corner radius 94 * @hide 95 */ 96 public float roundedCornerRadius; 97 98 /** 99 * Remove windowless surface. 100 */ 101 public boolean windowlessSurface; 102 103 /** 104 * Remove immediately. 105 */ 106 public boolean removeImmediately; 107 StartingWindowRemovalInfo()108 public StartingWindowRemovalInfo() { 109 110 } 111 StartingWindowRemovalInfo(@onNull Parcel source)112 private StartingWindowRemovalInfo(@NonNull Parcel source) { 113 readFromParcel(source); 114 } 115 116 @Override describeContents()117 public int describeContents() { 118 return 0; 119 } 120 readFromParcel(@onNull Parcel source)121 void readFromParcel(@NonNull Parcel source) { 122 taskId = source.readInt(); 123 windowAnimationLeash = source.readTypedObject(SurfaceControl.CREATOR); 124 mainFrame = source.readTypedObject(Rect.CREATOR); 125 playRevealAnimation = source.readBoolean(); 126 deferRemoveMode = source.readInt(); 127 roundedCornerRadius = source.readFloat(); 128 windowlessSurface = source.readBoolean(); 129 removeImmediately = source.readBoolean(); 130 } 131 132 @Override writeToParcel(@onNull Parcel dest, int flags)133 public void writeToParcel(@NonNull Parcel dest, int flags) { 134 dest.writeInt(taskId); 135 dest.writeTypedObject(windowAnimationLeash, flags); 136 dest.writeTypedObject(mainFrame, flags); 137 dest.writeBoolean(playRevealAnimation); 138 dest.writeInt(deferRemoveMode); 139 dest.writeFloat(roundedCornerRadius); 140 dest.writeBoolean(windowlessSurface); 141 dest.writeBoolean(removeImmediately); 142 } 143 144 @Override toString()145 public String toString() { 146 return "StartingWindowRemovalInfo{taskId=" + taskId 147 + " frame=" + mainFrame 148 + " playRevealAnimation=" + playRevealAnimation 149 + " roundedCornerRadius=" + roundedCornerRadius 150 + " deferRemoveMode=" + deferRemoveMode 151 + " windowlessSurface=" + windowlessSurface 152 + " removeImmediately=" + removeImmediately + "}"; 153 } 154 155 public static final @android.annotation.NonNull Creator<StartingWindowRemovalInfo> CREATOR = 156 new Creator<StartingWindowRemovalInfo>() { 157 public StartingWindowRemovalInfo createFromParcel(@NonNull Parcel source) { 158 return new StartingWindowRemovalInfo(source); 159 } 160 public StartingWindowRemovalInfo[] newArray(int size) { 161 return new StartingWindowRemovalInfo[size]; 162 } 163 }; 164 } 165