blob: 2f113ee47cb36e0cef4743157ec8e411f980976d [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// tag as surfaceflinger
18#define LOG_TAG "SurfaceFlinger"
19
20#include <stdint.h>
21#include <sys/types.h>
22
Pablo Gamito6ee484d2020-07-30 14:26:28 +000023#include <android/gui/ITransactionTraceListener.h>
24
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070025#include <binder/Parcel.h>
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070026#include <binder/IPCThreadState.h>
27#include <binder/IServiceManager.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080028
Mathias Agopiand0566bc2011-11-17 17:49:17 -080029#include <gui/IDisplayEventConnection.h>
Andy McFadden2adaf042012-12-18 09:49:45 -080030#include <gui/IGraphicBufferProducer.h>
Dan Stoza84ab9372018-12-17 15:27:57 -080031#include <gui/IRegionSamplingListener.h>
Mathias Agopian2b5dd402017-02-07 17:36:19 -080032#include <gui/ISurfaceComposer.h>
33#include <gui/ISurfaceComposerClient.h>
Kalle Raitaa099a242017-01-11 11:17:29 -080034#include <gui/LayerDebugInfo.h>
Robert Carr4cdc58f2017-08-23 14:22:20 -070035#include <gui/LayerState.h>
Mathias Agopiand0566bc2011-11-17 17:49:17 -080036
Michael Wright28f24d02016-07-12 13:30:53 -070037#include <system/graphics.h>
38
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -080039#include <ui/DisplayConfig.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080040#include <ui/DisplayInfo.h>
Lajos Molnar67d8bd62014-09-11 14:58:45 -070041#include <ui/DisplayStatInfo.h>
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -080042#include <ui/DisplayState.h>
Dan Stozac4f471e2016-03-24 09:31:08 -070043#include <ui/HdrCapabilities.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080044
Jamie Gennis134f0422011-03-08 12:18:54 -080045#include <utils/Log.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -080046
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080047// ---------------------------------------------------------------------------
48
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080049namespace android {
50
Peiyong Lin9f034472018-03-28 15:29:00 -070051using ui::ColorMode;
52
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080053class BpSurfaceComposer : public BpInterface<ISurfaceComposer>
54{
55public:
Chih-Hung Hsiehe2347b72016-04-25 15:41:05 -070056 explicit BpSurfaceComposer(const sp<IBinder>& impl)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080057 : BpInterface<ISurfaceComposer>(impl)
58 {
59 }
60
Dan Stozad723bd72014-11-18 10:24:03 -080061 virtual ~BpSurfaceComposer();
62
Mathias Agopian7e27f052010-05-28 14:22:23 -070063 virtual sp<ISurfaceComposerClient> createConnection()
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080064 {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080065 Parcel data, reply;
66 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
67 remote()->transact(BnSurfaceComposer::CREATE_CONNECTION, data, &reply);
Mathias Agopian7e27f052010-05-28 14:22:23 -070068 return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080069 }
70
chaviw308ddba2020-08-11 16:23:51 -070071 virtual status_t setTransactionState(
72 const Vector<ComposerState>& state, const Vector<DisplayState>& displays,
73 uint32_t flags, const sp<IBinder>& applyToken, const InputWindowCommands& commands,
74 int64_t desiredPresentTime, const client_cache_t& uncacheBuffer,
Pablo Gamito7eb7ee72020-08-05 10:57:05 +000075 bool hasListenerCallbacks, const std::vector<ListenerCallbacks>& listenerCallbacks,
76 uint64_t transactionId) {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080077 Parcel data, reply;
78 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Dan Stozad723bd72014-11-18 10:24:03 -080079
chaviw308ddba2020-08-11 16:23:51 -070080 SAFE_PARCEL(data.writeUint32, static_cast<uint32_t>(state.size()));
Dan Stozad723bd72014-11-18 10:24:03 -080081 for (const auto& s : state) {
chaviw308ddba2020-08-11 16:23:51 -070082 SAFE_PARCEL(s.write, data);
Mathias Agopian698c0872011-06-28 19:09:31 -070083 }
Dan Stozad723bd72014-11-18 10:24:03 -080084
chaviw308ddba2020-08-11 16:23:51 -070085 SAFE_PARCEL(data.writeUint32, static_cast<uint32_t>(displays.size()));
Dan Stozad723bd72014-11-18 10:24:03 -080086 for (const auto& d : displays) {
chaviw308ddba2020-08-11 16:23:51 -070087 SAFE_PARCEL(d.write, data);
Mathias Agopian8b33f032012-07-24 20:43:54 -070088 }
Dan Stozad723bd72014-11-18 10:24:03 -080089
chaviw308ddba2020-08-11 16:23:51 -070090 SAFE_PARCEL(data.writeUint32, flags);
91 SAFE_PARCEL(data.writeStrongBinder, applyToken);
92 SAFE_PARCEL(commands.write, data);
93 SAFE_PARCEL(data.writeInt64, desiredPresentTime);
94 SAFE_PARCEL(data.writeStrongBinder, uncacheBuffer.token.promote());
95 SAFE_PARCEL(data.writeUint64, uncacheBuffer.id);
96 SAFE_PARCEL(data.writeBool, hasListenerCallbacks);
Marissa Wall3dad52d2019-03-22 14:03:19 -070097
chaviw308ddba2020-08-11 16:23:51 -070098 SAFE_PARCEL(data.writeVectorSize, listenerCallbacks);
99 for (const auto& [listener, callbackIds] : listenerCallbacks) {
100 SAFE_PARCEL(data.writeStrongBinder, listener);
101 SAFE_PARCEL(data.writeInt64Vector, callbackIds);
Marissa Wall3dad52d2019-03-22 14:03:19 -0700102 }
103
Pablo Gamito7eb7ee72020-08-05 10:57:05 +0000104 SAFE_PARCEL(data.writeUint64, transactionId);
105
chaviw308ddba2020-08-11 16:23:51 -0700106 return remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800107 }
108
109 virtual void bootFinished()
110 {
111 Parcel data, reply;
112 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
113 remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply);
114 }
115
chaviwd2432892020-07-24 17:42:39 -0700116 virtual status_t captureDisplay(const DisplayCaptureArgs& args,
chaviw8ffc7b82020-08-18 11:25:37 -0700117 const sp<IScreenCaptureListener>& captureListener) {
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800118 Parcel data, reply;
119 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
chaviw308ddba2020-08-11 16:23:51 -0700120 SAFE_PARCEL(args.write, data);
chaviw8ffc7b82020-08-18 11:25:37 -0700121 SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(captureListener));
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000122
chaviw8ffc7b82020-08-18 11:25:37 -0700123 return remote()->transact(BnSurfaceComposer::CAPTURE_DISPLAY, data, &reply);
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800124 }
125
chaviwd2432892020-07-24 17:42:39 -0700126 virtual status_t captureDisplay(uint64_t displayOrLayerStack,
chaviw8ffc7b82020-08-18 11:25:37 -0700127 const sp<IScreenCaptureListener>& captureListener) {
chaviw93df2ea2019-04-30 16:45:12 -0700128 Parcel data, reply;
129 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
chaviw8ffc7b82020-08-18 11:25:37 -0700130 SAFE_PARCEL(data.writeUint64, displayOrLayerStack);
131 SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(captureListener));
chaviw93df2ea2019-04-30 16:45:12 -0700132
chaviw8ffc7b82020-08-18 11:25:37 -0700133 return remote()->transact(BnSurfaceComposer::CAPTURE_DISPLAY_BY_ID, data, &reply);
chaviw93df2ea2019-04-30 16:45:12 -0700134 }
135
chaviw3efadb12020-07-27 10:07:15 -0700136 virtual status_t captureLayers(const LayerCaptureArgs& args,
chaviw8ffc7b82020-08-18 11:25:37 -0700137 const sp<IScreenCaptureListener>& captureListener) {
chaviwa76b2712017-09-20 12:02:26 -0700138 Parcel data, reply;
139 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
chaviw308ddba2020-08-11 16:23:51 -0700140 SAFE_PARCEL(args.write, data);
chaviw8ffc7b82020-08-18 11:25:37 -0700141 SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(captureListener));
chaviw3efadb12020-07-27 10:07:15 -0700142
chaviw8ffc7b82020-08-18 11:25:37 -0700143 return remote()->transact(BnSurfaceComposer::CAPTURE_LAYERS, data, &reply);
chaviwa76b2712017-09-20 12:02:26 -0700144 }
145
Jamie Gennis582270d2011-08-17 18:19:00 -0700146 virtual bool authenticateSurfaceTexture(
Andy McFadden2adaf042012-12-18 09:49:45 -0800147 const sp<IGraphicBufferProducer>& bufferProducer) const
Jamie Gennis134f0422011-03-08 12:18:54 -0800148 {
149 Parcel data, reply;
150 int err = NO_ERROR;
151 err = data.writeInterfaceToken(
152 ISurfaceComposer::getInterfaceDescriptor());
153 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000154 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis134f0422011-03-08 12:18:54 -0800155 "interface descriptor: %s (%d)", strerror(-err), -err);
156 return false;
157 }
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800158 err = data.writeStrongBinder(IInterface::asBinder(bufferProducer));
Jamie Gennis134f0422011-03-08 12:18:54 -0800159 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000160 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis582270d2011-08-17 18:19:00 -0700161 "strong binder to parcel: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800162 return false;
163 }
164 err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
165 &reply);
166 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000167 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700168 "performing transaction: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800169 return false;
170 }
171 int32_t result = 0;
172 err = reply.readInt32(&result);
173 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000174 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700175 "retrieving result: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800176 return false;
177 }
178 return result != 0;
179 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800180
Brian Anderson6b376712017-04-04 10:51:39 -0700181 virtual status_t getSupportedFrameTimestamps(
182 std::vector<FrameEvent>* outSupported) const {
183 if (!outSupported) {
184 return UNEXPECTED_NULL;
185 }
186 outSupported->clear();
187
188 Parcel data, reply;
189
190 status_t err = data.writeInterfaceToken(
191 ISurfaceComposer::getInterfaceDescriptor());
192 if (err != NO_ERROR) {
193 return err;
194 }
195
196 err = remote()->transact(
197 BnSurfaceComposer::GET_SUPPORTED_FRAME_TIMESTAMPS,
198 data, &reply);
199 if (err != NO_ERROR) {
200 return err;
201 }
202
203 int32_t result = 0;
204 err = reply.readInt32(&result);
205 if (err != NO_ERROR) {
206 return err;
207 }
208 if (result != NO_ERROR) {
209 return result;
210 }
211
212 std::vector<int32_t> supported;
213 err = reply.readInt32Vector(&supported);
214 if (err != NO_ERROR) {
215 return err;
216 }
217
218 outSupported->reserve(supported.size());
219 for (int32_t s : supported) {
220 outSupported->push_back(static_cast<FrameEvent>(s));
221 }
222 return NO_ERROR;
223 }
224
Ady Abraham0f4a1b12019-06-04 16:04:04 -0700225 virtual sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource,
226 ConfigChanged configChanged) {
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800227 Parcel data, reply;
228 sp<IDisplayEventConnection> result;
229 int err = data.writeInterfaceToken(
230 ISurfaceComposer::getInterfaceDescriptor());
231 if (err != NO_ERROR) {
232 return result;
233 }
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700234 data.writeInt32(static_cast<int32_t>(vsyncSource));
Ady Abraham0f4a1b12019-06-04 16:04:04 -0700235 data.writeInt32(static_cast<int32_t>(configChanged));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800236 err = remote()->transact(
237 BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION,
238 data, &reply);
239 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000240 ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing "
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800241 "transaction: %s (%d)", strerror(-err), -err);
242 return result;
243 }
244 result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder());
245 return result;
246 }
Colin Cross8e533062012-06-07 13:17:52 -0700247
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700248 virtual sp<IBinder> createDisplay(const String8& displayName, bool secure)
Mathias Agopiane57f2922012-08-09 16:29:12 -0700249 {
250 Parcel data, reply;
251 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
chaviwd4a61642020-09-01 14:53:46 -0700252 status_t status = data.writeString8(displayName);
253 if (status) {
254 return nullptr;
255 }
256 status = data.writeBool(secure);
257 if (status) {
258 return nullptr;
259 }
260
261 status = remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply);
262 if (status) {
263 return nullptr;
264 }
265 sp<IBinder> display;
266 status = reply.readNullableStrongBinder(&display);
267 if (status) {
268 return nullptr;
269 }
270 return display;
Mathias Agopiane57f2922012-08-09 16:29:12 -0700271 }
272
Jesse Hall6c913be2013-08-08 12:15:49 -0700273 virtual void destroyDisplay(const sp<IBinder>& display)
274 {
275 Parcel data, reply;
276 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
277 data.writeStrongBinder(display);
278 remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply);
279 }
280
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800281 virtual std::vector<PhysicalDisplayId> getPhysicalDisplayIds() const {
Mathias Agopiane57f2922012-08-09 16:29:12 -0700282 Parcel data, reply;
283 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800284 if (remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_IDS, data, &reply) ==
285 NO_ERROR) {
Marin Shalamanova524a092020-07-27 21:39:55 +0200286 std::vector<uint64_t> rawIds;
287 if (reply.readUint64Vector(&rawIds) == NO_ERROR) {
288 std::vector<PhysicalDisplayId> displayIds(rawIds.size());
289 std::transform(rawIds.begin(), rawIds.end(), displayIds.begin(),
290 [](uint64_t rawId) { return PhysicalDisplayId(rawId); });
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800291 return displayIds;
292 }
293 }
294
295 return {};
296 }
297
298 virtual sp<IBinder> getPhysicalDisplayToken(PhysicalDisplayId displayId) const {
299 Parcel data, reply;
300 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Marin Shalamanova524a092020-07-27 21:39:55 +0200301 data.writeUint64(displayId.value);
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800302 remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_TOKEN, data, &reply);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700303 return reply.readStrongBinder();
304 }
305
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700306 virtual void setPowerMode(const sp<IBinder>& display, int mode)
Colin Cross8e533062012-06-07 13:17:52 -0700307 {
308 Parcel data, reply;
309 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700310 data.writeStrongBinder(display);
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700311 data.writeInt32(mode);
312 remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply);
Colin Cross8e533062012-06-07 13:17:52 -0700313 }
Mathias Agopian3094df32012-06-18 18:06:45 -0700314
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800315 virtual status_t getDisplayState(const sp<IBinder>& display, ui::DisplayState* state) {
316 Parcel data, reply;
317 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
318 data.writeStrongBinder(display);
319 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATE, data, &reply);
320 const status_t result = reply.readInt32();
321 if (result == NO_ERROR) {
322 memcpy(state, reply.readInplace(sizeof(ui::DisplayState)), sizeof(ui::DisplayState));
323 }
324 return result;
325 }
326
327 virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) {
328 Parcel data, reply;
329 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
330 data.writeStrongBinder(display);
331 remote()->transact(BnSurfaceComposer::GET_DISPLAY_INFO, data, &reply);
332 const status_t result = reply.readInt32();
Marin Shalamanov359a7e72020-02-17 17:03:07 +0100333 if (result != NO_ERROR) return result;
334 return reply.read(*info);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800335 }
336
337 virtual status_t getDisplayConfigs(const sp<IBinder>& display, Vector<DisplayConfig>* configs) {
Mathias Agopianc666cae2012-07-25 18:56:13 -0700338 Parcel data, reply;
339 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700340 data.writeStrongBinder(display);
Dan Stoza7f7da322014-05-02 15:26:25 -0700341 remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800342 const status_t result = reply.readInt32();
Dan Stoza7f7da322014-05-02 15:26:25 -0700343 if (result == NO_ERROR) {
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800344 const size_t numConfigs = reply.readUint32();
Dan Stoza7f7da322014-05-02 15:26:25 -0700345 configs->clear();
346 configs->resize(numConfigs);
347 for (size_t c = 0; c < numConfigs; ++c) {
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800348 memcpy(&(configs->editItemAt(c)), reply.readInplace(sizeof(DisplayConfig)),
349 sizeof(DisplayConfig));
Dan Stoza7f7da322014-05-02 15:26:25 -0700350 }
351 }
352 return result;
353 }
354
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700355 virtual status_t getDisplayStats(const sp<IBinder>& display,
356 DisplayStatInfo* stats)
357 {
358 Parcel data, reply;
359 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
360 data.writeStrongBinder(display);
361 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply);
362 status_t result = reply.readInt32();
363 if (result == NO_ERROR) {
364 memcpy(stats,
365 reply.readInplace(sizeof(DisplayStatInfo)),
366 sizeof(DisplayStatInfo));
367 }
368 return result;
369 }
370
Dan Stoza7f7da322014-05-02 15:26:25 -0700371 virtual int getActiveConfig(const sp<IBinder>& display)
372 {
373 Parcel data, reply;
374 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
375 data.writeStrongBinder(display);
376 remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply);
377 return reply.readInt32();
378 }
379
Michael Wright28f24d02016-07-12 13:30:53 -0700380 virtual status_t getDisplayColorModes(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700381 Vector<ColorMode>* outColorModes) {
Michael Wright28f24d02016-07-12 13:30:53 -0700382 Parcel data, reply;
383 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
384 if (result != NO_ERROR) {
385 ALOGE("getDisplayColorModes failed to writeInterfaceToken: %d", result);
386 return result;
387 }
388 result = data.writeStrongBinder(display);
389 if (result != NO_ERROR) {
390 ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result);
391 return result;
392 }
393 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply);
394 if (result != NO_ERROR) {
395 ALOGE("getDisplayColorModes failed to transact: %d", result);
396 return result;
397 }
398 result = static_cast<status_t>(reply.readInt32());
399 if (result == NO_ERROR) {
400 size_t numModes = reply.readUint32();
401 outColorModes->clear();
402 outColorModes->resize(numModes);
403 for (size_t i = 0; i < numModes; ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -0700404 outColorModes->replaceAt(static_cast<ColorMode>(reply.readInt32()), i);
Michael Wright28f24d02016-07-12 13:30:53 -0700405 }
406 }
407 return result;
408 }
409
Daniel Solomon42d04562019-01-20 21:03:19 -0800410 virtual status_t getDisplayNativePrimaries(const sp<IBinder>& display,
411 ui::DisplayPrimaries& primaries) {
412 Parcel data, reply;
413 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
414 if (result != NO_ERROR) {
415 ALOGE("getDisplayNativePrimaries failed to writeInterfaceToken: %d", result);
416 return result;
417 }
418 result = data.writeStrongBinder(display);
419 if (result != NO_ERROR) {
420 ALOGE("getDisplayNativePrimaries failed to writeStrongBinder: %d", result);
421 return result;
422 }
423 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_NATIVE_PRIMARIES, data, &reply);
424 if (result != NO_ERROR) {
425 ALOGE("getDisplayNativePrimaries failed to transact: %d", result);
426 return result;
427 }
428 result = reply.readInt32();
429 if (result == NO_ERROR) {
430 memcpy(&primaries, reply.readInplace(sizeof(ui::DisplayPrimaries)),
431 sizeof(ui::DisplayPrimaries));
432 }
433 return result;
434 }
435
Peiyong Lina52f0292018-03-14 17:26:31 -0700436 virtual ColorMode getActiveColorMode(const sp<IBinder>& display) {
Michael Wright28f24d02016-07-12 13:30:53 -0700437 Parcel data, reply;
438 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
439 if (result != NO_ERROR) {
440 ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700441 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700442 }
443 result = data.writeStrongBinder(display);
444 if (result != NO_ERROR) {
445 ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700446 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700447 }
448 result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply);
449 if (result != NO_ERROR) {
450 ALOGE("getActiveColorMode failed to transact: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700451 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700452 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700453 return static_cast<ColorMode>(reply.readInt32());
Michael Wright28f24d02016-07-12 13:30:53 -0700454 }
455
456 virtual status_t setActiveColorMode(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700457 ColorMode colorMode) {
Michael Wright28f24d02016-07-12 13:30:53 -0700458 Parcel data, reply;
459 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
460 if (result != NO_ERROR) {
461 ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result);
462 return result;
463 }
464 result = data.writeStrongBinder(display);
465 if (result != NO_ERROR) {
466 ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result);
467 return result;
468 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700469 result = data.writeInt32(static_cast<int32_t>(colorMode));
Michael Wright28f24d02016-07-12 13:30:53 -0700470 if (result != NO_ERROR) {
471 ALOGE("setActiveColorMode failed to writeInt32: %d", result);
472 return result;
473 }
474 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply);
475 if (result != NO_ERROR) {
476 ALOGE("setActiveColorMode failed to transact: %d", result);
477 return result;
478 }
479 return static_cast<status_t>(reply.readInt32());
480 }
481
Galia Peycheva5492cb52019-10-30 14:13:16 +0100482 virtual status_t getAutoLowLatencyModeSupport(const sp<IBinder>& display,
483 bool* outSupport) const {
484 Parcel data, reply;
485 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
486 status_t result = data.writeStrongBinder(display);
487 if (result != NO_ERROR) {
488 ALOGE("getAutoLowLatencyModeSupport failed to writeStrongBinder: %d", result);
489 return result;
490 }
491 result = remote()->transact(BnSurfaceComposer::GET_AUTO_LOW_LATENCY_MODE_SUPPORT, data,
492 &reply);
493 if (result != NO_ERROR) {
494 ALOGE("getAutoLowLatencyModeSupport failed to transact: %d", result);
495 return result;
496 }
497 return reply.readBool(outSupport);
498 }
499
500 virtual void setAutoLowLatencyMode(const sp<IBinder>& display, bool on) {
501 Parcel data, reply;
502 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
503 if (result != NO_ERROR) {
504 ALOGE("setAutoLowLatencyMode failed to writeInterfaceToken: %d", result);
505 return;
506 }
507
508 result = data.writeStrongBinder(display);
509 if (result != NO_ERROR) {
510 ALOGE("setAutoLowLatencyMode failed to writeStrongBinder: %d", result);
511 return;
512 }
513 result = data.writeBool(on);
514 if (result != NO_ERROR) {
515 ALOGE("setAutoLowLatencyMode failed to writeBool: %d", result);
516 return;
517 }
518 result = remote()->transact(BnSurfaceComposer::SET_AUTO_LOW_LATENCY_MODE, data, &reply);
519 if (result != NO_ERROR) {
520 ALOGE("setAutoLowLatencyMode failed to transact: %d", result);
521 return;
522 }
523 }
524
525 virtual status_t getGameContentTypeSupport(const sp<IBinder>& display, bool* outSupport) const {
526 Parcel data, reply;
527 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
528 status_t result = data.writeStrongBinder(display);
529 if (result != NO_ERROR) {
530 ALOGE("getGameContentTypeSupport failed to writeStrongBinder: %d", result);
531 return result;
532 }
533 result = remote()->transact(BnSurfaceComposer::GET_GAME_CONTENT_TYPE_SUPPORT, data, &reply);
534 if (result != NO_ERROR) {
535 ALOGE("getGameContentTypeSupport failed to transact: %d", result);
536 return result;
537 }
538 return reply.readBool(outSupport);
539 }
540
541 virtual void setGameContentType(const sp<IBinder>& display, bool on) {
542 Parcel data, reply;
543 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
544 if (result != NO_ERROR) {
545 ALOGE("setGameContentType failed to writeInterfaceToken: %d", result);
546 return;
547 }
548 result = data.writeStrongBinder(display);
549 if (result != NO_ERROR) {
550 ALOGE("setGameContentType failed to writeStrongBinder: %d", result);
551 return;
552 }
553 result = data.writeBool(on);
554 if (result != NO_ERROR) {
555 ALOGE("setGameContentType failed to writeBool: %d", result);
556 return;
557 }
558 result = remote()->transact(BnSurfaceComposer::SET_GAME_CONTENT_TYPE, data, &reply);
559 if (result != NO_ERROR) {
560 ALOGE("setGameContentType failed to transact: %d", result);
561 }
562 }
563
Svetoslavd85084b2014-03-20 10:28:31 -0700564 virtual status_t clearAnimationFrameStats() {
565 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700566 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
567 if (result != NO_ERROR) {
568 ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result);
569 return result;
570 }
571 result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply);
572 if (result != NO_ERROR) {
573 ALOGE("clearAnimationFrameStats failed to transact: %d", result);
574 return result;
575 }
Svetoslavd85084b2014-03-20 10:28:31 -0700576 return reply.readInt32();
577 }
578
579 virtual status_t getAnimationFrameStats(FrameStats* outStats) const {
580 Parcel data, reply;
581 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
582 remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply);
583 reply.read(*outStats);
584 return reply.readInt32();
585 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700586
587 virtual status_t getHdrCapabilities(const sp<IBinder>& display,
588 HdrCapabilities* outCapabilities) const {
589 Parcel data, reply;
590 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
591 status_t result = data.writeStrongBinder(display);
592 if (result != NO_ERROR) {
593 ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result);
594 return result;
595 }
596 result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES,
597 data, &reply);
598 if (result != NO_ERROR) {
599 ALOGE("getHdrCapabilities failed to transact: %d", result);
600 return result;
601 }
602 result = reply.readInt32();
603 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800604 result = reply.read(*outCapabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700605 }
606 return result;
607 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700608
609 virtual status_t enableVSyncInjections(bool enable) {
610 Parcel data, reply;
611 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
612 if (result != NO_ERROR) {
613 ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result);
614 return result;
615 }
616 result = data.writeBool(enable);
617 if (result != NO_ERROR) {
618 ALOGE("enableVSyncInjections failed to writeBool: %d", result);
619 return result;
620 }
Steven Moreland366eb422019-04-01 19:22:32 -0700621 result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS, data, &reply,
622 IBinder::FLAG_ONEWAY);
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700623 if (result != NO_ERROR) {
624 ALOGE("enableVSyncInjections failed to transact: %d", result);
625 return result;
626 }
627 return result;
628 }
629
630 virtual status_t injectVSync(nsecs_t when) {
631 Parcel data, reply;
632 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
633 if (result != NO_ERROR) {
634 ALOGE("injectVSync failed to writeInterfaceToken: %d", result);
635 return result;
636 }
637 result = data.writeInt64(when);
638 if (result != NO_ERROR) {
639 ALOGE("injectVSync failed to writeInt64: %d", result);
640 return result;
641 }
Steven Moreland366eb422019-04-01 19:22:32 -0700642 result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply,
643 IBinder::FLAG_ONEWAY);
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700644 if (result != NO_ERROR) {
645 ALOGE("injectVSync failed to transact: %d", result);
646 return result;
647 }
648 return result;
649 }
650
Vishnu Nair43bccf82020-06-05 10:53:37 -0700651 virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) {
Kalle Raitaa099a242017-01-11 11:17:29 -0800652 if (!outLayers) {
653 return UNEXPECTED_NULL;
654 }
655
656 Parcel data, reply;
657
658 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
659 if (err != NO_ERROR) {
660 return err;
661 }
662
663 err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply);
664 if (err != NO_ERROR) {
665 return err;
666 }
667
668 int32_t result = 0;
669 err = reply.readInt32(&result);
670 if (err != NO_ERROR) {
671 return err;
672 }
673 if (result != NO_ERROR) {
674 return result;
675 }
676
677 outLayers->clear();
678 return reply.readParcelableVector(outLayers);
679 }
Peiyong Lin0256f722018-08-31 15:45:10 -0700680
Peiyong Linc6780972018-10-28 15:24:08 -0700681 virtual status_t getCompositionPreference(ui::Dataspace* defaultDataspace,
682 ui::PixelFormat* defaultPixelFormat,
683 ui::Dataspace* wideColorGamutDataspace,
684 ui::PixelFormat* wideColorGamutPixelFormat) const {
Peiyong Lin0256f722018-08-31 15:45:10 -0700685 Parcel data, reply;
686 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
687 if (error != NO_ERROR) {
688 return error;
689 }
690 error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply);
691 if (error != NO_ERROR) {
692 return error;
693 }
694 error = static_cast<status_t>(reply.readInt32());
695 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -0700696 *defaultDataspace = static_cast<ui::Dataspace>(reply.readInt32());
697 *defaultPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
698 *wideColorGamutDataspace = static_cast<ui::Dataspace>(reply.readInt32());
699 *wideColorGamutPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
Peiyong Lin0256f722018-08-31 15:45:10 -0700700 }
701 return error;
702 }
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700703
Ady Abraham37965d42018-11-01 13:43:32 -0700704 virtual status_t getColorManagement(bool* outGetColorManagement) const {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700705 Parcel data, reply;
706 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Ady Abraham37965d42018-11-01 13:43:32 -0700707 remote()->transact(BnSurfaceComposer::GET_COLOR_MANAGEMENT, data, &reply);
708 bool result;
709 status_t err = reply.readBool(&result);
710 if (err == NO_ERROR) {
711 *outGetColorManagement = result;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700712 }
Ady Abraham37965d42018-11-01 13:43:32 -0700713 return err;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700714 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -0700715
716 virtual status_t getDisplayedContentSamplingAttributes(const sp<IBinder>& display,
717 ui::PixelFormat* outFormat,
718 ui::Dataspace* outDataspace,
719 uint8_t* outComponentMask) const {
720 if (!outFormat || !outDataspace || !outComponentMask) return BAD_VALUE;
721 Parcel data, reply;
722 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
723 data.writeStrongBinder(display);
724
725 status_t error =
726 remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES,
727 data, &reply);
728 if (error != NO_ERROR) {
729 return error;
730 }
731
732 uint32_t value = 0;
733 error = reply.readUint32(&value);
734 if (error != NO_ERROR) {
735 return error;
736 }
737 *outFormat = static_cast<ui::PixelFormat>(value);
738
739 error = reply.readUint32(&value);
740 if (error != NO_ERROR) {
741 return error;
742 }
743 *outDataspace = static_cast<ui::Dataspace>(value);
744
745 error = reply.readUint32(&value);
746 if (error != NO_ERROR) {
747 return error;
748 }
749 *outComponentMask = static_cast<uint8_t>(value);
750 return error;
751 }
Kevin DuBois74e53772018-11-19 10:52:38 -0800752
753 virtual status_t setDisplayContentSamplingEnabled(const sp<IBinder>& display, bool enable,
Dominik Laskowski470df5f2020-04-02 22:27:42 -0700754 uint8_t componentMask, uint64_t maxFrames) {
Kevin DuBois74e53772018-11-19 10:52:38 -0800755 Parcel data, reply;
756 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
757 data.writeStrongBinder(display);
758 data.writeBool(enable);
759 data.writeByte(static_cast<int8_t>(componentMask));
760 data.writeUint64(maxFrames);
761 status_t result =
762 remote()->transact(BnSurfaceComposer::SET_DISPLAY_CONTENT_SAMPLING_ENABLED, data,
763 &reply);
764 return result;
765 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700766
767 virtual status_t getDisplayedContentSample(const sp<IBinder>& display, uint64_t maxFrames,
768 uint64_t timestamp,
769 DisplayedFrameStats* outStats) const {
770 if (!outStats) return BAD_VALUE;
771
772 Parcel data, reply;
773 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
774 data.writeStrongBinder(display);
775 data.writeUint64(maxFrames);
776 data.writeUint64(timestamp);
777
778 status_t result =
779 remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLE, data, &reply);
780
781 if (result != NO_ERROR) {
782 return result;
783 }
784
785 result = reply.readUint64(&outStats->numFrames);
786 if (result != NO_ERROR) {
787 return result;
788 }
789
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800790 result = reply.readUint64Vector(&outStats->component_0_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700791 if (result != NO_ERROR) {
792 return result;
793 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800794 result = reply.readUint64Vector(&outStats->component_1_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700795 if (result != NO_ERROR) {
796 return result;
797 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800798 result = reply.readUint64Vector(&outStats->component_2_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700799 if (result != NO_ERROR) {
800 return result;
801 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800802 result = reply.readUint64Vector(&outStats->component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700803 return result;
804 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800805
806 virtual status_t getProtectedContentSupport(bool* outSupported) const {
807 Parcel data, reply;
808 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Peiyong Linb6888fa2019-01-28 13:20:58 -0800809 status_t error =
810 remote()->transact(BnSurfaceComposer::GET_PROTECTED_CONTENT_SUPPORT, data, &reply);
811 if (error != NO_ERROR) {
812 return error;
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800813 }
Peiyong Linb6888fa2019-01-28 13:20:58 -0800814 error = reply.readBool(outSupported);
815 return error;
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800816 }
Marissa Wallebc2c052019-01-16 19:16:55 -0800817
Peiyong Lin4f3fddf2019-01-24 17:21:24 -0800818 virtual status_t isWideColorDisplay(const sp<IBinder>& token,
819 bool* outIsWideColorDisplay) const {
820 Parcel data, reply;
821 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
822 if (error != NO_ERROR) {
823 return error;
824 }
825 error = data.writeStrongBinder(token);
826 if (error != NO_ERROR) {
827 return error;
828 }
829
830 error = remote()->transact(BnSurfaceComposer::IS_WIDE_COLOR_DISPLAY, data, &reply);
831 if (error != NO_ERROR) {
832 return error;
833 }
834 error = reply.readBool(outIsWideColorDisplay);
835 return error;
836 }
Dan Stoza84ab9372018-12-17 15:27:57 -0800837
838 virtual status_t addRegionSamplingListener(const Rect& samplingArea,
839 const sp<IBinder>& stopLayerHandle,
840 const sp<IRegionSamplingListener>& listener) {
841 Parcel data, reply;
842 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
843 if (error != NO_ERROR) {
844 ALOGE("addRegionSamplingListener: Failed to write interface token");
845 return error;
846 }
847 error = data.write(samplingArea);
848 if (error != NO_ERROR) {
849 ALOGE("addRegionSamplingListener: Failed to write sampling area");
850 return error;
851 }
852 error = data.writeStrongBinder(stopLayerHandle);
853 if (error != NO_ERROR) {
854 ALOGE("addRegionSamplingListener: Failed to write stop layer handle");
855 return error;
856 }
857 error = data.writeStrongBinder(IInterface::asBinder(listener));
858 if (error != NO_ERROR) {
859 ALOGE("addRegionSamplingListener: Failed to write listener");
860 return error;
861 }
862 error = remote()->transact(BnSurfaceComposer::ADD_REGION_SAMPLING_LISTENER, data, &reply);
863 if (error != NO_ERROR) {
864 ALOGE("addRegionSamplingListener: Failed to transact");
865 }
866 return error;
867 }
868
869 virtual status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) {
870 Parcel data, reply;
871 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
872 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800873 ALOGE("removeRegionSamplingListener: Failed to write interface token");
Dan Stoza84ab9372018-12-17 15:27:57 -0800874 return error;
875 }
876 error = data.writeStrongBinder(IInterface::asBinder(listener));
877 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800878 ALOGE("removeRegionSamplingListener: Failed to write listener");
Dan Stoza84ab9372018-12-17 15:27:57 -0800879 return error;
880 }
881 error = remote()->transact(BnSurfaceComposer::REMOVE_REGION_SAMPLING_LISTENER, data,
882 &reply);
883 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800884 ALOGE("removeRegionSamplingListener: Failed to transact");
Dan Stoza84ab9372018-12-17 15:27:57 -0800885 }
886 return error;
887 }
Ady Abraham838de062019-02-04 10:24:03 -0800888
Ana Krulec0782b882019-10-15 17:34:54 -0700889 virtual status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
Steven Thomasf734df42020-04-13 21:09:28 -0700890 int32_t defaultConfig,
891 float primaryRefreshRateMin,
892 float primaryRefreshRateMax,
893 float appRequestRefreshRateMin,
894 float appRequestRefreshRateMax) {
Ana Krulec0782b882019-10-15 17:34:54 -0700895 Parcel data, reply;
896 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
897 if (result != NO_ERROR) {
898 ALOGE("setDesiredDisplayConfigSpecs: failed to writeInterfaceToken: %d", result);
899 return result;
900 }
901 result = data.writeStrongBinder(displayToken);
902 if (result != NO_ERROR) {
903 ALOGE("setDesiredDisplayConfigSpecs: failed to write display token: %d", result);
904 return result;
905 }
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100906 result = data.writeInt32(defaultConfig);
Ana Krulec0782b882019-10-15 17:34:54 -0700907 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100908 ALOGE("setDesiredDisplayConfigSpecs failed to write defaultConfig: %d", result);
Ana Krulec0782b882019-10-15 17:34:54 -0700909 return result;
910 }
Steven Thomasf734df42020-04-13 21:09:28 -0700911 result = data.writeFloat(primaryRefreshRateMin);
Ana Krulec0782b882019-10-15 17:34:54 -0700912 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -0700913 ALOGE("setDesiredDisplayConfigSpecs failed to write primaryRefreshRateMin: %d", result);
Ana Krulec0782b882019-10-15 17:34:54 -0700914 return result;
915 }
Steven Thomasf734df42020-04-13 21:09:28 -0700916 result = data.writeFloat(primaryRefreshRateMax);
Ana Krulec0782b882019-10-15 17:34:54 -0700917 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -0700918 ALOGE("setDesiredDisplayConfigSpecs failed to write primaryRefreshRateMax: %d", result);
919 return result;
920 }
921 result = data.writeFloat(appRequestRefreshRateMin);
922 if (result != NO_ERROR) {
923 ALOGE("setDesiredDisplayConfigSpecs failed to write appRequestRefreshRateMin: %d",
924 result);
925 return result;
926 }
927 result = data.writeFloat(appRequestRefreshRateMax);
928 if (result != NO_ERROR) {
929 ALOGE("setDesiredDisplayConfigSpecs failed to write appRequestRefreshRateMax: %d",
930 result);
Ana Krulec0782b882019-10-15 17:34:54 -0700931 return result;
932 }
933
934 result = remote()->transact(BnSurfaceComposer::SET_DESIRED_DISPLAY_CONFIG_SPECS, data,
935 &reply);
936 if (result != NO_ERROR) {
937 ALOGE("setDesiredDisplayConfigSpecs failed to transact: %d", result);
938 return result;
939 }
940 return reply.readInt32();
941 }
942
Ana Krulec234bb162019-11-10 22:55:55 +0100943 virtual status_t getDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100944 int32_t* outDefaultConfig,
Steven Thomasf734df42020-04-13 21:09:28 -0700945 float* outPrimaryRefreshRateMin,
946 float* outPrimaryRefreshRateMax,
947 float* outAppRequestRefreshRateMin,
948 float* outAppRequestRefreshRateMax) {
949 if (!outDefaultConfig || !outPrimaryRefreshRateMin || !outPrimaryRefreshRateMax ||
950 !outAppRequestRefreshRateMin || !outAppRequestRefreshRateMax) {
951 return BAD_VALUE;
952 }
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800953 Parcel data, reply;
954 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
955 if (result != NO_ERROR) {
Ana Krulec234bb162019-11-10 22:55:55 +0100956 ALOGE("getDesiredDisplayConfigSpecs failed to writeInterfaceToken: %d", result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800957 return result;
958 }
959 result = data.writeStrongBinder(displayToken);
960 if (result != NO_ERROR) {
Ana Krulec234bb162019-11-10 22:55:55 +0100961 ALOGE("getDesiredDisplayConfigSpecs failed to writeStrongBinder: %d", result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800962 return result;
963 }
Ana Krulec234bb162019-11-10 22:55:55 +0100964 result = remote()->transact(BnSurfaceComposer::GET_DESIRED_DISPLAY_CONFIG_SPECS, data,
965 &reply);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800966 if (result != NO_ERROR) {
Ana Krulec234bb162019-11-10 22:55:55 +0100967 ALOGE("getDesiredDisplayConfigSpecs failed to transact: %d", result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800968 return result;
969 }
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100970 result = reply.readInt32(outDefaultConfig);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800971 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100972 ALOGE("getDesiredDisplayConfigSpecs failed to read defaultConfig: %d", result);
Ana Krulec234bb162019-11-10 22:55:55 +0100973 return result;
974 }
Steven Thomasf734df42020-04-13 21:09:28 -0700975 result = reply.readFloat(outPrimaryRefreshRateMin);
Ana Krulec234bb162019-11-10 22:55:55 +0100976 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -0700977 ALOGE("getDesiredDisplayConfigSpecs failed to read primaryRefreshRateMin: %d", result);
Ana Krulec234bb162019-11-10 22:55:55 +0100978 return result;
979 }
Steven Thomasf734df42020-04-13 21:09:28 -0700980 result = reply.readFloat(outPrimaryRefreshRateMax);
Ana Krulec234bb162019-11-10 22:55:55 +0100981 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -0700982 ALOGE("getDesiredDisplayConfigSpecs failed to read primaryRefreshRateMax: %d", result);
983 return result;
984 }
985 result = reply.readFloat(outAppRequestRefreshRateMin);
986 if (result != NO_ERROR) {
987 ALOGE("getDesiredDisplayConfigSpecs failed to read appRequestRefreshRateMin: %d",
988 result);
989 return result;
990 }
991 result = reply.readFloat(outAppRequestRefreshRateMax);
992 if (result != NO_ERROR) {
993 ALOGE("getDesiredDisplayConfigSpecs failed to read appRequestRefreshRateMax: %d",
994 result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800995 return result;
996 }
997 return reply.readInt32();
998 }
Dan Gittik57e63c52019-01-18 16:37:54 +0000999
1000 virtual status_t getDisplayBrightnessSupport(const sp<IBinder>& displayToken,
1001 bool* outSupport) const {
1002 Parcel data, reply;
1003 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1004 if (error != NO_ERROR) {
1005 ALOGE("getDisplayBrightnessSupport: failed to write interface token: %d", error);
1006 return error;
1007 }
1008 error = data.writeStrongBinder(displayToken);
1009 if (error != NO_ERROR) {
1010 ALOGE("getDisplayBrightnessSupport: failed to write display token: %d", error);
1011 return error;
1012 }
1013 error = remote()->transact(BnSurfaceComposer::GET_DISPLAY_BRIGHTNESS_SUPPORT, data, &reply);
1014 if (error != NO_ERROR) {
1015 ALOGE("getDisplayBrightnessSupport: failed to transact: %d", error);
1016 return error;
1017 }
1018 bool support;
1019 error = reply.readBool(&support);
1020 if (error != NO_ERROR) {
1021 ALOGE("getDisplayBrightnessSupport: failed to read support: %d", error);
1022 return error;
1023 }
1024 *outSupport = support;
1025 return NO_ERROR;
1026 }
1027
Dominik Laskowski470df5f2020-04-02 22:27:42 -07001028 virtual status_t setDisplayBrightness(const sp<IBinder>& displayToken, float brightness) {
Dan Gittik57e63c52019-01-18 16:37:54 +00001029 Parcel data, reply;
1030 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1031 if (error != NO_ERROR) {
1032 ALOGE("setDisplayBrightness: failed to write interface token: %d", error);
1033 return error;
1034 }
1035 error = data.writeStrongBinder(displayToken);
1036 if (error != NO_ERROR) {
1037 ALOGE("setDisplayBrightness: failed to write display token: %d", error);
1038 return error;
1039 }
1040 error = data.writeFloat(brightness);
1041 if (error != NO_ERROR) {
1042 ALOGE("setDisplayBrightness: failed to write brightness: %d", error);
1043 return error;
1044 }
1045 error = remote()->transact(BnSurfaceComposer::SET_DISPLAY_BRIGHTNESS, data, &reply);
1046 if (error != NO_ERROR) {
1047 ALOGE("setDisplayBrightness: failed to transact: %d", error);
1048 return error;
1049 }
1050 return NO_ERROR;
1051 }
Ady Abraham8532d012019-05-08 14:50:56 -07001052
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001053 virtual status_t notifyPowerBoost(int32_t boostId) {
Ady Abraham8532d012019-05-08 14:50:56 -07001054 Parcel data, reply;
1055 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1056 if (error != NO_ERROR) {
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001057 ALOGE("notifyPowerBoost: failed to write interface token: %d", error);
Ady Abraham8532d012019-05-08 14:50:56 -07001058 return error;
1059 }
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001060 error = data.writeInt32(boostId);
Ady Abraham8532d012019-05-08 14:50:56 -07001061 if (error != NO_ERROR) {
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001062 ALOGE("notifyPowerBoost: failed to write boostId: %d", error);
Ady Abraham8532d012019-05-08 14:50:56 -07001063 return error;
1064 }
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001065 error = remote()->transact(BnSurfaceComposer::NOTIFY_POWER_BOOST, data, &reply,
Ady Abraham8532d012019-05-08 14:50:56 -07001066 IBinder::FLAG_ONEWAY);
1067 if (error != NO_ERROR) {
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001068 ALOGE("notifyPowerBoost: failed to transact: %d", error);
Ady Abraham8532d012019-05-08 14:50:56 -07001069 return error;
1070 }
1071 return NO_ERROR;
1072 }
Vishnu Nairb13bb952019-11-15 10:24:08 -08001073
1074 virtual status_t setGlobalShadowSettings(const half4& ambientColor, const half4& spotColor,
1075 float lightPosY, float lightPosZ, float lightRadius) {
1076 Parcel data, reply;
1077 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1078 if (error != NO_ERROR) {
1079 ALOGE("setGlobalShadowSettings: failed to write interface token: %d", error);
1080 return error;
1081 }
1082
1083 std::vector<float> shadowConfig = {ambientColor.r, ambientColor.g, ambientColor.b,
1084 ambientColor.a, spotColor.r, spotColor.g,
1085 spotColor.b, spotColor.a, lightPosY,
1086 lightPosZ, lightRadius};
1087
1088 error = data.writeFloatVector(shadowConfig);
1089 if (error != NO_ERROR) {
1090 ALOGE("setGlobalShadowSettings: failed to write shadowConfig: %d", error);
1091 return error;
1092 }
1093
1094 error = remote()->transact(BnSurfaceComposer::SET_GLOBAL_SHADOW_SETTINGS, data, &reply,
1095 IBinder::FLAG_ONEWAY);
1096 if (error != NO_ERROR) {
1097 ALOGE("setGlobalShadowSettings: failed to transact: %d", error);
1098 return error;
1099 }
1100 return NO_ERROR;
1101 }
Steven Thomas62a4cf82020-01-31 12:04:03 -08001102
1103 virtual status_t setFrameRate(const sp<IGraphicBufferProducer>& surface, float frameRate,
1104 int8_t compatibility) {
1105 Parcel data, reply;
1106 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1107 if (err != NO_ERROR) {
1108 ALOGE("setFrameRate: failed writing interface token: %s (%d)", strerror(-err), -err);
1109 return err;
1110 }
1111
1112 err = data.writeStrongBinder(IInterface::asBinder(surface));
1113 if (err != NO_ERROR) {
1114 ALOGE("setFrameRate: failed writing strong binder: %s (%d)", strerror(-err), -err);
1115 return err;
1116 }
1117
1118 err = data.writeFloat(frameRate);
1119 if (err != NO_ERROR) {
1120 ALOGE("setFrameRate: failed writing float: %s (%d)", strerror(-err), -err);
1121 return err;
1122 }
1123
1124 err = data.writeByte(compatibility);
1125 if (err != NO_ERROR) {
1126 ALOGE("setFrameRate: failed writing byte: %s (%d)", strerror(-err), -err);
1127 return err;
1128 }
1129
Ady Abraham60e42ea2020-03-09 19:17:31 -07001130 err = remote()->transact(BnSurfaceComposer::SET_FRAME_RATE, data, &reply);
Steven Thomas62a4cf82020-01-31 12:04:03 -08001131 if (err != NO_ERROR) {
1132 ALOGE("setFrameRate: failed to transact: %s (%d)", strerror(-err), err);
1133 return err;
1134 }
Steven Thomasd4071902020-03-24 16:02:53 -07001135
1136 return reply.readInt32();
1137 }
1138
1139 virtual status_t acquireFrameRateFlexibilityToken(sp<IBinder>* outToken) {
1140 if (!outToken) return BAD_VALUE;
1141
1142 Parcel data, reply;
1143 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1144 if (err != NO_ERROR) {
1145 ALOGE("acquireFrameRateFlexibilityToken: failed writing interface token: %s (%d)",
1146 strerror(-err), -err);
1147 return err;
1148 }
1149
1150 err = remote()->transact(BnSurfaceComposer::ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN, data,
1151 &reply);
1152 if (err != NO_ERROR) {
1153 ALOGE("acquireFrameRateFlexibilityToken: failed to transact: %s (%d)", strerror(-err),
1154 err);
1155 return err;
1156 }
1157
1158 err = reply.readInt32();
1159 if (err != NO_ERROR) {
1160 ALOGE("acquireFrameRateFlexibilityToken: call failed: %s (%d)", strerror(-err), err);
1161 return err;
1162 }
1163
1164 err = reply.readStrongBinder(outToken);
1165 if (err != NO_ERROR) {
1166 ALOGE("acquireFrameRateFlexibilityToken: failed reading binder token: %s (%d)",
1167 strerror(-err), err);
1168 return err;
1169 }
1170
Steven Thomas62a4cf82020-01-31 12:04:03 -08001171 return NO_ERROR;
1172 }
Ady Abraham74e17562020-08-24 18:18:19 -07001173
1174 virtual status_t setFrameTimelineVsync(const sp<IGraphicBufferProducer>& surface,
1175 int64_t frameTimelineVsyncId) {
1176 Parcel data, reply;
1177 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1178 if (err != NO_ERROR) {
1179 ALOGE("setFrameTimelineVsync: failed writing interface token: %s (%d)", strerror(-err),
1180 -err);
1181 return err;
1182 }
1183
1184 err = data.writeStrongBinder(IInterface::asBinder(surface));
1185 if (err != NO_ERROR) {
1186 ALOGE("setFrameTimelineVsync: failed writing strong binder: %s (%d)", strerror(-err),
1187 -err);
1188 return err;
1189 }
1190
1191 err = data.writeInt64(frameTimelineVsyncId);
1192 if (err != NO_ERROR) {
1193 ALOGE("setFrameTimelineVsync: failed writing int64_t: %s (%d)", strerror(-err), -err);
1194 return err;
1195 }
1196
1197 err = remote()->transact(BnSurfaceComposer::SET_FRAME_TIMELINE_VSYNC, data, &reply);
1198 if (err != NO_ERROR) {
1199 ALOGE("setFrameTimelineVsync: failed to transact: %s (%d)", strerror(-err), err);
1200 return err;
1201 }
1202
1203 return reply.readInt32();
1204 }
Pablo Gamito6ee484d2020-07-30 14:26:28 +00001205
1206 virtual status_t addTransactionTraceListener(
1207 const sp<gui::ITransactionTraceListener>& listener) {
1208 Parcel data, reply;
1209 SAFE_PARCEL(data.writeInterfaceToken, ISurfaceComposer::getInterfaceDescriptor());
1210 SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(listener));
1211
1212 return remote()->transact(BnSurfaceComposer::ADD_TRANSACTION_TRACE_LISTENER, data, &reply);
1213 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001214};
1215
Dan Stozad723bd72014-11-18 10:24:03 -08001216// Out-of-line virtual method definition to trigger vtable emission in this
1217// translation unit (see clang warning -Wweak-vtables)
1218BpSurfaceComposer::~BpSurfaceComposer() {}
1219
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001220IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
1221
1222// ----------------------------------------------------------------------
1223
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001224status_t BnSurfaceComposer::onTransact(
1225 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
1226{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001227 switch(code) {
1228 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001229 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -08001230 sp<IBinder> b = IInterface::asBinder(createConnection());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001231 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -07001232 return NO_ERROR;
1233 }
Mathias Agopian698c0872011-06-28 19:09:31 -07001234 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001235 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -08001236
chaviw308ddba2020-08-11 16:23:51 -07001237 uint32_t count = 0;
1238 SAFE_PARCEL_READ_SIZE(data.readUint32, &count, data.dataSize());
Mathias Agopian698c0872011-06-28 19:09:31 -07001239 Vector<ComposerState> state;
1240 state.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -08001241 for (size_t i = 0; i < count; i++) {
Marissa Wallc837b5e2018-10-12 10:04:44 -07001242 ComposerState s;
chaviw308ddba2020-08-11 16:23:51 -07001243 SAFE_PARCEL(s.read, data);
Mathias Agopian698c0872011-06-28 19:09:31 -07001244 state.add(s);
1245 }
Dan Stozad723bd72014-11-18 10:24:03 -08001246
chaviw308ddba2020-08-11 16:23:51 -07001247 SAFE_PARCEL_READ_SIZE(data.readUint32, &count, data.dataSize());
Mathias Agopian8b33f032012-07-24 20:43:54 -07001248 DisplayState d;
1249 Vector<DisplayState> displays;
1250 displays.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -08001251 for (size_t i = 0; i < count; i++) {
chaviw308ddba2020-08-11 16:23:51 -07001252 SAFE_PARCEL(d.read, data);
Mathias Agopian8b33f032012-07-24 20:43:54 -07001253 displays.add(d);
1254 }
Dan Stozad723bd72014-11-18 10:24:03 -08001255
chaviw308ddba2020-08-11 16:23:51 -07001256 uint32_t stateFlags = 0;
1257 SAFE_PARCEL(data.readUint32, &stateFlags);
1258 sp<IBinder> applyToken;
1259 SAFE_PARCEL(data.readStrongBinder, &applyToken);
chaviw273171b2018-12-26 11:46:30 -08001260 InputWindowCommands inputWindowCommands;
chaviw308ddba2020-08-11 16:23:51 -07001261 SAFE_PARCEL(inputWindowCommands.read, data);
Marissa Wall17b4e452018-12-26 16:32:34 -08001262
chaviw308ddba2020-08-11 16:23:51 -07001263 int64_t desiredPresentTime = 0;
1264 SAFE_PARCEL(data.readInt64, &desiredPresentTime);
Marissa Wall78b72202019-03-15 14:58:34 -07001265
Marissa Wall947d34e2019-03-29 14:03:53 -07001266 client_cache_t uncachedBuffer;
chaviw308ddba2020-08-11 16:23:51 -07001267 sp<IBinder> tmpBinder;
1268 SAFE_PARCEL(data.readNullableStrongBinder, &tmpBinder);
1269 uncachedBuffer.token = tmpBinder;
1270 SAFE_PARCEL(data.readUint64, &uncachedBuffer.id);
Marissa Wall78b72202019-03-15 14:58:34 -07001271
chaviw308ddba2020-08-11 16:23:51 -07001272 bool hasListenerCallbacks = false;
1273 SAFE_PARCEL(data.readBool, &hasListenerCallbacks);
Valerie Hau9dab9732019-08-20 09:29:25 -07001274
Marissa Wall3dad52d2019-03-22 14:03:19 -07001275 std::vector<ListenerCallbacks> listenerCallbacks;
chaviw308ddba2020-08-11 16:23:51 -07001276 int32_t listenersSize = 0;
1277 SAFE_PARCEL_READ_SIZE(data.readInt32, &listenersSize, data.dataSize());
Marissa Wall3dad52d2019-03-22 14:03:19 -07001278 for (int32_t i = 0; i < listenersSize; i++) {
chaviw308ddba2020-08-11 16:23:51 -07001279 SAFE_PARCEL(data.readStrongBinder, &tmpBinder);
Marissa Wall3dad52d2019-03-22 14:03:19 -07001280 std::vector<CallbackId> callbackIds;
chaviw308ddba2020-08-11 16:23:51 -07001281 SAFE_PARCEL(data.readInt64Vector, &callbackIds);
1282 listenerCallbacks.emplace_back(tmpBinder, callbackIds);
Marissa Wall3dad52d2019-03-22 14:03:19 -07001283 }
Pablo Gamito7eb7ee72020-08-05 10:57:05 +00001284
1285 uint64_t transactionId = -1;
1286 SAFE_PARCEL(data.readUint64, &transactionId);
1287
chaviw308ddba2020-08-11 16:23:51 -07001288 return setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands,
1289 desiredPresentTime, uncachedBuffer, hasListenerCallbacks,
Pablo Gamito7eb7ee72020-08-05 10:57:05 +00001290 listenerCallbacks, transactionId);
Jesse Hall6c913be2013-08-08 12:15:49 -07001291 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001292 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001293 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001294 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -07001295 return NO_ERROR;
1296 }
chaviwd2432892020-07-24 17:42:39 -07001297 case CAPTURE_DISPLAY: {
Mathias Agopian2a9fc492013-03-01 13:42:57 -08001298 CHECK_INTERFACE(ISurfaceComposer, data, reply);
chaviwd2432892020-07-24 17:42:39 -07001299 DisplayCaptureArgs args;
chaviw8ffc7b82020-08-18 11:25:37 -07001300 sp<IScreenCaptureListener> captureListener;
chaviw308ddba2020-08-11 16:23:51 -07001301 SAFE_PARCEL(args.read, data);
chaviw8ffc7b82020-08-18 11:25:37 -07001302 SAFE_PARCEL(data.readStrongBinder, &captureListener);
1303
1304 return captureDisplay(args, captureListener);
Jesse Hall6c913be2013-08-08 12:15:49 -07001305 }
chaviwd2432892020-07-24 17:42:39 -07001306 case CAPTURE_DISPLAY_BY_ID: {
chaviw93df2ea2019-04-30 16:45:12 -07001307 CHECK_INTERFACE(ISurfaceComposer, data, reply);
chaviw308ddba2020-08-11 16:23:51 -07001308 uint64_t displayOrLayerStack = 0;
chaviw8ffc7b82020-08-18 11:25:37 -07001309 sp<IScreenCaptureListener> captureListener;
chaviw308ddba2020-08-11 16:23:51 -07001310 SAFE_PARCEL(data.readUint64, &displayOrLayerStack);
chaviw8ffc7b82020-08-18 11:25:37 -07001311 SAFE_PARCEL(data.readStrongBinder, &captureListener);
1312
1313 return captureDisplay(displayOrLayerStack, captureListener);
chaviw93df2ea2019-04-30 16:45:12 -07001314 }
chaviwa76b2712017-09-20 12:02:26 -07001315 case CAPTURE_LAYERS: {
1316 CHECK_INTERFACE(ISurfaceComposer, data, reply);
chaviw3efadb12020-07-27 10:07:15 -07001317 LayerCaptureArgs args;
chaviw8ffc7b82020-08-18 11:25:37 -07001318 sp<IScreenCaptureListener> captureListener;
chaviw308ddba2020-08-11 16:23:51 -07001319 SAFE_PARCEL(args.read, data);
chaviw8ffc7b82020-08-18 11:25:37 -07001320 SAFE_PARCEL(data.readStrongBinder, &captureListener);
1321
1322 return captureLayers(args, captureListener);
chaviwa76b2712017-09-20 12:02:26 -07001323 }
Jamie Gennis134f0422011-03-08 12:18:54 -08001324 case AUTHENTICATE_SURFACE: {
1325 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -08001326 sp<IGraphicBufferProducer> bufferProducer =
1327 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
1328 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -08001329 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -07001330 return NO_ERROR;
1331 }
Brian Anderson6b376712017-04-04 10:51:39 -07001332 case GET_SUPPORTED_FRAME_TIMESTAMPS: {
1333 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1334 std::vector<FrameEvent> supportedTimestamps;
1335 status_t result = getSupportedFrameTimestamps(&supportedTimestamps);
1336 status_t err = reply->writeInt32(result);
1337 if (err != NO_ERROR) {
1338 return err;
1339 }
1340 if (result != NO_ERROR) {
1341 return result;
1342 }
1343
1344 std::vector<int32_t> supported;
1345 supported.reserve(supportedTimestamps.size());
1346 for (FrameEvent s : supportedTimestamps) {
1347 supported.push_back(static_cast<int32_t>(s));
1348 }
1349 return reply->writeInt32Vector(supported);
1350 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001351 case CREATE_DISPLAY_EVENT_CONNECTION: {
1352 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Ady Abraham0f4a1b12019-06-04 16:04:04 -07001353 auto vsyncSource = static_cast<ISurfaceComposer::VsyncSource>(data.readInt32());
1354 auto configChanged = static_cast<ISurfaceComposer::ConfigChanged>(data.readInt32());
1355
1356 sp<IDisplayEventConnection> connection(
1357 createDisplayEventConnection(vsyncSource, configChanged));
Marco Nelissen2ea926b2014-11-14 08:01:01 -08001358 reply->writeStrongBinder(IInterface::asBinder(connection));
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001359 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001360 }
Mathias Agopiane57f2922012-08-09 16:29:12 -07001361 case CREATE_DISPLAY: {
1362 CHECK_INTERFACE(ISurfaceComposer, data, reply);
chaviwd4a61642020-09-01 14:53:46 -07001363 String8 displayName;
1364 SAFE_PARCEL(data.readString8, &displayName);
1365 bool secure = false;
1366 SAFE_PARCEL(data.readBool, &secure);
1367 sp<IBinder> display = createDisplay(displayName, secure);
1368 SAFE_PARCEL(reply->writeStrongBinder, display);
Mathias Agopiane57f2922012-08-09 16:29:12 -07001369 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001370 }
1371 case DESTROY_DISPLAY: {
1372 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1373 sp<IBinder> display = data.readStrongBinder();
1374 destroyDisplay(display);
1375 return NO_ERROR;
1376 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001377 case GET_PHYSICAL_DISPLAY_TOKEN: {
Mathias Agopiane57f2922012-08-09 16:29:12 -07001378 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marin Shalamanova524a092020-07-27 21:39:55 +02001379 PhysicalDisplayId displayId(data.readUint64());
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001380 sp<IBinder> display = getPhysicalDisplayToken(displayId);
Mathias Agopiane57f2922012-08-09 16:29:12 -07001381 reply->writeStrongBinder(display);
1382 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001383 }
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001384 case GET_DISPLAY_STATE: {
1385 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1386 ui::DisplayState state;
1387 const sp<IBinder> display = data.readStrongBinder();
1388 const status_t result = getDisplayState(display, &state);
1389 reply->writeInt32(result);
1390 if (result == NO_ERROR) {
1391 memcpy(reply->writeInplace(sizeof(ui::DisplayState)), &state,
1392 sizeof(ui::DisplayState));
1393 }
1394 return NO_ERROR;
1395 }
1396 case GET_DISPLAY_INFO: {
1397 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1398 DisplayInfo info;
1399 const sp<IBinder> display = data.readStrongBinder();
1400 const status_t result = getDisplayInfo(display, &info);
1401 reply->writeInt32(result);
Marin Shalamanov359a7e72020-02-17 17:03:07 +01001402 if (result != NO_ERROR) return result;
1403 return reply->write(info);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001404 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001405 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -07001406 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001407 Vector<DisplayConfig> configs;
1408 const sp<IBinder> display = data.readStrongBinder();
1409 const status_t result = getDisplayConfigs(display, &configs);
Dan Stoza7f7da322014-05-02 15:26:25 -07001410 reply->writeInt32(result);
1411 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -08001412 reply->writeUint32(static_cast<uint32_t>(configs.size()));
Dan Stoza7f7da322014-05-02 15:26:25 -07001413 for (size_t c = 0; c < configs.size(); ++c) {
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001414 memcpy(reply->writeInplace(sizeof(DisplayConfig)), &configs[c],
1415 sizeof(DisplayConfig));
Dan Stoza7f7da322014-05-02 15:26:25 -07001416 }
1417 }
1418 return NO_ERROR;
1419 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -07001420 case GET_DISPLAY_STATS: {
1421 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1422 DisplayStatInfo stats;
1423 sp<IBinder> display = data.readStrongBinder();
1424 status_t result = getDisplayStats(display, &stats);
1425 reply->writeInt32(result);
1426 if (result == NO_ERROR) {
1427 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
1428 &stats, sizeof(DisplayStatInfo));
1429 }
1430 return NO_ERROR;
1431 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001432 case GET_ACTIVE_CONFIG: {
1433 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1434 sp<IBinder> display = data.readStrongBinder();
1435 int id = getActiveConfig(display);
1436 reply->writeInt32(id);
1437 return NO_ERROR;
1438 }
Michael Wright28f24d02016-07-12 13:30:53 -07001439 case GET_DISPLAY_COLOR_MODES: {
1440 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Lina52f0292018-03-14 17:26:31 -07001441 Vector<ColorMode> colorModes;
Michael Wright28f24d02016-07-12 13:30:53 -07001442 sp<IBinder> display = nullptr;
1443 status_t result = data.readStrongBinder(&display);
1444 if (result != NO_ERROR) {
1445 ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result);
1446 return result;
1447 }
1448 result = getDisplayColorModes(display, &colorModes);
1449 reply->writeInt32(result);
1450 if (result == NO_ERROR) {
1451 reply->writeUint32(static_cast<uint32_t>(colorModes.size()));
1452 for (size_t i = 0; i < colorModes.size(); ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -07001453 reply->writeInt32(static_cast<int32_t>(colorModes[i]));
Michael Wright28f24d02016-07-12 13:30:53 -07001454 }
1455 }
1456 return NO_ERROR;
1457 }
Daniel Solomon42d04562019-01-20 21:03:19 -08001458 case GET_DISPLAY_NATIVE_PRIMARIES: {
1459 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1460 ui::DisplayPrimaries primaries;
1461 sp<IBinder> display = nullptr;
1462
1463 status_t result = data.readStrongBinder(&display);
1464 if (result != NO_ERROR) {
1465 ALOGE("getDisplayNativePrimaries failed to readStrongBinder: %d", result);
1466 return result;
1467 }
1468
1469 result = getDisplayNativePrimaries(display, primaries);
1470 reply->writeInt32(result);
1471 if (result == NO_ERROR) {
1472 memcpy(reply->writeInplace(sizeof(ui::DisplayPrimaries)), &primaries,
1473 sizeof(ui::DisplayPrimaries));
1474 }
1475
1476 return NO_ERROR;
1477 }
Michael Wright28f24d02016-07-12 13:30:53 -07001478 case GET_ACTIVE_COLOR_MODE: {
1479 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1480 sp<IBinder> display = nullptr;
1481 status_t result = data.readStrongBinder(&display);
1482 if (result != NO_ERROR) {
1483 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1484 return result;
1485 }
Peiyong Lina52f0292018-03-14 17:26:31 -07001486 ColorMode colorMode = getActiveColorMode(display);
Michael Wright28f24d02016-07-12 13:30:53 -07001487 result = reply->writeInt32(static_cast<int32_t>(colorMode));
1488 return result;
1489 }
1490 case SET_ACTIVE_COLOR_MODE: {
1491 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1492 sp<IBinder> display = nullptr;
1493 status_t result = data.readStrongBinder(&display);
1494 if (result != NO_ERROR) {
1495 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1496 return result;
1497 }
1498 int32_t colorModeInt = 0;
1499 result = data.readInt32(&colorModeInt);
1500 if (result != NO_ERROR) {
1501 ALOGE("setActiveColorMode failed to readInt32: %d", result);
1502 return result;
1503 }
1504 result = setActiveColorMode(display,
Peiyong Lina52f0292018-03-14 17:26:31 -07001505 static_cast<ColorMode>(colorModeInt));
Michael Wright28f24d02016-07-12 13:30:53 -07001506 result = reply->writeInt32(result);
1507 return result;
1508 }
Galia Peycheva5492cb52019-10-30 14:13:16 +01001509
1510 case GET_AUTO_LOW_LATENCY_MODE_SUPPORT: {
1511 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1512 sp<IBinder> display = nullptr;
1513 status_t result = data.readStrongBinder(&display);
1514 if (result != NO_ERROR) {
1515 ALOGE("getAutoLowLatencyModeSupport failed to readStrongBinder: %d", result);
1516 return result;
1517 }
1518 bool supported = false;
1519 result = getAutoLowLatencyModeSupport(display, &supported);
1520 if (result == NO_ERROR) {
1521 result = reply->writeBool(supported);
1522 }
1523 return result;
1524 }
1525
1526 case SET_AUTO_LOW_LATENCY_MODE: {
1527 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1528 sp<IBinder> display = nullptr;
1529 status_t result = data.readStrongBinder(&display);
1530 if (result != NO_ERROR) {
1531 ALOGE("setAutoLowLatencyMode failed to readStrongBinder: %d", result);
1532 return result;
1533 }
1534 bool setAllm = false;
1535 result = data.readBool(&setAllm);
1536 if (result != NO_ERROR) {
1537 ALOGE("setAutoLowLatencyMode failed to readBool: %d", result);
1538 return result;
1539 }
1540 setAutoLowLatencyMode(display, setAllm);
1541 return result;
1542 }
1543
1544 case GET_GAME_CONTENT_TYPE_SUPPORT: {
1545 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1546 sp<IBinder> display = nullptr;
1547 status_t result = data.readStrongBinder(&display);
1548 if (result != NO_ERROR) {
1549 ALOGE("getGameContentTypeSupport failed to readStrongBinder: %d", result);
1550 return result;
1551 }
1552 bool supported = false;
1553 result = getGameContentTypeSupport(display, &supported);
1554 if (result == NO_ERROR) {
1555 result = reply->writeBool(supported);
1556 }
1557 return result;
1558 }
1559
1560 case SET_GAME_CONTENT_TYPE: {
1561 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1562 sp<IBinder> display = nullptr;
1563 status_t result = data.readStrongBinder(&display);
1564 if (result != NO_ERROR) {
1565 ALOGE("setGameContentType failed to readStrongBinder: %d", result);
1566 return result;
1567 }
1568 bool setGameContentTypeOn = false;
1569 result = data.readBool(&setGameContentTypeOn);
1570 if (result != NO_ERROR) {
1571 ALOGE("setGameContentType failed to readBool: %d", result);
1572 return result;
1573 }
1574 setGameContentType(display, setGameContentTypeOn);
1575 return result;
1576 }
1577
Svetoslavd85084b2014-03-20 10:28:31 -07001578 case CLEAR_ANIMATION_FRAME_STATS: {
1579 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1580 status_t result = clearAnimationFrameStats();
1581 reply->writeInt32(result);
1582 return NO_ERROR;
1583 }
1584 case GET_ANIMATION_FRAME_STATS: {
1585 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1586 FrameStats stats;
1587 status_t result = getAnimationFrameStats(&stats);
1588 reply->write(stats);
1589 reply->writeInt32(result);
1590 return NO_ERROR;
1591 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -07001592 case SET_POWER_MODE: {
1593 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1594 sp<IBinder> display = data.readStrongBinder();
1595 int32_t mode = data.readInt32();
1596 setPowerMode(display, mode);
1597 return NO_ERROR;
1598 }
Dan Stozac4f471e2016-03-24 09:31:08 -07001599 case GET_HDR_CAPABILITIES: {
1600 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1601 sp<IBinder> display = nullptr;
1602 status_t result = data.readStrongBinder(&display);
1603 if (result != NO_ERROR) {
1604 ALOGE("getHdrCapabilities failed to readStrongBinder: %d",
1605 result);
1606 return result;
1607 }
1608 HdrCapabilities capabilities;
1609 result = getHdrCapabilities(display, &capabilities);
1610 reply->writeInt32(result);
1611 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -08001612 reply->write(capabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -07001613 }
1614 return NO_ERROR;
1615 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -07001616 case ENABLE_VSYNC_INJECTIONS: {
1617 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1618 bool enable = false;
1619 status_t result = data.readBool(&enable);
1620 if (result != NO_ERROR) {
1621 ALOGE("enableVSyncInjections failed to readBool: %d", result);
1622 return result;
1623 }
1624 return enableVSyncInjections(enable);
1625 }
1626 case INJECT_VSYNC: {
1627 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1628 int64_t when = 0;
1629 status_t result = data.readInt64(&when);
1630 if (result != NO_ERROR) {
1631 ALOGE("enableVSyncInjections failed to readInt64: %d", result);
1632 return result;
1633 }
1634 return injectVSync(when);
1635 }
Kalle Raitaa099a242017-01-11 11:17:29 -08001636 case GET_LAYER_DEBUG_INFO: {
1637 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1638 std::vector<LayerDebugInfo> outLayers;
1639 status_t result = getLayerDebugInfo(&outLayers);
1640 reply->writeInt32(result);
1641 if (result == NO_ERROR)
1642 {
1643 result = reply->writeParcelableVector(outLayers);
1644 }
1645 return result;
1646 }
Peiyong Lin0256f722018-08-31 15:45:10 -07001647 case GET_COMPOSITION_PREFERENCE: {
1648 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Linc6780972018-10-28 15:24:08 -07001649 ui::Dataspace defaultDataspace;
1650 ui::PixelFormat defaultPixelFormat;
1651 ui::Dataspace wideColorGamutDataspace;
1652 ui::PixelFormat wideColorGamutPixelFormat;
1653 status_t error =
1654 getCompositionPreference(&defaultDataspace, &defaultPixelFormat,
1655 &wideColorGamutDataspace, &wideColorGamutPixelFormat);
Peiyong Lin0256f722018-08-31 15:45:10 -07001656 reply->writeInt32(error);
1657 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -07001658 reply->writeInt32(static_cast<int32_t>(defaultDataspace));
1659 reply->writeInt32(static_cast<int32_t>(defaultPixelFormat));
1660 reply->writeInt32(static_cast<int32_t>(wideColorGamutDataspace));
Peiyong Linaa3da6a2018-12-12 02:48:43 -08001661 reply->writeInt32(static_cast<int32_t>(wideColorGamutPixelFormat));
Peiyong Lin0256f722018-08-31 15:45:10 -07001662 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001663 return error;
Peiyong Lin0256f722018-08-31 15:45:10 -07001664 }
Ady Abraham37965d42018-11-01 13:43:32 -07001665 case GET_COLOR_MANAGEMENT: {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001666 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Ady Abraham37965d42018-11-01 13:43:32 -07001667 bool result;
1668 status_t error = getColorManagement(&result);
1669 if (error == NO_ERROR) {
1670 reply->writeBool(result);
1671 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001672 return error;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001673 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -07001674 case GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: {
1675 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1676
1677 sp<IBinder> display = data.readStrongBinder();
1678 ui::PixelFormat format;
1679 ui::Dataspace dataspace;
1680 uint8_t component = 0;
1681 auto result =
1682 getDisplayedContentSamplingAttributes(display, &format, &dataspace, &component);
1683 if (result == NO_ERROR) {
1684 reply->writeUint32(static_cast<uint32_t>(format));
1685 reply->writeUint32(static_cast<uint32_t>(dataspace));
1686 reply->writeUint32(static_cast<uint32_t>(component));
1687 }
1688 return result;
1689 }
Kevin DuBois74e53772018-11-19 10:52:38 -08001690 case SET_DISPLAY_CONTENT_SAMPLING_ENABLED: {
1691 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1692
1693 sp<IBinder> display = nullptr;
1694 bool enable = false;
1695 int8_t componentMask = 0;
1696 uint64_t maxFrames = 0;
1697 status_t result = data.readStrongBinder(&display);
1698 if (result != NO_ERROR) {
1699 ALOGE("setDisplayContentSamplingEnabled failure in reading Display token: %d",
1700 result);
1701 return result;
1702 }
1703
1704 result = data.readBool(&enable);
1705 if (result != NO_ERROR) {
1706 ALOGE("setDisplayContentSamplingEnabled failure in reading enable: %d", result);
1707 return result;
1708 }
1709
1710 result = data.readByte(static_cast<int8_t*>(&componentMask));
1711 if (result != NO_ERROR) {
1712 ALOGE("setDisplayContentSamplingEnabled failure in reading component mask: %d",
1713 result);
1714 return result;
1715 }
1716
1717 result = data.readUint64(&maxFrames);
1718 if (result != NO_ERROR) {
1719 ALOGE("setDisplayContentSamplingEnabled failure in reading max frames: %d", result);
1720 return result;
1721 }
1722
1723 return setDisplayContentSamplingEnabled(display, enable,
1724 static_cast<uint8_t>(componentMask), maxFrames);
1725 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001726 case GET_DISPLAYED_CONTENT_SAMPLE: {
1727 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1728
1729 sp<IBinder> display = data.readStrongBinder();
1730 uint64_t maxFrames = 0;
1731 uint64_t timestamp = 0;
1732
1733 status_t result = data.readUint64(&maxFrames);
1734 if (result != NO_ERROR) {
1735 ALOGE("getDisplayedContentSample failure in reading max frames: %d", result);
1736 return result;
1737 }
1738
1739 result = data.readUint64(&timestamp);
1740 if (result != NO_ERROR) {
1741 ALOGE("getDisplayedContentSample failure in reading timestamp: %d", result);
1742 return result;
1743 }
1744
1745 DisplayedFrameStats stats;
1746 result = getDisplayedContentSample(display, maxFrames, timestamp, &stats);
1747 if (result == NO_ERROR) {
1748 reply->writeUint64(stats.numFrames);
Kevin DuBois1d4c6a62018-12-12 13:59:46 -08001749 reply->writeUint64Vector(stats.component_0_sample);
1750 reply->writeUint64Vector(stats.component_1_sample);
1751 reply->writeUint64Vector(stats.component_2_sample);
1752 reply->writeUint64Vector(stats.component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001753 }
1754 return result;
1755 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001756 case GET_PROTECTED_CONTENT_SUPPORT: {
1757 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1758 bool result;
1759 status_t error = getProtectedContentSupport(&result);
1760 if (error == NO_ERROR) {
1761 reply->writeBool(result);
1762 }
1763 return error;
1764 }
Peiyong Lin4f3fddf2019-01-24 17:21:24 -08001765 case IS_WIDE_COLOR_DISPLAY: {
1766 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1767 sp<IBinder> display = nullptr;
1768 status_t error = data.readStrongBinder(&display);
1769 if (error != NO_ERROR) {
1770 return error;
1771 }
1772 bool result;
1773 error = isWideColorDisplay(display, &result);
1774 if (error == NO_ERROR) {
1775 reply->writeBool(result);
1776 }
1777 return error;
1778 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001779 case GET_PHYSICAL_DISPLAY_IDS: {
1780 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marin Shalamanova524a092020-07-27 21:39:55 +02001781 std::vector<PhysicalDisplayId> ids = getPhysicalDisplayIds();
1782 std::vector<uint64_t> rawIds(ids.size());
1783 std::transform(ids.begin(), ids.end(), rawIds.begin(),
1784 [](PhysicalDisplayId id) { return id.value; });
1785 return reply->writeUint64Vector(rawIds);
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001786 }
Dan Stoza84ab9372018-12-17 15:27:57 -08001787 case ADD_REGION_SAMPLING_LISTENER: {
1788 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1789 Rect samplingArea;
1790 status_t result = data.read(samplingArea);
1791 if (result != NO_ERROR) {
1792 ALOGE("addRegionSamplingListener: Failed to read sampling area");
1793 return result;
1794 }
1795 sp<IBinder> stopLayerHandle;
1796 result = data.readNullableStrongBinder(&stopLayerHandle);
1797 if (result != NO_ERROR) {
1798 ALOGE("addRegionSamplingListener: Failed to read stop layer handle");
1799 return result;
1800 }
1801 sp<IRegionSamplingListener> listener;
1802 result = data.readNullableStrongBinder(&listener);
1803 if (result != NO_ERROR) {
1804 ALOGE("addRegionSamplingListener: Failed to read listener");
1805 return result;
1806 }
1807 return addRegionSamplingListener(samplingArea, stopLayerHandle, listener);
1808 }
1809 case REMOVE_REGION_SAMPLING_LISTENER: {
1810 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1811 sp<IRegionSamplingListener> listener;
1812 status_t result = data.readNullableStrongBinder(&listener);
1813 if (result != NO_ERROR) {
1814 ALOGE("removeRegionSamplingListener: Failed to read listener");
1815 return result;
1816 }
1817 return removeRegionSamplingListener(listener);
1818 }
Ana Krulec0782b882019-10-15 17:34:54 -07001819 case SET_DESIRED_DISPLAY_CONFIG_SPECS: {
1820 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1821 sp<IBinder> displayToken = data.readStrongBinder();
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001822 int32_t defaultConfig;
1823 status_t result = data.readInt32(&defaultConfig);
Ana Krulec0782b882019-10-15 17:34:54 -07001824 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001825 ALOGE("setDesiredDisplayConfigSpecs: failed to read defaultConfig: %d", result);
Ana Krulec0782b882019-10-15 17:34:54 -07001826 return result;
1827 }
Steven Thomasf734df42020-04-13 21:09:28 -07001828 float primaryRefreshRateMin;
1829 result = data.readFloat(&primaryRefreshRateMin);
Ana Krulec0782b882019-10-15 17:34:54 -07001830 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001831 ALOGE("setDesiredDisplayConfigSpecs: failed to read primaryRefreshRateMin: %d",
1832 result);
Ana Krulec0782b882019-10-15 17:34:54 -07001833 return result;
1834 }
Steven Thomasf734df42020-04-13 21:09:28 -07001835 float primaryRefreshRateMax;
1836 result = data.readFloat(&primaryRefreshRateMax);
Ana Krulec0782b882019-10-15 17:34:54 -07001837 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001838 ALOGE("setDesiredDisplayConfigSpecs: failed to read primaryRefreshRateMax: %d",
1839 result);
Ana Krulec0782b882019-10-15 17:34:54 -07001840 return result;
1841 }
Steven Thomasf734df42020-04-13 21:09:28 -07001842 float appRequestRefreshRateMin;
1843 result = data.readFloat(&appRequestRefreshRateMin);
1844 if (result != NO_ERROR) {
1845 ALOGE("setDesiredDisplayConfigSpecs: failed to read appRequestRefreshRateMin: %d",
1846 result);
1847 return result;
1848 }
1849 float appRequestRefreshRateMax;
1850 result = data.readFloat(&appRequestRefreshRateMax);
1851 if (result != NO_ERROR) {
1852 ALOGE("setDesiredDisplayConfigSpecs: failed to read appRequestRefreshRateMax: %d",
1853 result);
1854 return result;
1855 }
1856 result =
1857 setDesiredDisplayConfigSpecs(displayToken, defaultConfig, primaryRefreshRateMin,
1858 primaryRefreshRateMax, appRequestRefreshRateMin,
1859 appRequestRefreshRateMax);
Ana Krulec0782b882019-10-15 17:34:54 -07001860 if (result != NO_ERROR) {
1861 ALOGE("setDesiredDisplayConfigSpecs: failed to call setDesiredDisplayConfigSpecs: "
1862 "%d",
1863 result);
1864 return result;
1865 }
1866 reply->writeInt32(result);
1867 return result;
1868 }
Ana Krulec234bb162019-11-10 22:55:55 +01001869 case GET_DESIRED_DISPLAY_CONFIG_SPECS: {
1870 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1871 sp<IBinder> displayToken = data.readStrongBinder();
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001872 int32_t defaultConfig;
Steven Thomasf734df42020-04-13 21:09:28 -07001873 float primaryRefreshRateMin;
1874 float primaryRefreshRateMax;
1875 float appRequestRefreshRateMin;
1876 float appRequestRefreshRateMax;
Ana Krulec234bb162019-11-10 22:55:55 +01001877
Steven Thomasf734df42020-04-13 21:09:28 -07001878 status_t result =
1879 getDesiredDisplayConfigSpecs(displayToken, &defaultConfig,
1880 &primaryRefreshRateMin, &primaryRefreshRateMax,
1881 &appRequestRefreshRateMin,
1882 &appRequestRefreshRateMax);
Ana Krulec234bb162019-11-10 22:55:55 +01001883 if (result != NO_ERROR) {
1884 ALOGE("getDesiredDisplayConfigSpecs: failed to get getDesiredDisplayConfigSpecs: "
1885 "%d",
1886 result);
1887 return result;
1888 }
1889
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001890 result = reply->writeInt32(defaultConfig);
Ana Krulec234bb162019-11-10 22:55:55 +01001891 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001892 ALOGE("getDesiredDisplayConfigSpecs: failed to write defaultConfig: %d", result);
Ana Krulec234bb162019-11-10 22:55:55 +01001893 return result;
1894 }
Steven Thomasf734df42020-04-13 21:09:28 -07001895 result = reply->writeFloat(primaryRefreshRateMin);
Ana Krulec234bb162019-11-10 22:55:55 +01001896 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001897 ALOGE("getDesiredDisplayConfigSpecs: failed to write primaryRefreshRateMin: %d",
1898 result);
Ana Krulec234bb162019-11-10 22:55:55 +01001899 return result;
1900 }
Steven Thomasf734df42020-04-13 21:09:28 -07001901 result = reply->writeFloat(primaryRefreshRateMax);
Ana Krulec234bb162019-11-10 22:55:55 +01001902 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001903 ALOGE("getDesiredDisplayConfigSpecs: failed to write primaryRefreshRateMax: %d",
1904 result);
1905 return result;
1906 }
1907 result = reply->writeFloat(appRequestRefreshRateMin);
1908 if (result != NO_ERROR) {
1909 ALOGE("getDesiredDisplayConfigSpecs: failed to write appRequestRefreshRateMin: %d",
1910 result);
1911 return result;
1912 }
1913 result = reply->writeFloat(appRequestRefreshRateMax);
1914 if (result != NO_ERROR) {
1915 ALOGE("getDesiredDisplayConfigSpecs: failed to write appRequestRefreshRateMax: %d",
1916 result);
Ana Krulec234bb162019-11-10 22:55:55 +01001917 return result;
1918 }
1919 reply->writeInt32(result);
1920 return result;
1921 }
Dan Gittik57e63c52019-01-18 16:37:54 +00001922 case GET_DISPLAY_BRIGHTNESS_SUPPORT: {
1923 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1924 sp<IBinder> displayToken;
1925 status_t error = data.readNullableStrongBinder(&displayToken);
1926 if (error != NO_ERROR) {
1927 ALOGE("getDisplayBrightnessSupport: failed to read display token: %d", error);
1928 return error;
1929 }
1930 bool support = false;
1931 error = getDisplayBrightnessSupport(displayToken, &support);
1932 reply->writeBool(support);
1933 return error;
1934 }
1935 case SET_DISPLAY_BRIGHTNESS: {
1936 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1937 sp<IBinder> displayToken;
1938 status_t error = data.readNullableStrongBinder(&displayToken);
1939 if (error != NO_ERROR) {
1940 ALOGE("setDisplayBrightness: failed to read display token: %d", error);
1941 return error;
1942 }
1943 float brightness = -1.0f;
1944 error = data.readFloat(&brightness);
1945 if (error != NO_ERROR) {
1946 ALOGE("setDisplayBrightness: failed to read brightness: %d", error);
1947 return error;
1948 }
1949 return setDisplayBrightness(displayToken, brightness);
1950 }
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001951 case NOTIFY_POWER_BOOST: {
Ady Abraham8532d012019-05-08 14:50:56 -07001952 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001953 int32_t boostId;
1954 status_t error = data.readInt32(&boostId);
Ady Abraham8532d012019-05-08 14:50:56 -07001955 if (error != NO_ERROR) {
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001956 ALOGE("notifyPowerBoost: failed to read boostId: %d", error);
Ady Abraham8532d012019-05-08 14:50:56 -07001957 return error;
1958 }
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001959 return notifyPowerBoost(boostId);
Ady Abraham8532d012019-05-08 14:50:56 -07001960 }
Vishnu Nairb13bb952019-11-15 10:24:08 -08001961 case SET_GLOBAL_SHADOW_SETTINGS: {
1962 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1963
1964 std::vector<float> shadowConfig;
1965 status_t error = data.readFloatVector(&shadowConfig);
1966 if (error != NO_ERROR || shadowConfig.size() != 11) {
1967 ALOGE("setGlobalShadowSettings: failed to read shadowConfig: %d", error);
1968 return error;
1969 }
1970
1971 half4 ambientColor = {shadowConfig[0], shadowConfig[1], shadowConfig[2],
1972 shadowConfig[3]};
1973 half4 spotColor = {shadowConfig[4], shadowConfig[5], shadowConfig[6], shadowConfig[7]};
1974 float lightPosY = shadowConfig[8];
1975 float lightPosZ = shadowConfig[9];
1976 float lightRadius = shadowConfig[10];
1977 return setGlobalShadowSettings(ambientColor, spotColor, lightPosY, lightPosZ,
1978 lightRadius);
1979 }
Steven Thomas62a4cf82020-01-31 12:04:03 -08001980 case SET_FRAME_RATE: {
1981 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1982 sp<IBinder> binder;
1983 status_t err = data.readStrongBinder(&binder);
1984 if (err != NO_ERROR) {
1985 ALOGE("setFrameRate: failed to read strong binder: %s (%d)", strerror(-err), -err);
1986 return err;
1987 }
1988 sp<IGraphicBufferProducer> surface = interface_cast<IGraphicBufferProducer>(binder);
1989 if (!surface) {
1990 ALOGE("setFrameRate: failed to cast to IGraphicBufferProducer: %s (%d)",
1991 strerror(-err), -err);
1992 return err;
1993 }
1994 float frameRate;
1995 err = data.readFloat(&frameRate);
1996 if (err != NO_ERROR) {
1997 ALOGE("setFrameRate: failed to read float: %s (%d)", strerror(-err), -err);
1998 return err;
1999 }
2000 int8_t compatibility;
2001 err = data.readByte(&compatibility);
2002 if (err != NO_ERROR) {
2003 ALOGE("setFrameRate: failed to read byte: %s (%d)", strerror(-err), -err);
2004 return err;
2005 }
2006 status_t result = setFrameRate(surface, frameRate, compatibility);
2007 reply->writeInt32(result);
2008 return NO_ERROR;
2009 }
Steven Thomasd4071902020-03-24 16:02:53 -07002010 case ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN: {
2011 CHECK_INTERFACE(ISurfaceComposer, data, reply);
2012 sp<IBinder> token;
2013 status_t result = acquireFrameRateFlexibilityToken(&token);
2014 reply->writeInt32(result);
2015 if (result == NO_ERROR) {
2016 reply->writeStrongBinder(token);
2017 }
2018 return NO_ERROR;
2019 }
Ady Abraham74e17562020-08-24 18:18:19 -07002020 case SET_FRAME_TIMELINE_VSYNC: {
2021 CHECK_INTERFACE(ISurfaceComposer, data, reply);
2022 sp<IBinder> binder;
2023 status_t err = data.readStrongBinder(&binder);
2024 if (err != NO_ERROR) {
2025 ALOGE("setFrameTimelineVsync: failed to read strong binder: %s (%d)",
2026 strerror(-err), -err);
2027 return err;
2028 }
2029 sp<IGraphicBufferProducer> surface = interface_cast<IGraphicBufferProducer>(binder);
2030 if (!surface) {
2031 ALOGE("setFrameTimelineVsync: failed to cast to IGraphicBufferProducer: %s (%d)",
2032 strerror(-err), -err);
2033 return err;
2034 }
2035 int64_t frameTimelineVsyncId;
2036 err = data.readInt64(&frameTimelineVsyncId);
2037 if (err != NO_ERROR) {
2038 ALOGE("setFrameTimelineVsync: failed to read int64_t: %s (%d)", strerror(-err),
2039 -err);
2040 return err;
2041 }
2042
2043 status_t result = setFrameTimelineVsync(surface, frameTimelineVsyncId);
2044 reply->writeInt32(result);
2045 return NO_ERROR;
2046 }
Pablo Gamito6ee484d2020-07-30 14:26:28 +00002047 case ADD_TRANSACTION_TRACE_LISTENER: {
2048 CHECK_INTERFACE(ISurfaceComposer, data, reply);
2049 sp<gui::ITransactionTraceListener> listener;
2050 SAFE_PARCEL(data.readStrongBinder, &listener);
2051
2052 return addTransactionTraceListener(listener);
2053 }
Jesse Hall6c913be2013-08-08 12:15:49 -07002054 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -07002055 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -07002056 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08002057 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08002058}
2059
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08002060} // namespace android