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