blob: e1afb524e72f344347619e7a53c066725294e5d1 [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>
20#include <cmath>
Garfield Tan8a3083e2018-12-03 13:21:07 -080021
Huihong Luod3d8f8e2022-03-08 14:48:46 -080022#include <android/gui/ISurfaceComposerClient.h>
Marin Shalamanovc5986772021-03-16 16:09:49 +010023#include <android/native_window.h>
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070024#include <binder/Parcel.h>
Andy McFadden2adaf042012-12-18 09:49:45 -080025#include <gui/IGraphicBufferProducer.h>
Robert Carr4cdc58f2017-08-23 14:22:20 -070026#include <gui/LayerState.h>
Vishnu Nairaa799bd2022-11-16 23:09:09 +000027#include <gui/SurfaceControl.h>
Marin Shalamanov3b1f7bc2021-03-16 15:51:53 +010028#include <private/gui/ParcelUtils.h>
Dominik Laskowski1f6fc702022-03-21 08:34:50 -070029#include <system/window.h>
Pablo Gamito11dcc222020-09-12 15:49:39 +000030#include <utils/Errors.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080031
Vishnu Nairaa799bd2022-11-16 23:09:09 +000032#define CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD) \
33 { \
34 if ((OTHER.what & CHANGE_FLAG) && (FIELD != OTHER.FIELD)) { \
35 DIFF_RESULT |= CHANGE_FLAG; \
36 } \
37 }
38
39#define CHECK_DIFF2(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD1, FIELD2) \
40 { \
41 CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD1) \
42 CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD2) \
43 }
44
45#define CHECK_DIFF3(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD1, FIELD2, FIELD3) \
46 { \
47 CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD1) \
48 CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD2) \
49 CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD3) \
50 }
51
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080052namespace android {
53
chaviw98318de2021-05-19 16:45:23 -050054using gui::FocusRequest;
55using gui::WindowInfoHandle;
56
Pablo Gamito11dcc222020-09-12 15:49:39 +000057layer_state_t::layer_state_t()
Vishnu Nair685cfef2022-02-02 10:01:25 -080058 : surface(nullptr),
59 layerId(-1),
60 what(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000061 x(0),
62 y(0),
63 z(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000064 flags(0),
65 mask(0),
66 reserved(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000067 cornerRadius(0.0f),
68 backgroundBlurRadius(0),
Vishnu Nairbbceb462022-10-10 04:52:13 +000069 color(0),
70 bufferTransform(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000071 transformToDisplayInverse(false),
72 crop(Rect::INVALID_RECT),
Pablo Gamito11dcc222020-09-12 15:49:39 +000073 dataspace(ui::Dataspace::UNKNOWN),
74 surfaceDamageRegion(),
75 api(-1),
76 colorTransform(mat4()),
Vishnu Naird47bcee2023-02-24 18:08:51 +000077 bgColor(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000078 bgColorDataspace(ui::Dataspace::UNKNOWN),
79 colorSpaceAgnostic(false),
80 shadowRadius(0.0f),
81 frameRateSelectionPriority(-1),
82 frameRate(0.0f),
83 frameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
Marin Shalamanovc5986772021-03-16 16:09:49 +010084 changeFrameRateStrategy(ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS),
Andy Labrada096227e2022-06-15 16:58:11 +000085 defaultFrameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
Rachel Leece6e0042023-06-27 11:22:54 -070086 frameRateCategory(ANATIVEWINDOW_FRAME_RATE_CATEGORY_DEFAULT),
Pablo Gamito11dcc222020-09-12 15:49:39 +000087 fixedTransformHint(ui::Transform::ROT_INVALID),
Vishnu Nair1506b182021-02-22 14:35:15 -080088 autoRefresh(false),
Winson Chunga30f7c92021-06-29 15:42:56 -070089 isTrustedOverlay(false),
Tianhao Yao67dd7122022-02-22 17:48:33 +000090 borderEnabled(false),
Vishnu Nair6bdec7d2021-05-10 15:01:13 -070091 bufferCrop(Rect::INVALID_RECT),
92 destinationFrame(Rect::INVALID_RECT),
Vishnu Nair9cf4a4d2021-09-17 12:16:08 -070093 dropInputMode(gui::DropInputMode::NONE) {
Pablo Gamito11dcc222020-09-12 15:49:39 +000094 matrix.dsdx = matrix.dtdy = 1.0f;
95 matrix.dsdy = matrix.dtdx = 0.0f;
96 hdrMetadata.validTypes = 0;
97}
98
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080099status_t layer_state_t::write(Parcel& output) const
100{
chaviw308ddba2020-08-11 16:23:51 -0700101 SAFE_PARCEL(output.writeStrongBinder, surface);
Pablo Gamitodbc31672020-09-01 18:28:58 +0000102 SAFE_PARCEL(output.writeInt32, layerId);
chaviw308ddba2020-08-11 16:23:51 -0700103 SAFE_PARCEL(output.writeUint64, what);
104 SAFE_PARCEL(output.writeFloat, x);
105 SAFE_PARCEL(output.writeFloat, y);
106 SAFE_PARCEL(output.writeInt32, z);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700107 SAFE_PARCEL(output.writeUint32, layerStack.id);
chaviw308ddba2020-08-11 16:23:51 -0700108 SAFE_PARCEL(output.writeUint32, flags);
109 SAFE_PARCEL(output.writeUint32, mask);
110 SAFE_PARCEL(matrix.write, output);
chaviw25714502021-02-11 10:01:08 -0800111 SAFE_PARCEL(output.write, crop);
Pablo Gamito11dcc222020-09-12 15:49:39 +0000112 SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, relativeLayerSurfaceControl);
113 SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, parentSurfaceControlForChild);
chaviw308ddba2020-08-11 16:23:51 -0700114 SAFE_PARCEL(output.writeFloat, color.r);
115 SAFE_PARCEL(output.writeFloat, color.g);
116 SAFE_PARCEL(output.writeFloat, color.b);
Vishnu Nairbbceb462022-10-10 04:52:13 +0000117 SAFE_PARCEL(output.writeFloat, color.a);
chaviw98318de2021-05-19 16:45:23 -0500118 SAFE_PARCEL(windowInfoHandle->writeToParcel, &output);
chaviw308ddba2020-08-11 16:23:51 -0700119 SAFE_PARCEL(output.write, transparentRegion);
Vishnu Nairbbceb462022-10-10 04:52:13 +0000120 SAFE_PARCEL(output.writeUint32, bufferTransform);
chaviw308ddba2020-08-11 16:23:51 -0700121 SAFE_PARCEL(output.writeBool, transformToDisplayInverse);
Tianhao Yao67dd7122022-02-22 17:48:33 +0000122 SAFE_PARCEL(output.writeBool, borderEnabled);
Tianhao Yao10cea3c2022-03-30 01:37:22 +0000123 SAFE_PARCEL(output.writeFloat, borderWidth);
124 SAFE_PARCEL(output.writeFloat, borderColor.r);
125 SAFE_PARCEL(output.writeFloat, borderColor.g);
126 SAFE_PARCEL(output.writeFloat, borderColor.b);
127 SAFE_PARCEL(output.writeFloat, borderColor.a);
chaviw308ddba2020-08-11 16:23:51 -0700128 SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dataspace));
129 SAFE_PARCEL(output.write, hdrMetadata);
130 SAFE_PARCEL(output.write, surfaceDamageRegion);
131 SAFE_PARCEL(output.writeInt32, api);
132
Marissa Wall61c58622018-07-18 10:12:20 -0700133 if (sidebandStream) {
chaviw308ddba2020-08-11 16:23:51 -0700134 SAFE_PARCEL(output.writeBool, true);
135 SAFE_PARCEL(output.writeNativeHandle, sidebandStream->handle());
Marissa Wall61c58622018-07-18 10:12:20 -0700136 } else {
chaviw308ddba2020-08-11 16:23:51 -0700137 SAFE_PARCEL(output.writeBool, false);
Marissa Wall61c58622018-07-18 10:12:20 -0700138 }
139
chaviw308ddba2020-08-11 16:23:51 -0700140 SAFE_PARCEL(output.write, colorTransform.asArray(), 16 * sizeof(float));
141 SAFE_PARCEL(output.writeFloat, cornerRadius);
142 SAFE_PARCEL(output.writeUint32, backgroundBlurRadius);
chaviw308ddba2020-08-11 16:23:51 -0700143 SAFE_PARCEL(output.writeParcelable, metadata);
Vishnu Naird47bcee2023-02-24 18:08:51 +0000144 SAFE_PARCEL(output.writeFloat, bgColor.r);
145 SAFE_PARCEL(output.writeFloat, bgColor.g);
146 SAFE_PARCEL(output.writeFloat, bgColor.b);
147 SAFE_PARCEL(output.writeFloat, bgColor.a);
chaviw308ddba2020-08-11 16:23:51 -0700148 SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(bgColorDataspace));
149 SAFE_PARCEL(output.writeBool, colorSpaceAgnostic);
150 SAFE_PARCEL(output.writeVectorSize, listeners);
Valerie Hau9dab9732019-08-20 09:29:25 -0700151
152 for (auto listener : listeners) {
chaviw308ddba2020-08-11 16:23:51 -0700153 SAFE_PARCEL(output.writeStrongBinder, listener.transactionCompletedListener);
Vishnu Nairfc46c1e2021-04-21 08:31:32 -0700154 SAFE_PARCEL(output.writeParcelableVector, listener.callbackIds);
Valerie Hau9dab9732019-08-20 09:29:25 -0700155 }
chaviw308ddba2020-08-11 16:23:51 -0700156 SAFE_PARCEL(output.writeFloat, shadowRadius);
157 SAFE_PARCEL(output.writeInt32, frameRateSelectionPriority);
158 SAFE_PARCEL(output.writeFloat, frameRate);
159 SAFE_PARCEL(output.writeByte, frameRateCompatibility);
Marin Shalamanovc5986772021-03-16 16:09:49 +0100160 SAFE_PARCEL(output.writeByte, changeFrameRateStrategy);
Andy Labrada096227e2022-06-15 16:58:11 +0000161 SAFE_PARCEL(output.writeByte, defaultFrameRateCompatibility);
Rachel Leece6e0042023-06-27 11:22:54 -0700162 SAFE_PARCEL(output.writeByte, frameRateCategory);
chaviw308ddba2020-08-11 16:23:51 -0700163 SAFE_PARCEL(output.writeUint32, fixedTransformHint);
Vishnu Naircf26a0a2020-11-13 12:56:20 -0800164 SAFE_PARCEL(output.writeBool, autoRefresh);
Sally Qi81d95e62022-03-21 19:41:33 -0700165 SAFE_PARCEL(output.writeBool, dimmingEnabled);
Lucas Dupinc3800b82020-10-02 16:24:48 -0700166
167 SAFE_PARCEL(output.writeUint32, blurRegions.size());
168 for (auto region : blurRegions) {
169 SAFE_PARCEL(output.writeUint32, region.blurRadius);
170 SAFE_PARCEL(output.writeFloat, region.cornerRadiusTL);
171 SAFE_PARCEL(output.writeFloat, region.cornerRadiusTR);
172 SAFE_PARCEL(output.writeFloat, region.cornerRadiusBL);
173 SAFE_PARCEL(output.writeFloat, region.cornerRadiusBR);
174 SAFE_PARCEL(output.writeFloat, region.alpha);
175 SAFE_PARCEL(output.writeInt32, region.left);
176 SAFE_PARCEL(output.writeInt32, region.top);
177 SAFE_PARCEL(output.writeInt32, region.right);
178 SAFE_PARCEL(output.writeInt32, region.bottom);
179 }
John Reckcdb4ed72021-02-04 13:39:33 -0500180
181 SAFE_PARCEL(output.write, stretchEffect);
chaviwf3f40fe2021-04-27 15:54:02 -0500182 SAFE_PARCEL(output.write, bufferCrop);
Vishnu Nair6bdec7d2021-05-10 15:01:13 -0700183 SAFE_PARCEL(output.write, destinationFrame);
Winson Chunga30f7c92021-06-29 15:42:56 -0700184 SAFE_PARCEL(output.writeBool, isTrustedOverlay);
John Reckcdb4ed72021-02-04 13:39:33 -0500185
Vishnu Nair9cf4a4d2021-09-17 12:16:08 -0700186 SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dropInputMode));
Vishnu Nair685cfef2022-02-02 10:01:25 -0800187
188 const bool hasBufferData = (bufferData != nullptr);
189 SAFE_PARCEL(output.writeBool, hasBufferData);
190 if (hasBufferData) {
191 SAFE_PARCEL(output.writeParcelable, *bufferData);
192 }
Chavi Weingarten076acac2023-01-19 17:20:43 +0000193 SAFE_PARCEL(output.writeParcelable, trustedPresentationThresholds);
194 SAFE_PARCEL(output.writeParcelable, trustedPresentationListener);
Sally Qi963049b2023-03-23 14:06:21 -0700195 SAFE_PARCEL(output.writeFloat, currentHdrSdrRatio);
196 SAFE_PARCEL(output.writeFloat, desiredHdrSdrRatio);
Alec Mourif4af03e2023-02-11 00:25:24 +0000197 SAFE_PARCEL(output.writeInt32, static_cast<int32_t>(cachingHint))
Mathias Agopianac9fa422013-02-11 16:40:36 -0800198 return NO_ERROR;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800199}
200
201status_t layer_state_t::read(const Parcel& input)
202{
chaviw308ddba2020-08-11 16:23:51 -0700203 SAFE_PARCEL(input.readNullableStrongBinder, &surface);
Pablo Gamitodbc31672020-09-01 18:28:58 +0000204 SAFE_PARCEL(input.readInt32, &layerId);
chaviw308ddba2020-08-11 16:23:51 -0700205 SAFE_PARCEL(input.readUint64, &what);
206 SAFE_PARCEL(input.readFloat, &x);
207 SAFE_PARCEL(input.readFloat, &y);
208 SAFE_PARCEL(input.readInt32, &z);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700209 SAFE_PARCEL(input.readUint32, &layerStack.id);
Robert Carr2c358bf2018-08-08 15:58:15 -0700210
Vishnu Nairf6eddb62021-01-27 22:02:11 -0800211 SAFE_PARCEL(input.readUint32, &flags);
chaviw308ddba2020-08-11 16:23:51 -0700212
Vishnu Nairf6eddb62021-01-27 22:02:11 -0800213 SAFE_PARCEL(input.readUint32, &mask);
chaviw308ddba2020-08-11 16:23:51 -0700214
215 SAFE_PARCEL(matrix.read, input);
chaviw25714502021-02-11 10:01:08 -0800216 SAFE_PARCEL(input.read, crop);
chaviw308ddba2020-08-11 16:23:51 -0700217
Pablo Gamito11dcc222020-09-12 15:49:39 +0000218 SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &relativeLayerSurfaceControl);
219 SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &parentSurfaceControlForChild);
220
chaviw308ddba2020-08-11 16:23:51 -0700221 float tmpFloat = 0;
chaviw308ddba2020-08-11 16:23:51 -0700222 SAFE_PARCEL(input.readFloat, &tmpFloat);
223 color.r = tmpFloat;
224 SAFE_PARCEL(input.readFloat, &tmpFloat);
225 color.g = tmpFloat;
226 SAFE_PARCEL(input.readFloat, &tmpFloat);
227 color.b = tmpFloat;
Vishnu Nairbbceb462022-10-10 04:52:13 +0000228 SAFE_PARCEL(input.readFloat, &tmpFloat);
229 color.a = tmpFloat;
230
chaviw98318de2021-05-19 16:45:23 -0500231 SAFE_PARCEL(windowInfoHandle->readFromParcel, &input);
Robert Carr2c358bf2018-08-08 15:58:15 -0700232
chaviw308ddba2020-08-11 16:23:51 -0700233 SAFE_PARCEL(input.read, transparentRegion);
Vishnu Nairbbceb462022-10-10 04:52:13 +0000234 SAFE_PARCEL(input.readUint32, &bufferTransform);
chaviw308ddba2020-08-11 16:23:51 -0700235 SAFE_PARCEL(input.readBool, &transformToDisplayInverse);
Tianhao Yao67dd7122022-02-22 17:48:33 +0000236 SAFE_PARCEL(input.readBool, &borderEnabled);
Tianhao Yao10cea3c2022-03-30 01:37:22 +0000237 SAFE_PARCEL(input.readFloat, &tmpFloat);
238 borderWidth = tmpFloat;
239 SAFE_PARCEL(input.readFloat, &tmpFloat);
240 borderColor.r = tmpFloat;
241 SAFE_PARCEL(input.readFloat, &tmpFloat);
242 borderColor.g = tmpFloat;
243 SAFE_PARCEL(input.readFloat, &tmpFloat);
244 borderColor.b = tmpFloat;
245 SAFE_PARCEL(input.readFloat, &tmpFloat);
246 borderColor.a = tmpFloat;
chaviw308ddba2020-08-11 16:23:51 -0700247
Vishnu Nairf6eddb62021-01-27 22:02:11 -0800248 uint32_t tmpUint32 = 0;
chaviw308ddba2020-08-11 16:23:51 -0700249 SAFE_PARCEL(input.readUint32, &tmpUint32);
250 dataspace = static_cast<ui::Dataspace>(tmpUint32);
251
252 SAFE_PARCEL(input.read, hdrMetadata);
253 SAFE_PARCEL(input.read, surfaceDamageRegion);
254 SAFE_PARCEL(input.readInt32, &api);
chaviwba4320c2021-09-15 15:20:53 -0500255
256 bool tmpBool = false;
chaviw308ddba2020-08-11 16:23:51 -0700257 SAFE_PARCEL(input.readBool, &tmpBool);
258 if (tmpBool) {
Marissa Wall61c58622018-07-18 10:12:20 -0700259 sidebandStream = NativeHandle::create(input.readNativeHandle(), true);
260 }
261
chaviw308ddba2020-08-11 16:23:51 -0700262 SAFE_PARCEL(input.read, &colorTransform, 16 * sizeof(float));
263 SAFE_PARCEL(input.readFloat, &cornerRadius);
264 SAFE_PARCEL(input.readUint32, &backgroundBlurRadius);
chaviw308ddba2020-08-11 16:23:51 -0700265 SAFE_PARCEL(input.readParcelable, &metadata);
Marissa Wallebc2c052019-01-16 19:16:55 -0800266
Vishnu Naird47bcee2023-02-24 18:08:51 +0000267 SAFE_PARCEL(input.readFloat, &tmpFloat);
268 bgColor.r = tmpFloat;
269 SAFE_PARCEL(input.readFloat, &tmpFloat);
270 bgColor.g = tmpFloat;
271 SAFE_PARCEL(input.readFloat, &tmpFloat);
272 bgColor.b = tmpFloat;
273 SAFE_PARCEL(input.readFloat, &tmpFloat);
274 bgColor.a = tmpFloat;
chaviw308ddba2020-08-11 16:23:51 -0700275 SAFE_PARCEL(input.readUint32, &tmpUint32);
276 bgColorDataspace = static_cast<ui::Dataspace>(tmpUint32);
277 SAFE_PARCEL(input.readBool, &colorSpaceAgnostic);
Valerie Haued54efa2019-01-11 20:03:14 -0800278
chaviw308ddba2020-08-11 16:23:51 -0700279 int32_t numListeners = 0;
280 SAFE_PARCEL_READ_SIZE(input.readInt32, &numListeners, input.dataSize());
Valerie Hau9dab9732019-08-20 09:29:25 -0700281 listeners.clear();
282 for (int i = 0; i < numListeners; i++) {
chaviw308ddba2020-08-11 16:23:51 -0700283 sp<IBinder> listener;
Valerie Hau9dab9732019-08-20 09:29:25 -0700284 std::vector<CallbackId> callbackIds;
chaviw308ddba2020-08-11 16:23:51 -0700285 SAFE_PARCEL(input.readNullableStrongBinder, &listener);
Vishnu Nairfc46c1e2021-04-21 08:31:32 -0700286 SAFE_PARCEL(input.readParcelableVector, &callbackIds);
Valerie Hau9dab9732019-08-20 09:29:25 -0700287 listeners.emplace_back(listener, callbackIds);
288 }
chaviw308ddba2020-08-11 16:23:51 -0700289 SAFE_PARCEL(input.readFloat, &shadowRadius);
290 SAFE_PARCEL(input.readInt32, &frameRateSelectionPriority);
291 SAFE_PARCEL(input.readFloat, &frameRate);
292 SAFE_PARCEL(input.readByte, &frameRateCompatibility);
Marin Shalamanovc5986772021-03-16 16:09:49 +0100293 SAFE_PARCEL(input.readByte, &changeFrameRateStrategy);
Andy Labrada096227e2022-06-15 16:58:11 +0000294 SAFE_PARCEL(input.readByte, &defaultFrameRateCompatibility);
Rachel Leece6e0042023-06-27 11:22:54 -0700295 SAFE_PARCEL(input.readByte, &frameRateCategory);
chaviw308ddba2020-08-11 16:23:51 -0700296 SAFE_PARCEL(input.readUint32, &tmpUint32);
297 fixedTransformHint = static_cast<ui::Transform::RotationFlags>(tmpUint32);
Vishnu Naircf26a0a2020-11-13 12:56:20 -0800298 SAFE_PARCEL(input.readBool, &autoRefresh);
Sally Qi81d95e62022-03-21 19:41:33 -0700299 SAFE_PARCEL(input.readBool, &dimmingEnabled);
Lucas Dupinc3800b82020-10-02 16:24:48 -0700300
301 uint32_t numRegions = 0;
302 SAFE_PARCEL(input.readUint32, &numRegions);
303 blurRegions.clear();
304 for (uint32_t i = 0; i < numRegions; i++) {
305 BlurRegion region;
306 SAFE_PARCEL(input.readUint32, &region.blurRadius);
307 SAFE_PARCEL(input.readFloat, &region.cornerRadiusTL);
308 SAFE_PARCEL(input.readFloat, &region.cornerRadiusTR);
309 SAFE_PARCEL(input.readFloat, &region.cornerRadiusBL);
310 SAFE_PARCEL(input.readFloat, &region.cornerRadiusBR);
311 SAFE_PARCEL(input.readFloat, &region.alpha);
312 SAFE_PARCEL(input.readInt32, &region.left);
313 SAFE_PARCEL(input.readInt32, &region.top);
314 SAFE_PARCEL(input.readInt32, &region.right);
315 SAFE_PARCEL(input.readInt32, &region.bottom);
316 blurRegions.push_back(region);
317 }
John Reckcdb4ed72021-02-04 13:39:33 -0500318
319 SAFE_PARCEL(input.read, stretchEffect);
chaviwf3f40fe2021-04-27 15:54:02 -0500320 SAFE_PARCEL(input.read, bufferCrop);
Vishnu Nair6bdec7d2021-05-10 15:01:13 -0700321 SAFE_PARCEL(input.read, destinationFrame);
Winson Chunga30f7c92021-06-29 15:42:56 -0700322 SAFE_PARCEL(input.readBool, &isTrustedOverlay);
John Reckcdb4ed72021-02-04 13:39:33 -0500323
Vishnu Nair9cf4a4d2021-09-17 12:16:08 -0700324 uint32_t mode;
325 SAFE_PARCEL(input.readUint32, &mode);
326 dropInputMode = static_cast<gui::DropInputMode>(mode);
Vishnu Nair685cfef2022-02-02 10:01:25 -0800327
328 bool hasBufferData;
329 SAFE_PARCEL(input.readBool, &hasBufferData);
330 if (hasBufferData) {
331 bufferData = std::make_shared<BufferData>();
332 SAFE_PARCEL(input.readParcelable, bufferData.get());
333 } else {
334 bufferData = nullptr;
335 }
Chavi Weingarten076acac2023-01-19 17:20:43 +0000336
337 SAFE_PARCEL(input.readParcelable, &trustedPresentationThresholds);
338 SAFE_PARCEL(input.readParcelable, &trustedPresentationListener);
339
John Reck68796592023-01-25 13:47:12 -0500340 SAFE_PARCEL(input.readFloat, &tmpFloat);
Sally Qi963049b2023-03-23 14:06:21 -0700341 currentHdrSdrRatio = tmpFloat;
John Reck68796592023-01-25 13:47:12 -0500342 SAFE_PARCEL(input.readFloat, &tmpFloat);
Sally Qi963049b2023-03-23 14:06:21 -0700343 desiredHdrSdrRatio = tmpFloat;
John Reck68796592023-01-25 13:47:12 -0500344
Alec Mourif4af03e2023-02-11 00:25:24 +0000345 int32_t tmpInt32;
346 SAFE_PARCEL(input.readInt32, &tmpInt32);
347 cachingHint = static_cast<gui::CachingHint>(tmpInt32);
348
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800349 return NO_ERROR;
350}
351
Mathias Agopian698c0872011-06-28 19:09:31 -0700352status_t ComposerState::write(Parcel& output) const {
Mathias Agopian698c0872011-06-28 19:09:31 -0700353 return state.write(output);
354}
355
356status_t ComposerState::read(const Parcel& input) {
Mathias Agopian698c0872011-06-28 19:09:31 -0700357 return state.read(input);
358}
359
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700360DisplayState::DisplayState() = default;
Pablo Ceballos60d69222015-08-07 14:47:20 -0700361
Mathias Agopian8b33f032012-07-24 20:43:54 -0700362status_t DisplayState::write(Parcel& output) const {
chaviw308ddba2020-08-11 16:23:51 -0700363 SAFE_PARCEL(output.writeStrongBinder, token);
364 SAFE_PARCEL(output.writeStrongBinder, IInterface::asBinder(surface));
365 SAFE_PARCEL(output.writeUint32, what);
Evan Rosky2239b372021-05-20 13:43:47 -0700366 SAFE_PARCEL(output.writeUint32, flags);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700367 SAFE_PARCEL(output.writeUint32, layerStack.id);
chaviw308ddba2020-08-11 16:23:51 -0700368 SAFE_PARCEL(output.writeUint32, toRotationInt(orientation));
369 SAFE_PARCEL(output.write, layerStackSpaceRect);
370 SAFE_PARCEL(output.write, orientedDisplaySpaceRect);
371 SAFE_PARCEL(output.writeUint32, width);
372 SAFE_PARCEL(output.writeUint32, height);
Mathias Agopian8b33f032012-07-24 20:43:54 -0700373 return NO_ERROR;
374}
375
376status_t DisplayState::read(const Parcel& input) {
chaviw308ddba2020-08-11 16:23:51 -0700377 SAFE_PARCEL(input.readStrongBinder, &token);
378 sp<IBinder> tmpBinder;
379 SAFE_PARCEL(input.readNullableStrongBinder, &tmpBinder);
380 surface = interface_cast<IGraphicBufferProducer>(tmpBinder);
381
382 SAFE_PARCEL(input.readUint32, &what);
Evan Rosky2239b372021-05-20 13:43:47 -0700383 SAFE_PARCEL(input.readUint32, &flags);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700384 SAFE_PARCEL(input.readUint32, &layerStack.id);
chaviw308ddba2020-08-11 16:23:51 -0700385 uint32_t tmpUint = 0;
386 SAFE_PARCEL(input.readUint32, &tmpUint);
387 orientation = ui::toRotation(tmpUint);
388
389 SAFE_PARCEL(input.read, layerStackSpaceRect);
390 SAFE_PARCEL(input.read, orientedDisplaySpaceRect);
391 SAFE_PARCEL(input.readUint32, &width);
392 SAFE_PARCEL(input.readUint32, &height);
Mathias Agopian8b33f032012-07-24 20:43:54 -0700393 return NO_ERROR;
394}
395
Robert Carr2c5f6d22017-09-26 12:30:35 -0700396void DisplayState::merge(const DisplayState& other) {
397 if (other.what & eSurfaceChanged) {
398 what |= eSurfaceChanged;
399 surface = other.surface;
400 }
401 if (other.what & eLayerStackChanged) {
402 what |= eLayerStackChanged;
403 layerStack = other.layerStack;
404 }
Evan Rosky2239b372021-05-20 13:43:47 -0700405 if (other.what & eFlagsChanged) {
406 what |= eFlagsChanged;
407 flags = other.flags;
408 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700409 if (other.what & eDisplayProjectionChanged) {
410 what |= eDisplayProjectionChanged;
411 orientation = other.orientation;
Marin Shalamanov6ad317c2020-07-29 23:34:07 +0200412 layerStackSpaceRect = other.layerStackSpaceRect;
413 orientedDisplaySpaceRect = other.orientedDisplaySpaceRect;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700414 }
415 if (other.what & eDisplaySizeChanged) {
416 what |= eDisplaySizeChanged;
417 width = other.width;
418 height = other.height;
419 }
420}
421
Sally Qi6bb12822022-10-05 11:42:30 -0700422void DisplayState::sanitize(int32_t permissions) {
423 if (what & DisplayState::eLayerStackChanged) {
424 if (!(permissions & layer_state_t::Permission::ACCESS_SURFACE_FLINGER)) {
425 what &= ~DisplayState::eLayerStackChanged;
426 ALOGE("Stripped attempt to set eLayerStackChanged in sanitize");
427 }
428 }
429 if (what & DisplayState::eDisplayProjectionChanged) {
430 if (!(permissions & layer_state_t::Permission::ACCESS_SURFACE_FLINGER)) {
431 what &= ~DisplayState::eDisplayProjectionChanged;
432 ALOGE("Stripped attempt to set eDisplayProjectionChanged in sanitize");
433 }
434 }
435 if (what & DisplayState::eSurfaceChanged) {
436 if (!(permissions & layer_state_t::Permission::ACCESS_SURFACE_FLINGER)) {
437 what &= ~DisplayState::eSurfaceChanged;
438 ALOGE("Stripped attempt to set eSurfaceChanged in sanitize");
439 }
440 }
441}
442
Robert Carrde6d7b42022-01-07 18:23:06 -0800443void layer_state_t::sanitize(int32_t permissions) {
444 // TODO: b/109894387
445 //
446 // SurfaceFlinger's renderer is not prepared to handle cropping in the face of arbitrary
447 // rotation. To see the problem observe that if we have a square parent, and a child
448 // of the same size, then we rotate the child 45 degrees around its center, the child
449 // must now be cropped to a non rectangular 8 sided region.
450 //
451 // Of course we can fix this in the future. For now, we are lucky, SurfaceControl is
452 // private API, and arbitrary rotation is used in limited use cases, for instance:
453 // - WindowManager only uses rotation in one case, which is on a top level layer in which
454 // cropping is not an issue.
455 // - Launcher, as a privileged app, uses this to transition an application to PiP
456 // (picture-in-picture) mode.
457 //
458 // However given that abuse of rotation matrices could lead to surfaces extending outside
459 // of cropped areas, we need to prevent non-root clients without permission
460 // ACCESS_SURFACE_FLINGER nor ROTATE_SURFACE_FLINGER
461 // (a.k.a. everyone except WindowManager / tests / Launcher) from setting non rectangle
462 // preserving transformations.
463 if (what & eMatrixChanged) {
464 if (!(permissions & Permission::ROTATE_SURFACE_FLINGER)) {
465 ui::Transform t;
466 t.set(matrix.dsdx, matrix.dtdy, matrix.dtdx, matrix.dsdy);
467 if (!t.preserveRects()) {
468 what &= ~eMatrixChanged;
469 ALOGE("Stripped non rect preserving matrix in sanitize");
470 }
471 }
472 }
473
474 if (what & eFlagsChanged) {
475 if ((flags & eLayerIsDisplayDecoration) &&
476 !(permissions & Permission::INTERNAL_SYSTEM_WINDOW)) {
477 flags &= ~eLayerIsDisplayDecoration;
478 ALOGE("Stripped attempt to set LayerIsDisplayDecoration in sanitize");
479 }
480 }
481
482 if (what & layer_state_t::eInputInfoChanged) {
483 if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
484 what &= ~eInputInfoChanged;
485 ALOGE("Stripped attempt to set eInputInfoChanged in sanitize");
486 }
487 }
488 if (what & layer_state_t::eTrustedOverlayChanged) {
489 if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
490 what &= ~eTrustedOverlayChanged;
491 ALOGE("Stripped attempt to set eTrustedOverlay in sanitize");
492 }
493 }
494 if (what & layer_state_t::eDropInputModeChanged) {
495 if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
496 what &= ~eDropInputModeChanged;
497 ALOGE("Stripped attempt to set eDropInputModeChanged in sanitize");
498 }
499 }
500 if (what & layer_state_t::eFrameRateSelectionPriority) {
501 if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
502 what &= ~eFrameRateSelectionPriority;
503 ALOGE("Stripped attempt to set eFrameRateSelectionPriority in sanitize");
504 }
505 }
506 if (what & layer_state_t::eFrameRateChanged) {
507 if (!ValidateFrameRate(frameRate, frameRateCompatibility,
508 changeFrameRateStrategy,
509 "layer_state_t::sanitize",
510 permissions & Permission::ACCESS_SURFACE_FLINGER)) {
511 what &= ~eFrameRateChanged; // logged in ValidateFrameRate
512 }
513 }
514}
515
Robert Carr2c5f6d22017-09-26 12:30:35 -0700516void layer_state_t::merge(const layer_state_t& other) {
517 if (other.what & ePositionChanged) {
518 what |= ePositionChanged;
519 x = other.x;
520 y = other.y;
521 }
522 if (other.what & eLayerChanged) {
523 what |= eLayerChanged;
chaviw32377582019-05-13 11:15:19 -0700524 what &= ~eRelativeLayerChanged;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700525 z = other.z;
526 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700527 if (other.what & eAlphaChanged) {
528 what |= eAlphaChanged;
Vishnu Nairbbceb462022-10-10 04:52:13 +0000529 color.a = other.color.a;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700530 }
531 if (other.what & eMatrixChanged) {
532 what |= eMatrixChanged;
533 matrix = other.matrix;
534 }
535 if (other.what & eTransparentRegionChanged) {
536 what |= eTransparentRegionChanged;
537 transparentRegion = other.transparentRegion;
538 }
539 if (other.what & eFlagsChanged) {
540 what |= eFlagsChanged;
Vishnu Nair996bc422019-07-16 14:15:33 -0700541 flags &= ~other.mask;
542 flags |= (other.flags & other.mask);
543 mask |= other.mask;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700544 }
545 if (other.what & eLayerStackChanged) {
546 what |= eLayerStackChanged;
547 layerStack = other.layerStack;
548 }
Lucas Dupin1b6531c2018-07-05 17:18:21 -0700549 if (other.what & eCornerRadiusChanged) {
550 what |= eCornerRadiusChanged;
551 cornerRadius = other.cornerRadius;
552 }
Lucas Dupin19c8f0e2019-11-25 17:55:44 -0800553 if (other.what & eBackgroundBlurRadiusChanged) {
554 what |= eBackgroundBlurRadiusChanged;
555 backgroundBlurRadius = other.backgroundBlurRadius;
556 }
Lucas Dupinc3800b82020-10-02 16:24:48 -0700557 if (other.what & eBlurRegionsChanged) {
558 what |= eBlurRegionsChanged;
559 blurRegions = other.blurRegions;
560 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700561 if (other.what & eRelativeLayerChanged) {
562 what |= eRelativeLayerChanged;
chaviw32377582019-05-13 11:15:19 -0700563 what &= ~eLayerChanged;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700564 z = other.z;
Pablo Gamito11dcc222020-09-12 15:49:39 +0000565 relativeLayerSurfaceControl = other.relativeLayerSurfaceControl;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700566 }
567 if (other.what & eReparent) {
568 what |= eReparent;
Pablo Gamito11dcc222020-09-12 15:49:39 +0000569 parentSurfaceControlForChild = other.parentSurfaceControlForChild;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700570 }
Vishnu Nairbbceb462022-10-10 04:52:13 +0000571 if (other.what & eBufferTransformChanged) {
572 what |= eBufferTransformChanged;
573 bufferTransform = other.bufferTransform;
Marissa Wall61c58622018-07-18 10:12:20 -0700574 }
575 if (other.what & eTransformToDisplayInverseChanged) {
576 what |= eTransformToDisplayInverseChanged;
577 transformToDisplayInverse = other.transformToDisplayInverse;
578 }
579 if (other.what & eCropChanged) {
580 what |= eCropChanged;
581 crop = other.crop;
582 }
583 if (other.what & eBufferChanged) {
584 what |= eBufferChanged;
chaviwba4320c2021-09-15 15:20:53 -0500585 bufferData = other.bufferData;
Marissa Wall61c58622018-07-18 10:12:20 -0700586 }
Chavi Weingarten076acac2023-01-19 17:20:43 +0000587 if (other.what & eTrustedPresentationInfoChanged) {
588 what |= eTrustedPresentationInfoChanged;
589 trustedPresentationListener = other.trustedPresentationListener;
590 trustedPresentationThresholds = other.trustedPresentationThresholds;
591 }
Marissa Wall61c58622018-07-18 10:12:20 -0700592 if (other.what & eDataspaceChanged) {
593 what |= eDataspaceChanged;
594 dataspace = other.dataspace;
595 }
John Reck68796592023-01-25 13:47:12 -0500596 if (other.what & eExtendedRangeBrightnessChanged) {
597 what |= eExtendedRangeBrightnessChanged;
Sally Qi963049b2023-03-23 14:06:21 -0700598 desiredHdrSdrRatio = other.desiredHdrSdrRatio;
599 currentHdrSdrRatio = other.currentHdrSdrRatio;
John Reck68796592023-01-25 13:47:12 -0500600 }
Alec Mourif4af03e2023-02-11 00:25:24 +0000601 if (other.what & eCachingHintChanged) {
602 what |= eCachingHintChanged;
603 cachingHint = other.cachingHint;
604 }
Marissa Wall61c58622018-07-18 10:12:20 -0700605 if (other.what & eHdrMetadataChanged) {
606 what |= eHdrMetadataChanged;
607 hdrMetadata = other.hdrMetadata;
608 }
609 if (other.what & eSurfaceDamageRegionChanged) {
610 what |= eSurfaceDamageRegionChanged;
611 surfaceDamageRegion = other.surfaceDamageRegion;
612 }
613 if (other.what & eApiChanged) {
614 what |= eApiChanged;
615 api = other.api;
616 }
617 if (other.what & eSidebandStreamChanged) {
618 what |= eSidebandStreamChanged;
619 sidebandStream = other.sidebandStream;
620 }
Peiyong Lind3788632018-09-18 16:01:31 -0700621 if (other.what & eColorTransformChanged) {
622 what |= eColorTransformChanged;
623 colorTransform = other.colorTransform;
624 }
Marissa Wall3dad52d2019-03-22 14:03:19 -0700625 if (other.what & eHasListenerCallbacksChanged) {
626 what |= eHasListenerCallbacksChanged;
Marissa Wallc837b5e2018-10-12 10:04:44 -0700627 }
Robert Carr2c358bf2018-08-08 15:58:15 -0700628 if (other.what & eInputInfoChanged) {
629 what |= eInputInfoChanged;
chaviw98318de2021-05-19 16:45:23 -0500630 windowInfoHandle = new WindowInfoHandle(*other.windowInfoHandle);
Robert Carr2c358bf2018-08-08 15:58:15 -0700631 }
Valerie Haudd0b7572019-01-29 14:59:27 -0800632 if (other.what & eBackgroundColorChanged) {
633 what |= eBackgroundColorChanged;
Vishnu Naird47bcee2023-02-24 18:08:51 +0000634 bgColor = other.bgColor;
Valerie Haudd0b7572019-01-29 14:59:27 -0800635 bgColorDataspace = other.bgColorDataspace;
Valerie Haued54efa2019-01-11 20:03:14 -0800636 }
Evan Rosky1f6d6d52018-12-06 10:47:26 -0800637 if (other.what & eMetadataChanged) {
638 what |= eMetadataChanged;
639 metadata.merge(other.metadata);
640 }
Vishnu Nairc97b8db2019-10-29 18:19:35 -0700641 if (other.what & eShadowRadiusChanged) {
642 what |= eShadowRadiusChanged;
643 shadowRadius = other.shadowRadius;
644 }
Tianhao Yao67dd7122022-02-22 17:48:33 +0000645 if (other.what & eRenderBorderChanged) {
646 what |= eRenderBorderChanged;
647 borderEnabled = other.borderEnabled;
Tianhao Yao10cea3c2022-03-30 01:37:22 +0000648 borderWidth = other.borderWidth;
649 borderColor = other.borderColor;
Tianhao Yao67dd7122022-02-22 17:48:33 +0000650 }
Andy Labrada096227e2022-06-15 16:58:11 +0000651 if (other.what & eDefaultFrameRateCompatibilityChanged) {
652 what |= eDefaultFrameRateCompatibilityChanged;
653 defaultFrameRateCompatibility = other.defaultFrameRateCompatibility;
654 }
Ana Krulecc84d09b2019-11-02 23:10:29 +0100655 if (other.what & eFrameRateSelectionPriority) {
656 what |= eFrameRateSelectionPriority;
657 frameRateSelectionPriority = other.frameRateSelectionPriority;
658 }
Steven Thomas3172e202020-01-06 19:25:30 -0800659 if (other.what & eFrameRateChanged) {
660 what |= eFrameRateChanged;
661 frameRate = other.frameRate;
Steven Thomas62a4cf82020-01-31 12:04:03 -0800662 frameRateCompatibility = other.frameRateCompatibility;
Marin Shalamanovc5986772021-03-16 16:09:49 +0100663 changeFrameRateStrategy = other.changeFrameRateStrategy;
Steven Thomas3172e202020-01-06 19:25:30 -0800664 }
Rachel Leece6e0042023-06-27 11:22:54 -0700665 if (other.what & eFrameRateCategoryChanged) {
666 what |= eFrameRateCategoryChanged;
667 frameRateCategory = other.frameRateCategory;
668 }
Vishnu Nair6213bd92020-05-08 17:42:25 -0700669 if (other.what & eFixedTransformHintChanged) {
670 what |= eFixedTransformHintChanged;
671 fixedTransformHint = other.fixedTransformHint;
672 }
Vishnu Naircf26a0a2020-11-13 12:56:20 -0800673 if (other.what & eAutoRefreshChanged) {
674 what |= eAutoRefreshChanged;
675 autoRefresh = other.autoRefresh;
676 }
Winson Chunga30f7c92021-06-29 15:42:56 -0700677 if (other.what & eTrustedOverlayChanged) {
678 what |= eTrustedOverlayChanged;
679 isTrustedOverlay = other.isTrustedOverlay;
680 }
John Reckc00c6692021-02-16 11:37:33 -0500681 if (other.what & eStretchChanged) {
682 what |= eStretchChanged;
683 stretchEffect = other.stretchEffect;
684 }
chaviwf3f40fe2021-04-27 15:54:02 -0500685 if (other.what & eBufferCropChanged) {
686 what |= eBufferCropChanged;
687 bufferCrop = other.bufferCrop;
688 }
Vishnu Nair6bdec7d2021-05-10 15:01:13 -0700689 if (other.what & eDestinationFrameChanged) {
690 what |= eDestinationFrameChanged;
691 destinationFrame = other.destinationFrame;
692 }
Vishnu Nair0e816872021-07-14 10:53:04 -0700693 if (other.what & eProducerDisconnect) {
694 what |= eProducerDisconnect;
695 }
Vishnu Nair9cf4a4d2021-09-17 12:16:08 -0700696 if (other.what & eDropInputModeChanged) {
697 what |= eDropInputModeChanged;
698 dropInputMode = other.dropInputMode;
699 }
chaviw4c36cd82021-11-18 10:37:33 -0600700 if (other.what & eColorChanged) {
701 what |= eColorChanged;
Vishnu Nairbbceb462022-10-10 04:52:13 +0000702 color.rgb = other.color.rgb;
chaviw4c36cd82021-11-18 10:37:33 -0600703 }
Arthur Hung91b346a2022-03-14 21:36:22 +0800704 if (other.what & eColorSpaceAgnosticChanged) {
705 what |= eColorSpaceAgnosticChanged;
706 colorSpaceAgnostic = other.colorSpaceAgnostic;
707 }
Sally Qi81d95e62022-03-21 19:41:33 -0700708 if (other.what & eDimmingEnabledChanged) {
709 what |= eDimmingEnabledChanged;
710 dimmingEnabled = other.dimmingEnabled;
711 }
Pascal Muetschardb39918f2023-01-27 11:36:11 +0100712 if (other.what & eFlushJankData) {
713 what |= eFlushJankData;
714 }
Vishnu Nair217d8e62018-09-12 16:34:49 -0700715 if ((other.what & what) != other.what) {
716 ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? "
Vishnu Nair0e816872021-07-14 10:53:04 -0700717 "other.what=0x%" PRIX64 " what=0x%" PRIX64 " unmerged flags=0x%" PRIX64,
718 other.what, what, (other.what & what) ^ other.what);
Robert Carrd314f162018-08-15 13:12:42 -0700719 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700720}
Mathias Agopian8b33f032012-07-24 20:43:54 -0700721
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000722uint64_t layer_state_t::diff(const layer_state_t& other) const {
723 uint64_t diff = 0;
724 CHECK_DIFF2(diff, ePositionChanged, other, x, y);
725 if (other.what & eLayerChanged) {
726 diff |= eLayerChanged;
727 diff &= ~eRelativeLayerChanged;
728 }
729 CHECK_DIFF(diff, eAlphaChanged, other, color.a);
730 CHECK_DIFF(diff, eMatrixChanged, other, matrix);
731 if (other.what & eTransparentRegionChanged &&
732 (!transparentRegion.hasSameRects(other.transparentRegion))) {
733 diff |= eTransparentRegionChanged;
734 }
735 if (other.what & eFlagsChanged) {
736 uint64_t changedFlags = (flags & other.mask) ^ (other.flags & other.mask);
737 if (changedFlags) diff |= eFlagsChanged;
738 }
739 CHECK_DIFF(diff, eLayerStackChanged, other, layerStack);
740 CHECK_DIFF(diff, eCornerRadiusChanged, other, cornerRadius);
741 CHECK_DIFF(diff, eBackgroundBlurRadiusChanged, other, backgroundBlurRadius);
742 if (other.what & eBlurRegionsChanged) diff |= eBlurRegionsChanged;
743 if (other.what & eRelativeLayerChanged) {
744 diff |= eRelativeLayerChanged;
745 diff &= ~eLayerChanged;
746 }
747 if (other.what & eReparent &&
748 !SurfaceControl::isSameSurface(parentSurfaceControlForChild,
749 other.parentSurfaceControlForChild)) {
750 diff |= eReparent;
751 }
752 CHECK_DIFF(diff, eBufferTransformChanged, other, bufferTransform);
753 CHECK_DIFF(diff, eTransformToDisplayInverseChanged, other, transformToDisplayInverse);
754 CHECK_DIFF(diff, eCropChanged, other, crop);
755 if (other.what & eBufferChanged) diff |= eBufferChanged;
756 CHECK_DIFF(diff, eDataspaceChanged, other, dataspace);
Sally Qi963049b2023-03-23 14:06:21 -0700757 CHECK_DIFF2(diff, eExtendedRangeBrightnessChanged, other, currentHdrSdrRatio,
758 desiredHdrSdrRatio);
Alec Mourif4af03e2023-02-11 00:25:24 +0000759 CHECK_DIFF(diff, eCachingHintChanged, other, cachingHint);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000760 CHECK_DIFF(diff, eHdrMetadataChanged, other, hdrMetadata);
761 if (other.what & eSurfaceDamageRegionChanged &&
762 (!surfaceDamageRegion.hasSameRects(other.surfaceDamageRegion))) {
763 diff |= eSurfaceDamageRegionChanged;
764 }
765 CHECK_DIFF(diff, eApiChanged, other, api);
766 if (other.what & eSidebandStreamChanged) diff |= eSidebandStreamChanged;
767 CHECK_DIFF(diff, eApiChanged, other, api);
768 CHECK_DIFF(diff, eColorTransformChanged, other, colorTransform);
769 if (other.what & eHasListenerCallbacksChanged) diff |= eHasListenerCallbacksChanged;
770 if (other.what & eInputInfoChanged) diff |= eInputInfoChanged;
Vishnu Naird47bcee2023-02-24 18:08:51 +0000771 CHECK_DIFF2(diff, eBackgroundColorChanged, other, bgColor, bgColorDataspace);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000772 if (other.what & eMetadataChanged) diff |= eMetadataChanged;
773 CHECK_DIFF(diff, eShadowRadiusChanged, other, shadowRadius);
774 CHECK_DIFF3(diff, eRenderBorderChanged, other, borderEnabled, borderWidth, borderColor);
775 CHECK_DIFF(diff, eDefaultFrameRateCompatibilityChanged, other, defaultFrameRateCompatibility);
776 CHECK_DIFF(diff, eFrameRateSelectionPriority, other, frameRateSelectionPriority);
777 CHECK_DIFF3(diff, eFrameRateChanged, other, frameRate, frameRateCompatibility,
778 changeFrameRateStrategy);
Rachel Leece6e0042023-06-27 11:22:54 -0700779 CHECK_DIFF(diff, eFrameRateCategoryChanged, other, frameRateCategory);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000780 CHECK_DIFF(diff, eFixedTransformHintChanged, other, fixedTransformHint);
781 CHECK_DIFF(diff, eAutoRefreshChanged, other, autoRefresh);
782 CHECK_DIFF(diff, eTrustedOverlayChanged, other, isTrustedOverlay);
783 CHECK_DIFF(diff, eStretchChanged, other, stretchEffect);
784 CHECK_DIFF(diff, eBufferCropChanged, other, bufferCrop);
785 CHECK_DIFF(diff, eDestinationFrameChanged, other, destinationFrame);
786 if (other.what & eProducerDisconnect) diff |= eProducerDisconnect;
787 CHECK_DIFF(diff, eDropInputModeChanged, other, dropInputMode);
788 CHECK_DIFF(diff, eColorChanged, other, color.rgb);
789 CHECK_DIFF(diff, eColorSpaceAgnosticChanged, other, colorSpaceAgnostic);
790 CHECK_DIFF(diff, eDimmingEnabledChanged, other, dimmingEnabled);
791 return diff;
792}
793
Vishnu Nairddf9b5c2021-03-29 18:53:41 -0700794bool layer_state_t::hasBufferChanges() const {
chaviwba4320c2021-09-15 15:20:53 -0500795 return what & layer_state_t::eBufferChanged;
Vishnu Nairddf9b5c2021-03-29 18:53:41 -0700796}
797
Ady Abraham6e8e3642021-07-08 19:44:07 -0700798bool layer_state_t::hasValidBuffer() const {
Vishnu Nair59f6d2d2022-10-05 16:59:56 -0700799 return bufferData && (bufferData->hasBuffer() || bufferData->cachedBuffer.isValid());
Ady Abraham6e8e3642021-07-08 19:44:07 -0700800}
801
chaviw308ddba2020-08-11 16:23:51 -0700802status_t layer_state_t::matrix22_t::write(Parcel& output) const {
803 SAFE_PARCEL(output.writeFloat, dsdx);
804 SAFE_PARCEL(output.writeFloat, dtdx);
805 SAFE_PARCEL(output.writeFloat, dtdy);
806 SAFE_PARCEL(output.writeFloat, dsdy);
807 return NO_ERROR;
808}
809
810status_t layer_state_t::matrix22_t::read(const Parcel& input) {
811 SAFE_PARCEL(input.readFloat, &dsdx);
812 SAFE_PARCEL(input.readFloat, &dtdx);
813 SAFE_PARCEL(input.readFloat, &dtdy);
814 SAFE_PARCEL(input.readFloat, &dsdy);
815 return NO_ERROR;
816}
817
chaviw273171b2018-12-26 11:46:30 -0800818// ------------------------------- InputWindowCommands ----------------------------------------
819
Vishnu Naire798b472020-07-23 13:52:21 -0700820bool InputWindowCommands::merge(const InputWindowCommands& other) {
821 bool changes = false;
Vishnu Naire798b472020-07-23 13:52:21 -0700822 changes |= !other.focusRequests.empty();
823 focusRequests.insert(focusRequests.end(), std::make_move_iterator(other.focusRequests.begin()),
824 std::make_move_iterator(other.focusRequests.end()));
Patrick Williams641f7f22022-06-22 19:25:35 +0000825 changes |= !other.windowInfosReportedListeners.empty();
826 windowInfosReportedListeners.insert(other.windowInfosReportedListeners.begin(),
827 other.windowInfosReportedListeners.end());
Vishnu Naire798b472020-07-23 13:52:21 -0700828 return changes;
chaviw273171b2018-12-26 11:46:30 -0800829}
830
Vishnu Nair958da932020-08-21 17:12:37 -0700831bool InputWindowCommands::empty() const {
Patrick Williams641f7f22022-06-22 19:25:35 +0000832 return focusRequests.empty() && windowInfosReportedListeners.empty();
Vishnu Nair958da932020-08-21 17:12:37 -0700833}
834
chaviw273171b2018-12-26 11:46:30 -0800835void InputWindowCommands::clear() {
Vishnu Naire798b472020-07-23 13:52:21 -0700836 focusRequests.clear();
Patrick Williams641f7f22022-06-22 19:25:35 +0000837 windowInfosReportedListeners.clear();
chaviw273171b2018-12-26 11:46:30 -0800838}
839
chaviw308ddba2020-08-11 16:23:51 -0700840status_t InputWindowCommands::write(Parcel& output) const {
chaviw308ddba2020-08-11 16:23:51 -0700841 SAFE_PARCEL(output.writeParcelableVector, focusRequests);
Patrick Williams641f7f22022-06-22 19:25:35 +0000842
843 SAFE_PARCEL(output.writeInt32, windowInfosReportedListeners.size());
844 for (const auto& listener : windowInfosReportedListeners) {
845 SAFE_PARCEL(output.writeStrongBinder, listener);
846 }
847
chaviw308ddba2020-08-11 16:23:51 -0700848 return NO_ERROR;
chaviw273171b2018-12-26 11:46:30 -0800849}
850
chaviw308ddba2020-08-11 16:23:51 -0700851status_t InputWindowCommands::read(const Parcel& input) {
chaviw308ddba2020-08-11 16:23:51 -0700852 SAFE_PARCEL(input.readParcelableVector, &focusRequests);
Patrick Williams641f7f22022-06-22 19:25:35 +0000853
854 int listenerSize = 0;
855 SAFE_PARCEL_READ_SIZE(input.readInt32, &listenerSize, input.dataSize());
856 windowInfosReportedListeners.reserve(listenerSize);
857 for (int i = 0; i < listenerSize; i++) {
858 sp<gui::IWindowInfosReportedListener> listener;
859 SAFE_PARCEL(input.readStrongBinder, &listener);
860 windowInfosReportedListeners.insert(listener);
861 }
862
chaviw308ddba2020-08-11 16:23:51 -0700863 return NO_ERROR;
chaviw273171b2018-12-26 11:46:30 -0800864}
865
Marin Shalamanovc5986772021-03-16 16:09:49 +0100866bool ValidateFrameRate(float frameRate, int8_t compatibility, int8_t changeFrameRateStrategy,
867 const char* inFunctionName, bool privileged) {
Steven Thomas62a4cf82020-01-31 12:04:03 -0800868 const char* functionName = inFunctionName != nullptr ? inFunctionName : "call";
869 int floatClassification = std::fpclassify(frameRate);
870 if (frameRate < 0 || floatClassification == FP_INFINITE || floatClassification == FP_NAN) {
871 ALOGE("%s failed - invalid frame rate %f", functionName, frameRate);
872 return false;
873 }
874
875 if (compatibility != ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT &&
Ady Abrahamdd5bfa92021-01-07 17:56:08 -0800876 compatibility != ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_FIXED_SOURCE &&
Dominik Laskowski1f6fc702022-03-21 08:34:50 -0700877 (!privileged ||
878 (compatibility != ANATIVEWINDOW_FRAME_RATE_EXACT &&
879 compatibility != ANATIVEWINDOW_FRAME_RATE_NO_VOTE))) {
Ady Abrahamdd5bfa92021-01-07 17:56:08 -0800880 ALOGE("%s failed - invalid compatibility value %d privileged: %s", functionName,
881 compatibility, privileged ? "yes" : "no");
Steven Thomas62a4cf82020-01-31 12:04:03 -0800882 return false;
883 }
884
Marin Shalamanovc5986772021-03-16 16:09:49 +0100885 if (changeFrameRateStrategy != ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS &&
886 changeFrameRateStrategy != ANATIVEWINDOW_CHANGE_FRAME_RATE_ALWAYS) {
887 ALOGE("%s failed - invalid change frame rate strategy value %d", functionName,
888 changeFrameRateStrategy);
889 }
890
Steven Thomas62a4cf82020-01-31 12:04:03 -0800891 return true;
892}
893
chaviw618c42d2020-07-24 15:25:08 -0700894// ----------------------------------------------------------------------------
895
Huihong Luo9e84f332021-12-16 14:33:46 -0800896namespace gui {
897
898status_t CaptureArgs::writeToParcel(Parcel* output) const {
899 SAFE_PARCEL(output->writeInt32, static_cast<int32_t>(pixelFormat));
900 SAFE_PARCEL(output->write, sourceCrop);
901 SAFE_PARCEL(output->writeFloat, frameScaleX);
902 SAFE_PARCEL(output->writeFloat, frameScaleY);
903 SAFE_PARCEL(output->writeBool, captureSecureLayers);
904 SAFE_PARCEL(output->writeInt32, uid);
905 SAFE_PARCEL(output->writeInt32, static_cast<int32_t>(dataspace));
906 SAFE_PARCEL(output->writeBool, allowProtected);
907 SAFE_PARCEL(output->writeBool, grayscale);
Ajinkya Chalke02844632023-03-01 12:10:14 +0000908 SAFE_PARCEL(output->writeInt32, excludeHandles.size());
909 for (auto& excludeHandle : excludeHandles) {
910 SAFE_PARCEL(output->writeStrongBinder, excludeHandle);
911 }
Alec Mouri3e5965f2023-04-07 18:00:58 +0000912 SAFE_PARCEL(output->writeBool, hintForSeamlessTransition);
chaviw308ddba2020-08-11 16:23:51 -0700913 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700914}
915
Huihong Luo9e84f332021-12-16 14:33:46 -0800916status_t CaptureArgs::readFromParcel(const Parcel* input) {
Peiyong Lincd261472020-10-06 18:05:25 -0700917 int32_t value = 0;
Huihong Luo9e84f332021-12-16 14:33:46 -0800918 SAFE_PARCEL(input->readInt32, &value);
Peiyong Lincd261472020-10-06 18:05:25 -0700919 pixelFormat = static_cast<ui::PixelFormat>(value);
Huihong Luo9e84f332021-12-16 14:33:46 -0800920 SAFE_PARCEL(input->read, sourceCrop);
921 SAFE_PARCEL(input->readFloat, &frameScaleX);
922 SAFE_PARCEL(input->readFloat, &frameScaleY);
923 SAFE_PARCEL(input->readBool, &captureSecureLayers);
924 SAFE_PARCEL(input->readInt32, &uid);
925 SAFE_PARCEL(input->readInt32, &value);
Peiyong Lincd261472020-10-06 18:05:25 -0700926 dataspace = static_cast<ui::Dataspace>(value);
Huihong Luo9e84f332021-12-16 14:33:46 -0800927 SAFE_PARCEL(input->readBool, &allowProtected);
928 SAFE_PARCEL(input->readBool, &grayscale);
Ajinkya Chalke02844632023-03-01 12:10:14 +0000929 int32_t numExcludeHandles = 0;
930 SAFE_PARCEL_READ_SIZE(input->readInt32, &numExcludeHandles, input->dataSize());
931 excludeHandles.reserve(numExcludeHandles);
932 for (int i = 0; i < numExcludeHandles; i++) {
933 sp<IBinder> binder;
934 SAFE_PARCEL(input->readStrongBinder, &binder);
935 excludeHandles.emplace(binder);
936 }
Alec Mouri3e5965f2023-04-07 18:00:58 +0000937 SAFE_PARCEL(input->readBool, &hintForSeamlessTransition);
chaviw308ddba2020-08-11 16:23:51 -0700938 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700939}
940
Huihong Luo9e84f332021-12-16 14:33:46 -0800941status_t DisplayCaptureArgs::writeToParcel(Parcel* output) const {
942 SAFE_PARCEL(CaptureArgs::writeToParcel, output);
chaviw618c42d2020-07-24 15:25:08 -0700943
Huihong Luo9e84f332021-12-16 14:33:46 -0800944 SAFE_PARCEL(output->writeStrongBinder, displayToken);
945 SAFE_PARCEL(output->writeUint32, width);
946 SAFE_PARCEL(output->writeUint32, height);
947 SAFE_PARCEL(output->writeBool, useIdentityTransform);
chaviw308ddba2020-08-11 16:23:51 -0700948 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700949}
950
Huihong Luo9e84f332021-12-16 14:33:46 -0800951status_t DisplayCaptureArgs::readFromParcel(const Parcel* input) {
952 SAFE_PARCEL(CaptureArgs::readFromParcel, input);
chaviw618c42d2020-07-24 15:25:08 -0700953
Huihong Luo9e84f332021-12-16 14:33:46 -0800954 SAFE_PARCEL(input->readStrongBinder, &displayToken);
955 SAFE_PARCEL(input->readUint32, &width);
956 SAFE_PARCEL(input->readUint32, &height);
957 SAFE_PARCEL(input->readBool, &useIdentityTransform);
chaviw308ddba2020-08-11 16:23:51 -0700958 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700959}
960
Huihong Luo9e84f332021-12-16 14:33:46 -0800961status_t LayerCaptureArgs::writeToParcel(Parcel* output) const {
962 SAFE_PARCEL(CaptureArgs::writeToParcel, output);
chaviw618c42d2020-07-24 15:25:08 -0700963
Huihong Luo9e84f332021-12-16 14:33:46 -0800964 SAFE_PARCEL(output->writeStrongBinder, layerHandle);
Huihong Luo9e84f332021-12-16 14:33:46 -0800965 SAFE_PARCEL(output->writeBool, childrenOnly);
chaviw308ddba2020-08-11 16:23:51 -0700966 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700967}
968
Huihong Luo9e84f332021-12-16 14:33:46 -0800969status_t LayerCaptureArgs::readFromParcel(const Parcel* input) {
970 SAFE_PARCEL(CaptureArgs::readFromParcel, input);
chaviw618c42d2020-07-24 15:25:08 -0700971
Huihong Luo9e84f332021-12-16 14:33:46 -0800972 SAFE_PARCEL(input->readStrongBinder, &layerHandle);
chaviw618c42d2020-07-24 15:25:08 -0700973
Huihong Luo9e84f332021-12-16 14:33:46 -0800974 SAFE_PARCEL(input->readBool, &childrenOnly);
chaviw308ddba2020-08-11 16:23:51 -0700975 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700976}
977
Huihong Luo9e84f332021-12-16 14:33:46 -0800978}; // namespace gui
979
chaviw8dd181f2022-01-05 18:36:46 -0600980ReleaseCallbackId BufferData::generateReleaseCallbackId() const {
chaviwdcba9e02022-03-21 17:54:23 -0500981 uint64_t bufferId;
982 if (buffer) {
983 bufferId = buffer->getId();
984 } else {
985 bufferId = cachedBuffer.id;
986 }
987 return {bufferId, frameNumber};
chaviw8dd181f2022-01-05 18:36:46 -0600988}
989
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800990status_t BufferData::writeToParcel(Parcel* output) const {
991 SAFE_PARCEL(output->writeInt32, flags.get());
chaviwba4320c2021-09-15 15:20:53 -0500992
993 if (buffer) {
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800994 SAFE_PARCEL(output->writeBool, true);
995 SAFE_PARCEL(output->write, *buffer);
chaviwba4320c2021-09-15 15:20:53 -0500996 } else {
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800997 SAFE_PARCEL(output->writeBool, false);
chaviwba4320c2021-09-15 15:20:53 -0500998 }
999
1000 if (acquireFence) {
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001001 SAFE_PARCEL(output->writeBool, true);
1002 SAFE_PARCEL(output->write, *acquireFence);
chaviwba4320c2021-09-15 15:20:53 -05001003 } else {
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001004 SAFE_PARCEL(output->writeBool, false);
chaviwba4320c2021-09-15 15:20:53 -05001005 }
1006
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001007 SAFE_PARCEL(output->writeUint64, frameNumber);
1008 SAFE_PARCEL(output->writeStrongBinder, IInterface::asBinder(releaseBufferListener));
1009 SAFE_PARCEL(output->writeStrongBinder, releaseBufferEndpoint);
chaviwba4320c2021-09-15 15:20:53 -05001010
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001011 SAFE_PARCEL(output->writeStrongBinder, cachedBuffer.token.promote());
1012 SAFE_PARCEL(output->writeUint64, cachedBuffer.id);
Robert Carr79dc06a2022-02-22 15:28:59 -08001013 SAFE_PARCEL(output->writeBool, hasBarrier);
1014 SAFE_PARCEL(output->writeUint64, barrierFrameNumber);
liulijuneb489f62022-10-17 22:02:14 +08001015 SAFE_PARCEL(output->writeUint32, producerId);
chaviwba4320c2021-09-15 15:20:53 -05001016
1017 return NO_ERROR;
1018}
1019
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001020status_t BufferData::readFromParcel(const Parcel* input) {
chaviwba4320c2021-09-15 15:20:53 -05001021 int32_t tmpInt32;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001022 SAFE_PARCEL(input->readInt32, &tmpInt32);
Dominik Laskowski2f01d772022-03-23 16:01:29 -07001023 flags = ftl::Flags<BufferDataChange>(tmpInt32);
chaviwba4320c2021-09-15 15:20:53 -05001024
1025 bool tmpBool = false;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001026 SAFE_PARCEL(input->readBool, &tmpBool);
chaviwba4320c2021-09-15 15:20:53 -05001027 if (tmpBool) {
1028 buffer = new GraphicBuffer();
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001029 SAFE_PARCEL(input->read, *buffer);
chaviwba4320c2021-09-15 15:20:53 -05001030 }
1031
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001032 SAFE_PARCEL(input->readBool, &tmpBool);
chaviwba4320c2021-09-15 15:20:53 -05001033 if (tmpBool) {
1034 acquireFence = new Fence();
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001035 SAFE_PARCEL(input->read, *acquireFence);
chaviwba4320c2021-09-15 15:20:53 -05001036 }
1037
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001038 SAFE_PARCEL(input->readUint64, &frameNumber);
chaviwba4320c2021-09-15 15:20:53 -05001039
1040 sp<IBinder> tmpBinder = nullptr;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001041 SAFE_PARCEL(input->readNullableStrongBinder, &tmpBinder);
chaviwba4320c2021-09-15 15:20:53 -05001042 if (tmpBinder) {
1043 releaseBufferListener = checked_interface_cast<ITransactionCompletedListener>(tmpBinder);
1044 }
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001045 SAFE_PARCEL(input->readNullableStrongBinder, &releaseBufferEndpoint);
chaviwba4320c2021-09-15 15:20:53 -05001046
1047 tmpBinder = nullptr;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001048 SAFE_PARCEL(input->readNullableStrongBinder, &tmpBinder);
chaviwba4320c2021-09-15 15:20:53 -05001049 cachedBuffer.token = tmpBinder;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001050 SAFE_PARCEL(input->readUint64, &cachedBuffer.id);
chaviwba4320c2021-09-15 15:20:53 -05001051
Robert Carr79dc06a2022-02-22 15:28:59 -08001052 SAFE_PARCEL(input->readBool, &hasBarrier);
1053 SAFE_PARCEL(input->readUint64, &barrierFrameNumber);
liulijuneb489f62022-10-17 22:02:14 +08001054 SAFE_PARCEL(input->readUint32, &producerId);
Robert Carr79dc06a2022-02-22 15:28:59 -08001055
chaviwba4320c2021-09-15 15:20:53 -05001056 return NO_ERROR;
1057}
1058
Chavi Weingarten076acac2023-01-19 17:20:43 +00001059status_t TrustedPresentationListener::writeToParcel(Parcel* parcel) const {
1060 SAFE_PARCEL(parcel->writeStrongBinder, callbackInterface);
1061 SAFE_PARCEL(parcel->writeInt32, callbackId);
1062 return NO_ERROR;
1063}
1064
1065status_t TrustedPresentationListener::readFromParcel(const Parcel* parcel) {
1066 sp<IBinder> tmpBinder = nullptr;
1067 SAFE_PARCEL(parcel->readNullableStrongBinder, &tmpBinder);
1068 if (tmpBinder) {
1069 callbackInterface = checked_interface_cast<ITransactionCompletedListener>(tmpBinder);
1070 }
1071 SAFE_PARCEL(parcel->readInt32, &callbackId);
1072 return NO_ERROR;
1073}
1074
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001075}; // namespace android