blob: ebfc62f33f9ca4b9a3e0c362125ea586b0947e27 [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2008 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
Vishnu Nair217d8e62018-09-12 16:34:49 -070017#define LOG_TAG "LayerState"
18
Dominik Laskowski1f6fc702022-03-21 08:34:50 -070019#include <cinttypes>
Garfield Tan8a3083e2018-12-03 13:21:07 -080020
Huihong Luod3d8f8e2022-03-08 14:48:46 -080021#include <android/gui/ISurfaceComposerClient.h>
Marin Shalamanovc5986772021-03-16 16:09:49 +010022#include <android/native_window.h>
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070023#include <binder/Parcel.h>
Brian Lindahl07dcd492024-10-30 11:43:23 -060024#include <com_android_graphics_libgui_flags.h>
Ady Abraham6cdd3fd2023-09-07 18:45:58 -070025#include <gui/FrameRateUtils.h>
Andy McFadden2adaf042012-12-18 09:49:45 -080026#include <gui/IGraphicBufferProducer.h>
Robert Carr4cdc58f2017-08-23 14:22:20 -070027#include <gui/LayerState.h>
Vishnu Nairaa799bd2022-11-16 23:09:09 +000028#include <gui/SurfaceControl.h>
Marin Shalamanov3b1f7bc2021-03-16 15:51:53 +010029#include <private/gui/ParcelUtils.h>
Dominik Laskowski1f6fc702022-03-21 08:34:50 -070030#include <system/window.h>
Pablo Gamito11dcc222020-09-12 15:49:39 +000031#include <utils/Errors.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080032
Vishnu Nairaa799bd2022-11-16 23:09:09 +000033#define CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD) \
34 { \
35 if ((OTHER.what & CHANGE_FLAG) && (FIELD != OTHER.FIELD)) { \
36 DIFF_RESULT |= CHANGE_FLAG; \
37 } \
38 }
39
40#define CHECK_DIFF2(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD1, FIELD2) \
41 { \
42 CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD1) \
43 CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD2) \
44 }
45
46#define CHECK_DIFF3(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD1, FIELD2, FIELD3) \
47 { \
48 CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD1) \
49 CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD2) \
50 CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD3) \
51 }
52
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080053namespace android {
54
chaviw98318de2021-05-19 16:45:23 -050055using gui::FocusRequest;
56using gui::WindowInfoHandle;
57
Pablo Gamito11dcc222020-09-12 15:49:39 +000058layer_state_t::layer_state_t()
Vishnu Nair685cfef2022-02-02 10:01:25 -080059 : surface(nullptr),
60 layerId(-1),
61 what(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000062 x(0),
63 y(0),
64 z(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000065 flags(0),
66 mask(0),
67 reserved(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000068 cornerRadius(0.0f),
Surbhi Kadam9674ffa2024-11-14 23:06:27 +000069 clientDrawnCornerRadius(0.0f),
Pablo Gamito11dcc222020-09-12 15:49:39 +000070 backgroundBlurRadius(0),
Vishnu Nairbbceb462022-10-10 04:52:13 +000071 color(0),
72 bufferTransform(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000073 transformToDisplayInverse(false),
Vishnu Naira9123c82024-10-03 03:56:44 +000074 crop({0, 0, -1, -1}),
Pablo Gamito11dcc222020-09-12 15:49:39 +000075 dataspace(ui::Dataspace::UNKNOWN),
76 surfaceDamageRegion(),
77 api(-1),
78 colorTransform(mat4()),
Vishnu Naird47bcee2023-02-24 18:08:51 +000079 bgColor(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000080 bgColorDataspace(ui::Dataspace::UNKNOWN),
81 colorSpaceAgnostic(false),
82 shadowRadius(0.0f),
83 frameRateSelectionPriority(-1),
84 frameRate(0.0f),
85 frameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
Marin Shalamanovc5986772021-03-16 16:09:49 +010086 changeFrameRateStrategy(ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS),
Andy Labrada096227e2022-06-15 16:58:11 +000087 defaultFrameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
Rachel Leece6e0042023-06-27 11:22:54 -070088 frameRateCategory(ANATIVEWINDOW_FRAME_RATE_CATEGORY_DEFAULT),
Rachel Lee67afbea2023-09-28 15:35:07 -070089 frameRateCategorySmoothSwitchOnly(false),
Rachel Lee70f7b692023-11-22 11:24:02 -080090 frameRateSelectionStrategy(ANATIVEWINDOW_FRAME_RATE_SELECTION_STRATEGY_PROPAGATE),
Pablo Gamito11dcc222020-09-12 15:49:39 +000091 fixedTransformHint(ui::Transform::ROT_INVALID),
Vishnu Nair1506b182021-02-22 14:35:15 -080092 autoRefresh(false),
Vishnu Nair9e0017e2024-05-22 19:02:44 +000093 trustedOverlay(gui::TrustedOverlay::UNSET),
Vishnu Nair6bdec7d2021-05-10 15:01:13 -070094 bufferCrop(Rect::INVALID_RECT),
95 destinationFrame(Rect::INVALID_RECT),
Brian Lindahl07dcd492024-10-30 11:43:23 -060096 dropInputMode(gui::DropInputMode::NONE),
97 pictureProfileHandle(PictureProfileHandle::NONE),
98 appContentPriority(0) {
Pablo Gamito11dcc222020-09-12 15:49:39 +000099 matrix.dsdx = matrix.dtdy = 1.0f;
100 matrix.dsdy = matrix.dtdx = 0.0f;
101 hdrMetadata.validTypes = 0;
102}
103
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800104status_t layer_state_t::write(Parcel& output) const
105{
chaviw308ddba2020-08-11 16:23:51 -0700106 SAFE_PARCEL(output.writeStrongBinder, surface);
Pablo Gamitodbc31672020-09-01 18:28:58 +0000107 SAFE_PARCEL(output.writeInt32, layerId);
chaviw308ddba2020-08-11 16:23:51 -0700108 SAFE_PARCEL(output.writeUint64, what);
109 SAFE_PARCEL(output.writeFloat, x);
110 SAFE_PARCEL(output.writeFloat, y);
111 SAFE_PARCEL(output.writeInt32, z);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700112 SAFE_PARCEL(output.writeUint32, layerStack.id);
chaviw308ddba2020-08-11 16:23:51 -0700113 SAFE_PARCEL(output.writeUint32, flags);
114 SAFE_PARCEL(output.writeUint32, mask);
115 SAFE_PARCEL(matrix.write, output);
Vishnu Naira9123c82024-10-03 03:56:44 +0000116 SAFE_PARCEL(output.writeFloat, crop.top);
117 SAFE_PARCEL(output.writeFloat, crop.left);
118 SAFE_PARCEL(output.writeFloat, crop.bottom);
119 SAFE_PARCEL(output.writeFloat, crop.right);
Pablo Gamito11dcc222020-09-12 15:49:39 +0000120 SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, relativeLayerSurfaceControl);
121 SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, parentSurfaceControlForChild);
chaviw308ddba2020-08-11 16:23:51 -0700122 SAFE_PARCEL(output.writeFloat, color.r);
123 SAFE_PARCEL(output.writeFloat, color.g);
124 SAFE_PARCEL(output.writeFloat, color.b);
Vishnu Nairbbceb462022-10-10 04:52:13 +0000125 SAFE_PARCEL(output.writeFloat, color.a);
chaviw98318de2021-05-19 16:45:23 -0500126 SAFE_PARCEL(windowInfoHandle->writeToParcel, &output);
chaviw308ddba2020-08-11 16:23:51 -0700127 SAFE_PARCEL(output.write, transparentRegion);
Vishnu Nairbbceb462022-10-10 04:52:13 +0000128 SAFE_PARCEL(output.writeUint32, bufferTransform);
chaviw308ddba2020-08-11 16:23:51 -0700129 SAFE_PARCEL(output.writeBool, transformToDisplayInverse);
chaviw308ddba2020-08-11 16:23:51 -0700130 SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dataspace));
131 SAFE_PARCEL(output.write, hdrMetadata);
132 SAFE_PARCEL(output.write, surfaceDamageRegion);
133 SAFE_PARCEL(output.writeInt32, api);
134
Marissa Wall61c58622018-07-18 10:12:20 -0700135 if (sidebandStream) {
chaviw308ddba2020-08-11 16:23:51 -0700136 SAFE_PARCEL(output.writeBool, true);
137 SAFE_PARCEL(output.writeNativeHandle, sidebandStream->handle());
Marissa Wall61c58622018-07-18 10:12:20 -0700138 } else {
chaviw308ddba2020-08-11 16:23:51 -0700139 SAFE_PARCEL(output.writeBool, false);
Marissa Wall61c58622018-07-18 10:12:20 -0700140 }
141
chaviw308ddba2020-08-11 16:23:51 -0700142 SAFE_PARCEL(output.write, colorTransform.asArray(), 16 * sizeof(float));
143 SAFE_PARCEL(output.writeFloat, cornerRadius);
Surbhi Kadam9674ffa2024-11-14 23:06:27 +0000144 SAFE_PARCEL(output.writeFloat, clientDrawnCornerRadius);
chaviw308ddba2020-08-11 16:23:51 -0700145 SAFE_PARCEL(output.writeUint32, backgroundBlurRadius);
chaviw308ddba2020-08-11 16:23:51 -0700146 SAFE_PARCEL(output.writeParcelable, metadata);
Vishnu Naird47bcee2023-02-24 18:08:51 +0000147 SAFE_PARCEL(output.writeFloat, bgColor.r);
148 SAFE_PARCEL(output.writeFloat, bgColor.g);
149 SAFE_PARCEL(output.writeFloat, bgColor.b);
150 SAFE_PARCEL(output.writeFloat, bgColor.a);
chaviw308ddba2020-08-11 16:23:51 -0700151 SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(bgColorDataspace));
152 SAFE_PARCEL(output.writeBool, colorSpaceAgnostic);
153 SAFE_PARCEL(output.writeVectorSize, listeners);
Valerie Hau9dab9732019-08-20 09:29:25 -0700154
155 for (auto listener : listeners) {
chaviw308ddba2020-08-11 16:23:51 -0700156 SAFE_PARCEL(output.writeStrongBinder, listener.transactionCompletedListener);
Vishnu Nairfc46c1e2021-04-21 08:31:32 -0700157 SAFE_PARCEL(output.writeParcelableVector, listener.callbackIds);
Valerie Hau9dab9732019-08-20 09:29:25 -0700158 }
chaviw308ddba2020-08-11 16:23:51 -0700159 SAFE_PARCEL(output.writeFloat, shadowRadius);
160 SAFE_PARCEL(output.writeInt32, frameRateSelectionPriority);
161 SAFE_PARCEL(output.writeFloat, frameRate);
162 SAFE_PARCEL(output.writeByte, frameRateCompatibility);
Marin Shalamanovc5986772021-03-16 16:09:49 +0100163 SAFE_PARCEL(output.writeByte, changeFrameRateStrategy);
Andy Labrada096227e2022-06-15 16:58:11 +0000164 SAFE_PARCEL(output.writeByte, defaultFrameRateCompatibility);
Rachel Leece6e0042023-06-27 11:22:54 -0700165 SAFE_PARCEL(output.writeByte, frameRateCategory);
Rachel Lee67afbea2023-09-28 15:35:07 -0700166 SAFE_PARCEL(output.writeBool, frameRateCategorySmoothSwitchOnly);
Rachel Lee58cc90d2023-09-05 18:50:20 -0700167 SAFE_PARCEL(output.writeByte, frameRateSelectionStrategy);
chaviw308ddba2020-08-11 16:23:51 -0700168 SAFE_PARCEL(output.writeUint32, fixedTransformHint);
Vishnu Naircf26a0a2020-11-13 12:56:20 -0800169 SAFE_PARCEL(output.writeBool, autoRefresh);
Sally Qi81d95e62022-03-21 19:41:33 -0700170 SAFE_PARCEL(output.writeBool, dimmingEnabled);
Lucas Dupinc3800b82020-10-02 16:24:48 -0700171
172 SAFE_PARCEL(output.writeUint32, blurRegions.size());
173 for (auto region : blurRegions) {
174 SAFE_PARCEL(output.writeUint32, region.blurRadius);
175 SAFE_PARCEL(output.writeFloat, region.cornerRadiusTL);
176 SAFE_PARCEL(output.writeFloat, region.cornerRadiusTR);
177 SAFE_PARCEL(output.writeFloat, region.cornerRadiusBL);
178 SAFE_PARCEL(output.writeFloat, region.cornerRadiusBR);
179 SAFE_PARCEL(output.writeFloat, region.alpha);
180 SAFE_PARCEL(output.writeInt32, region.left);
181 SAFE_PARCEL(output.writeInt32, region.top);
182 SAFE_PARCEL(output.writeInt32, region.right);
183 SAFE_PARCEL(output.writeInt32, region.bottom);
184 }
John Reckcdb4ed72021-02-04 13:39:33 -0500185
186 SAFE_PARCEL(output.write, stretchEffect);
Marzia Favarodcc9d9b2024-01-10 10:17:00 +0000187 SAFE_PARCEL(output.writeParcelable, edgeExtensionParameters);
chaviwf3f40fe2021-04-27 15:54:02 -0500188 SAFE_PARCEL(output.write, bufferCrop);
Vishnu Nair6bdec7d2021-05-10 15:01:13 -0700189 SAFE_PARCEL(output.write, destinationFrame);
Vishnu Nair9e0017e2024-05-22 19:02:44 +0000190 SAFE_PARCEL(output.writeInt32, static_cast<uint32_t>(trustedOverlay));
John Reckcdb4ed72021-02-04 13:39:33 -0500191
Vishnu Nair9cf4a4d2021-09-17 12:16:08 -0700192 SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dropInputMode));
Vishnu Nair685cfef2022-02-02 10:01:25 -0800193
194 const bool hasBufferData = (bufferData != nullptr);
195 SAFE_PARCEL(output.writeBool, hasBufferData);
196 if (hasBufferData) {
197 SAFE_PARCEL(output.writeParcelable, *bufferData);
198 }
Chavi Weingarten076acac2023-01-19 17:20:43 +0000199 SAFE_PARCEL(output.writeParcelable, trustedPresentationThresholds);
200 SAFE_PARCEL(output.writeParcelable, trustedPresentationListener);
Sally Qi963049b2023-03-23 14:06:21 -0700201 SAFE_PARCEL(output.writeFloat, currentHdrSdrRatio);
202 SAFE_PARCEL(output.writeFloat, desiredHdrSdrRatio);
Vishnu Nair59a6be32024-01-29 10:26:21 -0800203 SAFE_PARCEL(output.writeInt32, static_cast<int32_t>(cachingHint));
Patrick Williamsf693bcf2024-08-02 09:55:23 -0500204
205 const bool hasBufferReleaseChannel = (bufferReleaseChannel != nullptr);
206 SAFE_PARCEL(output.writeBool, hasBufferReleaseChannel);
207 if (hasBufferReleaseChannel) {
208 SAFE_PARCEL(output.writeParcelable, *bufferReleaseChannel);
209 }
Brian Lindahl07dcd492024-10-30 11:43:23 -0600210#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS_APPLY_PICTURE_PROFILES
211 SAFE_PARCEL(output.writeInt64, pictureProfileHandle.getId());
212 SAFE_PARCEL(output.writeInt32, appContentPriority);
213#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS_APPLY_PICTURE_PROFILES
Patrick Williamsf693bcf2024-08-02 09:55:23 -0500214
Sally Qief006582024-10-11 13:23:09 -0700215 const bool hasLuts = (luts != nullptr);
216 SAFE_PARCEL(output.writeBool, hasLuts);
217 if (hasLuts) {
218 SAFE_PARCEL(output.writeParcelable, *luts);
219 }
220
Mathias Agopianac9fa422013-02-11 16:40:36 -0800221 return NO_ERROR;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800222}
223
224status_t layer_state_t::read(const Parcel& input)
225{
chaviw308ddba2020-08-11 16:23:51 -0700226 SAFE_PARCEL(input.readNullableStrongBinder, &surface);
Pablo Gamitodbc31672020-09-01 18:28:58 +0000227 SAFE_PARCEL(input.readInt32, &layerId);
chaviw308ddba2020-08-11 16:23:51 -0700228 SAFE_PARCEL(input.readUint64, &what);
229 SAFE_PARCEL(input.readFloat, &x);
230 SAFE_PARCEL(input.readFloat, &y);
231 SAFE_PARCEL(input.readInt32, &z);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700232 SAFE_PARCEL(input.readUint32, &layerStack.id);
Robert Carr2c358bf2018-08-08 15:58:15 -0700233
Vishnu Nairf6eddb62021-01-27 22:02:11 -0800234 SAFE_PARCEL(input.readUint32, &flags);
chaviw308ddba2020-08-11 16:23:51 -0700235
Vishnu Nairf6eddb62021-01-27 22:02:11 -0800236 SAFE_PARCEL(input.readUint32, &mask);
chaviw308ddba2020-08-11 16:23:51 -0700237
238 SAFE_PARCEL(matrix.read, input);
Vishnu Naira9123c82024-10-03 03:56:44 +0000239 SAFE_PARCEL(input.readFloat, &crop.top);
240 SAFE_PARCEL(input.readFloat, &crop.left);
241 SAFE_PARCEL(input.readFloat, &crop.bottom);
242 SAFE_PARCEL(input.readFloat, &crop.right);
chaviw308ddba2020-08-11 16:23:51 -0700243
Pablo Gamito11dcc222020-09-12 15:49:39 +0000244 SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &relativeLayerSurfaceControl);
245 SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &parentSurfaceControlForChild);
246
chaviw308ddba2020-08-11 16:23:51 -0700247 float tmpFloat = 0;
chaviw308ddba2020-08-11 16:23:51 -0700248 SAFE_PARCEL(input.readFloat, &tmpFloat);
249 color.r = tmpFloat;
250 SAFE_PARCEL(input.readFloat, &tmpFloat);
251 color.g = tmpFloat;
252 SAFE_PARCEL(input.readFloat, &tmpFloat);
253 color.b = tmpFloat;
Vishnu Nairbbceb462022-10-10 04:52:13 +0000254 SAFE_PARCEL(input.readFloat, &tmpFloat);
255 color.a = tmpFloat;
256
chaviw98318de2021-05-19 16:45:23 -0500257 SAFE_PARCEL(windowInfoHandle->readFromParcel, &input);
Robert Carr2c358bf2018-08-08 15:58:15 -0700258
chaviw308ddba2020-08-11 16:23:51 -0700259 SAFE_PARCEL(input.read, transparentRegion);
Vishnu Nairbbceb462022-10-10 04:52:13 +0000260 SAFE_PARCEL(input.readUint32, &bufferTransform);
chaviw308ddba2020-08-11 16:23:51 -0700261 SAFE_PARCEL(input.readBool, &transformToDisplayInverse);
chaviw308ddba2020-08-11 16:23:51 -0700262
Vishnu Nairf6eddb62021-01-27 22:02:11 -0800263 uint32_t tmpUint32 = 0;
chaviw308ddba2020-08-11 16:23:51 -0700264 SAFE_PARCEL(input.readUint32, &tmpUint32);
265 dataspace = static_cast<ui::Dataspace>(tmpUint32);
266
267 SAFE_PARCEL(input.read, hdrMetadata);
268 SAFE_PARCEL(input.read, surfaceDamageRegion);
269 SAFE_PARCEL(input.readInt32, &api);
chaviwba4320c2021-09-15 15:20:53 -0500270
271 bool tmpBool = false;
chaviw308ddba2020-08-11 16:23:51 -0700272 SAFE_PARCEL(input.readBool, &tmpBool);
273 if (tmpBool) {
Marissa Wall61c58622018-07-18 10:12:20 -0700274 sidebandStream = NativeHandle::create(input.readNativeHandle(), true);
275 }
276
chaviw308ddba2020-08-11 16:23:51 -0700277 SAFE_PARCEL(input.read, &colorTransform, 16 * sizeof(float));
278 SAFE_PARCEL(input.readFloat, &cornerRadius);
Surbhi Kadam9674ffa2024-11-14 23:06:27 +0000279 SAFE_PARCEL(input.readFloat, &clientDrawnCornerRadius);
chaviw308ddba2020-08-11 16:23:51 -0700280 SAFE_PARCEL(input.readUint32, &backgroundBlurRadius);
chaviw308ddba2020-08-11 16:23:51 -0700281 SAFE_PARCEL(input.readParcelable, &metadata);
Marissa Wallebc2c052019-01-16 19:16:55 -0800282
Vishnu Naird47bcee2023-02-24 18:08:51 +0000283 SAFE_PARCEL(input.readFloat, &tmpFloat);
284 bgColor.r = tmpFloat;
285 SAFE_PARCEL(input.readFloat, &tmpFloat);
286 bgColor.g = tmpFloat;
287 SAFE_PARCEL(input.readFloat, &tmpFloat);
288 bgColor.b = tmpFloat;
289 SAFE_PARCEL(input.readFloat, &tmpFloat);
290 bgColor.a = tmpFloat;
chaviw308ddba2020-08-11 16:23:51 -0700291 SAFE_PARCEL(input.readUint32, &tmpUint32);
292 bgColorDataspace = static_cast<ui::Dataspace>(tmpUint32);
293 SAFE_PARCEL(input.readBool, &colorSpaceAgnostic);
Valerie Haued54efa2019-01-11 20:03:14 -0800294
chaviw308ddba2020-08-11 16:23:51 -0700295 int32_t numListeners = 0;
296 SAFE_PARCEL_READ_SIZE(input.readInt32, &numListeners, input.dataSize());
Valerie Hau9dab9732019-08-20 09:29:25 -0700297 listeners.clear();
298 for (int i = 0; i < numListeners; i++) {
chaviw308ddba2020-08-11 16:23:51 -0700299 sp<IBinder> listener;
Valerie Hau9dab9732019-08-20 09:29:25 -0700300 std::vector<CallbackId> callbackIds;
chaviw308ddba2020-08-11 16:23:51 -0700301 SAFE_PARCEL(input.readNullableStrongBinder, &listener);
Vishnu Nairfc46c1e2021-04-21 08:31:32 -0700302 SAFE_PARCEL(input.readParcelableVector, &callbackIds);
Valerie Hau9dab9732019-08-20 09:29:25 -0700303 listeners.emplace_back(listener, callbackIds);
304 }
chaviw308ddba2020-08-11 16:23:51 -0700305 SAFE_PARCEL(input.readFloat, &shadowRadius);
306 SAFE_PARCEL(input.readInt32, &frameRateSelectionPriority);
307 SAFE_PARCEL(input.readFloat, &frameRate);
308 SAFE_PARCEL(input.readByte, &frameRateCompatibility);
Marin Shalamanovc5986772021-03-16 16:09:49 +0100309 SAFE_PARCEL(input.readByte, &changeFrameRateStrategy);
Andy Labrada096227e2022-06-15 16:58:11 +0000310 SAFE_PARCEL(input.readByte, &defaultFrameRateCompatibility);
Rachel Leece6e0042023-06-27 11:22:54 -0700311 SAFE_PARCEL(input.readByte, &frameRateCategory);
Rachel Lee67afbea2023-09-28 15:35:07 -0700312 SAFE_PARCEL(input.readBool, &frameRateCategorySmoothSwitchOnly);
Rachel Lee58cc90d2023-09-05 18:50:20 -0700313 SAFE_PARCEL(input.readByte, &frameRateSelectionStrategy);
chaviw308ddba2020-08-11 16:23:51 -0700314 SAFE_PARCEL(input.readUint32, &tmpUint32);
315 fixedTransformHint = static_cast<ui::Transform::RotationFlags>(tmpUint32);
Vishnu Naircf26a0a2020-11-13 12:56:20 -0800316 SAFE_PARCEL(input.readBool, &autoRefresh);
Sally Qi81d95e62022-03-21 19:41:33 -0700317 SAFE_PARCEL(input.readBool, &dimmingEnabled);
Lucas Dupinc3800b82020-10-02 16:24:48 -0700318
319 uint32_t numRegions = 0;
320 SAFE_PARCEL(input.readUint32, &numRegions);
321 blurRegions.clear();
322 for (uint32_t i = 0; i < numRegions; i++) {
323 BlurRegion region;
324 SAFE_PARCEL(input.readUint32, &region.blurRadius);
325 SAFE_PARCEL(input.readFloat, &region.cornerRadiusTL);
326 SAFE_PARCEL(input.readFloat, &region.cornerRadiusTR);
327 SAFE_PARCEL(input.readFloat, &region.cornerRadiusBL);
328 SAFE_PARCEL(input.readFloat, &region.cornerRadiusBR);
329 SAFE_PARCEL(input.readFloat, &region.alpha);
330 SAFE_PARCEL(input.readInt32, &region.left);
331 SAFE_PARCEL(input.readInt32, &region.top);
332 SAFE_PARCEL(input.readInt32, &region.right);
333 SAFE_PARCEL(input.readInt32, &region.bottom);
334 blurRegions.push_back(region);
335 }
John Reckcdb4ed72021-02-04 13:39:33 -0500336
337 SAFE_PARCEL(input.read, stretchEffect);
Marzia Favarodcc9d9b2024-01-10 10:17:00 +0000338 SAFE_PARCEL(input.readParcelable, &edgeExtensionParameters);
chaviwf3f40fe2021-04-27 15:54:02 -0500339 SAFE_PARCEL(input.read, bufferCrop);
Vishnu Nair6bdec7d2021-05-10 15:01:13 -0700340 SAFE_PARCEL(input.read, destinationFrame);
Vishnu Nair9e0017e2024-05-22 19:02:44 +0000341 uint32_t trustedOverlayInt;
342 SAFE_PARCEL(input.readUint32, &trustedOverlayInt);
343 trustedOverlay = static_cast<gui::TrustedOverlay>(trustedOverlayInt);
John Reckcdb4ed72021-02-04 13:39:33 -0500344
Vishnu Nair9cf4a4d2021-09-17 12:16:08 -0700345 uint32_t mode;
346 SAFE_PARCEL(input.readUint32, &mode);
347 dropInputMode = static_cast<gui::DropInputMode>(mode);
Vishnu Nair685cfef2022-02-02 10:01:25 -0800348
349 bool hasBufferData;
350 SAFE_PARCEL(input.readBool, &hasBufferData);
351 if (hasBufferData) {
352 bufferData = std::make_shared<BufferData>();
353 SAFE_PARCEL(input.readParcelable, bufferData.get());
354 } else {
355 bufferData = nullptr;
356 }
Chavi Weingarten076acac2023-01-19 17:20:43 +0000357
358 SAFE_PARCEL(input.readParcelable, &trustedPresentationThresholds);
359 SAFE_PARCEL(input.readParcelable, &trustedPresentationListener);
360
John Reck68796592023-01-25 13:47:12 -0500361 SAFE_PARCEL(input.readFloat, &tmpFloat);
Sally Qi963049b2023-03-23 14:06:21 -0700362 currentHdrSdrRatio = tmpFloat;
John Reck68796592023-01-25 13:47:12 -0500363 SAFE_PARCEL(input.readFloat, &tmpFloat);
Sally Qi963049b2023-03-23 14:06:21 -0700364 desiredHdrSdrRatio = tmpFloat;
John Reck68796592023-01-25 13:47:12 -0500365
Alec Mourif4af03e2023-02-11 00:25:24 +0000366 int32_t tmpInt32;
367 SAFE_PARCEL(input.readInt32, &tmpInt32);
368 cachingHint = static_cast<gui::CachingHint>(tmpInt32);
369
Patrick Williamsf693bcf2024-08-02 09:55:23 -0500370 bool hasBufferReleaseChannel;
371 SAFE_PARCEL(input.readBool, &hasBufferReleaseChannel);
372 if (hasBufferReleaseChannel) {
373 bufferReleaseChannel = std::make_shared<gui::BufferReleaseChannel::ProducerEndpoint>();
374 SAFE_PARCEL(input.readParcelable, bufferReleaseChannel.get());
375 }
Brian Lindahl07dcd492024-10-30 11:43:23 -0600376#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS_APPLY_PICTURE_PROFILES
377 int64_t pictureProfileId;
378 SAFE_PARCEL(input.readInt64, &pictureProfileId);
379 pictureProfileHandle = PictureProfileHandle(pictureProfileId);
380 SAFE_PARCEL(input.readInt32, &appContentPriority);
381#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS_APPLY_PICTURE_PROFILES
Patrick Williamsf693bcf2024-08-02 09:55:23 -0500382
Sally Qief006582024-10-11 13:23:09 -0700383 bool hasLuts;
384 SAFE_PARCEL(input.readBool, &hasLuts);
385 if (hasLuts) {
386 luts = std::make_shared<gui::DisplayLuts>();
387 SAFE_PARCEL(input.readParcelable, luts.get());
388 } else {
389 luts = nullptr;
390 }
391
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800392 return NO_ERROR;
393}
394
Mathias Agopian698c0872011-06-28 19:09:31 -0700395status_t ComposerState::write(Parcel& output) const {
Mathias Agopian698c0872011-06-28 19:09:31 -0700396 return state.write(output);
397}
398
399status_t ComposerState::read(const Parcel& input) {
Mathias Agopian698c0872011-06-28 19:09:31 -0700400 return state.read(input);
401}
402
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700403DisplayState::DisplayState() = default;
Pablo Ceballos60d69222015-08-07 14:47:20 -0700404
Mathias Agopian8b33f032012-07-24 20:43:54 -0700405status_t DisplayState::write(Parcel& output) const {
chaviw308ddba2020-08-11 16:23:51 -0700406 SAFE_PARCEL(output.writeStrongBinder, token);
407 SAFE_PARCEL(output.writeStrongBinder, IInterface::asBinder(surface));
408 SAFE_PARCEL(output.writeUint32, what);
Evan Rosky2239b372021-05-20 13:43:47 -0700409 SAFE_PARCEL(output.writeUint32, flags);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700410 SAFE_PARCEL(output.writeUint32, layerStack.id);
chaviw308ddba2020-08-11 16:23:51 -0700411 SAFE_PARCEL(output.writeUint32, toRotationInt(orientation));
412 SAFE_PARCEL(output.write, layerStackSpaceRect);
413 SAFE_PARCEL(output.write, orientedDisplaySpaceRect);
414 SAFE_PARCEL(output.writeUint32, width);
415 SAFE_PARCEL(output.writeUint32, height);
Mathias Agopian8b33f032012-07-24 20:43:54 -0700416 return NO_ERROR;
417}
418
419status_t DisplayState::read(const Parcel& input) {
chaviw308ddba2020-08-11 16:23:51 -0700420 SAFE_PARCEL(input.readStrongBinder, &token);
421 sp<IBinder> tmpBinder;
422 SAFE_PARCEL(input.readNullableStrongBinder, &tmpBinder);
423 surface = interface_cast<IGraphicBufferProducer>(tmpBinder);
424
425 SAFE_PARCEL(input.readUint32, &what);
Evan Rosky2239b372021-05-20 13:43:47 -0700426 SAFE_PARCEL(input.readUint32, &flags);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700427 SAFE_PARCEL(input.readUint32, &layerStack.id);
chaviw308ddba2020-08-11 16:23:51 -0700428 uint32_t tmpUint = 0;
429 SAFE_PARCEL(input.readUint32, &tmpUint);
430 orientation = ui::toRotation(tmpUint);
431
432 SAFE_PARCEL(input.read, layerStackSpaceRect);
433 SAFE_PARCEL(input.read, orientedDisplaySpaceRect);
434 SAFE_PARCEL(input.readUint32, &width);
435 SAFE_PARCEL(input.readUint32, &height);
Mathias Agopian8b33f032012-07-24 20:43:54 -0700436 return NO_ERROR;
437}
438
Robert Carr2c5f6d22017-09-26 12:30:35 -0700439void DisplayState::merge(const DisplayState& other) {
440 if (other.what & eSurfaceChanged) {
441 what |= eSurfaceChanged;
442 surface = other.surface;
443 }
444 if (other.what & eLayerStackChanged) {
445 what |= eLayerStackChanged;
446 layerStack = other.layerStack;
447 }
Evan Rosky2239b372021-05-20 13:43:47 -0700448 if (other.what & eFlagsChanged) {
449 what |= eFlagsChanged;
450 flags = other.flags;
451 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700452 if (other.what & eDisplayProjectionChanged) {
453 what |= eDisplayProjectionChanged;
454 orientation = other.orientation;
Marin Shalamanov6ad317c2020-07-29 23:34:07 +0200455 layerStackSpaceRect = other.layerStackSpaceRect;
456 orientedDisplaySpaceRect = other.orientedDisplaySpaceRect;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700457 }
458 if (other.what & eDisplaySizeChanged) {
459 what |= eDisplaySizeChanged;
460 width = other.width;
461 height = other.height;
462 }
463}
464
Sally Qi6bb12822022-10-05 11:42:30 -0700465void DisplayState::sanitize(int32_t permissions) {
466 if (what & DisplayState::eLayerStackChanged) {
467 if (!(permissions & layer_state_t::Permission::ACCESS_SURFACE_FLINGER)) {
468 what &= ~DisplayState::eLayerStackChanged;
469 ALOGE("Stripped attempt to set eLayerStackChanged in sanitize");
470 }
471 }
472 if (what & DisplayState::eDisplayProjectionChanged) {
473 if (!(permissions & layer_state_t::Permission::ACCESS_SURFACE_FLINGER)) {
474 what &= ~DisplayState::eDisplayProjectionChanged;
475 ALOGE("Stripped attempt to set eDisplayProjectionChanged in sanitize");
476 }
477 }
478 if (what & DisplayState::eSurfaceChanged) {
479 if (!(permissions & layer_state_t::Permission::ACCESS_SURFACE_FLINGER)) {
480 what &= ~DisplayState::eSurfaceChanged;
481 ALOGE("Stripped attempt to set eSurfaceChanged in sanitize");
482 }
483 }
484}
485
Robert Carrde6d7b42022-01-07 18:23:06 -0800486void layer_state_t::sanitize(int32_t permissions) {
487 // TODO: b/109894387
488 //
489 // SurfaceFlinger's renderer is not prepared to handle cropping in the face of arbitrary
490 // rotation. To see the problem observe that if we have a square parent, and a child
491 // of the same size, then we rotate the child 45 degrees around its center, the child
492 // must now be cropped to a non rectangular 8 sided region.
493 //
494 // Of course we can fix this in the future. For now, we are lucky, SurfaceControl is
495 // private API, and arbitrary rotation is used in limited use cases, for instance:
496 // - WindowManager only uses rotation in one case, which is on a top level layer in which
497 // cropping is not an issue.
498 // - Launcher, as a privileged app, uses this to transition an application to PiP
499 // (picture-in-picture) mode.
500 //
501 // However given that abuse of rotation matrices could lead to surfaces extending outside
502 // of cropped areas, we need to prevent non-root clients without permission
503 // ACCESS_SURFACE_FLINGER nor ROTATE_SURFACE_FLINGER
504 // (a.k.a. everyone except WindowManager / tests / Launcher) from setting non rectangle
505 // preserving transformations.
506 if (what & eMatrixChanged) {
507 if (!(permissions & Permission::ROTATE_SURFACE_FLINGER)) {
508 ui::Transform t;
509 t.set(matrix.dsdx, matrix.dtdy, matrix.dtdx, matrix.dsdy);
510 if (!t.preserveRects()) {
511 what &= ~eMatrixChanged;
512 ALOGE("Stripped non rect preserving matrix in sanitize");
513 }
514 }
515 }
516
517 if (what & eFlagsChanged) {
518 if ((flags & eLayerIsDisplayDecoration) &&
519 !(permissions & Permission::INTERNAL_SYSTEM_WINDOW)) {
520 flags &= ~eLayerIsDisplayDecoration;
521 ALOGE("Stripped attempt to set LayerIsDisplayDecoration in sanitize");
522 }
Vishnu Nair59a6be32024-01-29 10:26:21 -0800523 if ((mask & eCanOccludePresentation) &&
524 !(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
525 flags &= ~eCanOccludePresentation;
526 mask &= ~eCanOccludePresentation;
527 ALOGE("Stripped attempt to set eCanOccludePresentation in sanitize");
528 }
Robert Carrde6d7b42022-01-07 18:23:06 -0800529 }
530
531 if (what & layer_state_t::eInputInfoChanged) {
532 if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
533 what &= ~eInputInfoChanged;
534 ALOGE("Stripped attempt to set eInputInfoChanged in sanitize");
535 }
536 }
537 if (what & layer_state_t::eTrustedOverlayChanged) {
538 if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
539 what &= ~eTrustedOverlayChanged;
540 ALOGE("Stripped attempt to set eTrustedOverlay in sanitize");
541 }
542 }
543 if (what & layer_state_t::eDropInputModeChanged) {
544 if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
545 what &= ~eDropInputModeChanged;
546 ALOGE("Stripped attempt to set eDropInputModeChanged in sanitize");
547 }
548 }
549 if (what & layer_state_t::eFrameRateSelectionPriority) {
550 if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
551 what &= ~eFrameRateSelectionPriority;
552 ALOGE("Stripped attempt to set eFrameRateSelectionPriority in sanitize");
553 }
554 }
555 if (what & layer_state_t::eFrameRateChanged) {
556 if (!ValidateFrameRate(frameRate, frameRateCompatibility,
557 changeFrameRateStrategy,
558 "layer_state_t::sanitize",
559 permissions & Permission::ACCESS_SURFACE_FLINGER)) {
560 what &= ~eFrameRateChanged; // logged in ValidateFrameRate
561 }
562 }
563}
564
Robert Carr2c5f6d22017-09-26 12:30:35 -0700565void layer_state_t::merge(const layer_state_t& other) {
566 if (other.what & ePositionChanged) {
567 what |= ePositionChanged;
568 x = other.x;
569 y = other.y;
570 }
571 if (other.what & eLayerChanged) {
572 what |= eLayerChanged;
chaviw32377582019-05-13 11:15:19 -0700573 what &= ~eRelativeLayerChanged;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700574 z = other.z;
575 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700576 if (other.what & eAlphaChanged) {
577 what |= eAlphaChanged;
Vishnu Nairbbceb462022-10-10 04:52:13 +0000578 color.a = other.color.a;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700579 }
580 if (other.what & eMatrixChanged) {
581 what |= eMatrixChanged;
582 matrix = other.matrix;
583 }
584 if (other.what & eTransparentRegionChanged) {
585 what |= eTransparentRegionChanged;
586 transparentRegion = other.transparentRegion;
587 }
588 if (other.what & eFlagsChanged) {
589 what |= eFlagsChanged;
Vishnu Nair996bc422019-07-16 14:15:33 -0700590 flags &= ~other.mask;
591 flags |= (other.flags & other.mask);
592 mask |= other.mask;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700593 }
594 if (other.what & eLayerStackChanged) {
595 what |= eLayerStackChanged;
596 layerStack = other.layerStack;
597 }
Lucas Dupin1b6531c2018-07-05 17:18:21 -0700598 if (other.what & eCornerRadiusChanged) {
599 what |= eCornerRadiusChanged;
600 cornerRadius = other.cornerRadius;
601 }
Surbhi Kadam9674ffa2024-11-14 23:06:27 +0000602 if (other.what & eClientDrawnCornerRadiusChanged) {
603 what |= eClientDrawnCornerRadiusChanged;
604 clientDrawnCornerRadius = other.clientDrawnCornerRadius;
605 }
Lucas Dupin19c8f0e2019-11-25 17:55:44 -0800606 if (other.what & eBackgroundBlurRadiusChanged) {
607 what |= eBackgroundBlurRadiusChanged;
608 backgroundBlurRadius = other.backgroundBlurRadius;
609 }
Lucas Dupinc3800b82020-10-02 16:24:48 -0700610 if (other.what & eBlurRegionsChanged) {
611 what |= eBlurRegionsChanged;
612 blurRegions = other.blurRegions;
613 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700614 if (other.what & eRelativeLayerChanged) {
615 what |= eRelativeLayerChanged;
chaviw32377582019-05-13 11:15:19 -0700616 what &= ~eLayerChanged;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700617 z = other.z;
Pablo Gamito11dcc222020-09-12 15:49:39 +0000618 relativeLayerSurfaceControl = other.relativeLayerSurfaceControl;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700619 }
620 if (other.what & eReparent) {
621 what |= eReparent;
Pablo Gamito11dcc222020-09-12 15:49:39 +0000622 parentSurfaceControlForChild = other.parentSurfaceControlForChild;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700623 }
Vishnu Nairbbceb462022-10-10 04:52:13 +0000624 if (other.what & eBufferTransformChanged) {
625 what |= eBufferTransformChanged;
626 bufferTransform = other.bufferTransform;
Marissa Wall61c58622018-07-18 10:12:20 -0700627 }
628 if (other.what & eTransformToDisplayInverseChanged) {
629 what |= eTransformToDisplayInverseChanged;
630 transformToDisplayInverse = other.transformToDisplayInverse;
631 }
632 if (other.what & eCropChanged) {
633 what |= eCropChanged;
634 crop = other.crop;
635 }
636 if (other.what & eBufferChanged) {
637 what |= eBufferChanged;
chaviwba4320c2021-09-15 15:20:53 -0500638 bufferData = other.bufferData;
Marissa Wall61c58622018-07-18 10:12:20 -0700639 }
Chavi Weingarten076acac2023-01-19 17:20:43 +0000640 if (other.what & eTrustedPresentationInfoChanged) {
641 what |= eTrustedPresentationInfoChanged;
642 trustedPresentationListener = other.trustedPresentationListener;
643 trustedPresentationThresholds = other.trustedPresentationThresholds;
644 }
Marissa Wall61c58622018-07-18 10:12:20 -0700645 if (other.what & eDataspaceChanged) {
646 what |= eDataspaceChanged;
647 dataspace = other.dataspace;
648 }
John Reck68796592023-01-25 13:47:12 -0500649 if (other.what & eExtendedRangeBrightnessChanged) {
650 what |= eExtendedRangeBrightnessChanged;
Sally Qi963049b2023-03-23 14:06:21 -0700651 desiredHdrSdrRatio = other.desiredHdrSdrRatio;
652 currentHdrSdrRatio = other.currentHdrSdrRatio;
John Reck68796592023-01-25 13:47:12 -0500653 }
Alec Mouri1b0d4e12024-02-12 22:27:19 +0000654 if (other.what & eDesiredHdrHeadroomChanged) {
655 what |= eDesiredHdrHeadroomChanged;
656 desiredHdrSdrRatio = other.desiredHdrSdrRatio;
657 }
Alec Mourif4af03e2023-02-11 00:25:24 +0000658 if (other.what & eCachingHintChanged) {
659 what |= eCachingHintChanged;
660 cachingHint = other.cachingHint;
661 }
Marissa Wall61c58622018-07-18 10:12:20 -0700662 if (other.what & eHdrMetadataChanged) {
663 what |= eHdrMetadataChanged;
664 hdrMetadata = other.hdrMetadata;
665 }
666 if (other.what & eSurfaceDamageRegionChanged) {
667 what |= eSurfaceDamageRegionChanged;
668 surfaceDamageRegion = other.surfaceDamageRegion;
669 }
670 if (other.what & eApiChanged) {
671 what |= eApiChanged;
672 api = other.api;
673 }
674 if (other.what & eSidebandStreamChanged) {
675 what |= eSidebandStreamChanged;
676 sidebandStream = other.sidebandStream;
677 }
Peiyong Lind3788632018-09-18 16:01:31 -0700678 if (other.what & eColorTransformChanged) {
679 what |= eColorTransformChanged;
680 colorTransform = other.colorTransform;
681 }
Marissa Wall3dad52d2019-03-22 14:03:19 -0700682 if (other.what & eHasListenerCallbacksChanged) {
683 what |= eHasListenerCallbacksChanged;
Marissa Wallc837b5e2018-10-12 10:04:44 -0700684 }
Robert Carr2c358bf2018-08-08 15:58:15 -0700685 if (other.what & eInputInfoChanged) {
686 what |= eInputInfoChanged;
Priyanka Advani (xWF)f73db7a2025-02-19 17:35:16 -0800687 windowInfoHandle = new WindowInfoHandle(*other.windowInfoHandle);
Robert Carr2c358bf2018-08-08 15:58:15 -0700688 }
Valerie Haudd0b7572019-01-29 14:59:27 -0800689 if (other.what & eBackgroundColorChanged) {
690 what |= eBackgroundColorChanged;
Vishnu Naird47bcee2023-02-24 18:08:51 +0000691 bgColor = other.bgColor;
Valerie Haudd0b7572019-01-29 14:59:27 -0800692 bgColorDataspace = other.bgColorDataspace;
Valerie Haued54efa2019-01-11 20:03:14 -0800693 }
Evan Rosky1f6d6d52018-12-06 10:47:26 -0800694 if (other.what & eMetadataChanged) {
695 what |= eMetadataChanged;
696 metadata.merge(other.metadata);
697 }
Vishnu Nairc97b8db2019-10-29 18:19:35 -0700698 if (other.what & eShadowRadiusChanged) {
699 what |= eShadowRadiusChanged;
700 shadowRadius = other.shadowRadius;
701 }
Sally Qi0abc4a52024-09-26 16:13:06 -0700702 if (other.what & eLutsChanged) {
703 what |= eLutsChanged;
704 luts = other.luts;
705 }
Andy Labrada096227e2022-06-15 16:58:11 +0000706 if (other.what & eDefaultFrameRateCompatibilityChanged) {
707 what |= eDefaultFrameRateCompatibilityChanged;
708 defaultFrameRateCompatibility = other.defaultFrameRateCompatibility;
709 }
Ana Krulecc84d09b2019-11-02 23:10:29 +0100710 if (other.what & eFrameRateSelectionPriority) {
711 what |= eFrameRateSelectionPriority;
712 frameRateSelectionPriority = other.frameRateSelectionPriority;
713 }
Steven Thomas3172e202020-01-06 19:25:30 -0800714 if (other.what & eFrameRateChanged) {
715 what |= eFrameRateChanged;
716 frameRate = other.frameRate;
Steven Thomas62a4cf82020-01-31 12:04:03 -0800717 frameRateCompatibility = other.frameRateCompatibility;
Marin Shalamanovc5986772021-03-16 16:09:49 +0100718 changeFrameRateStrategy = other.changeFrameRateStrategy;
Steven Thomas3172e202020-01-06 19:25:30 -0800719 }
Rachel Leece6e0042023-06-27 11:22:54 -0700720 if (other.what & eFrameRateCategoryChanged) {
721 what |= eFrameRateCategoryChanged;
722 frameRateCategory = other.frameRateCategory;
Rachel Lee67afbea2023-09-28 15:35:07 -0700723 frameRateCategorySmoothSwitchOnly = other.frameRateCategorySmoothSwitchOnly;
Rachel Leece6e0042023-06-27 11:22:54 -0700724 }
Rachel Lee58cc90d2023-09-05 18:50:20 -0700725 if (other.what & eFrameRateSelectionStrategyChanged) {
726 what |= eFrameRateSelectionStrategyChanged;
727 frameRateSelectionStrategy = other.frameRateSelectionStrategy;
728 }
Vishnu Nair6213bd92020-05-08 17:42:25 -0700729 if (other.what & eFixedTransformHintChanged) {
730 what |= eFixedTransformHintChanged;
731 fixedTransformHint = other.fixedTransformHint;
732 }
Vishnu Naircf26a0a2020-11-13 12:56:20 -0800733 if (other.what & eAutoRefreshChanged) {
734 what |= eAutoRefreshChanged;
735 autoRefresh = other.autoRefresh;
736 }
Winson Chunga30f7c92021-06-29 15:42:56 -0700737 if (other.what & eTrustedOverlayChanged) {
738 what |= eTrustedOverlayChanged;
Vishnu Nair9e0017e2024-05-22 19:02:44 +0000739 trustedOverlay = other.trustedOverlay;
Winson Chunga30f7c92021-06-29 15:42:56 -0700740 }
John Reckc00c6692021-02-16 11:37:33 -0500741 if (other.what & eStretchChanged) {
742 what |= eStretchChanged;
743 stretchEffect = other.stretchEffect;
744 }
Marzia Favarodcc9d9b2024-01-10 10:17:00 +0000745 if (other.what & eEdgeExtensionChanged) {
746 what |= eEdgeExtensionChanged;
747 edgeExtensionParameters = other.edgeExtensionParameters;
748 }
chaviwf3f40fe2021-04-27 15:54:02 -0500749 if (other.what & eBufferCropChanged) {
750 what |= eBufferCropChanged;
751 bufferCrop = other.bufferCrop;
752 }
Vishnu Nair6bdec7d2021-05-10 15:01:13 -0700753 if (other.what & eDestinationFrameChanged) {
754 what |= eDestinationFrameChanged;
755 destinationFrame = other.destinationFrame;
756 }
Vishnu Nair0e816872021-07-14 10:53:04 -0700757 if (other.what & eProducerDisconnect) {
758 what |= eProducerDisconnect;
759 }
Vishnu Nair9cf4a4d2021-09-17 12:16:08 -0700760 if (other.what & eDropInputModeChanged) {
761 what |= eDropInputModeChanged;
762 dropInputMode = other.dropInputMode;
763 }
chaviw4c36cd82021-11-18 10:37:33 -0600764 if (other.what & eColorChanged) {
765 what |= eColorChanged;
Vishnu Nairbbceb462022-10-10 04:52:13 +0000766 color.rgb = other.color.rgb;
chaviw4c36cd82021-11-18 10:37:33 -0600767 }
Arthur Hung91b346a2022-03-14 21:36:22 +0800768 if (other.what & eColorSpaceAgnosticChanged) {
769 what |= eColorSpaceAgnosticChanged;
770 colorSpaceAgnostic = other.colorSpaceAgnostic;
771 }
Sally Qi81d95e62022-03-21 19:41:33 -0700772 if (other.what & eDimmingEnabledChanged) {
773 what |= eDimmingEnabledChanged;
774 dimmingEnabled = other.dimmingEnabled;
775 }
Pascal Muetschardb39918f2023-01-27 11:36:11 +0100776 if (other.what & eFlushJankData) {
777 what |= eFlushJankData;
778 }
Patrick Williamsf693bcf2024-08-02 09:55:23 -0500779 if (other.what & eBufferReleaseChannelChanged) {
780 what |= eBufferReleaseChannelChanged;
781 bufferReleaseChannel = other.bufferReleaseChannel;
782 }
Brian Lindahl07dcd492024-10-30 11:43:23 -0600783 if (com_android_graphics_libgui_flags_apply_picture_profiles()) {
784 if (other.what & ePictureProfileHandleChanged) {
785 what |= ePictureProfileHandleChanged;
786 pictureProfileHandle = other.pictureProfileHandle;
787 }
788 if (other.what & eAppContentPriorityChanged) {
789 what |= eAppContentPriorityChanged;
790 appContentPriority = other.appContentPriority;
791 }
792 }
Vishnu Nair217d8e62018-09-12 16:34:49 -0700793 if ((other.what & what) != other.what) {
794 ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? "
Vishnu Nair0e816872021-07-14 10:53:04 -0700795 "other.what=0x%" PRIX64 " what=0x%" PRIX64 " unmerged flags=0x%" PRIX64,
796 other.what, what, (other.what & what) ^ other.what);
Robert Carrd314f162018-08-15 13:12:42 -0700797 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700798}
Mathias Agopian8b33f032012-07-24 20:43:54 -0700799
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000800uint64_t layer_state_t::diff(const layer_state_t& other) const {
801 uint64_t diff = 0;
802 CHECK_DIFF2(diff, ePositionChanged, other, x, y);
803 if (other.what & eLayerChanged) {
804 diff |= eLayerChanged;
805 diff &= ~eRelativeLayerChanged;
806 }
807 CHECK_DIFF(diff, eAlphaChanged, other, color.a);
808 CHECK_DIFF(diff, eMatrixChanged, other, matrix);
809 if (other.what & eTransparentRegionChanged &&
810 (!transparentRegion.hasSameRects(other.transparentRegion))) {
811 diff |= eTransparentRegionChanged;
812 }
813 if (other.what & eFlagsChanged) {
814 uint64_t changedFlags = (flags & other.mask) ^ (other.flags & other.mask);
815 if (changedFlags) diff |= eFlagsChanged;
816 }
817 CHECK_DIFF(diff, eLayerStackChanged, other, layerStack);
818 CHECK_DIFF(diff, eCornerRadiusChanged, other, cornerRadius);
Surbhi Kadam9674ffa2024-11-14 23:06:27 +0000819 CHECK_DIFF(diff, eClientDrawnCornerRadiusChanged, other, clientDrawnCornerRadius);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000820 CHECK_DIFF(diff, eBackgroundBlurRadiusChanged, other, backgroundBlurRadius);
821 if (other.what & eBlurRegionsChanged) diff |= eBlurRegionsChanged;
822 if (other.what & eRelativeLayerChanged) {
823 diff |= eRelativeLayerChanged;
824 diff &= ~eLayerChanged;
825 }
826 if (other.what & eReparent &&
827 !SurfaceControl::isSameSurface(parentSurfaceControlForChild,
828 other.parentSurfaceControlForChild)) {
829 diff |= eReparent;
830 }
831 CHECK_DIFF(diff, eBufferTransformChanged, other, bufferTransform);
832 CHECK_DIFF(diff, eTransformToDisplayInverseChanged, other, transformToDisplayInverse);
833 CHECK_DIFF(diff, eCropChanged, other, crop);
834 if (other.what & eBufferChanged) diff |= eBufferChanged;
835 CHECK_DIFF(diff, eDataspaceChanged, other, dataspace);
Sally Qi963049b2023-03-23 14:06:21 -0700836 CHECK_DIFF2(diff, eExtendedRangeBrightnessChanged, other, currentHdrSdrRatio,
837 desiredHdrSdrRatio);
Alec Mouri1b0d4e12024-02-12 22:27:19 +0000838 CHECK_DIFF(diff, eDesiredHdrHeadroomChanged, other, desiredHdrSdrRatio);
Alec Mourif4af03e2023-02-11 00:25:24 +0000839 CHECK_DIFF(diff, eCachingHintChanged, other, cachingHint);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000840 CHECK_DIFF(diff, eHdrMetadataChanged, other, hdrMetadata);
841 if (other.what & eSurfaceDamageRegionChanged &&
842 (!surfaceDamageRegion.hasSameRects(other.surfaceDamageRegion))) {
843 diff |= eSurfaceDamageRegionChanged;
844 }
845 CHECK_DIFF(diff, eApiChanged, other, api);
846 if (other.what & eSidebandStreamChanged) diff |= eSidebandStreamChanged;
847 CHECK_DIFF(diff, eApiChanged, other, api);
848 CHECK_DIFF(diff, eColorTransformChanged, other, colorTransform);
849 if (other.what & eHasListenerCallbacksChanged) diff |= eHasListenerCallbacksChanged;
850 if (other.what & eInputInfoChanged) diff |= eInputInfoChanged;
Vishnu Naird47bcee2023-02-24 18:08:51 +0000851 CHECK_DIFF2(diff, eBackgroundColorChanged, other, bgColor, bgColorDataspace);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000852 if (other.what & eMetadataChanged) diff |= eMetadataChanged;
853 CHECK_DIFF(diff, eShadowRadiusChanged, other, shadowRadius);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000854 CHECK_DIFF(diff, eDefaultFrameRateCompatibilityChanged, other, defaultFrameRateCompatibility);
855 CHECK_DIFF(diff, eFrameRateSelectionPriority, other, frameRateSelectionPriority);
856 CHECK_DIFF3(diff, eFrameRateChanged, other, frameRate, frameRateCompatibility,
857 changeFrameRateStrategy);
Rachel Lee67afbea2023-09-28 15:35:07 -0700858 CHECK_DIFF2(diff, eFrameRateCategoryChanged, other, frameRateCategory,
859 frameRateCategorySmoothSwitchOnly);
Rachel Lee58cc90d2023-09-05 18:50:20 -0700860 CHECK_DIFF(diff, eFrameRateSelectionStrategyChanged, other, frameRateSelectionStrategy);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000861 CHECK_DIFF(diff, eFixedTransformHintChanged, other, fixedTransformHint);
862 CHECK_DIFF(diff, eAutoRefreshChanged, other, autoRefresh);
Vishnu Nair9e0017e2024-05-22 19:02:44 +0000863 CHECK_DIFF(diff, eTrustedOverlayChanged, other, trustedOverlay);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000864 CHECK_DIFF(diff, eStretchChanged, other, stretchEffect);
Marzia Favarodcc9d9b2024-01-10 10:17:00 +0000865 CHECK_DIFF(diff, eEdgeExtensionChanged, other, edgeExtensionParameters);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000866 CHECK_DIFF(diff, eBufferCropChanged, other, bufferCrop);
867 CHECK_DIFF(diff, eDestinationFrameChanged, other, destinationFrame);
868 if (other.what & eProducerDisconnect) diff |= eProducerDisconnect;
869 CHECK_DIFF(diff, eDropInputModeChanged, other, dropInputMode);
870 CHECK_DIFF(diff, eColorChanged, other, color.rgb);
871 CHECK_DIFF(diff, eColorSpaceAgnosticChanged, other, colorSpaceAgnostic);
872 CHECK_DIFF(diff, eDimmingEnabledChanged, other, dimmingEnabled);
Patrick Williamsf693bcf2024-08-02 09:55:23 -0500873 if (other.what & eBufferReleaseChannelChanged) diff |= eBufferReleaseChannelChanged;
Sally Qi0abc4a52024-09-26 16:13:06 -0700874 if (other.what & eLutsChanged) diff |= eLutsChanged;
Brian Lindahl07dcd492024-10-30 11:43:23 -0600875 CHECK_DIFF(diff, ePictureProfileHandleChanged, other, pictureProfileHandle);
876 CHECK_DIFF(diff, eAppContentPriorityChanged, other, appContentPriority);
Sally Qi0abc4a52024-09-26 16:13:06 -0700877
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000878 return diff;
879}
880
Vishnu Nairddf9b5c2021-03-29 18:53:41 -0700881bool layer_state_t::hasBufferChanges() const {
chaviwba4320c2021-09-15 15:20:53 -0500882 return what & layer_state_t::eBufferChanged;
Vishnu Nairddf9b5c2021-03-29 18:53:41 -0700883}
884
Ady Abraham6e8e3642021-07-08 19:44:07 -0700885bool layer_state_t::hasValidBuffer() const {
Vishnu Nair59f6d2d2022-10-05 16:59:56 -0700886 return bufferData && (bufferData->hasBuffer() || bufferData->cachedBuffer.isValid());
Ady Abraham6e8e3642021-07-08 19:44:07 -0700887}
888
chaviw308ddba2020-08-11 16:23:51 -0700889status_t layer_state_t::matrix22_t::write(Parcel& output) const {
890 SAFE_PARCEL(output.writeFloat, dsdx);
891 SAFE_PARCEL(output.writeFloat, dtdx);
892 SAFE_PARCEL(output.writeFloat, dtdy);
893 SAFE_PARCEL(output.writeFloat, dsdy);
894 return NO_ERROR;
895}
896
897status_t layer_state_t::matrix22_t::read(const Parcel& input) {
898 SAFE_PARCEL(input.readFloat, &dsdx);
899 SAFE_PARCEL(input.readFloat, &dtdx);
900 SAFE_PARCEL(input.readFloat, &dtdy);
901 SAFE_PARCEL(input.readFloat, &dsdy);
902 return NO_ERROR;
903}
904
chaviw273171b2018-12-26 11:46:30 -0800905// ------------------------------- InputWindowCommands ----------------------------------------
906
Vishnu Naire798b472020-07-23 13:52:21 -0700907bool InputWindowCommands::merge(const InputWindowCommands& other) {
908 bool changes = false;
Vishnu Naire798b472020-07-23 13:52:21 -0700909 changes |= !other.focusRequests.empty();
910 focusRequests.insert(focusRequests.end(), std::make_move_iterator(other.focusRequests.begin()),
911 std::make_move_iterator(other.focusRequests.end()));
Patrick Williams641f7f22022-06-22 19:25:35 +0000912 changes |= !other.windowInfosReportedListeners.empty();
913 windowInfosReportedListeners.insert(other.windowInfosReportedListeners.begin(),
914 other.windowInfosReportedListeners.end());
Vishnu Naire798b472020-07-23 13:52:21 -0700915 return changes;
chaviw273171b2018-12-26 11:46:30 -0800916}
917
Vishnu Nair958da932020-08-21 17:12:37 -0700918bool InputWindowCommands::empty() const {
Patrick Williams641f7f22022-06-22 19:25:35 +0000919 return focusRequests.empty() && windowInfosReportedListeners.empty();
Vishnu Nair958da932020-08-21 17:12:37 -0700920}
921
chaviw273171b2018-12-26 11:46:30 -0800922void InputWindowCommands::clear() {
Vishnu Naire798b472020-07-23 13:52:21 -0700923 focusRequests.clear();
Patrick Williams641f7f22022-06-22 19:25:35 +0000924 windowInfosReportedListeners.clear();
chaviw273171b2018-12-26 11:46:30 -0800925}
926
chaviw308ddba2020-08-11 16:23:51 -0700927status_t InputWindowCommands::write(Parcel& output) const {
chaviw308ddba2020-08-11 16:23:51 -0700928 SAFE_PARCEL(output.writeParcelableVector, focusRequests);
Patrick Williams641f7f22022-06-22 19:25:35 +0000929
930 SAFE_PARCEL(output.writeInt32, windowInfosReportedListeners.size());
931 for (const auto& listener : windowInfosReportedListeners) {
932 SAFE_PARCEL(output.writeStrongBinder, listener);
933 }
934
chaviw308ddba2020-08-11 16:23:51 -0700935 return NO_ERROR;
chaviw273171b2018-12-26 11:46:30 -0800936}
937
chaviw308ddba2020-08-11 16:23:51 -0700938status_t InputWindowCommands::read(const Parcel& input) {
chaviw308ddba2020-08-11 16:23:51 -0700939 SAFE_PARCEL(input.readParcelableVector, &focusRequests);
Patrick Williams641f7f22022-06-22 19:25:35 +0000940
941 int listenerSize = 0;
942 SAFE_PARCEL_READ_SIZE(input.readInt32, &listenerSize, input.dataSize());
943 windowInfosReportedListeners.reserve(listenerSize);
944 for (int i = 0; i < listenerSize; i++) {
945 sp<gui::IWindowInfosReportedListener> listener;
946 SAFE_PARCEL(input.readStrongBinder, &listener);
947 windowInfosReportedListeners.insert(listener);
948 }
949
chaviw308ddba2020-08-11 16:23:51 -0700950 return NO_ERROR;
chaviw273171b2018-12-26 11:46:30 -0800951}
952
chaviw618c42d2020-07-24 15:25:08 -0700953// ----------------------------------------------------------------------------
954
chaviw8dd181f2022-01-05 18:36:46 -0600955ReleaseCallbackId BufferData::generateReleaseCallbackId() const {
chaviwdcba9e02022-03-21 17:54:23 -0500956 uint64_t bufferId;
957 if (buffer) {
958 bufferId = buffer->getId();
959 } else {
960 bufferId = cachedBuffer.id;
961 }
962 return {bufferId, frameNumber};
chaviw8dd181f2022-01-05 18:36:46 -0600963}
964
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800965status_t BufferData::writeToParcel(Parcel* output) const {
966 SAFE_PARCEL(output->writeInt32, flags.get());
chaviwba4320c2021-09-15 15:20:53 -0500967
968 if (buffer) {
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800969 SAFE_PARCEL(output->writeBool, true);
970 SAFE_PARCEL(output->write, *buffer);
chaviwba4320c2021-09-15 15:20:53 -0500971 } else {
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800972 SAFE_PARCEL(output->writeBool, false);
chaviwba4320c2021-09-15 15:20:53 -0500973 }
974
975 if (acquireFence) {
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800976 SAFE_PARCEL(output->writeBool, true);
977 SAFE_PARCEL(output->write, *acquireFence);
chaviwba4320c2021-09-15 15:20:53 -0500978 } else {
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800979 SAFE_PARCEL(output->writeBool, false);
chaviwba4320c2021-09-15 15:20:53 -0500980 }
981
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800982 SAFE_PARCEL(output->writeUint64, frameNumber);
983 SAFE_PARCEL(output->writeStrongBinder, IInterface::asBinder(releaseBufferListener));
984 SAFE_PARCEL(output->writeStrongBinder, releaseBufferEndpoint);
chaviwba4320c2021-09-15 15:20:53 -0500985
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800986 SAFE_PARCEL(output->writeStrongBinder, cachedBuffer.token.promote());
987 SAFE_PARCEL(output->writeUint64, cachedBuffer.id);
Robert Carr79dc06a2022-02-22 15:28:59 -0800988 SAFE_PARCEL(output->writeBool, hasBarrier);
989 SAFE_PARCEL(output->writeUint64, barrierFrameNumber);
liulijuneb489f62022-10-17 22:02:14 +0800990 SAFE_PARCEL(output->writeUint32, producerId);
Nergi Rahardi39f510f2024-05-23 15:16:54 +0900991 SAFE_PARCEL(output->writeInt64, dequeueTime);
chaviwba4320c2021-09-15 15:20:53 -0500992
993 return NO_ERROR;
994}
995
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800996status_t BufferData::readFromParcel(const Parcel* input) {
chaviwba4320c2021-09-15 15:20:53 -0500997 int32_t tmpInt32;
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800998 SAFE_PARCEL(input->readInt32, &tmpInt32);
Dominik Laskowski2f01d772022-03-23 16:01:29 -0700999 flags = ftl::Flags<BufferDataChange>(tmpInt32);
chaviwba4320c2021-09-15 15:20:53 -05001000
1001 bool tmpBool = false;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001002 SAFE_PARCEL(input->readBool, &tmpBool);
chaviwba4320c2021-09-15 15:20:53 -05001003 if (tmpBool) {
Priyanka Advani (xWF)f73db7a2025-02-19 17:35:16 -08001004 buffer = new GraphicBuffer();
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001005 SAFE_PARCEL(input->read, *buffer);
chaviwba4320c2021-09-15 15:20:53 -05001006 }
1007
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001008 SAFE_PARCEL(input->readBool, &tmpBool);
chaviwba4320c2021-09-15 15:20:53 -05001009 if (tmpBool) {
Priyanka Advani (xWF)f73db7a2025-02-19 17:35:16 -08001010 acquireFence = new Fence();
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001011 SAFE_PARCEL(input->read, *acquireFence);
chaviwba4320c2021-09-15 15:20:53 -05001012 }
1013
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001014 SAFE_PARCEL(input->readUint64, &frameNumber);
chaviwba4320c2021-09-15 15:20:53 -05001015
1016 sp<IBinder> tmpBinder = nullptr;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001017 SAFE_PARCEL(input->readNullableStrongBinder, &tmpBinder);
chaviwba4320c2021-09-15 15:20:53 -05001018 if (tmpBinder) {
1019 releaseBufferListener = checked_interface_cast<ITransactionCompletedListener>(tmpBinder);
1020 }
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001021 SAFE_PARCEL(input->readNullableStrongBinder, &releaseBufferEndpoint);
chaviwba4320c2021-09-15 15:20:53 -05001022
1023 tmpBinder = nullptr;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001024 SAFE_PARCEL(input->readNullableStrongBinder, &tmpBinder);
chaviwba4320c2021-09-15 15:20:53 -05001025 cachedBuffer.token = tmpBinder;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001026 SAFE_PARCEL(input->readUint64, &cachedBuffer.id);
chaviwba4320c2021-09-15 15:20:53 -05001027
Robert Carr79dc06a2022-02-22 15:28:59 -08001028 SAFE_PARCEL(input->readBool, &hasBarrier);
1029 SAFE_PARCEL(input->readUint64, &barrierFrameNumber);
liulijuneb489f62022-10-17 22:02:14 +08001030 SAFE_PARCEL(input->readUint32, &producerId);
Nergi Rahardi39f510f2024-05-23 15:16:54 +09001031 SAFE_PARCEL(input->readInt64, &dequeueTime);
Robert Carr79dc06a2022-02-22 15:28:59 -08001032
chaviwba4320c2021-09-15 15:20:53 -05001033 return NO_ERROR;
1034}
1035
Chavi Weingarten076acac2023-01-19 17:20:43 +00001036status_t TrustedPresentationListener::writeToParcel(Parcel* parcel) const {
1037 SAFE_PARCEL(parcel->writeStrongBinder, callbackInterface);
1038 SAFE_PARCEL(parcel->writeInt32, callbackId);
1039 return NO_ERROR;
1040}
1041
1042status_t TrustedPresentationListener::readFromParcel(const Parcel* parcel) {
1043 sp<IBinder> tmpBinder = nullptr;
1044 SAFE_PARCEL(parcel->readNullableStrongBinder, &tmpBinder);
1045 if (tmpBinder) {
1046 callbackInterface = checked_interface_cast<ITransactionCompletedListener>(tmpBinder);
1047 }
1048 SAFE_PARCEL(parcel->readInt32, &callbackId);
1049 return NO_ERROR;
1050}
1051
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001052}; // namespace android