blob: 7564c26316c625fa1efe593e2dd791cc3bdf03b1 [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>
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),
69 backgroundBlurRadius(0),
Vishnu Nairbbceb462022-10-10 04:52:13 +000070 color(0),
71 bufferTransform(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000072 transformToDisplayInverse(false),
73 crop(Rect::INVALID_RECT),
Pablo Gamito11dcc222020-09-12 15:49:39 +000074 dataspace(ui::Dataspace::UNKNOWN),
75 surfaceDamageRegion(),
76 api(-1),
77 colorTransform(mat4()),
Vishnu Naird47bcee2023-02-24 18:08:51 +000078 bgColor(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000079 bgColorDataspace(ui::Dataspace::UNKNOWN),
80 colorSpaceAgnostic(false),
81 shadowRadius(0.0f),
82 frameRateSelectionPriority(-1),
83 frameRate(0.0f),
84 frameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
Marin Shalamanovc5986772021-03-16 16:09:49 +010085 changeFrameRateStrategy(ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS),
Andy Labrada096227e2022-06-15 16:58:11 +000086 defaultFrameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
Rachel Leece6e0042023-06-27 11:22:54 -070087 frameRateCategory(ANATIVEWINDOW_FRAME_RATE_CATEGORY_DEFAULT),
Rachel Lee67afbea2023-09-28 15:35:07 -070088 frameRateCategorySmoothSwitchOnly(false),
Rachel Lee70f7b692023-11-22 11:24:02 -080089 frameRateSelectionStrategy(ANATIVEWINDOW_FRAME_RATE_SELECTION_STRATEGY_PROPAGATE),
Pablo Gamito11dcc222020-09-12 15:49:39 +000090 fixedTransformHint(ui::Transform::ROT_INVALID),
Vishnu Nair1506b182021-02-22 14:35:15 -080091 autoRefresh(false),
Winson Chunga30f7c92021-06-29 15:42:56 -070092 isTrustedOverlay(false),
Tianhao Yao67dd7122022-02-22 17:48:33 +000093 borderEnabled(false),
Vishnu Nair6bdec7d2021-05-10 15:01:13 -070094 bufferCrop(Rect::INVALID_RECT),
95 destinationFrame(Rect::INVALID_RECT),
Vishnu Nair9cf4a4d2021-09-17 12:16:08 -070096 dropInputMode(gui::DropInputMode::NONE) {
Pablo Gamito11dcc222020-09-12 15:49:39 +000097 matrix.dsdx = matrix.dtdy = 1.0f;
98 matrix.dsdy = matrix.dtdx = 0.0f;
99 hdrMetadata.validTypes = 0;
100}
101
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800102status_t layer_state_t::write(Parcel& output) const
103{
chaviw308ddba2020-08-11 16:23:51 -0700104 SAFE_PARCEL(output.writeStrongBinder, surface);
Pablo Gamitodbc31672020-09-01 18:28:58 +0000105 SAFE_PARCEL(output.writeInt32, layerId);
chaviw308ddba2020-08-11 16:23:51 -0700106 SAFE_PARCEL(output.writeUint64, what);
107 SAFE_PARCEL(output.writeFloat, x);
108 SAFE_PARCEL(output.writeFloat, y);
109 SAFE_PARCEL(output.writeInt32, z);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700110 SAFE_PARCEL(output.writeUint32, layerStack.id);
chaviw308ddba2020-08-11 16:23:51 -0700111 SAFE_PARCEL(output.writeUint32, flags);
112 SAFE_PARCEL(output.writeUint32, mask);
113 SAFE_PARCEL(matrix.write, output);
chaviw25714502021-02-11 10:01:08 -0800114 SAFE_PARCEL(output.write, crop);
Pablo Gamito11dcc222020-09-12 15:49:39 +0000115 SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, relativeLayerSurfaceControl);
116 SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, parentSurfaceControlForChild);
chaviw308ddba2020-08-11 16:23:51 -0700117 SAFE_PARCEL(output.writeFloat, color.r);
118 SAFE_PARCEL(output.writeFloat, color.g);
119 SAFE_PARCEL(output.writeFloat, color.b);
Vishnu Nairbbceb462022-10-10 04:52:13 +0000120 SAFE_PARCEL(output.writeFloat, color.a);
chaviw98318de2021-05-19 16:45:23 -0500121 SAFE_PARCEL(windowInfoHandle->writeToParcel, &output);
chaviw308ddba2020-08-11 16:23:51 -0700122 SAFE_PARCEL(output.write, transparentRegion);
Vishnu Nairbbceb462022-10-10 04:52:13 +0000123 SAFE_PARCEL(output.writeUint32, bufferTransform);
chaviw308ddba2020-08-11 16:23:51 -0700124 SAFE_PARCEL(output.writeBool, transformToDisplayInverse);
Tianhao Yao67dd7122022-02-22 17:48:33 +0000125 SAFE_PARCEL(output.writeBool, borderEnabled);
Tianhao Yao10cea3c2022-03-30 01:37:22 +0000126 SAFE_PARCEL(output.writeFloat, borderWidth);
127 SAFE_PARCEL(output.writeFloat, borderColor.r);
128 SAFE_PARCEL(output.writeFloat, borderColor.g);
129 SAFE_PARCEL(output.writeFloat, borderColor.b);
130 SAFE_PARCEL(output.writeFloat, borderColor.a);
chaviw308ddba2020-08-11 16:23:51 -0700131 SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dataspace));
132 SAFE_PARCEL(output.write, hdrMetadata);
133 SAFE_PARCEL(output.write, surfaceDamageRegion);
134 SAFE_PARCEL(output.writeInt32, api);
135
Marissa Wall61c58622018-07-18 10:12:20 -0700136 if (sidebandStream) {
chaviw308ddba2020-08-11 16:23:51 -0700137 SAFE_PARCEL(output.writeBool, true);
138 SAFE_PARCEL(output.writeNativeHandle, sidebandStream->handle());
Marissa Wall61c58622018-07-18 10:12:20 -0700139 } else {
chaviw308ddba2020-08-11 16:23:51 -0700140 SAFE_PARCEL(output.writeBool, false);
Marissa Wall61c58622018-07-18 10:12:20 -0700141 }
142
chaviw308ddba2020-08-11 16:23:51 -0700143 SAFE_PARCEL(output.write, colorTransform.asArray(), 16 * sizeof(float));
144 SAFE_PARCEL(output.writeFloat, cornerRadius);
145 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);
chaviwf3f40fe2021-04-27 15:54:02 -0500187 SAFE_PARCEL(output.write, bufferCrop);
Vishnu Nair6bdec7d2021-05-10 15:01:13 -0700188 SAFE_PARCEL(output.write, destinationFrame);
Winson Chunga30f7c92021-06-29 15:42:56 -0700189 SAFE_PARCEL(output.writeBool, isTrustedOverlay);
John Reckcdb4ed72021-02-04 13:39:33 -0500190
Vishnu Nair9cf4a4d2021-09-17 12:16:08 -0700191 SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dropInputMode));
Vishnu Nair685cfef2022-02-02 10:01:25 -0800192
193 const bool hasBufferData = (bufferData != nullptr);
194 SAFE_PARCEL(output.writeBool, hasBufferData);
195 if (hasBufferData) {
196 SAFE_PARCEL(output.writeParcelable, *bufferData);
197 }
Chavi Weingarten076acac2023-01-19 17:20:43 +0000198 SAFE_PARCEL(output.writeParcelable, trustedPresentationThresholds);
199 SAFE_PARCEL(output.writeParcelable, trustedPresentationListener);
Sally Qi963049b2023-03-23 14:06:21 -0700200 SAFE_PARCEL(output.writeFloat, currentHdrSdrRatio);
201 SAFE_PARCEL(output.writeFloat, desiredHdrSdrRatio);
Vishnu Nair59a6be32024-01-29 10:26:21 -0800202 SAFE_PARCEL(output.writeInt32, static_cast<int32_t>(cachingHint));
Mathias Agopianac9fa422013-02-11 16:40:36 -0800203 return NO_ERROR;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800204}
205
206status_t layer_state_t::read(const Parcel& input)
207{
chaviw308ddba2020-08-11 16:23:51 -0700208 SAFE_PARCEL(input.readNullableStrongBinder, &surface);
Pablo Gamitodbc31672020-09-01 18:28:58 +0000209 SAFE_PARCEL(input.readInt32, &layerId);
chaviw308ddba2020-08-11 16:23:51 -0700210 SAFE_PARCEL(input.readUint64, &what);
211 SAFE_PARCEL(input.readFloat, &x);
212 SAFE_PARCEL(input.readFloat, &y);
213 SAFE_PARCEL(input.readInt32, &z);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700214 SAFE_PARCEL(input.readUint32, &layerStack.id);
Robert Carr2c358bf2018-08-08 15:58:15 -0700215
Vishnu Nairf6eddb62021-01-27 22:02:11 -0800216 SAFE_PARCEL(input.readUint32, &flags);
chaviw308ddba2020-08-11 16:23:51 -0700217
Vishnu Nairf6eddb62021-01-27 22:02:11 -0800218 SAFE_PARCEL(input.readUint32, &mask);
chaviw308ddba2020-08-11 16:23:51 -0700219
220 SAFE_PARCEL(matrix.read, input);
chaviw25714502021-02-11 10:01:08 -0800221 SAFE_PARCEL(input.read, crop);
chaviw308ddba2020-08-11 16:23:51 -0700222
Pablo Gamito11dcc222020-09-12 15:49:39 +0000223 SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &relativeLayerSurfaceControl);
224 SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &parentSurfaceControlForChild);
225
chaviw308ddba2020-08-11 16:23:51 -0700226 float tmpFloat = 0;
chaviw308ddba2020-08-11 16:23:51 -0700227 SAFE_PARCEL(input.readFloat, &tmpFloat);
228 color.r = tmpFloat;
229 SAFE_PARCEL(input.readFloat, &tmpFloat);
230 color.g = tmpFloat;
231 SAFE_PARCEL(input.readFloat, &tmpFloat);
232 color.b = tmpFloat;
Vishnu Nairbbceb462022-10-10 04:52:13 +0000233 SAFE_PARCEL(input.readFloat, &tmpFloat);
234 color.a = tmpFloat;
235
chaviw98318de2021-05-19 16:45:23 -0500236 SAFE_PARCEL(windowInfoHandle->readFromParcel, &input);
Robert Carr2c358bf2018-08-08 15:58:15 -0700237
chaviw308ddba2020-08-11 16:23:51 -0700238 SAFE_PARCEL(input.read, transparentRegion);
Vishnu Nairbbceb462022-10-10 04:52:13 +0000239 SAFE_PARCEL(input.readUint32, &bufferTransform);
chaviw308ddba2020-08-11 16:23:51 -0700240 SAFE_PARCEL(input.readBool, &transformToDisplayInverse);
Tianhao Yao67dd7122022-02-22 17:48:33 +0000241 SAFE_PARCEL(input.readBool, &borderEnabled);
Tianhao Yao10cea3c2022-03-30 01:37:22 +0000242 SAFE_PARCEL(input.readFloat, &tmpFloat);
243 borderWidth = tmpFloat;
244 SAFE_PARCEL(input.readFloat, &tmpFloat);
245 borderColor.r = tmpFloat;
246 SAFE_PARCEL(input.readFloat, &tmpFloat);
247 borderColor.g = tmpFloat;
248 SAFE_PARCEL(input.readFloat, &tmpFloat);
249 borderColor.b = tmpFloat;
250 SAFE_PARCEL(input.readFloat, &tmpFloat);
251 borderColor.a = tmpFloat;
chaviw308ddba2020-08-11 16:23:51 -0700252
Vishnu Nairf6eddb62021-01-27 22:02:11 -0800253 uint32_t tmpUint32 = 0;
chaviw308ddba2020-08-11 16:23:51 -0700254 SAFE_PARCEL(input.readUint32, &tmpUint32);
255 dataspace = static_cast<ui::Dataspace>(tmpUint32);
256
257 SAFE_PARCEL(input.read, hdrMetadata);
258 SAFE_PARCEL(input.read, surfaceDamageRegion);
259 SAFE_PARCEL(input.readInt32, &api);
chaviwba4320c2021-09-15 15:20:53 -0500260
261 bool tmpBool = false;
chaviw308ddba2020-08-11 16:23:51 -0700262 SAFE_PARCEL(input.readBool, &tmpBool);
263 if (tmpBool) {
Marissa Wall61c58622018-07-18 10:12:20 -0700264 sidebandStream = NativeHandle::create(input.readNativeHandle(), true);
265 }
266
chaviw308ddba2020-08-11 16:23:51 -0700267 SAFE_PARCEL(input.read, &colorTransform, 16 * sizeof(float));
268 SAFE_PARCEL(input.readFloat, &cornerRadius);
269 SAFE_PARCEL(input.readUint32, &backgroundBlurRadius);
chaviw308ddba2020-08-11 16:23:51 -0700270 SAFE_PARCEL(input.readParcelable, &metadata);
Marissa Wallebc2c052019-01-16 19:16:55 -0800271
Vishnu Naird47bcee2023-02-24 18:08:51 +0000272 SAFE_PARCEL(input.readFloat, &tmpFloat);
273 bgColor.r = tmpFloat;
274 SAFE_PARCEL(input.readFloat, &tmpFloat);
275 bgColor.g = tmpFloat;
276 SAFE_PARCEL(input.readFloat, &tmpFloat);
277 bgColor.b = tmpFloat;
278 SAFE_PARCEL(input.readFloat, &tmpFloat);
279 bgColor.a = tmpFloat;
chaviw308ddba2020-08-11 16:23:51 -0700280 SAFE_PARCEL(input.readUint32, &tmpUint32);
281 bgColorDataspace = static_cast<ui::Dataspace>(tmpUint32);
282 SAFE_PARCEL(input.readBool, &colorSpaceAgnostic);
Valerie Haued54efa2019-01-11 20:03:14 -0800283
chaviw308ddba2020-08-11 16:23:51 -0700284 int32_t numListeners = 0;
285 SAFE_PARCEL_READ_SIZE(input.readInt32, &numListeners, input.dataSize());
Valerie Hau9dab9732019-08-20 09:29:25 -0700286 listeners.clear();
287 for (int i = 0; i < numListeners; i++) {
chaviw308ddba2020-08-11 16:23:51 -0700288 sp<IBinder> listener;
Valerie Hau9dab9732019-08-20 09:29:25 -0700289 std::vector<CallbackId> callbackIds;
chaviw308ddba2020-08-11 16:23:51 -0700290 SAFE_PARCEL(input.readNullableStrongBinder, &listener);
Vishnu Nairfc46c1e2021-04-21 08:31:32 -0700291 SAFE_PARCEL(input.readParcelableVector, &callbackIds);
Valerie Hau9dab9732019-08-20 09:29:25 -0700292 listeners.emplace_back(listener, callbackIds);
293 }
chaviw308ddba2020-08-11 16:23:51 -0700294 SAFE_PARCEL(input.readFloat, &shadowRadius);
295 SAFE_PARCEL(input.readInt32, &frameRateSelectionPriority);
296 SAFE_PARCEL(input.readFloat, &frameRate);
297 SAFE_PARCEL(input.readByte, &frameRateCompatibility);
Marin Shalamanovc5986772021-03-16 16:09:49 +0100298 SAFE_PARCEL(input.readByte, &changeFrameRateStrategy);
Andy Labrada096227e2022-06-15 16:58:11 +0000299 SAFE_PARCEL(input.readByte, &defaultFrameRateCompatibility);
Rachel Leece6e0042023-06-27 11:22:54 -0700300 SAFE_PARCEL(input.readByte, &frameRateCategory);
Rachel Lee67afbea2023-09-28 15:35:07 -0700301 SAFE_PARCEL(input.readBool, &frameRateCategorySmoothSwitchOnly);
Rachel Lee58cc90d2023-09-05 18:50:20 -0700302 SAFE_PARCEL(input.readByte, &frameRateSelectionStrategy);
chaviw308ddba2020-08-11 16:23:51 -0700303 SAFE_PARCEL(input.readUint32, &tmpUint32);
304 fixedTransformHint = static_cast<ui::Transform::RotationFlags>(tmpUint32);
Vishnu Naircf26a0a2020-11-13 12:56:20 -0800305 SAFE_PARCEL(input.readBool, &autoRefresh);
Sally Qi81d95e62022-03-21 19:41:33 -0700306 SAFE_PARCEL(input.readBool, &dimmingEnabled);
Lucas Dupinc3800b82020-10-02 16:24:48 -0700307
308 uint32_t numRegions = 0;
309 SAFE_PARCEL(input.readUint32, &numRegions);
310 blurRegions.clear();
311 for (uint32_t i = 0; i < numRegions; i++) {
312 BlurRegion region;
313 SAFE_PARCEL(input.readUint32, &region.blurRadius);
314 SAFE_PARCEL(input.readFloat, &region.cornerRadiusTL);
315 SAFE_PARCEL(input.readFloat, &region.cornerRadiusTR);
316 SAFE_PARCEL(input.readFloat, &region.cornerRadiusBL);
317 SAFE_PARCEL(input.readFloat, &region.cornerRadiusBR);
318 SAFE_PARCEL(input.readFloat, &region.alpha);
319 SAFE_PARCEL(input.readInt32, &region.left);
320 SAFE_PARCEL(input.readInt32, &region.top);
321 SAFE_PARCEL(input.readInt32, &region.right);
322 SAFE_PARCEL(input.readInt32, &region.bottom);
323 blurRegions.push_back(region);
324 }
John Reckcdb4ed72021-02-04 13:39:33 -0500325
326 SAFE_PARCEL(input.read, stretchEffect);
chaviwf3f40fe2021-04-27 15:54:02 -0500327 SAFE_PARCEL(input.read, bufferCrop);
Vishnu Nair6bdec7d2021-05-10 15:01:13 -0700328 SAFE_PARCEL(input.read, destinationFrame);
Winson Chunga30f7c92021-06-29 15:42:56 -0700329 SAFE_PARCEL(input.readBool, &isTrustedOverlay);
John Reckcdb4ed72021-02-04 13:39:33 -0500330
Vishnu Nair9cf4a4d2021-09-17 12:16:08 -0700331 uint32_t mode;
332 SAFE_PARCEL(input.readUint32, &mode);
333 dropInputMode = static_cast<gui::DropInputMode>(mode);
Vishnu Nair685cfef2022-02-02 10:01:25 -0800334
335 bool hasBufferData;
336 SAFE_PARCEL(input.readBool, &hasBufferData);
337 if (hasBufferData) {
338 bufferData = std::make_shared<BufferData>();
339 SAFE_PARCEL(input.readParcelable, bufferData.get());
340 } else {
341 bufferData = nullptr;
342 }
Chavi Weingarten076acac2023-01-19 17:20:43 +0000343
344 SAFE_PARCEL(input.readParcelable, &trustedPresentationThresholds);
345 SAFE_PARCEL(input.readParcelable, &trustedPresentationListener);
346
John Reck68796592023-01-25 13:47:12 -0500347 SAFE_PARCEL(input.readFloat, &tmpFloat);
Sally Qi963049b2023-03-23 14:06:21 -0700348 currentHdrSdrRatio = tmpFloat;
John Reck68796592023-01-25 13:47:12 -0500349 SAFE_PARCEL(input.readFloat, &tmpFloat);
Sally Qi963049b2023-03-23 14:06:21 -0700350 desiredHdrSdrRatio = tmpFloat;
John Reck68796592023-01-25 13:47:12 -0500351
Alec Mourif4af03e2023-02-11 00:25:24 +0000352 int32_t tmpInt32;
353 SAFE_PARCEL(input.readInt32, &tmpInt32);
354 cachingHint = static_cast<gui::CachingHint>(tmpInt32);
355
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800356 return NO_ERROR;
357}
358
Mathias Agopian698c0872011-06-28 19:09:31 -0700359status_t ComposerState::write(Parcel& output) const {
Mathias Agopian698c0872011-06-28 19:09:31 -0700360 return state.write(output);
361}
362
363status_t ComposerState::read(const Parcel& input) {
Mathias Agopian698c0872011-06-28 19:09:31 -0700364 return state.read(input);
365}
366
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700367DisplayState::DisplayState() = default;
Pablo Ceballos60d69222015-08-07 14:47:20 -0700368
Mathias Agopian8b33f032012-07-24 20:43:54 -0700369status_t DisplayState::write(Parcel& output) const {
chaviw308ddba2020-08-11 16:23:51 -0700370 SAFE_PARCEL(output.writeStrongBinder, token);
371 SAFE_PARCEL(output.writeStrongBinder, IInterface::asBinder(surface));
372 SAFE_PARCEL(output.writeUint32, what);
Evan Rosky2239b372021-05-20 13:43:47 -0700373 SAFE_PARCEL(output.writeUint32, flags);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700374 SAFE_PARCEL(output.writeUint32, layerStack.id);
chaviw308ddba2020-08-11 16:23:51 -0700375 SAFE_PARCEL(output.writeUint32, toRotationInt(orientation));
376 SAFE_PARCEL(output.write, layerStackSpaceRect);
377 SAFE_PARCEL(output.write, orientedDisplaySpaceRect);
378 SAFE_PARCEL(output.writeUint32, width);
379 SAFE_PARCEL(output.writeUint32, height);
Mathias Agopian8b33f032012-07-24 20:43:54 -0700380 return NO_ERROR;
381}
382
383status_t DisplayState::read(const Parcel& input) {
chaviw308ddba2020-08-11 16:23:51 -0700384 SAFE_PARCEL(input.readStrongBinder, &token);
385 sp<IBinder> tmpBinder;
386 SAFE_PARCEL(input.readNullableStrongBinder, &tmpBinder);
387 surface = interface_cast<IGraphicBufferProducer>(tmpBinder);
388
389 SAFE_PARCEL(input.readUint32, &what);
Evan Rosky2239b372021-05-20 13:43:47 -0700390 SAFE_PARCEL(input.readUint32, &flags);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700391 SAFE_PARCEL(input.readUint32, &layerStack.id);
chaviw308ddba2020-08-11 16:23:51 -0700392 uint32_t tmpUint = 0;
393 SAFE_PARCEL(input.readUint32, &tmpUint);
394 orientation = ui::toRotation(tmpUint);
395
396 SAFE_PARCEL(input.read, layerStackSpaceRect);
397 SAFE_PARCEL(input.read, orientedDisplaySpaceRect);
398 SAFE_PARCEL(input.readUint32, &width);
399 SAFE_PARCEL(input.readUint32, &height);
Mathias Agopian8b33f032012-07-24 20:43:54 -0700400 return NO_ERROR;
401}
402
Robert Carr2c5f6d22017-09-26 12:30:35 -0700403void DisplayState::merge(const DisplayState& other) {
404 if (other.what & eSurfaceChanged) {
405 what |= eSurfaceChanged;
406 surface = other.surface;
407 }
408 if (other.what & eLayerStackChanged) {
409 what |= eLayerStackChanged;
410 layerStack = other.layerStack;
411 }
Evan Rosky2239b372021-05-20 13:43:47 -0700412 if (other.what & eFlagsChanged) {
413 what |= eFlagsChanged;
414 flags = other.flags;
415 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700416 if (other.what & eDisplayProjectionChanged) {
417 what |= eDisplayProjectionChanged;
418 orientation = other.orientation;
Marin Shalamanov6ad317c2020-07-29 23:34:07 +0200419 layerStackSpaceRect = other.layerStackSpaceRect;
420 orientedDisplaySpaceRect = other.orientedDisplaySpaceRect;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700421 }
422 if (other.what & eDisplaySizeChanged) {
423 what |= eDisplaySizeChanged;
424 width = other.width;
425 height = other.height;
426 }
427}
428
Sally Qi6bb12822022-10-05 11:42:30 -0700429void DisplayState::sanitize(int32_t permissions) {
430 if (what & DisplayState::eLayerStackChanged) {
431 if (!(permissions & layer_state_t::Permission::ACCESS_SURFACE_FLINGER)) {
432 what &= ~DisplayState::eLayerStackChanged;
433 ALOGE("Stripped attempt to set eLayerStackChanged in sanitize");
434 }
435 }
436 if (what & DisplayState::eDisplayProjectionChanged) {
437 if (!(permissions & layer_state_t::Permission::ACCESS_SURFACE_FLINGER)) {
438 what &= ~DisplayState::eDisplayProjectionChanged;
439 ALOGE("Stripped attempt to set eDisplayProjectionChanged in sanitize");
440 }
441 }
442 if (what & DisplayState::eSurfaceChanged) {
443 if (!(permissions & layer_state_t::Permission::ACCESS_SURFACE_FLINGER)) {
444 what &= ~DisplayState::eSurfaceChanged;
445 ALOGE("Stripped attempt to set eSurfaceChanged in sanitize");
446 }
447 }
448}
449
Robert Carrde6d7b42022-01-07 18:23:06 -0800450void layer_state_t::sanitize(int32_t permissions) {
451 // TODO: b/109894387
452 //
453 // SurfaceFlinger's renderer is not prepared to handle cropping in the face of arbitrary
454 // rotation. To see the problem observe that if we have a square parent, and a child
455 // of the same size, then we rotate the child 45 degrees around its center, the child
456 // must now be cropped to a non rectangular 8 sided region.
457 //
458 // Of course we can fix this in the future. For now, we are lucky, SurfaceControl is
459 // private API, and arbitrary rotation is used in limited use cases, for instance:
460 // - WindowManager only uses rotation in one case, which is on a top level layer in which
461 // cropping is not an issue.
462 // - Launcher, as a privileged app, uses this to transition an application to PiP
463 // (picture-in-picture) mode.
464 //
465 // However given that abuse of rotation matrices could lead to surfaces extending outside
466 // of cropped areas, we need to prevent non-root clients without permission
467 // ACCESS_SURFACE_FLINGER nor ROTATE_SURFACE_FLINGER
468 // (a.k.a. everyone except WindowManager / tests / Launcher) from setting non rectangle
469 // preserving transformations.
470 if (what & eMatrixChanged) {
471 if (!(permissions & Permission::ROTATE_SURFACE_FLINGER)) {
472 ui::Transform t;
473 t.set(matrix.dsdx, matrix.dtdy, matrix.dtdx, matrix.dsdy);
474 if (!t.preserveRects()) {
475 what &= ~eMatrixChanged;
476 ALOGE("Stripped non rect preserving matrix in sanitize");
477 }
478 }
479 }
480
481 if (what & eFlagsChanged) {
482 if ((flags & eLayerIsDisplayDecoration) &&
483 !(permissions & Permission::INTERNAL_SYSTEM_WINDOW)) {
484 flags &= ~eLayerIsDisplayDecoration;
485 ALOGE("Stripped attempt to set LayerIsDisplayDecoration in sanitize");
486 }
Vishnu Nair59a6be32024-01-29 10:26:21 -0800487 if ((mask & eCanOccludePresentation) &&
488 !(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
489 flags &= ~eCanOccludePresentation;
490 mask &= ~eCanOccludePresentation;
491 ALOGE("Stripped attempt to set eCanOccludePresentation in sanitize");
492 }
Robert Carrde6d7b42022-01-07 18:23:06 -0800493 }
494
495 if (what & layer_state_t::eInputInfoChanged) {
496 if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
497 what &= ~eInputInfoChanged;
498 ALOGE("Stripped attempt to set eInputInfoChanged in sanitize");
499 }
500 }
501 if (what & layer_state_t::eTrustedOverlayChanged) {
502 if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
503 what &= ~eTrustedOverlayChanged;
504 ALOGE("Stripped attempt to set eTrustedOverlay in sanitize");
505 }
506 }
507 if (what & layer_state_t::eDropInputModeChanged) {
508 if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
509 what &= ~eDropInputModeChanged;
510 ALOGE("Stripped attempt to set eDropInputModeChanged in sanitize");
511 }
512 }
513 if (what & layer_state_t::eFrameRateSelectionPriority) {
514 if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
515 what &= ~eFrameRateSelectionPriority;
516 ALOGE("Stripped attempt to set eFrameRateSelectionPriority in sanitize");
517 }
518 }
519 if (what & layer_state_t::eFrameRateChanged) {
520 if (!ValidateFrameRate(frameRate, frameRateCompatibility,
521 changeFrameRateStrategy,
522 "layer_state_t::sanitize",
523 permissions & Permission::ACCESS_SURFACE_FLINGER)) {
524 what &= ~eFrameRateChanged; // logged in ValidateFrameRate
525 }
526 }
527}
528
Robert Carr2c5f6d22017-09-26 12:30:35 -0700529void layer_state_t::merge(const layer_state_t& other) {
530 if (other.what & ePositionChanged) {
531 what |= ePositionChanged;
532 x = other.x;
533 y = other.y;
534 }
535 if (other.what & eLayerChanged) {
536 what |= eLayerChanged;
chaviw32377582019-05-13 11:15:19 -0700537 what &= ~eRelativeLayerChanged;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700538 z = other.z;
539 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700540 if (other.what & eAlphaChanged) {
541 what |= eAlphaChanged;
Vishnu Nairbbceb462022-10-10 04:52:13 +0000542 color.a = other.color.a;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700543 }
544 if (other.what & eMatrixChanged) {
545 what |= eMatrixChanged;
546 matrix = other.matrix;
547 }
548 if (other.what & eTransparentRegionChanged) {
549 what |= eTransparentRegionChanged;
550 transparentRegion = other.transparentRegion;
551 }
552 if (other.what & eFlagsChanged) {
553 what |= eFlagsChanged;
Vishnu Nair996bc422019-07-16 14:15:33 -0700554 flags &= ~other.mask;
555 flags |= (other.flags & other.mask);
556 mask |= other.mask;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700557 }
558 if (other.what & eLayerStackChanged) {
559 what |= eLayerStackChanged;
560 layerStack = other.layerStack;
561 }
Lucas Dupin1b6531c2018-07-05 17:18:21 -0700562 if (other.what & eCornerRadiusChanged) {
563 what |= eCornerRadiusChanged;
564 cornerRadius = other.cornerRadius;
565 }
Lucas Dupin19c8f0e2019-11-25 17:55:44 -0800566 if (other.what & eBackgroundBlurRadiusChanged) {
567 what |= eBackgroundBlurRadiusChanged;
568 backgroundBlurRadius = other.backgroundBlurRadius;
569 }
Lucas Dupinc3800b82020-10-02 16:24:48 -0700570 if (other.what & eBlurRegionsChanged) {
571 what |= eBlurRegionsChanged;
572 blurRegions = other.blurRegions;
573 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700574 if (other.what & eRelativeLayerChanged) {
575 what |= eRelativeLayerChanged;
chaviw32377582019-05-13 11:15:19 -0700576 what &= ~eLayerChanged;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700577 z = other.z;
Pablo Gamito11dcc222020-09-12 15:49:39 +0000578 relativeLayerSurfaceControl = other.relativeLayerSurfaceControl;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700579 }
580 if (other.what & eReparent) {
581 what |= eReparent;
Pablo Gamito11dcc222020-09-12 15:49:39 +0000582 parentSurfaceControlForChild = other.parentSurfaceControlForChild;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700583 }
Vishnu Nairbbceb462022-10-10 04:52:13 +0000584 if (other.what & eBufferTransformChanged) {
585 what |= eBufferTransformChanged;
586 bufferTransform = other.bufferTransform;
Marissa Wall61c58622018-07-18 10:12:20 -0700587 }
588 if (other.what & eTransformToDisplayInverseChanged) {
589 what |= eTransformToDisplayInverseChanged;
590 transformToDisplayInverse = other.transformToDisplayInverse;
591 }
592 if (other.what & eCropChanged) {
593 what |= eCropChanged;
594 crop = other.crop;
595 }
596 if (other.what & eBufferChanged) {
597 what |= eBufferChanged;
chaviwba4320c2021-09-15 15:20:53 -0500598 bufferData = other.bufferData;
Marissa Wall61c58622018-07-18 10:12:20 -0700599 }
Chavi Weingarten076acac2023-01-19 17:20:43 +0000600 if (other.what & eTrustedPresentationInfoChanged) {
601 what |= eTrustedPresentationInfoChanged;
602 trustedPresentationListener = other.trustedPresentationListener;
603 trustedPresentationThresholds = other.trustedPresentationThresholds;
604 }
Marissa Wall61c58622018-07-18 10:12:20 -0700605 if (other.what & eDataspaceChanged) {
606 what |= eDataspaceChanged;
607 dataspace = other.dataspace;
608 }
John Reck68796592023-01-25 13:47:12 -0500609 if (other.what & eExtendedRangeBrightnessChanged) {
610 what |= eExtendedRangeBrightnessChanged;
Sally Qi963049b2023-03-23 14:06:21 -0700611 desiredHdrSdrRatio = other.desiredHdrSdrRatio;
612 currentHdrSdrRatio = other.currentHdrSdrRatio;
John Reck68796592023-01-25 13:47:12 -0500613 }
Alec Mourif4af03e2023-02-11 00:25:24 +0000614 if (other.what & eCachingHintChanged) {
615 what |= eCachingHintChanged;
616 cachingHint = other.cachingHint;
617 }
Marissa Wall61c58622018-07-18 10:12:20 -0700618 if (other.what & eHdrMetadataChanged) {
619 what |= eHdrMetadataChanged;
620 hdrMetadata = other.hdrMetadata;
621 }
622 if (other.what & eSurfaceDamageRegionChanged) {
623 what |= eSurfaceDamageRegionChanged;
624 surfaceDamageRegion = other.surfaceDamageRegion;
625 }
626 if (other.what & eApiChanged) {
627 what |= eApiChanged;
628 api = other.api;
629 }
630 if (other.what & eSidebandStreamChanged) {
631 what |= eSidebandStreamChanged;
632 sidebandStream = other.sidebandStream;
633 }
Peiyong Lind3788632018-09-18 16:01:31 -0700634 if (other.what & eColorTransformChanged) {
635 what |= eColorTransformChanged;
636 colorTransform = other.colorTransform;
637 }
Marissa Wall3dad52d2019-03-22 14:03:19 -0700638 if (other.what & eHasListenerCallbacksChanged) {
639 what |= eHasListenerCallbacksChanged;
Marissa Wallc837b5e2018-10-12 10:04:44 -0700640 }
Robert Carr2c358bf2018-08-08 15:58:15 -0700641 if (other.what & eInputInfoChanged) {
642 what |= eInputInfoChanged;
chaviw98318de2021-05-19 16:45:23 -0500643 windowInfoHandle = new WindowInfoHandle(*other.windowInfoHandle);
Robert Carr2c358bf2018-08-08 15:58:15 -0700644 }
Valerie Haudd0b7572019-01-29 14:59:27 -0800645 if (other.what & eBackgroundColorChanged) {
646 what |= eBackgroundColorChanged;
Vishnu Naird47bcee2023-02-24 18:08:51 +0000647 bgColor = other.bgColor;
Valerie Haudd0b7572019-01-29 14:59:27 -0800648 bgColorDataspace = other.bgColorDataspace;
Valerie Haued54efa2019-01-11 20:03:14 -0800649 }
Evan Rosky1f6d6d52018-12-06 10:47:26 -0800650 if (other.what & eMetadataChanged) {
651 what |= eMetadataChanged;
652 metadata.merge(other.metadata);
653 }
Vishnu Nairc97b8db2019-10-29 18:19:35 -0700654 if (other.what & eShadowRadiusChanged) {
655 what |= eShadowRadiusChanged;
656 shadowRadius = other.shadowRadius;
657 }
Tianhao Yao67dd7122022-02-22 17:48:33 +0000658 if (other.what & eRenderBorderChanged) {
659 what |= eRenderBorderChanged;
660 borderEnabled = other.borderEnabled;
Tianhao Yao10cea3c2022-03-30 01:37:22 +0000661 borderWidth = other.borderWidth;
662 borderColor = other.borderColor;
Tianhao Yao67dd7122022-02-22 17:48:33 +0000663 }
Andy Labrada096227e2022-06-15 16:58:11 +0000664 if (other.what & eDefaultFrameRateCompatibilityChanged) {
665 what |= eDefaultFrameRateCompatibilityChanged;
666 defaultFrameRateCompatibility = other.defaultFrameRateCompatibility;
667 }
Ana Krulecc84d09b2019-11-02 23:10:29 +0100668 if (other.what & eFrameRateSelectionPriority) {
669 what |= eFrameRateSelectionPriority;
670 frameRateSelectionPriority = other.frameRateSelectionPriority;
671 }
Steven Thomas3172e202020-01-06 19:25:30 -0800672 if (other.what & eFrameRateChanged) {
673 what |= eFrameRateChanged;
674 frameRate = other.frameRate;
Steven Thomas62a4cf82020-01-31 12:04:03 -0800675 frameRateCompatibility = other.frameRateCompatibility;
Marin Shalamanovc5986772021-03-16 16:09:49 +0100676 changeFrameRateStrategy = other.changeFrameRateStrategy;
Steven Thomas3172e202020-01-06 19:25:30 -0800677 }
Rachel Leece6e0042023-06-27 11:22:54 -0700678 if (other.what & eFrameRateCategoryChanged) {
679 what |= eFrameRateCategoryChanged;
680 frameRateCategory = other.frameRateCategory;
Rachel Lee67afbea2023-09-28 15:35:07 -0700681 frameRateCategorySmoothSwitchOnly = other.frameRateCategorySmoothSwitchOnly;
Rachel Leece6e0042023-06-27 11:22:54 -0700682 }
Rachel Lee58cc90d2023-09-05 18:50:20 -0700683 if (other.what & eFrameRateSelectionStrategyChanged) {
684 what |= eFrameRateSelectionStrategyChanged;
685 frameRateSelectionStrategy = other.frameRateSelectionStrategy;
686 }
Vishnu Nair6213bd92020-05-08 17:42:25 -0700687 if (other.what & eFixedTransformHintChanged) {
688 what |= eFixedTransformHintChanged;
689 fixedTransformHint = other.fixedTransformHint;
690 }
Vishnu Naircf26a0a2020-11-13 12:56:20 -0800691 if (other.what & eAutoRefreshChanged) {
692 what |= eAutoRefreshChanged;
693 autoRefresh = other.autoRefresh;
694 }
Winson Chunga30f7c92021-06-29 15:42:56 -0700695 if (other.what & eTrustedOverlayChanged) {
696 what |= eTrustedOverlayChanged;
697 isTrustedOverlay = other.isTrustedOverlay;
698 }
John Reckc00c6692021-02-16 11:37:33 -0500699 if (other.what & eStretchChanged) {
700 what |= eStretchChanged;
701 stretchEffect = other.stretchEffect;
702 }
chaviwf3f40fe2021-04-27 15:54:02 -0500703 if (other.what & eBufferCropChanged) {
704 what |= eBufferCropChanged;
705 bufferCrop = other.bufferCrop;
706 }
Vishnu Nair6bdec7d2021-05-10 15:01:13 -0700707 if (other.what & eDestinationFrameChanged) {
708 what |= eDestinationFrameChanged;
709 destinationFrame = other.destinationFrame;
710 }
Vishnu Nair0e816872021-07-14 10:53:04 -0700711 if (other.what & eProducerDisconnect) {
712 what |= eProducerDisconnect;
713 }
Vishnu Nair9cf4a4d2021-09-17 12:16:08 -0700714 if (other.what & eDropInputModeChanged) {
715 what |= eDropInputModeChanged;
716 dropInputMode = other.dropInputMode;
717 }
chaviw4c36cd82021-11-18 10:37:33 -0600718 if (other.what & eColorChanged) {
719 what |= eColorChanged;
Vishnu Nairbbceb462022-10-10 04:52:13 +0000720 color.rgb = other.color.rgb;
chaviw4c36cd82021-11-18 10:37:33 -0600721 }
Arthur Hung91b346a2022-03-14 21:36:22 +0800722 if (other.what & eColorSpaceAgnosticChanged) {
723 what |= eColorSpaceAgnosticChanged;
724 colorSpaceAgnostic = other.colorSpaceAgnostic;
725 }
Sally Qi81d95e62022-03-21 19:41:33 -0700726 if (other.what & eDimmingEnabledChanged) {
727 what |= eDimmingEnabledChanged;
728 dimmingEnabled = other.dimmingEnabled;
729 }
Pascal Muetschardb39918f2023-01-27 11:36:11 +0100730 if (other.what & eFlushJankData) {
731 what |= eFlushJankData;
732 }
Vishnu Nair217d8e62018-09-12 16:34:49 -0700733 if ((other.what & what) != other.what) {
734 ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? "
Vishnu Nair0e816872021-07-14 10:53:04 -0700735 "other.what=0x%" PRIX64 " what=0x%" PRIX64 " unmerged flags=0x%" PRIX64,
736 other.what, what, (other.what & what) ^ other.what);
Robert Carrd314f162018-08-15 13:12:42 -0700737 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700738}
Mathias Agopian8b33f032012-07-24 20:43:54 -0700739
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000740uint64_t layer_state_t::diff(const layer_state_t& other) const {
741 uint64_t diff = 0;
742 CHECK_DIFF2(diff, ePositionChanged, other, x, y);
743 if (other.what & eLayerChanged) {
744 diff |= eLayerChanged;
745 diff &= ~eRelativeLayerChanged;
746 }
747 CHECK_DIFF(diff, eAlphaChanged, other, color.a);
748 CHECK_DIFF(diff, eMatrixChanged, other, matrix);
749 if (other.what & eTransparentRegionChanged &&
750 (!transparentRegion.hasSameRects(other.transparentRegion))) {
751 diff |= eTransparentRegionChanged;
752 }
753 if (other.what & eFlagsChanged) {
754 uint64_t changedFlags = (flags & other.mask) ^ (other.flags & other.mask);
755 if (changedFlags) diff |= eFlagsChanged;
756 }
757 CHECK_DIFF(diff, eLayerStackChanged, other, layerStack);
758 CHECK_DIFF(diff, eCornerRadiusChanged, other, cornerRadius);
759 CHECK_DIFF(diff, eBackgroundBlurRadiusChanged, other, backgroundBlurRadius);
760 if (other.what & eBlurRegionsChanged) diff |= eBlurRegionsChanged;
761 if (other.what & eRelativeLayerChanged) {
762 diff |= eRelativeLayerChanged;
763 diff &= ~eLayerChanged;
764 }
765 if (other.what & eReparent &&
766 !SurfaceControl::isSameSurface(parentSurfaceControlForChild,
767 other.parentSurfaceControlForChild)) {
768 diff |= eReparent;
769 }
770 CHECK_DIFF(diff, eBufferTransformChanged, other, bufferTransform);
771 CHECK_DIFF(diff, eTransformToDisplayInverseChanged, other, transformToDisplayInverse);
772 CHECK_DIFF(diff, eCropChanged, other, crop);
773 if (other.what & eBufferChanged) diff |= eBufferChanged;
774 CHECK_DIFF(diff, eDataspaceChanged, other, dataspace);
Sally Qi963049b2023-03-23 14:06:21 -0700775 CHECK_DIFF2(diff, eExtendedRangeBrightnessChanged, other, currentHdrSdrRatio,
776 desiredHdrSdrRatio);
Alec Mourif4af03e2023-02-11 00:25:24 +0000777 CHECK_DIFF(diff, eCachingHintChanged, other, cachingHint);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000778 CHECK_DIFF(diff, eHdrMetadataChanged, other, hdrMetadata);
779 if (other.what & eSurfaceDamageRegionChanged &&
780 (!surfaceDamageRegion.hasSameRects(other.surfaceDamageRegion))) {
781 diff |= eSurfaceDamageRegionChanged;
782 }
783 CHECK_DIFF(diff, eApiChanged, other, api);
784 if (other.what & eSidebandStreamChanged) diff |= eSidebandStreamChanged;
785 CHECK_DIFF(diff, eApiChanged, other, api);
786 CHECK_DIFF(diff, eColorTransformChanged, other, colorTransform);
787 if (other.what & eHasListenerCallbacksChanged) diff |= eHasListenerCallbacksChanged;
788 if (other.what & eInputInfoChanged) diff |= eInputInfoChanged;
Vishnu Naird47bcee2023-02-24 18:08:51 +0000789 CHECK_DIFF2(diff, eBackgroundColorChanged, other, bgColor, bgColorDataspace);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000790 if (other.what & eMetadataChanged) diff |= eMetadataChanged;
791 CHECK_DIFF(diff, eShadowRadiusChanged, other, shadowRadius);
792 CHECK_DIFF3(diff, eRenderBorderChanged, other, borderEnabled, borderWidth, borderColor);
793 CHECK_DIFF(diff, eDefaultFrameRateCompatibilityChanged, other, defaultFrameRateCompatibility);
794 CHECK_DIFF(diff, eFrameRateSelectionPriority, other, frameRateSelectionPriority);
795 CHECK_DIFF3(diff, eFrameRateChanged, other, frameRate, frameRateCompatibility,
796 changeFrameRateStrategy);
Rachel Lee67afbea2023-09-28 15:35:07 -0700797 CHECK_DIFF2(diff, eFrameRateCategoryChanged, other, frameRateCategory,
798 frameRateCategorySmoothSwitchOnly);
Rachel Lee58cc90d2023-09-05 18:50:20 -0700799 CHECK_DIFF(diff, eFrameRateSelectionStrategyChanged, other, frameRateSelectionStrategy);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000800 CHECK_DIFF(diff, eFixedTransformHintChanged, other, fixedTransformHint);
801 CHECK_DIFF(diff, eAutoRefreshChanged, other, autoRefresh);
802 CHECK_DIFF(diff, eTrustedOverlayChanged, other, isTrustedOverlay);
803 CHECK_DIFF(diff, eStretchChanged, other, stretchEffect);
804 CHECK_DIFF(diff, eBufferCropChanged, other, bufferCrop);
805 CHECK_DIFF(diff, eDestinationFrameChanged, other, destinationFrame);
806 if (other.what & eProducerDisconnect) diff |= eProducerDisconnect;
807 CHECK_DIFF(diff, eDropInputModeChanged, other, dropInputMode);
808 CHECK_DIFF(diff, eColorChanged, other, color.rgb);
809 CHECK_DIFF(diff, eColorSpaceAgnosticChanged, other, colorSpaceAgnostic);
810 CHECK_DIFF(diff, eDimmingEnabledChanged, other, dimmingEnabled);
811 return diff;
812}
813
Vishnu Nairddf9b5c2021-03-29 18:53:41 -0700814bool layer_state_t::hasBufferChanges() const {
chaviwba4320c2021-09-15 15:20:53 -0500815 return what & layer_state_t::eBufferChanged;
Vishnu Nairddf9b5c2021-03-29 18:53:41 -0700816}
817
Ady Abraham6e8e3642021-07-08 19:44:07 -0700818bool layer_state_t::hasValidBuffer() const {
Vishnu Nair59f6d2d2022-10-05 16:59:56 -0700819 return bufferData && (bufferData->hasBuffer() || bufferData->cachedBuffer.isValid());
Ady Abraham6e8e3642021-07-08 19:44:07 -0700820}
821
chaviw308ddba2020-08-11 16:23:51 -0700822status_t layer_state_t::matrix22_t::write(Parcel& output) const {
823 SAFE_PARCEL(output.writeFloat, dsdx);
824 SAFE_PARCEL(output.writeFloat, dtdx);
825 SAFE_PARCEL(output.writeFloat, dtdy);
826 SAFE_PARCEL(output.writeFloat, dsdy);
827 return NO_ERROR;
828}
829
830status_t layer_state_t::matrix22_t::read(const Parcel& input) {
831 SAFE_PARCEL(input.readFloat, &dsdx);
832 SAFE_PARCEL(input.readFloat, &dtdx);
833 SAFE_PARCEL(input.readFloat, &dtdy);
834 SAFE_PARCEL(input.readFloat, &dsdy);
835 return NO_ERROR;
836}
837
chaviw273171b2018-12-26 11:46:30 -0800838// ------------------------------- InputWindowCommands ----------------------------------------
839
Vishnu Naire798b472020-07-23 13:52:21 -0700840bool InputWindowCommands::merge(const InputWindowCommands& other) {
841 bool changes = false;
Vishnu Naire798b472020-07-23 13:52:21 -0700842 changes |= !other.focusRequests.empty();
843 focusRequests.insert(focusRequests.end(), std::make_move_iterator(other.focusRequests.begin()),
844 std::make_move_iterator(other.focusRequests.end()));
Patrick Williams641f7f22022-06-22 19:25:35 +0000845 changes |= !other.windowInfosReportedListeners.empty();
846 windowInfosReportedListeners.insert(other.windowInfosReportedListeners.begin(),
847 other.windowInfosReportedListeners.end());
Vishnu Naire798b472020-07-23 13:52:21 -0700848 return changes;
chaviw273171b2018-12-26 11:46:30 -0800849}
850
Vishnu Nair958da932020-08-21 17:12:37 -0700851bool InputWindowCommands::empty() const {
Patrick Williams641f7f22022-06-22 19:25:35 +0000852 return focusRequests.empty() && windowInfosReportedListeners.empty();
Vishnu Nair958da932020-08-21 17:12:37 -0700853}
854
chaviw273171b2018-12-26 11:46:30 -0800855void InputWindowCommands::clear() {
Vishnu Naire798b472020-07-23 13:52:21 -0700856 focusRequests.clear();
Patrick Williams641f7f22022-06-22 19:25:35 +0000857 windowInfosReportedListeners.clear();
chaviw273171b2018-12-26 11:46:30 -0800858}
859
chaviw308ddba2020-08-11 16:23:51 -0700860status_t InputWindowCommands::write(Parcel& output) const {
chaviw308ddba2020-08-11 16:23:51 -0700861 SAFE_PARCEL(output.writeParcelableVector, focusRequests);
Patrick Williams641f7f22022-06-22 19:25:35 +0000862
863 SAFE_PARCEL(output.writeInt32, windowInfosReportedListeners.size());
864 for (const auto& listener : windowInfosReportedListeners) {
865 SAFE_PARCEL(output.writeStrongBinder, listener);
866 }
867
chaviw308ddba2020-08-11 16:23:51 -0700868 return NO_ERROR;
chaviw273171b2018-12-26 11:46:30 -0800869}
870
chaviw308ddba2020-08-11 16:23:51 -0700871status_t InputWindowCommands::read(const Parcel& input) {
chaviw308ddba2020-08-11 16:23:51 -0700872 SAFE_PARCEL(input.readParcelableVector, &focusRequests);
Patrick Williams641f7f22022-06-22 19:25:35 +0000873
874 int listenerSize = 0;
875 SAFE_PARCEL_READ_SIZE(input.readInt32, &listenerSize, input.dataSize());
876 windowInfosReportedListeners.reserve(listenerSize);
877 for (int i = 0; i < listenerSize; i++) {
878 sp<gui::IWindowInfosReportedListener> listener;
879 SAFE_PARCEL(input.readStrongBinder, &listener);
880 windowInfosReportedListeners.insert(listener);
881 }
882
chaviw308ddba2020-08-11 16:23:51 -0700883 return NO_ERROR;
chaviw273171b2018-12-26 11:46:30 -0800884}
885
chaviw618c42d2020-07-24 15:25:08 -0700886// ----------------------------------------------------------------------------
887
Huihong Luo9e84f332021-12-16 14:33:46 -0800888namespace gui {
889
890status_t CaptureArgs::writeToParcel(Parcel* output) const {
891 SAFE_PARCEL(output->writeInt32, static_cast<int32_t>(pixelFormat));
892 SAFE_PARCEL(output->write, sourceCrop);
893 SAFE_PARCEL(output->writeFloat, frameScaleX);
894 SAFE_PARCEL(output->writeFloat, frameScaleY);
895 SAFE_PARCEL(output->writeBool, captureSecureLayers);
896 SAFE_PARCEL(output->writeInt32, uid);
897 SAFE_PARCEL(output->writeInt32, static_cast<int32_t>(dataspace));
898 SAFE_PARCEL(output->writeBool, allowProtected);
899 SAFE_PARCEL(output->writeBool, grayscale);
Ajinkya Chalke02844632023-03-01 12:10:14 +0000900 SAFE_PARCEL(output->writeInt32, excludeHandles.size());
901 for (auto& excludeHandle : excludeHandles) {
902 SAFE_PARCEL(output->writeStrongBinder, excludeHandle);
903 }
Alec Mouri3e5965f2023-04-07 18:00:58 +0000904 SAFE_PARCEL(output->writeBool, hintForSeamlessTransition);
chaviw308ddba2020-08-11 16:23:51 -0700905 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700906}
907
Huihong Luo9e84f332021-12-16 14:33:46 -0800908status_t CaptureArgs::readFromParcel(const Parcel* input) {
Peiyong Lincd261472020-10-06 18:05:25 -0700909 int32_t value = 0;
Huihong Luo9e84f332021-12-16 14:33:46 -0800910 SAFE_PARCEL(input->readInt32, &value);
Peiyong Lincd261472020-10-06 18:05:25 -0700911 pixelFormat = static_cast<ui::PixelFormat>(value);
Huihong Luo9e84f332021-12-16 14:33:46 -0800912 SAFE_PARCEL(input->read, sourceCrop);
913 SAFE_PARCEL(input->readFloat, &frameScaleX);
914 SAFE_PARCEL(input->readFloat, &frameScaleY);
915 SAFE_PARCEL(input->readBool, &captureSecureLayers);
916 SAFE_PARCEL(input->readInt32, &uid);
917 SAFE_PARCEL(input->readInt32, &value);
Peiyong Lincd261472020-10-06 18:05:25 -0700918 dataspace = static_cast<ui::Dataspace>(value);
Huihong Luo9e84f332021-12-16 14:33:46 -0800919 SAFE_PARCEL(input->readBool, &allowProtected);
920 SAFE_PARCEL(input->readBool, &grayscale);
Ajinkya Chalke02844632023-03-01 12:10:14 +0000921 int32_t numExcludeHandles = 0;
922 SAFE_PARCEL_READ_SIZE(input->readInt32, &numExcludeHandles, input->dataSize());
923 excludeHandles.reserve(numExcludeHandles);
924 for (int i = 0; i < numExcludeHandles; i++) {
925 sp<IBinder> binder;
926 SAFE_PARCEL(input->readStrongBinder, &binder);
927 excludeHandles.emplace(binder);
928 }
Alec Mouri3e5965f2023-04-07 18:00:58 +0000929 SAFE_PARCEL(input->readBool, &hintForSeamlessTransition);
chaviw308ddba2020-08-11 16:23:51 -0700930 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700931}
932
Huihong Luo9e84f332021-12-16 14:33:46 -0800933status_t DisplayCaptureArgs::writeToParcel(Parcel* output) const {
934 SAFE_PARCEL(CaptureArgs::writeToParcel, output);
chaviw618c42d2020-07-24 15:25:08 -0700935
Huihong Luo9e84f332021-12-16 14:33:46 -0800936 SAFE_PARCEL(output->writeStrongBinder, displayToken);
937 SAFE_PARCEL(output->writeUint32, width);
938 SAFE_PARCEL(output->writeUint32, height);
chaviw308ddba2020-08-11 16:23:51 -0700939 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700940}
941
Huihong Luo9e84f332021-12-16 14:33:46 -0800942status_t DisplayCaptureArgs::readFromParcel(const Parcel* input) {
943 SAFE_PARCEL(CaptureArgs::readFromParcel, input);
chaviw618c42d2020-07-24 15:25:08 -0700944
Huihong Luo9e84f332021-12-16 14:33:46 -0800945 SAFE_PARCEL(input->readStrongBinder, &displayToken);
946 SAFE_PARCEL(input->readUint32, &width);
947 SAFE_PARCEL(input->readUint32, &height);
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 LayerCaptureArgs::writeToParcel(Parcel* output) const {
952 SAFE_PARCEL(CaptureArgs::writeToParcel, output);
chaviw618c42d2020-07-24 15:25:08 -0700953
Huihong Luo9e84f332021-12-16 14:33:46 -0800954 SAFE_PARCEL(output->writeStrongBinder, layerHandle);
Huihong Luo9e84f332021-12-16 14:33:46 -0800955 SAFE_PARCEL(output->writeBool, childrenOnly);
chaviw308ddba2020-08-11 16:23:51 -0700956 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700957}
958
Huihong Luo9e84f332021-12-16 14:33:46 -0800959status_t LayerCaptureArgs::readFromParcel(const Parcel* input) {
960 SAFE_PARCEL(CaptureArgs::readFromParcel, input);
chaviw618c42d2020-07-24 15:25:08 -0700961
Huihong Luo9e84f332021-12-16 14:33:46 -0800962 SAFE_PARCEL(input->readStrongBinder, &layerHandle);
chaviw618c42d2020-07-24 15:25:08 -0700963
Huihong Luo9e84f332021-12-16 14:33:46 -0800964 SAFE_PARCEL(input->readBool, &childrenOnly);
chaviw308ddba2020-08-11 16:23:51 -0700965 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700966}
967
Huihong Luo9e84f332021-12-16 14:33:46 -0800968}; // namespace gui
969
chaviw8dd181f2022-01-05 18:36:46 -0600970ReleaseCallbackId BufferData::generateReleaseCallbackId() const {
chaviwdcba9e02022-03-21 17:54:23 -0500971 uint64_t bufferId;
972 if (buffer) {
973 bufferId = buffer->getId();
974 } else {
975 bufferId = cachedBuffer.id;
976 }
977 return {bufferId, frameNumber};
chaviw8dd181f2022-01-05 18:36:46 -0600978}
979
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800980status_t BufferData::writeToParcel(Parcel* output) const {
981 SAFE_PARCEL(output->writeInt32, flags.get());
chaviwba4320c2021-09-15 15:20:53 -0500982
983 if (buffer) {
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800984 SAFE_PARCEL(output->writeBool, true);
985 SAFE_PARCEL(output->write, *buffer);
chaviwba4320c2021-09-15 15:20:53 -0500986 } else {
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800987 SAFE_PARCEL(output->writeBool, false);
chaviwba4320c2021-09-15 15:20:53 -0500988 }
989
990 if (acquireFence) {
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800991 SAFE_PARCEL(output->writeBool, true);
992 SAFE_PARCEL(output->write, *acquireFence);
chaviwba4320c2021-09-15 15:20:53 -0500993 } else {
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800994 SAFE_PARCEL(output->writeBool, false);
chaviwba4320c2021-09-15 15:20:53 -0500995 }
996
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800997 SAFE_PARCEL(output->writeUint64, frameNumber);
998 SAFE_PARCEL(output->writeStrongBinder, IInterface::asBinder(releaseBufferListener));
999 SAFE_PARCEL(output->writeStrongBinder, releaseBufferEndpoint);
chaviwba4320c2021-09-15 15:20:53 -05001000
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001001 SAFE_PARCEL(output->writeStrongBinder, cachedBuffer.token.promote());
1002 SAFE_PARCEL(output->writeUint64, cachedBuffer.id);
Robert Carr79dc06a2022-02-22 15:28:59 -08001003 SAFE_PARCEL(output->writeBool, hasBarrier);
1004 SAFE_PARCEL(output->writeUint64, barrierFrameNumber);
liulijuneb489f62022-10-17 22:02:14 +08001005 SAFE_PARCEL(output->writeUint32, producerId);
chaviwba4320c2021-09-15 15:20:53 -05001006
1007 return NO_ERROR;
1008}
1009
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001010status_t BufferData::readFromParcel(const Parcel* input) {
chaviwba4320c2021-09-15 15:20:53 -05001011 int32_t tmpInt32;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001012 SAFE_PARCEL(input->readInt32, &tmpInt32);
Dominik Laskowski2f01d772022-03-23 16:01:29 -07001013 flags = ftl::Flags<BufferDataChange>(tmpInt32);
chaviwba4320c2021-09-15 15:20:53 -05001014
1015 bool tmpBool = false;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001016 SAFE_PARCEL(input->readBool, &tmpBool);
chaviwba4320c2021-09-15 15:20:53 -05001017 if (tmpBool) {
1018 buffer = new GraphicBuffer();
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001019 SAFE_PARCEL(input->read, *buffer);
chaviwba4320c2021-09-15 15:20:53 -05001020 }
1021
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001022 SAFE_PARCEL(input->readBool, &tmpBool);
chaviwba4320c2021-09-15 15:20:53 -05001023 if (tmpBool) {
1024 acquireFence = new Fence();
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001025 SAFE_PARCEL(input->read, *acquireFence);
chaviwba4320c2021-09-15 15:20:53 -05001026 }
1027
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001028 SAFE_PARCEL(input->readUint64, &frameNumber);
chaviwba4320c2021-09-15 15:20:53 -05001029
1030 sp<IBinder> tmpBinder = nullptr;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001031 SAFE_PARCEL(input->readNullableStrongBinder, &tmpBinder);
chaviwba4320c2021-09-15 15:20:53 -05001032 if (tmpBinder) {
1033 releaseBufferListener = checked_interface_cast<ITransactionCompletedListener>(tmpBinder);
1034 }
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001035 SAFE_PARCEL(input->readNullableStrongBinder, &releaseBufferEndpoint);
chaviwba4320c2021-09-15 15:20:53 -05001036
1037 tmpBinder = nullptr;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001038 SAFE_PARCEL(input->readNullableStrongBinder, &tmpBinder);
chaviwba4320c2021-09-15 15:20:53 -05001039 cachedBuffer.token = tmpBinder;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001040 SAFE_PARCEL(input->readUint64, &cachedBuffer.id);
chaviwba4320c2021-09-15 15:20:53 -05001041
Robert Carr79dc06a2022-02-22 15:28:59 -08001042 SAFE_PARCEL(input->readBool, &hasBarrier);
1043 SAFE_PARCEL(input->readUint64, &barrierFrameNumber);
liulijuneb489f62022-10-17 22:02:14 +08001044 SAFE_PARCEL(input->readUint32, &producerId);
Robert Carr79dc06a2022-02-22 15:28:59 -08001045
chaviwba4320c2021-09-15 15:20:53 -05001046 return NO_ERROR;
1047}
1048
Chavi Weingarten076acac2023-01-19 17:20:43 +00001049status_t TrustedPresentationListener::writeToParcel(Parcel* parcel) const {
1050 SAFE_PARCEL(parcel->writeStrongBinder, callbackInterface);
1051 SAFE_PARCEL(parcel->writeInt32, callbackId);
1052 return NO_ERROR;
1053}
1054
1055status_t TrustedPresentationListener::readFromParcel(const Parcel* parcel) {
1056 sp<IBinder> tmpBinder = nullptr;
1057 SAFE_PARCEL(parcel->readNullableStrongBinder, &tmpBinder);
1058 if (tmpBinder) {
1059 callbackInterface = checked_interface_cast<ITransactionCompletedListener>(tmpBinder);
1060 }
1061 SAFE_PARCEL(parcel->readInt32, &callbackId);
1062 return NO_ERROR;
1063}
1064
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001065}; // namespace android