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 static android.view.WindowManager.transitTypeToString;
20 
21 import android.annotation.Nullable;
22 import android.app.ActivityManager;
23 import android.app.WindowConfiguration;
24 import android.graphics.Rect;
25 import android.os.Parcelable;
26 import android.view.WindowManager;
27 
28 import com.android.internal.util.DataClass;
29 
30 /**
31  * Used to communicate information about what is changing during a transition to a TransitionPlayer.
32  * @hide
33  */
34 @DataClass(genToString = true, genSetters = true, genAidl = true)
35 public final class TransitionRequestInfo implements Parcelable {
36 
37     /** The type of the transition being requested. */
38     private final @WindowManager.TransitionType int mType;
39 
40     /**
41      * If non-null, the task containing the activity whose lifecycle change (start or
42      * finish) has caused this transition to occur.
43      */
44     private @Nullable ActivityManager.RunningTaskInfo mTriggerTask;
45 
46     /**
47      * If non-null, the task containing the pip activity that participates in this
48      * transition.
49      */
50     private @Nullable ActivityManager.RunningTaskInfo mPipTask;
51 
52     /** If non-null, a remote-transition associated with the source of this transition. */
53     private @Nullable RemoteTransition mRemoteTransition;
54 
55     /**
56      * If non-null, this request was triggered by this display change. This will not be complete:
57      * The reliable parts should be flags, rotation start/end (if rotating), and start/end bounds
58      * (if size is changing).
59      */
60     private @Nullable TransitionRequestInfo.DisplayChange mDisplayChange;
61 
62     /** The transition flags known at the time of the request. These may not be complete. */
63     private final int mFlags;
64 
65     /** This is only a BEST-EFFORT id used for log correlation. DO NOT USE for any real work! */
66     private final int mDebugId;
67 
68     /** constructor override */
TransitionRequestInfo( @indowManager.TransitionType int type, @Nullable ActivityManager.RunningTaskInfo triggerTask, @Nullable RemoteTransition remoteTransition)69     public TransitionRequestInfo(
70             @WindowManager.TransitionType int type,
71             @Nullable ActivityManager.RunningTaskInfo triggerTask,
72             @Nullable RemoteTransition remoteTransition) {
73         this(type, triggerTask, null /* pipTask */,
74                 remoteTransition, null /* displayChange */, 0 /* flags */, -1 /* debugId */);
75     }
76 
77     /** constructor override */
TransitionRequestInfo( @indowManager.TransitionType int type, @Nullable ActivityManager.RunningTaskInfo triggerTask, @Nullable RemoteTransition remoteTransition, int flags)78     public TransitionRequestInfo(
79             @WindowManager.TransitionType int type,
80             @Nullable ActivityManager.RunningTaskInfo triggerTask,
81             @Nullable RemoteTransition remoteTransition,
82             int flags) {
83         this(type, triggerTask, null /* pipTask */,
84                 remoteTransition, null /* displayChange */, flags, -1 /* debugId */);
85     }
86 
87         /** constructor override */
TransitionRequestInfo( @indowManager.TransitionType int type, @Nullable ActivityManager.RunningTaskInfo triggerTask, @Nullable RemoteTransition remoteTransition, @Nullable TransitionRequestInfo.DisplayChange displayChange, int flags)88     public TransitionRequestInfo(
89             @WindowManager.TransitionType int type,
90             @Nullable ActivityManager.RunningTaskInfo triggerTask,
91             @Nullable RemoteTransition remoteTransition,
92             @Nullable TransitionRequestInfo.DisplayChange displayChange,
93             int flags) {
94         this(type, triggerTask, null /* pipTask */, remoteTransition, displayChange, flags,
95                 -1 /* debugId */);
96     }
97 
98     /** constructor override */
TransitionRequestInfo( @indowManager.TransitionType int type, @Nullable ActivityManager.RunningTaskInfo triggerTask, @Nullable ActivityManager.RunningTaskInfo pipTask, @Nullable RemoteTransition remoteTransition, @Nullable TransitionRequestInfo.DisplayChange displayChange, int flags)99     public TransitionRequestInfo(
100             @WindowManager.TransitionType int type,
101             @Nullable ActivityManager.RunningTaskInfo triggerTask,
102             @Nullable ActivityManager.RunningTaskInfo pipTask,
103             @Nullable RemoteTransition remoteTransition,
104             @Nullable TransitionRequestInfo.DisplayChange displayChange,
105             int flags) {
106         this(type, triggerTask, pipTask, remoteTransition, displayChange, flags, -1 /* debugId */);
107     }
108 
109     /** @hide */
typeToString()110     String typeToString() {
111         return transitTypeToString(mType);
112     }
113 
114     /** Requested change to a display. */
115     @DataClass(genToString = true, genSetters = true, genBuilder = false, genConstructor = false)
116     public static final class DisplayChange implements Parcelable {
117         private final int mDisplayId;
118         @Nullable private Rect mStartAbsBounds = null;
119         @Nullable private Rect mEndAbsBounds = null;
120         private int mStartRotation = WindowConfiguration.ROTATION_UNDEFINED;
121         private int mEndRotation = WindowConfiguration.ROTATION_UNDEFINED;
122         private boolean mPhysicalDisplayChanged = false;
123 
124         /** Create empty display-change. */
DisplayChange(int displayId)125         public DisplayChange(int displayId) {
126             mDisplayId = displayId;
127         }
128 
129         /** Create a display-change representing a rotation. */
DisplayChange(int displayId, int startRotation, int endRotation)130         public DisplayChange(int displayId, int startRotation, int endRotation) {
131             mDisplayId = displayId;
132             mStartRotation = startRotation;
133             mEndRotation = endRotation;
134         }
135 
136 
137 
138         // Code below generated by codegen v1.0.23.
139         //
140         // DO NOT MODIFY!
141         // CHECKSTYLE:OFF Generated code
142         //
143         // To regenerate run:
144         // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/window/TransitionRequestInfo.java
145         //
146         // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
147         //   Settings > Editor > Code Style > Formatter Control
148         //@formatter:off
149 
150 
151         @DataClass.Generated.Member
getDisplayId()152         public int getDisplayId() {
153             return mDisplayId;
154         }
155 
156         @DataClass.Generated.Member
getStartAbsBounds()157         public @Nullable Rect getStartAbsBounds() {
158             return mStartAbsBounds;
159         }
160 
161         @DataClass.Generated.Member
getEndAbsBounds()162         public @Nullable Rect getEndAbsBounds() {
163             return mEndAbsBounds;
164         }
165 
166         @DataClass.Generated.Member
getStartRotation()167         public int getStartRotation() {
168             return mStartRotation;
169         }
170 
171         @DataClass.Generated.Member
getEndRotation()172         public int getEndRotation() {
173             return mEndRotation;
174         }
175 
176         @DataClass.Generated.Member
isPhysicalDisplayChanged()177         public boolean isPhysicalDisplayChanged() {
178             return mPhysicalDisplayChanged;
179         }
180 
181         @DataClass.Generated.Member
setStartAbsBounds(@ndroid.annotation.NonNull Rect value)182         public @android.annotation.NonNull DisplayChange setStartAbsBounds(@android.annotation.NonNull Rect value) {
183             mStartAbsBounds = value;
184             return this;
185         }
186 
187         @DataClass.Generated.Member
setEndAbsBounds(@ndroid.annotation.NonNull Rect value)188         public @android.annotation.NonNull DisplayChange setEndAbsBounds(@android.annotation.NonNull Rect value) {
189             mEndAbsBounds = value;
190             return this;
191         }
192 
193         @DataClass.Generated.Member
setStartRotation( int value)194         public @android.annotation.NonNull DisplayChange setStartRotation( int value) {
195             mStartRotation = value;
196             return this;
197         }
198 
199         @DataClass.Generated.Member
setEndRotation( int value)200         public @android.annotation.NonNull DisplayChange setEndRotation( int value) {
201             mEndRotation = value;
202             return this;
203         }
204 
205         @DataClass.Generated.Member
setPhysicalDisplayChanged( boolean value)206         public @android.annotation.NonNull DisplayChange setPhysicalDisplayChanged( boolean value) {
207             mPhysicalDisplayChanged = value;
208             return this;
209         }
210 
211         @Override
212         @DataClass.Generated.Member
toString()213         public String toString() {
214             // You can override field toString logic by defining methods like:
215             // String fieldNameToString() { ... }
216 
217             return "DisplayChange { " +
218                     "displayId = " + mDisplayId + ", " +
219                     "startAbsBounds = " + mStartAbsBounds + ", " +
220                     "endAbsBounds = " + mEndAbsBounds + ", " +
221                     "startRotation = " + mStartRotation + ", " +
222                     "endRotation = " + mEndRotation + ", " +
223                     "physicalDisplayChanged = " + mPhysicalDisplayChanged +
224             " }";
225         }
226 
227         @Override
228         @DataClass.Generated.Member
writeToParcel(@ndroid.annotation.NonNull android.os.Parcel dest, int flags)229         public void writeToParcel(@android.annotation.NonNull android.os.Parcel dest, int flags) {
230             // You can override field parcelling by defining methods like:
231             // void parcelFieldName(Parcel dest, int flags) { ... }
232 
233             byte flg = 0;
234             if (mPhysicalDisplayChanged) flg |= 0x20;
235             if (mStartAbsBounds != null) flg |= 0x2;
236             if (mEndAbsBounds != null) flg |= 0x4;
237             dest.writeByte(flg);
238             dest.writeInt(mDisplayId);
239             if (mStartAbsBounds != null) dest.writeTypedObject(mStartAbsBounds, flags);
240             if (mEndAbsBounds != null) dest.writeTypedObject(mEndAbsBounds, flags);
241             dest.writeInt(mStartRotation);
242             dest.writeInt(mEndRotation);
243         }
244 
245         @Override
246         @DataClass.Generated.Member
describeContents()247         public int describeContents() { return 0; }
248 
249         /** @hide */
250         @SuppressWarnings({"unchecked", "RedundantCast"})
251         @DataClass.Generated.Member
DisplayChange(@ndroid.annotation.NonNull android.os.Parcel in)252         protected DisplayChange(@android.annotation.NonNull android.os.Parcel in) {
253             // You can override field unparcelling by defining methods like:
254             // static FieldType unparcelFieldName(Parcel in) { ... }
255 
256             byte flg = in.readByte();
257             boolean physicalDisplayChanged = (flg & 0x20) != 0;
258             int displayId = in.readInt();
259             Rect startAbsBounds = (flg & 0x2) == 0 ? null : (Rect) in.readTypedObject(Rect.CREATOR);
260             Rect endAbsBounds = (flg & 0x4) == 0 ? null : (Rect) in.readTypedObject(Rect.CREATOR);
261             int startRotation = in.readInt();
262             int endRotation = in.readInt();
263 
264             this.mDisplayId = displayId;
265             this.mStartAbsBounds = startAbsBounds;
266             this.mEndAbsBounds = endAbsBounds;
267             this.mStartRotation = startRotation;
268             this.mEndRotation = endRotation;
269             this.mPhysicalDisplayChanged = physicalDisplayChanged;
270 
271             // onConstructed(); // You can define this method to get a callback
272         }
273 
274         @DataClass.Generated.Member
275         public static final @android.annotation.NonNull Parcelable.Creator<DisplayChange> CREATOR
276                 = new Parcelable.Creator<DisplayChange>() {
277             @Override
278             public DisplayChange[] newArray(int size) {
279                 return new DisplayChange[size];
280             }
281 
282             @Override
283             public DisplayChange createFromParcel(@android.annotation.NonNull android.os.Parcel in) {
284                 return new DisplayChange(in);
285             }
286         };
287 
288         @DataClass.Generated(
289                 time = 1697564781403L,
290                 codegenVersion = "1.0.23",
291                 sourceFile = "frameworks/base/core/java/android/window/TransitionRequestInfo.java",
292                 inputSignatures = "private final  int mDisplayId\nprivate @android.annotation.Nullable android.graphics.Rect mStartAbsBounds\nprivate @android.annotation.Nullable android.graphics.Rect mEndAbsBounds\nprivate  int mStartRotation\nprivate  int mEndRotation\nprivate  boolean mPhysicalDisplayChanged\nclass DisplayChange extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genSetters=true, genBuilder=false, genConstructor=false)")
293         @Deprecated
__metadata()294         private void __metadata() {}
295 
296 
297         //@formatter:on
298         // End of generated code
299 
300     }
301 
302 
303 
304 
305     // Code below generated by codegen v1.0.23.
306     //
307     // DO NOT MODIFY!
308     // CHECKSTYLE:OFF Generated code
309     //
310     // To regenerate run:
311     // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/window/TransitionRequestInfo.java
312     //
313     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
314     //   Settings > Editor > Code Style > Formatter Control
315     //@formatter:off
316 
317 
318     /**
319      * Creates a new TransitionRequestInfo.
320      *
321      * @param type
322      *   The type of the transition being requested.
323      * @param triggerTask
324      *   If non-null, the task containing the activity whose lifecycle change (start or
325      *   finish) has caused this transition to occur.
326      * @param pipTask
327      *   If non-null, the task containing the pip activity that participates in this
328      *   transition.
329      * @param remoteTransition
330      *   If non-null, a remote-transition associated with the source of this transition.
331      * @param displayChange
332      *   If non-null, this request was triggered by this display change. This will not be complete:
333      *   The reliable parts should be flags, rotation start/end (if rotating), and start/end bounds
334      *   (if size is changing).
335      * @param flags
336      *   The transition flags known at the time of the request. These may not be complete.
337      * @param debugId
338      *   This is only a BEST-EFFORT id used for log correlation. DO NOT USE for any real work!
339      */
340     @DataClass.Generated.Member
TransitionRequestInfo( @indowManager.TransitionType int type, @Nullable ActivityManager.RunningTaskInfo triggerTask, @Nullable ActivityManager.RunningTaskInfo pipTask, @Nullable RemoteTransition remoteTransition, @Nullable TransitionRequestInfo.DisplayChange displayChange, int flags, int debugId)341     public TransitionRequestInfo(
342             @WindowManager.TransitionType int type,
343             @Nullable ActivityManager.RunningTaskInfo triggerTask,
344             @Nullable ActivityManager.RunningTaskInfo pipTask,
345             @Nullable RemoteTransition remoteTransition,
346             @Nullable TransitionRequestInfo.DisplayChange displayChange,
347             int flags,
348             int debugId) {
349         this.mType = type;
350         com.android.internal.util.AnnotationValidations.validate(
351                 WindowManager.TransitionType.class, null, mType);
352         this.mTriggerTask = triggerTask;
353         this.mPipTask = pipTask;
354         this.mRemoteTransition = remoteTransition;
355         this.mDisplayChange = displayChange;
356         this.mFlags = flags;
357         this.mDebugId = debugId;
358 
359         // onConstructed(); // You can define this method to get a callback
360     }
361 
362     /**
363      * The type of the transition being requested.
364      */
365     @DataClass.Generated.Member
getType()366     public @WindowManager.TransitionType int getType() {
367         return mType;
368     }
369 
370     /**
371      * If non-null, the task containing the activity whose lifecycle change (start or
372      * finish) has caused this transition to occur.
373      */
374     @DataClass.Generated.Member
getTriggerTask()375     public @Nullable ActivityManager.RunningTaskInfo getTriggerTask() {
376         return mTriggerTask;
377     }
378 
379     /**
380      * If non-null, the task containing the pip activity that participates in this
381      * transition.
382      */
383     @DataClass.Generated.Member
getPipTask()384     public @Nullable ActivityManager.RunningTaskInfo getPipTask() {
385         return mPipTask;
386     }
387 
388     /**
389      * If non-null, a remote-transition associated with the source of this transition.
390      */
391     @DataClass.Generated.Member
getRemoteTransition()392     public @Nullable RemoteTransition getRemoteTransition() {
393         return mRemoteTransition;
394     }
395 
396     /**
397      * If non-null, this request was triggered by this display change. This will not be complete:
398      * The reliable parts should be flags, rotation start/end (if rotating), and start/end bounds
399      * (if size is changing).
400      */
401     @DataClass.Generated.Member
getDisplayChange()402     public @Nullable TransitionRequestInfo.DisplayChange getDisplayChange() {
403         return mDisplayChange;
404     }
405 
406     /**
407      * The transition flags known at the time of the request. These may not be complete.
408      */
409     @DataClass.Generated.Member
getFlags()410     public int getFlags() {
411         return mFlags;
412     }
413 
414     /**
415      * This is only a BEST-EFFORT id used for log correlation. DO NOT USE for any real work!
416      */
417     @DataClass.Generated.Member
getDebugId()418     public int getDebugId() {
419         return mDebugId;
420     }
421 
422     /**
423      * If non-null, the task containing the activity whose lifecycle change (start or
424      * finish) has caused this transition to occur.
425      */
426     @DataClass.Generated.Member
setTriggerTask(@ndroid.annotation.NonNull ActivityManager.RunningTaskInfo value)427     public @android.annotation.NonNull TransitionRequestInfo setTriggerTask(@android.annotation.NonNull ActivityManager.RunningTaskInfo value) {
428         mTriggerTask = value;
429         return this;
430     }
431 
432     /**
433      * If non-null, the task containing the pip activity that participates in this
434      * transition.
435      */
436     @DataClass.Generated.Member
setPipTask(@ndroid.annotation.NonNull ActivityManager.RunningTaskInfo value)437     public @android.annotation.NonNull TransitionRequestInfo setPipTask(@android.annotation.NonNull ActivityManager.RunningTaskInfo value) {
438         mPipTask = value;
439         return this;
440     }
441 
442     /**
443      * If non-null, a remote-transition associated with the source of this transition.
444      */
445     @DataClass.Generated.Member
setRemoteTransition(@ndroid.annotation.NonNull RemoteTransition value)446     public @android.annotation.NonNull TransitionRequestInfo setRemoteTransition(@android.annotation.NonNull RemoteTransition value) {
447         mRemoteTransition = value;
448         return this;
449     }
450 
451     /**
452      * If non-null, this request was triggered by this display change. This will not be complete:
453      * The reliable parts should be flags, rotation start/end (if rotating), and start/end bounds
454      * (if size is changing).
455      */
456     @DataClass.Generated.Member
setDisplayChange(@ndroid.annotation.NonNull TransitionRequestInfo.DisplayChange value)457     public @android.annotation.NonNull TransitionRequestInfo setDisplayChange(@android.annotation.NonNull TransitionRequestInfo.DisplayChange value) {
458         mDisplayChange = value;
459         return this;
460     }
461 
462     @Override
463     @DataClass.Generated.Member
toString()464     public String toString() {
465         // You can override field toString logic by defining methods like:
466         // String fieldNameToString() { ... }
467 
468         return "TransitionRequestInfo { " +
469                 "type = " + typeToString() + ", " +
470                 "triggerTask = " + mTriggerTask + ", " +
471                 "pipTask = " + mPipTask + ", " +
472                 "remoteTransition = " + mRemoteTransition + ", " +
473                 "displayChange = " + mDisplayChange + ", " +
474                 "flags = " + mFlags + ", " +
475                 "debugId = " + mDebugId +
476         " }";
477     }
478 
479     @Override
480     @DataClass.Generated.Member
writeToParcel(@ndroid.annotation.NonNull android.os.Parcel dest, int flags)481     public void writeToParcel(@android.annotation.NonNull android.os.Parcel dest, int flags) {
482         // You can override field parcelling by defining methods like:
483         // void parcelFieldName(Parcel dest, int flags) { ... }
484 
485         byte flg = 0;
486         if (mTriggerTask != null) flg |= 0x2;
487         if (mPipTask != null) flg |= 0x4;
488         if (mRemoteTransition != null) flg |= 0x8;
489         if (mDisplayChange != null) flg |= 0x10;
490         dest.writeByte(flg);
491         dest.writeInt(mType);
492         if (mTriggerTask != null) dest.writeTypedObject(mTriggerTask, flags);
493         if (mPipTask != null) dest.writeTypedObject(mPipTask, flags);
494         if (mRemoteTransition != null) dest.writeTypedObject(mRemoteTransition, flags);
495         if (mDisplayChange != null) dest.writeTypedObject(mDisplayChange, flags);
496         dest.writeInt(mFlags);
497         dest.writeInt(mDebugId);
498     }
499 
500     @Override
501     @DataClass.Generated.Member
describeContents()502     public int describeContents() { return 0; }
503 
504     /** @hide */
505     @SuppressWarnings({"unchecked", "RedundantCast"})
506     @DataClass.Generated.Member
TransitionRequestInfo(@ndroid.annotation.NonNull android.os.Parcel in)507     /* package-private */ TransitionRequestInfo(@android.annotation.NonNull android.os.Parcel in) {
508         // You can override field unparcelling by defining methods like:
509         // static FieldType unparcelFieldName(Parcel in) { ... }
510 
511         byte flg = in.readByte();
512         int type = in.readInt();
513         ActivityManager.RunningTaskInfo triggerTask = (flg & 0x2) == 0 ? null : (ActivityManager.RunningTaskInfo) in.readTypedObject(ActivityManager.RunningTaskInfo.CREATOR);
514         ActivityManager.RunningTaskInfo pipTask = (flg & 0x4) == 0 ? null : (ActivityManager.RunningTaskInfo) in.readTypedObject(ActivityManager.RunningTaskInfo.CREATOR);
515         RemoteTransition remoteTransition = (flg & 0x8) == 0 ? null : (RemoteTransition) in.readTypedObject(RemoteTransition.CREATOR);
516         TransitionRequestInfo.DisplayChange displayChange = (flg & 0x10) == 0 ? null : (TransitionRequestInfo.DisplayChange) in.readTypedObject(TransitionRequestInfo.DisplayChange.CREATOR);
517         int flags = in.readInt();
518         int debugId = in.readInt();
519 
520         this.mType = type;
521         com.android.internal.util.AnnotationValidations.validate(
522                 WindowManager.TransitionType.class, null, mType);
523         this.mTriggerTask = triggerTask;
524         this.mPipTask = pipTask;
525         this.mRemoteTransition = remoteTransition;
526         this.mDisplayChange = displayChange;
527         this.mFlags = flags;
528         this.mDebugId = debugId;
529 
530         // onConstructed(); // You can define this method to get a callback
531     }
532 
533     @DataClass.Generated.Member
534     public static final @android.annotation.NonNull Parcelable.Creator<TransitionRequestInfo> CREATOR
535             = new Parcelable.Creator<TransitionRequestInfo>() {
536         @Override
537         public TransitionRequestInfo[] newArray(int size) {
538             return new TransitionRequestInfo[size];
539         }
540 
541         @Override
542         public TransitionRequestInfo createFromParcel(@android.annotation.NonNull android.os.Parcel in) {
543             return new TransitionRequestInfo(in);
544         }
545     };
546 
547     @DataClass.Generated(
548             time = 1697564781438L,
549             codegenVersion = "1.0.23",
550             sourceFile = "frameworks/base/core/java/android/window/TransitionRequestInfo.java",
551             inputSignatures = "private final @android.view.WindowManager.TransitionType int mType\nprivate @android.annotation.Nullable android.app.ActivityManager.RunningTaskInfo mTriggerTask\nprivate @android.annotation.Nullable android.app.ActivityManager.RunningTaskInfo mPipTask\nprivate @android.annotation.Nullable android.window.RemoteTransition mRemoteTransition\nprivate @android.annotation.Nullable android.window.TransitionRequestInfo.DisplayChange mDisplayChange\nprivate final  int mFlags\nprivate final  int mDebugId\n  java.lang.String typeToString()\nclass TransitionRequestInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genSetters=true, genAidl=true)")
552     @Deprecated
__metadata()553     private void __metadata() {}
554 
555 
556     //@formatter:on
557     // End of generated code
558 
559 }
560