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.IntDef; 20 import android.annotation.NonNull; 21 import android.annotation.Nullable; 22 import android.app.ActivityManager; 23 import android.app.TaskInfo; 24 import android.content.pm.ActivityInfo; 25 import android.os.Parcel; 26 import android.os.Parcelable; 27 import android.view.InsetsState; 28 import android.view.InsetsVisibilities; 29 import android.view.WindowManager; 30 31 /** 32 * Information you can retrieve about a starting window of a particular task that is currently 33 * start in the system. 34 * @hide 35 */ 36 public final class StartingWindowInfo implements Parcelable { 37 /** 38 * Prefer nothing or not care the type of starting window. 39 * @hide 40 */ 41 public static final int STARTING_WINDOW_TYPE_NONE = 0; 42 /** 43 * Prefer splash screen starting window. 44 * @hide 45 */ 46 public static final int STARTING_WINDOW_TYPE_SPLASH_SCREEN = 1; 47 /** 48 * Prefer snapshot starting window. 49 * @hide 50 */ 51 public static final int STARTING_WINDOW_TYPE_SNAPSHOT = 2; 52 /** 53 * Prefer empty splash screen starting window. 54 * @hide 55 */ 56 public static final int STARTING_WINDOW_TYPE_EMPTY_SPLASH_SCREEN = 3; 57 58 /** @hide **/ 59 public static final int STARTING_WINDOW_TYPE_LEGACY_SPLASH_SCREEN = 4; 60 61 /** 62 * @hide 63 */ 64 @IntDef(flag = true, prefix = "STARTING_WINDOW_TYPE_", value = { 65 STARTING_WINDOW_TYPE_NONE, 66 STARTING_WINDOW_TYPE_SPLASH_SCREEN, 67 STARTING_WINDOW_TYPE_SNAPSHOT, 68 STARTING_WINDOW_TYPE_EMPTY_SPLASH_SCREEN, 69 STARTING_WINDOW_TYPE_LEGACY_SPLASH_SCREEN 70 }) 71 public @interface StartingWindowType {} 72 73 /** 74 * The {@link TaskInfo} from this task. 75 * @hide 76 */ 77 @NonNull 78 public ActivityManager.RunningTaskInfo taskInfo; 79 80 /** 81 * The {@link ActivityInfo} of the target activity which to create the starting window. 82 * It can be null if the info is the same as the top in task info. 83 * @hide 84 */ 85 @Nullable 86 public ActivityInfo targetActivityInfo; 87 88 /** 89 * InsetsState of TopFullscreenOpaqueWindow 90 * @hide 91 */ 92 @Nullable 93 public InsetsState topOpaqueWindowInsetsState; 94 95 /** 96 * LayoutParams of TopFullscreenOpaqueWindow 97 * @hide 98 */ 99 @Nullable 100 public WindowManager.LayoutParams topOpaqueWindowLayoutParams; 101 102 /** 103 * LayoutParams of MainWindow 104 * @hide 105 */ 106 @Nullable 107 public WindowManager.LayoutParams mainWindowLayoutParams; 108 109 /** 110 * @hide 111 */ 112 @IntDef(flag = true, prefix = "TYPE_PARAMETER_", value = { 113 TYPE_PARAMETER_NEW_TASK, 114 TYPE_PARAMETER_TASK_SWITCH, 115 TYPE_PARAMETER_PROCESS_RUNNING, 116 TYPE_PARAMETER_ALLOW_TASK_SNAPSHOT, 117 TYPE_PARAMETER_ACTIVITY_CREATED, 118 TYPE_PARAMETER_USE_EMPTY_SPLASH_SCREEN, 119 TYPE_PARAMETER_LEGACY_SPLASH_SCREEN 120 }) 121 public @interface StartingTypeParams {} 122 123 /** 124 * The parameters of the starting window... 125 * @hide 126 */ 127 public static final int TYPE_PARAMETER_NEW_TASK = 0x00000001; 128 /** @hide */ 129 public static final int TYPE_PARAMETER_TASK_SWITCH = 0x00000002; 130 /** @hide */ 131 public static final int TYPE_PARAMETER_PROCESS_RUNNING = 0x00000004; 132 /** @hide */ 133 public static final int TYPE_PARAMETER_ALLOW_TASK_SNAPSHOT = 0x00000008; 134 /** @hide */ 135 public static final int TYPE_PARAMETER_ACTIVITY_CREATED = 0x00000010; 136 /** @hide */ 137 public static final int TYPE_PARAMETER_USE_EMPTY_SPLASH_SCREEN = 0x00000020; 138 /** 139 * Application is allowed to use the legacy splash screen 140 * @hide 141 */ 142 public static final int TYPE_PARAMETER_LEGACY_SPLASH_SCREEN = 0x80000000; 143 144 /** 145 * The parameters which effect the starting window type. 146 * @see android.window.StartingWindowInfo.StartingTypeParams 147 * @hide 148 */ 149 public int startingWindowTypeParameter; 150 151 /** 152 * Specifies a theme for the splash screen. 153 * @hide 154 */ 155 public int splashScreenThemeResId; 156 157 /** 158 * Is keyguard occluded on default display. 159 * @hide 160 */ 161 public boolean isKeyguardOccluded = false; 162 163 /** 164 * TaskSnapshot. 165 * @hide 166 */ 167 public TaskSnapshot taskSnapshot; 168 169 /** 170 * The requested insets visibility of the top main window. 171 * @hide 172 */ 173 public final InsetsVisibilities requestedVisibilities = new InsetsVisibilities(); 174 StartingWindowInfo()175 public StartingWindowInfo() { 176 177 } 178 StartingWindowInfo(@onNull Parcel source)179 private StartingWindowInfo(@NonNull Parcel source) { 180 readFromParcel(source); 181 } 182 183 @Override describeContents()184 public int describeContents() { 185 return 0; 186 } 187 188 @Override writeToParcel(@onNull Parcel dest, int flags)189 public void writeToParcel(@NonNull Parcel dest, int flags) { 190 dest.writeTypedObject(taskInfo, flags); 191 dest.writeTypedObject(targetActivityInfo, flags); 192 dest.writeInt(startingWindowTypeParameter); 193 dest.writeTypedObject(topOpaqueWindowInsetsState, flags); 194 dest.writeTypedObject(topOpaqueWindowLayoutParams, flags); 195 dest.writeTypedObject(mainWindowLayoutParams, flags); 196 dest.writeInt(splashScreenThemeResId); 197 dest.writeBoolean(isKeyguardOccluded); 198 dest.writeTypedObject(taskSnapshot, flags); 199 requestedVisibilities.writeToParcel(dest, flags); 200 } 201 readFromParcel(@onNull Parcel source)202 void readFromParcel(@NonNull Parcel source) { 203 taskInfo = source.readTypedObject(ActivityManager.RunningTaskInfo.CREATOR); 204 targetActivityInfo = source.readTypedObject(ActivityInfo.CREATOR); 205 startingWindowTypeParameter = source.readInt(); 206 topOpaqueWindowInsetsState = source.readTypedObject(InsetsState.CREATOR); 207 topOpaqueWindowLayoutParams = source.readTypedObject( 208 WindowManager.LayoutParams.CREATOR); 209 mainWindowLayoutParams = source.readTypedObject(WindowManager.LayoutParams.CREATOR); 210 splashScreenThemeResId = source.readInt(); 211 isKeyguardOccluded = source.readBoolean(); 212 taskSnapshot = source.readTypedObject(TaskSnapshot.CREATOR); 213 requestedVisibilities.readFromParcel(source); 214 } 215 216 @Override toString()217 public String toString() { 218 return "StartingWindowInfo{taskId=" + taskInfo.taskId 219 + " targetActivityInfo=" + targetActivityInfo 220 + " displayId=" + taskInfo.displayId 221 + " topActivityType=" + taskInfo.topActivityType 222 + " preferredStartingWindowType=" 223 + Integer.toHexString(startingWindowTypeParameter) 224 + " insetsState=" + topOpaqueWindowInsetsState 225 + " topWindowLayoutParams=" + topOpaqueWindowLayoutParams 226 + " mainWindowLayoutParams=" + mainWindowLayoutParams 227 + " splashScreenThemeResId " + Integer.toHexString(splashScreenThemeResId); 228 } 229 230 public static final @android.annotation.NonNull Creator<StartingWindowInfo> CREATOR = 231 new Creator<StartingWindowInfo>() { 232 public StartingWindowInfo createFromParcel(@NonNull Parcel source) { 233 return new StartingWindowInfo(source); 234 } 235 public StartingWindowInfo[] newArray(int size) { 236 return new StartingWindowInfo[size]; 237 } 238 }; 239 } 240