1 /* 2 * Copyright (C) 2024 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.view; 18 19 import static java.util.Objects.requireNonNull; 20 21 import android.annotation.NonNull; 22 import android.annotation.Nullable; 23 import android.os.Parcel; 24 import android.os.Parcelable; 25 import android.util.MergedConfiguration; 26 import android.window.ActivityWindowInfo; 27 import android.window.ClientWindowFrames; 28 29 /** 30 * Stores information to pass to {@link IWindowSession#relayout} as AIDL out type. 31 * @hide 32 */ 33 public final class WindowRelayoutResult implements Parcelable { 34 35 /** The window frames used by the client side for layout. */ 36 @NonNull 37 public final ClientWindowFrames frames; 38 39 /** 40 * New config container that holds global, override and merged config for window, if it is now 41 * becoming visible and the merged config has changed since it was last displayed. 42 */ 43 @NonNull 44 public final MergedConfiguration mergedConfiguration; 45 46 /** Object in which is placed the new display surface. */ 47 @NonNull 48 public final SurfaceControl surfaceControl; 49 50 /** The current insets state in the system. */ 51 @NonNull 52 public final InsetsState insetsState; 53 54 /** Objects which allow controlling {@link InsetsSource}s. */ 55 @NonNull 56 public final InsetsSourceControl.Array activeControls; 57 58 /** The latest sync seq id for the relayout configuration. */ 59 public int syncSeqId; 60 61 /** 62 * The latest {@link ActivityWindowInfo} if this relayout window is an Activity window. 63 * {@code null} if this is not an Activity window. 64 */ 65 @Nullable 66 public ActivityWindowInfo activityWindowInfo; 67 WindowRelayoutResult()68 public WindowRelayoutResult() { 69 this(new ClientWindowFrames(), new MergedConfiguration(), new SurfaceControl(), 70 new InsetsState(), new InsetsSourceControl.Array()); 71 } 72 73 /** 74 * Stores information to pass for {@link IWindowSession#relayout}. 75 * 76 * @param frames The window frames used by the client side for layout. 77 * @param mergedConfiguration New config container that holds global, override and merged 78 * config for window, if it is now becoming visible and the merged 79 * config has changed since it was last displayed. 80 * @param surfaceControl Object in which is placed the new display surface. 81 * @param insetsState The current insets state in the system. 82 * @param activeControls Objects which allow controlling {@link InsetsSource}s. 83 */ WindowRelayoutResult(@onNull ClientWindowFrames frames, @NonNull MergedConfiguration mergedConfiguration, @NonNull SurfaceControl surfaceControl, @NonNull InsetsState insetsState, @NonNull InsetsSourceControl.Array activeControls)84 public WindowRelayoutResult(@NonNull ClientWindowFrames frames, 85 @NonNull MergedConfiguration mergedConfiguration, 86 @NonNull SurfaceControl surfaceControl, @NonNull InsetsState insetsState, 87 @NonNull InsetsSourceControl.Array activeControls) { 88 this.frames = requireNonNull(frames); 89 this.mergedConfiguration = requireNonNull(mergedConfiguration); 90 this.surfaceControl = requireNonNull(surfaceControl); 91 this.insetsState = requireNonNull(insetsState); 92 this.activeControls = requireNonNull(activeControls); 93 } 94 WindowRelayoutResult(@onNull Parcel in)95 private WindowRelayoutResult(@NonNull Parcel in) { 96 this(); 97 readFromParcel(in); 98 } 99 100 /** Needed for IBinder out parameter. */ readFromParcel(@onNull Parcel in)101 public void readFromParcel(@NonNull Parcel in) { 102 frames.readFromParcel(in); 103 mergedConfiguration.readFromParcel(in); 104 surfaceControl.readFromParcel(in); 105 insetsState.readFromParcel(in); 106 activeControls.readFromParcel(in); 107 syncSeqId = in.readInt(); 108 activityWindowInfo = in.readTypedObject(ActivityWindowInfo.CREATOR); 109 } 110 111 @Override writeToParcel(@onNull Parcel dest, int flags)112 public void writeToParcel(@NonNull Parcel dest, int flags) { 113 frames.writeToParcel(dest, flags); 114 mergedConfiguration.writeToParcel(dest, flags); 115 surfaceControl.writeToParcel(dest, flags); 116 insetsState.writeToParcel(dest, flags); 117 activeControls.writeToParcel(dest, flags); 118 dest.writeInt(syncSeqId); 119 dest.writeTypedObject(activityWindowInfo, flags); 120 } 121 122 @NonNull 123 public static final Creator<WindowRelayoutResult> CREATOR = 124 new Creator<>() { 125 @Override 126 public WindowRelayoutResult createFromParcel(@NonNull Parcel in) { 127 return new WindowRelayoutResult(in); 128 } 129 130 @Override 131 public WindowRelayoutResult[] newArray(int size) { 132 return new WindowRelayoutResult[size]; 133 } 134 }; 135 136 @Override describeContents()137 public int describeContents() { 138 return 0; 139 } 140 } 141