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