1 /*
2  * Copyright (C) 2011 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 com.android.server.wm;
18 
19 import android.annotation.IntDef;
20 
21 import com.android.server.wm.StartingSurfaceController.StartingSurface;
22 
23 /**
24  * Represents the model about how a starting window should be constructed.
25  */
26 public abstract class StartingData {
27 
28     /** Nothing need to do after transaction */
29     static final int AFTER_TRANSACTION_IDLE = 0;
30     /** Remove the starting window directly after transaction done. */
31     static final int AFTER_TRANSACTION_REMOVE_DIRECTLY = 1;
32     /** Do copy splash screen to client after transaction done. */
33     static final int AFTER_TRANSACTION_COPY_TO_CLIENT = 2;
34 
35     @IntDef(prefix = { "AFTER_TRANSACTION" }, value = {
36             AFTER_TRANSACTION_IDLE,
37             AFTER_TRANSACTION_REMOVE_DIRECTLY,
38             AFTER_TRANSACTION_COPY_TO_CLIENT,
39     })
40     @interface AfterTransaction {}
41 
42     protected final WindowManagerService mService;
43     protected final int mTypeParams;
44 
45     /**
46      * Tell whether the launching activity should use
47      * {@link android.view.WindowManager.LayoutParams#SOFT_INPUT_IS_FORWARD_NAVIGATION}.
48      */
49     boolean mIsTransitionForward;
50 
51     /**
52      * Non-null if the starting window should cover the bounds of associated task. It is assigned
53      * when the parent activity of starting window may be put in a partial area of the task.
54      */
55     Task mAssociatedTask;
56 
57 
58     /** Whether the starting window is resized from transfer across activities. */
59     boolean mResizedFromTransfer;
60 
61     /** Whether the starting window is drawn. */
62     boolean mIsDisplayed;
63 
64     /**
65      * For Shell transition.
66      * There will be a transition happen on attached activity, do not remove starting window during
67      * this period, because the transaction to show app window may not apply before remove starting
68      * window.
69      * Note this isn't equal to transition playing, the period should be
70      * Sync finishNow -> Start transaction apply.
71      */
72     boolean mWaitForSyncTransactionCommit;
73 
74     /**
75      * For Shell transition.
76      * This starting window should be removed after applying the start transaction of transition,
77      * which ensures the app window has shown.
78      */
79     @AfterTransaction int mRemoveAfterTransaction = AFTER_TRANSACTION_IDLE;
80 
81     /** Whether to prepare the removal animation. */
82     boolean mPrepareRemoveAnimation;
83 
84     /** Non-zero if this starting window is added in a collecting transition. */
85     int mTransitionId;
86 
StartingData(WindowManagerService service, int typeParams)87     protected StartingData(WindowManagerService service, int typeParams) {
88         mService = service;
89         mTypeParams = typeParams;
90     }
91 
92     /**
93      * Creates the actual starting window surface.
94      *
95      * @param activity the app to add the starting window to
96      * @return a class implementing {@link StartingSurface} for easy removal with
97      *         {@link StartingSurface#remove}
98      */
createStartingSurface(ActivityRecord activity)99     abstract StartingSurface createStartingSurface(ActivityRecord activity);
100 
101     /**
102      * @return Whether to apply reveal animation when exiting the starting window.
103      */
needRevealAnimation()104     abstract boolean needRevealAnimation();
105 
106     /** @see android.window.TaskSnapshot#hasImeSurface() */
hasImeSurface()107     boolean hasImeSurface() {
108         return false;
109     }
110 
111     @Override
toString()112     public String toString() {
113         return getClass().getSimpleName() + "{"
114                 + Integer.toHexString(System.identityHashCode(this))
115                 + " waitForSyncTransactionCommit=" + mWaitForSyncTransactionCommit
116                 + " removeAfterTransaction= " + mRemoveAfterTransaction
117                 + "}";
118     }
119 }
120