• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.IBinder;
26 import android.os.Parcel;
27 import android.os.Parcelable;
28 import android.os.RemoteException;
29 import android.view.InsetsState;
30 import android.view.SurfaceControl;
31 import android.view.WindowInsets;
32 import android.view.WindowInsets.Type.InsetsType;
33 import android.view.WindowManager;
34 
35 /**
36  * Information you can retrieve about a starting window of a particular task that is currently
37  * start in the system.
38  * @hide
39  */
40 public final class StartingWindowInfo implements Parcelable {
41     /**
42      * Prefer nothing or not care the type of starting window.
43      * @hide
44      */
45     public static final int STARTING_WINDOW_TYPE_NONE = 0;
46     /**
47      * Prefer splash screen starting window.
48      * @hide
49      */
50     public static final int STARTING_WINDOW_TYPE_SPLASH_SCREEN = 1;
51     /**
52      * Prefer snapshot starting window.
53      * @hide
54      */
55     public static final int STARTING_WINDOW_TYPE_SNAPSHOT = 2;
56     /**
57      * Prefer solid color splash screen starting window.
58      * @hide
59      */
60     public static final int STARTING_WINDOW_TYPE_SOLID_COLOR_SPLASH_SCREEN = 3;
61 
62     /** @hide **/
63     public static final int STARTING_WINDOW_TYPE_LEGACY_SPLASH_SCREEN = 4;
64 
65     public static final int STARTING_WINDOW_TYPE_WINDOWLESS = 5;
66 
67     /**
68      * @hide
69      */
70     @IntDef(flag = true, prefix = "STARTING_WINDOW_TYPE_", value = {
71             STARTING_WINDOW_TYPE_NONE,
72             STARTING_WINDOW_TYPE_SPLASH_SCREEN,
73             STARTING_WINDOW_TYPE_SNAPSHOT,
74             STARTING_WINDOW_TYPE_SOLID_COLOR_SPLASH_SCREEN,
75             STARTING_WINDOW_TYPE_LEGACY_SPLASH_SCREEN,
76             STARTING_WINDOW_TYPE_WINDOWLESS
77     })
78     public @interface StartingWindowType {}
79 
80     /**
81      * The {@link TaskInfo} from this task.
82      *  @hide
83      */
84     @NonNull
85     public ActivityManager.RunningTaskInfo taskInfo;
86 
87     /**
88      * The {@link ActivityInfo} of the target activity which to create the starting window.
89      * It can be null if the info is the same as the top in task info.
90      * @hide
91      */
92     @Nullable
93     public ActivityInfo targetActivityInfo;
94 
95     /**
96      * InsetsState of TopFullscreenOpaqueWindow
97      * @hide
98      */
99     @Nullable
100     public InsetsState topOpaqueWindowInsetsState;
101 
102     /**
103      * LayoutParams of TopFullscreenOpaqueWindow
104      * @hide
105      */
106     @Nullable
107     public WindowManager.LayoutParams topOpaqueWindowLayoutParams;
108 
109     /**
110      * LayoutParams of MainWindow
111      * @hide
112      */
113     @Nullable
114     public WindowManager.LayoutParams mainWindowLayoutParams;
115 
116     /**
117      * @hide
118      */
119     @IntDef(flag = true, prefix = "TYPE_PARAMETER_", value = {
120             TYPE_PARAMETER_NEW_TASK,
121             TYPE_PARAMETER_TASK_SWITCH,
122             TYPE_PARAMETER_PROCESS_RUNNING,
123             TYPE_PARAMETER_ALLOW_TASK_SNAPSHOT,
124             TYPE_PARAMETER_ACTIVITY_CREATED,
125             TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN,
126             TYPE_PARAMETER_ALLOW_HANDLE_SOLID_COLOR_SCREEN,
127             TYPE_PARAMETER_WINDOWLESS,
128             TYPE_PARAMETER_LEGACY_SPLASH_SCREEN
129     })
130     public @interface StartingTypeParams {}
131 
132     /**
133      * The parameters of the starting window...
134      * @hide
135      */
136     public static final int TYPE_PARAMETER_NEW_TASK = 0x00000001;
137     /** @hide */
138     public static final int TYPE_PARAMETER_TASK_SWITCH = 0x00000002;
139     /** @hide */
140     public static final int TYPE_PARAMETER_PROCESS_RUNNING = 0x00000004;
141     /** @hide */
142     public static final int TYPE_PARAMETER_ALLOW_TASK_SNAPSHOT = 0x00000008;
143     /** @hide */
144     public static final int TYPE_PARAMETER_ACTIVITY_CREATED = 0x00000010;
145     /** @hide */
146     public static final int TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN = 0x00000020;
147     /**
148      * The parameter which indicates if the activity has finished drawing.
149      * @hide
150      */
151     public static final int TYPE_PARAMETER_ACTIVITY_DRAWN = 0x00000040;
152     /**
153      * Application will receive the
154      * {@link
155      * android.window.SplashScreen.OnExitAnimationListener#onSplashScreenExit(SplashScreenView)}
156      * callback, even when the splash screen only shows a solid color.
157      *
158      * @hide
159      */
160     public static final int TYPE_PARAMETER_ALLOW_HANDLE_SOLID_COLOR_SCREEN = 0x00000080;
161 
162     /**
163      * Windowless surface
164      */
165     public static final int TYPE_PARAMETER_WINDOWLESS = 0x00000100;
166 
167     /**
168      * Application is allowed to use the legacy splash screen
169      * @hide
170      */
171     public static final int TYPE_PARAMETER_LEGACY_SPLASH_SCREEN = 0x80000000;
172 
173     /**
174      * The parameters which effect the starting window type.
175      * @see android.window.StartingWindowInfo.StartingTypeParams
176      * @hide
177      */
178     public int startingWindowTypeParameter;
179 
180     /**
181      * Specifies a theme for the splash screen.
182      * @hide
183      */
184     public int splashScreenThemeResId;
185 
186     /**
187      * Is keyguard occluded on default display.
188      * @hide
189      */
190     public boolean isKeyguardOccluded = false;
191 
192     /**
193      * TaskSnapshot.
194      * @hide
195      */
196     public TaskSnapshot taskSnapshot;
197 
198     @InsetsType public int requestedVisibleTypes = WindowInsets.Type.defaultVisible();
199 
200     /**
201      * App token where the starting window should add to.
202      */
203     public IBinder appToken;
204 
205     public IWindowlessStartingSurfaceCallback windowlessStartingSurfaceCallback;
206 
207     /**
208      * The root surface where windowless surface should attach on.
209      */
210     public SurfaceControl rootSurface;
211 
212     /**
213      * Notify windowless surface is created.
214      * @param addedSurface Created surface.
215      */
notifyAddComplete(SurfaceControl addedSurface)216     public void notifyAddComplete(SurfaceControl addedSurface) {
217         if (windowlessStartingSurfaceCallback != null) {
218             try {
219                 windowlessStartingSurfaceCallback.onSurfaceAdded(addedSurface);
220             } catch (RemoteException e) {
221                 //
222             }
223         }
224     }
225 
StartingWindowInfo()226     public StartingWindowInfo() {
227 
228     }
229 
StartingWindowInfo(@onNull Parcel source)230     private StartingWindowInfo(@NonNull Parcel source) {
231         readFromParcel(source);
232     }
233 
234     /**
235      * Return whether the application allow to handle the solid color style splash screen.
236      */
allowHandleSolidColorSplashScreen()237     public boolean allowHandleSolidColorSplashScreen() {
238         return (startingWindowTypeParameter & TYPE_PARAMETER_ALLOW_HANDLE_SOLID_COLOR_SCREEN) != 0;
239     }
240 
241     @Override
describeContents()242     public int describeContents() {
243         return 0;
244     }
245 
246     @Override
writeToParcel(@onNull Parcel dest, int flags)247     public void writeToParcel(@NonNull Parcel dest, int flags) {
248         dest.writeTypedObject(taskInfo, flags);
249         dest.writeTypedObject(targetActivityInfo, flags);
250         dest.writeInt(startingWindowTypeParameter);
251         dest.writeTypedObject(topOpaqueWindowInsetsState, flags);
252         dest.writeTypedObject(topOpaqueWindowLayoutParams, flags);
253         dest.writeTypedObject(mainWindowLayoutParams, flags);
254         dest.writeInt(splashScreenThemeResId);
255         dest.writeBoolean(isKeyguardOccluded);
256         dest.writeTypedObject(taskSnapshot, flags);
257         dest.writeInt(requestedVisibleTypes);
258         dest.writeStrongBinder(appToken);
259         dest.writeStrongInterface(windowlessStartingSurfaceCallback);
260         dest.writeTypedObject(rootSurface, flags);
261     }
262 
readFromParcel(@onNull Parcel source)263     void readFromParcel(@NonNull Parcel source) {
264         taskInfo = source.readTypedObject(ActivityManager.RunningTaskInfo.CREATOR);
265         targetActivityInfo = source.readTypedObject(ActivityInfo.CREATOR);
266         startingWindowTypeParameter = source.readInt();
267         topOpaqueWindowInsetsState = source.readTypedObject(InsetsState.CREATOR);
268         topOpaqueWindowLayoutParams = source.readTypedObject(
269                 WindowManager.LayoutParams.CREATOR);
270         mainWindowLayoutParams = source.readTypedObject(WindowManager.LayoutParams.CREATOR);
271         splashScreenThemeResId = source.readInt();
272         isKeyguardOccluded = source.readBoolean();
273         taskSnapshot = source.readTypedObject(TaskSnapshot.CREATOR);
274         requestedVisibleTypes = source.readInt();
275         appToken = source.readStrongBinder();
276         windowlessStartingSurfaceCallback = IWindowlessStartingSurfaceCallback.Stub
277                 .asInterface(source.readStrongBinder());
278         rootSurface = source.readTypedObject(SurfaceControl.CREATOR);
279     }
280 
281     @Override
toString()282     public String toString() {
283         return "StartingWindowInfo{taskId=" + taskInfo.taskId
284                 + " targetActivityInfo=" + targetActivityInfo
285                 + " displayId=" + taskInfo.displayId
286                 + " topActivityType=" + taskInfo.topActivityType
287                 + " preferredStartingWindowType="
288                 + Integer.toHexString(startingWindowTypeParameter)
289                 + " insetsState=" + topOpaqueWindowInsetsState
290                 + " topWindowLayoutParams=" + topOpaqueWindowLayoutParams
291                 + " mainWindowLayoutParams=" + mainWindowLayoutParams
292                 + " splashScreenThemeResId " + Integer.toHexString(splashScreenThemeResId);
293     }
294 
295     public static final @android.annotation.NonNull Creator<StartingWindowInfo> CREATOR =
296             new Creator<StartingWindowInfo>() {
297                 public StartingWindowInfo createFromParcel(@NonNull Parcel source) {
298                     return new StartingWindowInfo(source);
299                 }
300                 public StartingWindowInfo[] newArray(int size) {
301                     return new StartingWindowInfo[size];
302                 }
303             };
304 }
305