blob: 400daf0512680db8508cd71e4c4f2d6397847dcf [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
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070023#include <binder/Parcel.h>
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070024#include <binder/IPCThreadState.h>
25#include <binder/IServiceManager.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080026
Mathias Agopiand0566bc2011-11-17 17:49:17 -080027#include <gui/IDisplayEventConnection.h>
Andy McFadden2adaf042012-12-18 09:49:45 -080028#include <gui/IGraphicBufferProducer.h>
Dan Stoza84ab9372018-12-17 15:27:57 -080029#include <gui/IRegionSamplingListener.h>
Mathias Agopian2b5dd402017-02-07 17:36:19 -080030#include <gui/ISurfaceComposer.h>
31#include <gui/ISurfaceComposerClient.h>
Kalle Raitaa099a242017-01-11 11:17:29 -080032#include <gui/LayerDebugInfo.h>
Robert Carr4cdc58f2017-08-23 14:22:20 -070033#include <gui/LayerState.h>
Mathias Agopiand0566bc2011-11-17 17:49:17 -080034
Michael Wright28f24d02016-07-12 13:30:53 -070035#include <system/graphics.h>
36
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080037#include <ui/DisplayInfo.h>
Lajos Molnar67d8bd62014-09-11 14:58:45 -070038#include <ui/DisplayStatInfo.h>
Dan Stozac4f471e2016-03-24 09:31:08 -070039#include <ui/HdrCapabilities.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080040
Jamie Gennis134f0422011-03-08 12:18:54 -080041#include <utils/Log.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -080042
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080043// ---------------------------------------------------------------------------
44
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080045namespace android {
46
Peiyong Lin9f034472018-03-28 15:29:00 -070047using ui::ColorMode;
48
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080049class BpSurfaceComposer : public BpInterface<ISurfaceComposer>
50{
51public:
Chih-Hung Hsiehe2347b72016-04-25 15:41:05 -070052 explicit BpSurfaceComposer(const sp<IBinder>& impl)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080053 : BpInterface<ISurfaceComposer>(impl)
54 {
55 }
56
Dan Stozad723bd72014-11-18 10:24:03 -080057 virtual ~BpSurfaceComposer();
58
Mathias Agopian7e27f052010-05-28 14:22:23 -070059 virtual sp<ISurfaceComposerClient> createConnection()
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080060 {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080061 Parcel data, reply;
62 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
63 remote()->transact(BnSurfaceComposer::CREATE_CONNECTION, data, &reply);
Mathias Agopian7e27f052010-05-28 14:22:23 -070064 return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080065 }
66
Marissa Wall713b63f2018-10-17 15:42:43 -070067 virtual void setTransactionState(const Vector<ComposerState>& state,
68 const Vector<DisplayState>& displays, uint32_t flags,
chaviw273171b2018-12-26 11:46:30 -080069 const sp<IBinder>& applyToken,
Marissa Wall17b4e452018-12-26 16:32:34 -080070 const InputWindowCommands& commands,
71 int64_t desiredPresentTime) {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080072 Parcel data, reply;
73 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Dan Stozad723bd72014-11-18 10:24:03 -080074
75 data.writeUint32(static_cast<uint32_t>(state.size()));
76 for (const auto& s : state) {
77 s.write(data);
Mathias Agopian698c0872011-06-28 19:09:31 -070078 }
Dan Stozad723bd72014-11-18 10:24:03 -080079
80 data.writeUint32(static_cast<uint32_t>(displays.size()));
81 for (const auto& d : displays) {
82 d.write(data);
Mathias Agopian8b33f032012-07-24 20:43:54 -070083 }
Dan Stozad723bd72014-11-18 10:24:03 -080084
85 data.writeUint32(flags);
Marissa Wall713b63f2018-10-17 15:42:43 -070086 data.writeStrongBinder(applyToken);
chaviw273171b2018-12-26 11:46:30 -080087 commands.write(data);
Marissa Wall17b4e452018-12-26 16:32:34 -080088 data.writeInt64(desiredPresentTime);
Jamie Gennisb8d69a52011-10-10 15:48:06 -070089 remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080090 }
91
92 virtual void bootFinished()
93 {
94 Parcel data, reply;
95 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
96 remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply);
97 }
98
Chavi Weingarten40482ff2017-11-30 01:51:40 +000099 virtual status_t captureScreen(const sp<IBinder>& display, sp<GraphicBuffer>* outBuffer,
Peiyong Lin0e003c92018-09-17 11:09:51 -0700100 const ui::Dataspace reqDataspace,
101 const ui::PixelFormat reqPixelFormat, Rect sourceCrop,
102 uint32_t reqWidth, uint32_t reqHeight, bool useIdentityTransform,
Robert Carrfa8855f2019-02-19 10:05:00 -0800103 ISurfaceComposer::Rotation rotation, bool captureSecureLayers) {
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800104 Parcel data, reply;
105 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
106 data.writeStrongBinder(display);
Peiyong Lin0e003c92018-09-17 11:09:51 -0700107 data.writeInt32(static_cast<int32_t>(reqDataspace));
108 data.writeInt32(static_cast<int32_t>(reqPixelFormat));
Dan Stozac1879002014-05-22 15:59:05 -0700109 data.write(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800110 data.writeUint32(reqWidth);
111 data.writeUint32(reqHeight);
Dan Stozac7014012014-02-14 15:03:43 -0800112 data.writeInt32(static_cast<int32_t>(useIdentityTransform));
Riley Andrewsc3ebe662014-09-04 16:20:31 -0700113 data.writeInt32(static_cast<int32_t>(rotation));
Robert Carrfa8855f2019-02-19 10:05:00 -0800114 data.writeInt32(static_cast<int32_t>(captureSecureLayers));
Ana Krulec2d41e422018-07-26 12:07:43 -0700115 status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply);
116 if (result != NO_ERROR) {
117 ALOGE("captureScreen failed to transact: %d", result);
118 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000119 }
Ana Krulec2d41e422018-07-26 12:07:43 -0700120 result = reply.readInt32();
121 if (result != NO_ERROR) {
122 ALOGE("captureScreen failed to readInt32: %d", result);
123 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000124 }
125
126 *outBuffer = new GraphicBuffer();
127 reply.read(**outBuffer);
Peiyong Lin0e003c92018-09-17 11:09:51 -0700128
Ana Krulec2d41e422018-07-26 12:07:43 -0700129 return result;
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800130 }
131
chaviwa76b2712017-09-20 12:02:26 -0700132 virtual status_t captureLayers(const sp<IBinder>& layerHandleBinder,
Peiyong Lin0e003c92018-09-17 11:09:51 -0700133 sp<GraphicBuffer>* outBuffer, const ui::Dataspace reqDataspace,
134 const ui::PixelFormat reqPixelFormat, const Rect& sourceCrop,
Robert Carr578038f2018-03-09 12:25:24 -0800135 float frameScale, bool childrenOnly) {
chaviwa76b2712017-09-20 12:02:26 -0700136 Parcel data, reply;
137 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
138 data.writeStrongBinder(layerHandleBinder);
Peiyong Lin0e003c92018-09-17 11:09:51 -0700139 data.writeInt32(static_cast<int32_t>(reqDataspace));
140 data.writeInt32(static_cast<int32_t>(reqPixelFormat));
chaviw7206d492017-11-10 16:16:12 -0800141 data.write(sourceCrop);
142 data.writeFloat(frameScale);
Robert Carr578038f2018-03-09 12:25:24 -0800143 data.writeBool(childrenOnly);
Ana Krulec2d41e422018-07-26 12:07:43 -0700144 status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_LAYERS, data, &reply);
145 if (result != NO_ERROR) {
146 ALOGE("captureLayers failed to transact: %d", result);
147 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000148 }
Ana Krulec2d41e422018-07-26 12:07:43 -0700149 result = reply.readInt32();
150 if (result != NO_ERROR) {
151 ALOGE("captureLayers failed to readInt32: %d", result);
152 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000153 }
Peiyong Lin0e003c92018-09-17 11:09:51 -0700154
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000155 *outBuffer = new GraphicBuffer();
156 reply.read(**outBuffer);
157
Ana Krulec2d41e422018-07-26 12:07:43 -0700158 return result;
chaviwa76b2712017-09-20 12:02:26 -0700159 }
160
Jamie Gennis582270d2011-08-17 18:19:00 -0700161 virtual bool authenticateSurfaceTexture(
Andy McFadden2adaf042012-12-18 09:49:45 -0800162 const sp<IGraphicBufferProducer>& bufferProducer) const
Jamie Gennis134f0422011-03-08 12:18:54 -0800163 {
164 Parcel data, reply;
165 int err = NO_ERROR;
166 err = data.writeInterfaceToken(
167 ISurfaceComposer::getInterfaceDescriptor());
168 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000169 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis134f0422011-03-08 12:18:54 -0800170 "interface descriptor: %s (%d)", strerror(-err), -err);
171 return false;
172 }
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800173 err = data.writeStrongBinder(IInterface::asBinder(bufferProducer));
Jamie Gennis134f0422011-03-08 12:18:54 -0800174 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000175 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis582270d2011-08-17 18:19:00 -0700176 "strong binder to parcel: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800177 return false;
178 }
179 err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
180 &reply);
181 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000182 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700183 "performing transaction: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800184 return false;
185 }
186 int32_t result = 0;
187 err = reply.readInt32(&result);
188 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000189 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700190 "retrieving result: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800191 return false;
192 }
193 return result != 0;
194 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800195
Brian Anderson6b376712017-04-04 10:51:39 -0700196 virtual status_t getSupportedFrameTimestamps(
197 std::vector<FrameEvent>* outSupported) const {
198 if (!outSupported) {
199 return UNEXPECTED_NULL;
200 }
201 outSupported->clear();
202
203 Parcel data, reply;
204
205 status_t err = data.writeInterfaceToken(
206 ISurfaceComposer::getInterfaceDescriptor());
207 if (err != NO_ERROR) {
208 return err;
209 }
210
211 err = remote()->transact(
212 BnSurfaceComposer::GET_SUPPORTED_FRAME_TIMESTAMPS,
213 data, &reply);
214 if (err != NO_ERROR) {
215 return err;
216 }
217
218 int32_t result = 0;
219 err = reply.readInt32(&result);
220 if (err != NO_ERROR) {
221 return err;
222 }
223 if (result != NO_ERROR) {
224 return result;
225 }
226
227 std::vector<int32_t> supported;
228 err = reply.readInt32Vector(&supported);
229 if (err != NO_ERROR) {
230 return err;
231 }
232
233 outSupported->reserve(supported.size());
234 for (int32_t s : supported) {
235 outSupported->push_back(static_cast<FrameEvent>(s));
236 }
237 return NO_ERROR;
238 }
239
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700240 virtual sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource)
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800241 {
242 Parcel data, reply;
243 sp<IDisplayEventConnection> result;
244 int err = data.writeInterfaceToken(
245 ISurfaceComposer::getInterfaceDescriptor());
246 if (err != NO_ERROR) {
247 return result;
248 }
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700249 data.writeInt32(static_cast<int32_t>(vsyncSource));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800250 err = remote()->transact(
251 BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION,
252 data, &reply);
253 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000254 ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing "
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800255 "transaction: %s (%d)", strerror(-err), -err);
256 return result;
257 }
258 result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder());
259 return result;
260 }
Colin Cross8e533062012-06-07 13:17:52 -0700261
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700262 virtual sp<IBinder> createDisplay(const String8& displayName, bool secure)
Mathias Agopiane57f2922012-08-09 16:29:12 -0700263 {
264 Parcel data, reply;
265 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700266 data.writeString8(displayName);
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700267 data.writeInt32(secure ? 1 : 0);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700268 remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply);
269 return reply.readStrongBinder();
270 }
271
Jesse Hall6c913be2013-08-08 12:15:49 -0700272 virtual void destroyDisplay(const sp<IBinder>& display)
273 {
274 Parcel data, reply;
275 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
276 data.writeStrongBinder(display);
277 remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply);
278 }
279
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800280 virtual std::vector<PhysicalDisplayId> getPhysicalDisplayIds() const {
Mathias Agopiane57f2922012-08-09 16:29:12 -0700281 Parcel data, reply;
282 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800283 if (remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_IDS, data, &reply) ==
284 NO_ERROR) {
285 std::vector<PhysicalDisplayId> displayIds;
286 if (reply.readUint64Vector(&displayIds) == NO_ERROR) {
287 return displayIds;
288 }
289 }
290
291 return {};
292 }
293
294 virtual sp<IBinder> getPhysicalDisplayToken(PhysicalDisplayId displayId) const {
295 Parcel data, reply;
296 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
297 data.writeUint64(displayId);
298 remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_TOKEN, data, &reply);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700299 return reply.readStrongBinder();
300 }
301
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700302 virtual void setPowerMode(const sp<IBinder>& display, int mode)
Colin Cross8e533062012-06-07 13:17:52 -0700303 {
304 Parcel data, reply;
305 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700306 data.writeStrongBinder(display);
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700307 data.writeInt32(mode);
308 remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply);
Colin Cross8e533062012-06-07 13:17:52 -0700309 }
Mathias Agopian3094df32012-06-18 18:06:45 -0700310
Dan Stoza7f7da322014-05-02 15:26:25 -0700311 virtual status_t getDisplayConfigs(const sp<IBinder>& display,
312 Vector<DisplayInfo>* configs)
Mathias Agopianc666cae2012-07-25 18:56:13 -0700313 {
314 Parcel data, reply;
315 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700316 data.writeStrongBinder(display);
Dan Stoza7f7da322014-05-02 15:26:25 -0700317 remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply);
318 status_t result = reply.readInt32();
319 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -0800320 size_t numConfigs = reply.readUint32();
Dan Stoza7f7da322014-05-02 15:26:25 -0700321 configs->clear();
322 configs->resize(numConfigs);
323 for (size_t c = 0; c < numConfigs; ++c) {
324 memcpy(&(configs->editItemAt(c)),
325 reply.readInplace(sizeof(DisplayInfo)),
326 sizeof(DisplayInfo));
327 }
328 }
329 return result;
330 }
331
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700332 virtual status_t getDisplayStats(const sp<IBinder>& display,
333 DisplayStatInfo* stats)
334 {
335 Parcel data, reply;
336 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
337 data.writeStrongBinder(display);
338 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply);
339 status_t result = reply.readInt32();
340 if (result == NO_ERROR) {
341 memcpy(stats,
342 reply.readInplace(sizeof(DisplayStatInfo)),
343 sizeof(DisplayStatInfo));
344 }
345 return result;
346 }
347
Dan Stoza7f7da322014-05-02 15:26:25 -0700348 virtual int getActiveConfig(const sp<IBinder>& display)
349 {
350 Parcel data, reply;
351 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
352 data.writeStrongBinder(display);
353 remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply);
354 return reply.readInt32();
355 }
356
357 virtual status_t setActiveConfig(const sp<IBinder>& display, int id)
358 {
359 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700360 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
361 if (result != NO_ERROR) {
362 ALOGE("setActiveConfig failed to writeInterfaceToken: %d", result);
363 return result;
364 }
365 result = data.writeStrongBinder(display);
366 if (result != NO_ERROR) {
367 ALOGE("setActiveConfig failed to writeStrongBinder: %d", result);
368 return result;
369 }
370 result = data.writeInt32(id);
371 if (result != NO_ERROR) {
372 ALOGE("setActiveConfig failed to writeInt32: %d", result);
373 return result;
374 }
375 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply);
376 if (result != NO_ERROR) {
377 ALOGE("setActiveConfig failed to transact: %d", result);
378 return result;
379 }
Mathias Agopianc666cae2012-07-25 18:56:13 -0700380 return reply.readInt32();
381 }
Svetoslavd85084b2014-03-20 10:28:31 -0700382
Michael Wright28f24d02016-07-12 13:30:53 -0700383 virtual status_t getDisplayColorModes(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700384 Vector<ColorMode>* outColorModes) {
Michael Wright28f24d02016-07-12 13:30:53 -0700385 Parcel data, reply;
386 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
387 if (result != NO_ERROR) {
388 ALOGE("getDisplayColorModes failed to writeInterfaceToken: %d", result);
389 return result;
390 }
391 result = data.writeStrongBinder(display);
392 if (result != NO_ERROR) {
393 ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result);
394 return result;
395 }
396 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply);
397 if (result != NO_ERROR) {
398 ALOGE("getDisplayColorModes failed to transact: %d", result);
399 return result;
400 }
401 result = static_cast<status_t>(reply.readInt32());
402 if (result == NO_ERROR) {
403 size_t numModes = reply.readUint32();
404 outColorModes->clear();
405 outColorModes->resize(numModes);
406 for (size_t i = 0; i < numModes; ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -0700407 outColorModes->replaceAt(static_cast<ColorMode>(reply.readInt32()), i);
Michael Wright28f24d02016-07-12 13:30:53 -0700408 }
409 }
410 return result;
411 }
412
Daniel Solomon42d04562019-01-20 21:03:19 -0800413 virtual status_t getDisplayNativePrimaries(const sp<IBinder>& display,
414 ui::DisplayPrimaries& primaries) {
415 Parcel data, reply;
416 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
417 if (result != NO_ERROR) {
418 ALOGE("getDisplayNativePrimaries failed to writeInterfaceToken: %d", result);
419 return result;
420 }
421 result = data.writeStrongBinder(display);
422 if (result != NO_ERROR) {
423 ALOGE("getDisplayNativePrimaries failed to writeStrongBinder: %d", result);
424 return result;
425 }
426 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_NATIVE_PRIMARIES, data, &reply);
427 if (result != NO_ERROR) {
428 ALOGE("getDisplayNativePrimaries failed to transact: %d", result);
429 return result;
430 }
431 result = reply.readInt32();
432 if (result == NO_ERROR) {
433 memcpy(&primaries, reply.readInplace(sizeof(ui::DisplayPrimaries)),
434 sizeof(ui::DisplayPrimaries));
435 }
436 return result;
437 }
438
Peiyong Lina52f0292018-03-14 17:26:31 -0700439 virtual ColorMode getActiveColorMode(const sp<IBinder>& display) {
Michael Wright28f24d02016-07-12 13:30:53 -0700440 Parcel data, reply;
441 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
442 if (result != NO_ERROR) {
443 ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700444 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700445 }
446 result = data.writeStrongBinder(display);
447 if (result != NO_ERROR) {
448 ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700449 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700450 }
451 result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply);
452 if (result != NO_ERROR) {
453 ALOGE("getActiveColorMode failed to transact: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700454 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700455 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700456 return static_cast<ColorMode>(reply.readInt32());
Michael Wright28f24d02016-07-12 13:30:53 -0700457 }
458
459 virtual status_t setActiveColorMode(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700460 ColorMode colorMode) {
Michael Wright28f24d02016-07-12 13:30:53 -0700461 Parcel data, reply;
462 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
463 if (result != NO_ERROR) {
464 ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result);
465 return result;
466 }
467 result = data.writeStrongBinder(display);
468 if (result != NO_ERROR) {
469 ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result);
470 return result;
471 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700472 result = data.writeInt32(static_cast<int32_t>(colorMode));
Michael Wright28f24d02016-07-12 13:30:53 -0700473 if (result != NO_ERROR) {
474 ALOGE("setActiveColorMode failed to writeInt32: %d", result);
475 return result;
476 }
477 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply);
478 if (result != NO_ERROR) {
479 ALOGE("setActiveColorMode failed to transact: %d", result);
480 return result;
481 }
482 return static_cast<status_t>(reply.readInt32());
483 }
484
Svetoslavd85084b2014-03-20 10:28:31 -0700485 virtual status_t clearAnimationFrameStats() {
486 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700487 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
488 if (result != NO_ERROR) {
489 ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result);
490 return result;
491 }
492 result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply);
493 if (result != NO_ERROR) {
494 ALOGE("clearAnimationFrameStats failed to transact: %d", result);
495 return result;
496 }
Svetoslavd85084b2014-03-20 10:28:31 -0700497 return reply.readInt32();
498 }
499
500 virtual status_t getAnimationFrameStats(FrameStats* outStats) const {
501 Parcel data, reply;
502 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
503 remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply);
504 reply.read(*outStats);
505 return reply.readInt32();
506 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700507
508 virtual status_t getHdrCapabilities(const sp<IBinder>& display,
509 HdrCapabilities* outCapabilities) const {
510 Parcel data, reply;
511 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
512 status_t result = data.writeStrongBinder(display);
513 if (result != NO_ERROR) {
514 ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result);
515 return result;
516 }
517 result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES,
518 data, &reply);
519 if (result != NO_ERROR) {
520 ALOGE("getHdrCapabilities failed to transact: %d", result);
521 return result;
522 }
523 result = reply.readInt32();
524 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800525 result = reply.read(*outCapabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700526 }
527 return result;
528 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700529
530 virtual status_t enableVSyncInjections(bool enable) {
531 Parcel data, reply;
532 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
533 if (result != NO_ERROR) {
534 ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result);
535 return result;
536 }
537 result = data.writeBool(enable);
538 if (result != NO_ERROR) {
539 ALOGE("enableVSyncInjections failed to writeBool: %d", result);
540 return result;
541 }
542 result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS,
543 data, &reply, TF_ONE_WAY);
544 if (result != NO_ERROR) {
545 ALOGE("enableVSyncInjections failed to transact: %d", result);
546 return result;
547 }
548 return result;
549 }
550
551 virtual status_t injectVSync(nsecs_t when) {
552 Parcel data, reply;
553 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
554 if (result != NO_ERROR) {
555 ALOGE("injectVSync failed to writeInterfaceToken: %d", result);
556 return result;
557 }
558 result = data.writeInt64(when);
559 if (result != NO_ERROR) {
560 ALOGE("injectVSync failed to writeInt64: %d", result);
561 return result;
562 }
563 result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply, TF_ONE_WAY);
564 if (result != NO_ERROR) {
565 ALOGE("injectVSync failed to transact: %d", result);
566 return result;
567 }
568 return result;
569 }
570
Kalle Raitaa099a242017-01-11 11:17:29 -0800571 virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const
572 {
573 if (!outLayers) {
574 return UNEXPECTED_NULL;
575 }
576
577 Parcel data, reply;
578
579 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
580 if (err != NO_ERROR) {
581 return err;
582 }
583
584 err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply);
585 if (err != NO_ERROR) {
586 return err;
587 }
588
589 int32_t result = 0;
590 err = reply.readInt32(&result);
591 if (err != NO_ERROR) {
592 return err;
593 }
594 if (result != NO_ERROR) {
595 return result;
596 }
597
598 outLayers->clear();
599 return reply.readParcelableVector(outLayers);
600 }
Peiyong Lin0256f722018-08-31 15:45:10 -0700601
Peiyong Linc6780972018-10-28 15:24:08 -0700602 virtual status_t getCompositionPreference(ui::Dataspace* defaultDataspace,
603 ui::PixelFormat* defaultPixelFormat,
604 ui::Dataspace* wideColorGamutDataspace,
605 ui::PixelFormat* wideColorGamutPixelFormat) const {
Peiyong Lin0256f722018-08-31 15:45:10 -0700606 Parcel data, reply;
607 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
608 if (error != NO_ERROR) {
609 return error;
610 }
611 error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply);
612 if (error != NO_ERROR) {
613 return error;
614 }
615 error = static_cast<status_t>(reply.readInt32());
616 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -0700617 *defaultDataspace = static_cast<ui::Dataspace>(reply.readInt32());
618 *defaultPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
619 *wideColorGamutDataspace = static_cast<ui::Dataspace>(reply.readInt32());
620 *wideColorGamutPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
Peiyong Lin0256f722018-08-31 15:45:10 -0700621 }
622 return error;
623 }
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700624
Ady Abraham37965d42018-11-01 13:43:32 -0700625 virtual status_t getColorManagement(bool* outGetColorManagement) const {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700626 Parcel data, reply;
627 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Ady Abraham37965d42018-11-01 13:43:32 -0700628 remote()->transact(BnSurfaceComposer::GET_COLOR_MANAGEMENT, data, &reply);
629 bool result;
630 status_t err = reply.readBool(&result);
631 if (err == NO_ERROR) {
632 *outGetColorManagement = result;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700633 }
Ady Abraham37965d42018-11-01 13:43:32 -0700634 return err;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700635 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -0700636
637 virtual status_t getDisplayedContentSamplingAttributes(const sp<IBinder>& display,
638 ui::PixelFormat* outFormat,
639 ui::Dataspace* outDataspace,
640 uint8_t* outComponentMask) const {
641 if (!outFormat || !outDataspace || !outComponentMask) return BAD_VALUE;
642 Parcel data, reply;
643 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
644 data.writeStrongBinder(display);
645
646 status_t error =
647 remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES,
648 data, &reply);
649 if (error != NO_ERROR) {
650 return error;
651 }
652
653 uint32_t value = 0;
654 error = reply.readUint32(&value);
655 if (error != NO_ERROR) {
656 return error;
657 }
658 *outFormat = static_cast<ui::PixelFormat>(value);
659
660 error = reply.readUint32(&value);
661 if (error != NO_ERROR) {
662 return error;
663 }
664 *outDataspace = static_cast<ui::Dataspace>(value);
665
666 error = reply.readUint32(&value);
667 if (error != NO_ERROR) {
668 return error;
669 }
670 *outComponentMask = static_cast<uint8_t>(value);
671 return error;
672 }
Kevin DuBois74e53772018-11-19 10:52:38 -0800673
674 virtual status_t setDisplayContentSamplingEnabled(const sp<IBinder>& display, bool enable,
675 uint8_t componentMask,
676 uint64_t maxFrames) const {
677 Parcel data, reply;
678 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
679 data.writeStrongBinder(display);
680 data.writeBool(enable);
681 data.writeByte(static_cast<int8_t>(componentMask));
682 data.writeUint64(maxFrames);
683 status_t result =
684 remote()->transact(BnSurfaceComposer::SET_DISPLAY_CONTENT_SAMPLING_ENABLED, data,
685 &reply);
686 return result;
687 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700688
689 virtual status_t getDisplayedContentSample(const sp<IBinder>& display, uint64_t maxFrames,
690 uint64_t timestamp,
691 DisplayedFrameStats* outStats) const {
692 if (!outStats) return BAD_VALUE;
693
694 Parcel data, reply;
695 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
696 data.writeStrongBinder(display);
697 data.writeUint64(maxFrames);
698 data.writeUint64(timestamp);
699
700 status_t result =
701 remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLE, data, &reply);
702
703 if (result != NO_ERROR) {
704 return result;
705 }
706
707 result = reply.readUint64(&outStats->numFrames);
708 if (result != NO_ERROR) {
709 return result;
710 }
711
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800712 result = reply.readUint64Vector(&outStats->component_0_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700713 if (result != NO_ERROR) {
714 return result;
715 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800716 result = reply.readUint64Vector(&outStats->component_1_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700717 if (result != NO_ERROR) {
718 return result;
719 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800720 result = reply.readUint64Vector(&outStats->component_2_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700721 if (result != NO_ERROR) {
722 return result;
723 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800724 result = reply.readUint64Vector(&outStats->component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700725 return result;
726 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800727
728 virtual status_t getProtectedContentSupport(bool* outSupported) const {
729 Parcel data, reply;
730 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Peiyong Linb6888fa2019-01-28 13:20:58 -0800731 status_t error =
732 remote()->transact(BnSurfaceComposer::GET_PROTECTED_CONTENT_SUPPORT, data, &reply);
733 if (error != NO_ERROR) {
734 return error;
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800735 }
Peiyong Linb6888fa2019-01-28 13:20:58 -0800736 error = reply.readBool(outSupported);
737 return error;
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800738 }
Marissa Wallebc2c052019-01-16 19:16:55 -0800739
Peiyong Lin4f3fddf2019-01-24 17:21:24 -0800740 virtual status_t isWideColorDisplay(const sp<IBinder>& token,
741 bool* outIsWideColorDisplay) const {
742 Parcel data, reply;
743 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
744 if (error != NO_ERROR) {
745 return error;
746 }
747 error = data.writeStrongBinder(token);
748 if (error != NO_ERROR) {
749 return error;
750 }
751
752 error = remote()->transact(BnSurfaceComposer::IS_WIDE_COLOR_DISPLAY, data, &reply);
753 if (error != NO_ERROR) {
754 return error;
755 }
756 error = reply.readBool(outIsWideColorDisplay);
757 return error;
758 }
Dan Stoza84ab9372018-12-17 15:27:57 -0800759
760 virtual status_t addRegionSamplingListener(const Rect& samplingArea,
761 const sp<IBinder>& stopLayerHandle,
762 const sp<IRegionSamplingListener>& listener) {
763 Parcel data, reply;
764 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
765 if (error != NO_ERROR) {
766 ALOGE("addRegionSamplingListener: Failed to write interface token");
767 return error;
768 }
769 error = data.write(samplingArea);
770 if (error != NO_ERROR) {
771 ALOGE("addRegionSamplingListener: Failed to write sampling area");
772 return error;
773 }
774 error = data.writeStrongBinder(stopLayerHandle);
775 if (error != NO_ERROR) {
776 ALOGE("addRegionSamplingListener: Failed to write stop layer handle");
777 return error;
778 }
779 error = data.writeStrongBinder(IInterface::asBinder(listener));
780 if (error != NO_ERROR) {
781 ALOGE("addRegionSamplingListener: Failed to write listener");
782 return error;
783 }
784 error = remote()->transact(BnSurfaceComposer::ADD_REGION_SAMPLING_LISTENER, data, &reply);
785 if (error != NO_ERROR) {
786 ALOGE("addRegionSamplingListener: Failed to transact");
787 }
788 return error;
789 }
790
791 virtual status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) {
792 Parcel data, reply;
793 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
794 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800795 ALOGE("removeRegionSamplingListener: Failed to write interface token");
Dan Stoza84ab9372018-12-17 15:27:57 -0800796 return error;
797 }
798 error = data.writeStrongBinder(IInterface::asBinder(listener));
799 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800800 ALOGE("removeRegionSamplingListener: Failed to write listener");
Dan Stoza84ab9372018-12-17 15:27:57 -0800801 return error;
802 }
803 error = remote()->transact(BnSurfaceComposer::REMOVE_REGION_SAMPLING_LISTENER, data,
804 &reply);
805 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800806 ALOGE("removeRegionSamplingListener: Failed to transact");
Dan Stoza84ab9372018-12-17 15:27:57 -0800807 }
808 return error;
809 }
Ady Abraham838de062019-02-04 10:24:03 -0800810
811 virtual status_t setAllowedDisplayConfigs(const sp<IBinder>& displayToken,
812 const std::vector<int32_t>& allowedConfigs) {
813 Parcel data, reply;
814 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
815 if (result != NO_ERROR) {
816 ALOGE("setAllowedDisplayConfigs failed to writeInterfaceToken: %d", result);
817 return result;
818 }
819 result = data.writeStrongBinder(displayToken);
820 if (result != NO_ERROR) {
821 ALOGE("setAllowedDisplayConfigs failed to writeStrongBinder: %d", result);
822 return result;
823 }
824 result = data.writeInt32Vector(allowedConfigs);
825 if (result != NO_ERROR) {
826 ALOGE("setAllowedDisplayConfigs failed to writeInt32Vector: %d", result);
827 return result;
828 }
829 result = remote()->transact(BnSurfaceComposer::SET_ALLOWED_DISPLAY_CONFIGS, data, &reply);
830 if (result != NO_ERROR) {
831 ALOGE("setAllowedDisplayConfigs failed to transact: %d", result);
832 return result;
833 }
834 return reply.readInt32();
835 }
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800836
837 virtual status_t getAllowedDisplayConfigs(const sp<IBinder>& displayToken,
838 std::vector<int32_t>* outAllowedConfigs) {
839 if (!outAllowedConfigs) return BAD_VALUE;
840 Parcel data, reply;
841 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
842 if (result != NO_ERROR) {
843 ALOGE("getAllowedDisplayConfigs failed to writeInterfaceToken: %d", result);
844 return result;
845 }
846 result = data.writeStrongBinder(displayToken);
847 if (result != NO_ERROR) {
848 ALOGE("getAllowedDisplayConfigs failed to writeStrongBinder: %d", result);
849 return result;
850 }
851 result = remote()->transact(BnSurfaceComposer::GET_ALLOWED_DISPLAY_CONFIGS, data, &reply);
852 if (result != NO_ERROR) {
853 ALOGE("getAllowedDisplayConfigs failed to transact: %d", result);
854 return result;
855 }
856 result = reply.readInt32Vector(outAllowedConfigs);
857 if (result != NO_ERROR) {
858 ALOGE("getAllowedDisplayConfigs failed to readInt32Vector: %d", result);
859 return result;
860 }
861 return reply.readInt32();
862 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800863};
864
Dan Stozad723bd72014-11-18 10:24:03 -0800865// Out-of-line virtual method definition to trigger vtable emission in this
866// translation unit (see clang warning -Wweak-vtables)
867BpSurfaceComposer::~BpSurfaceComposer() {}
868
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800869IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
870
871// ----------------------------------------------------------------------
872
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800873status_t BnSurfaceComposer::onTransact(
874 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
875{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800876 switch(code) {
877 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700878 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800879 sp<IBinder> b = IInterface::asBinder(createConnection());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800880 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -0700881 return NO_ERROR;
882 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700883 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700884 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -0800885
886 size_t count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700887 if (count > data.dataSize()) {
888 return BAD_VALUE;
889 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700890 Vector<ComposerState> state;
891 state.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800892 for (size_t i = 0; i < count; i++) {
Marissa Wallc837b5e2018-10-12 10:04:44 -0700893 ComposerState s;
Michael Lentine8afa1c42014-10-31 11:10:13 -0700894 if (s.read(data) == BAD_VALUE) {
895 return BAD_VALUE;
896 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700897 state.add(s);
898 }
Dan Stozad723bd72014-11-18 10:24:03 -0800899
900 count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700901 if (count > data.dataSize()) {
902 return BAD_VALUE;
903 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700904 DisplayState d;
905 Vector<DisplayState> displays;
906 displays.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800907 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700908 if (d.read(data) == BAD_VALUE) {
909 return BAD_VALUE;
910 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700911 displays.add(d);
912 }
Dan Stozad723bd72014-11-18 10:24:03 -0800913
914 uint32_t stateFlags = data.readUint32();
Marissa Wall713b63f2018-10-17 15:42:43 -0700915 sp<IBinder> applyToken = data.readStrongBinder();
chaviw273171b2018-12-26 11:46:30 -0800916 InputWindowCommands inputWindowCommands;
917 inputWindowCommands.read(data);
Marissa Wall17b4e452018-12-26 16:32:34 -0800918
919 int64_t desiredPresentTime = data.readInt64();
920 setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands,
921 desiredPresentTime);
Jesse Hall6c913be2013-08-08 12:15:49 -0700922 return NO_ERROR;
923 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800924 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700925 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800926 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -0700927 return NO_ERROR;
928 }
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800929 case CAPTURE_SCREEN: {
930 CHECK_INTERFACE(ISurfaceComposer, data, reply);
931 sp<IBinder> display = data.readStrongBinder();
Peiyong Lin0e003c92018-09-17 11:09:51 -0700932 ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32());
933 ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32());
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000934 sp<GraphicBuffer> outBuffer;
Pablo Ceballos60d69222015-08-07 14:47:20 -0700935 Rect sourceCrop(Rect::EMPTY_RECT);
Dan Stozac1879002014-05-22 15:59:05 -0700936 data.read(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800937 uint32_t reqWidth = data.readUint32();
938 uint32_t reqHeight = data.readUint32();
Dan Stozac7014012014-02-14 15:03:43 -0800939 bool useIdentityTransform = static_cast<bool>(data.readInt32());
Dan Stozad723bd72014-11-18 10:24:03 -0800940 int32_t rotation = data.readInt32();
Robert Carrfa8855f2019-02-19 10:05:00 -0800941 bool captureSecureLayers = static_cast<bool>(data.readInt32());
Dan Stozac7014012014-02-14 15:03:43 -0800942
Peiyong Lin0e003c92018-09-17 11:09:51 -0700943 status_t res = captureScreen(display, &outBuffer, reqDataspace, reqPixelFormat,
944 sourceCrop, reqWidth, reqHeight, useIdentityTransform,
Robert Carrfa8855f2019-02-19 10:05:00 -0800945 static_cast<ISurfaceComposer::Rotation>(rotation), captureSecureLayers);
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800946 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000947 if (res == NO_ERROR) {
948 reply->write(*outBuffer);
949 }
Jesse Hall6c913be2013-08-08 12:15:49 -0700950 return NO_ERROR;
951 }
chaviwa76b2712017-09-20 12:02:26 -0700952 case CAPTURE_LAYERS: {
953 CHECK_INTERFACE(ISurfaceComposer, data, reply);
954 sp<IBinder> layerHandleBinder = data.readStrongBinder();
Peiyong Lin0e003c92018-09-17 11:09:51 -0700955 ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32());
956 ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32());
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000957 sp<GraphicBuffer> outBuffer;
chaviw7206d492017-11-10 16:16:12 -0800958 Rect sourceCrop(Rect::EMPTY_RECT);
959 data.read(sourceCrop);
960 float frameScale = data.readFloat();
Robert Carr578038f2018-03-09 12:25:24 -0800961 bool childrenOnly = data.readBool();
chaviwa76b2712017-09-20 12:02:26 -0700962
Peiyong Lin0e003c92018-09-17 11:09:51 -0700963 status_t res = captureLayers(layerHandleBinder, &outBuffer, reqDataspace,
964 reqPixelFormat, sourceCrop, frameScale, childrenOnly);
chaviwa76b2712017-09-20 12:02:26 -0700965 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000966 if (res == NO_ERROR) {
967 reply->write(*outBuffer);
968 }
chaviwa76b2712017-09-20 12:02:26 -0700969 return NO_ERROR;
970 }
Jamie Gennis134f0422011-03-08 12:18:54 -0800971 case AUTHENTICATE_SURFACE: {
972 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -0800973 sp<IGraphicBufferProducer> bufferProducer =
974 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
975 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -0800976 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700977 return NO_ERROR;
978 }
Brian Anderson6b376712017-04-04 10:51:39 -0700979 case GET_SUPPORTED_FRAME_TIMESTAMPS: {
980 CHECK_INTERFACE(ISurfaceComposer, data, reply);
981 std::vector<FrameEvent> supportedTimestamps;
982 status_t result = getSupportedFrameTimestamps(&supportedTimestamps);
983 status_t err = reply->writeInt32(result);
984 if (err != NO_ERROR) {
985 return err;
986 }
987 if (result != NO_ERROR) {
988 return result;
989 }
990
991 std::vector<int32_t> supported;
992 supported.reserve(supportedTimestamps.size());
993 for (FrameEvent s : supportedTimestamps) {
994 supported.push_back(static_cast<int32_t>(s));
995 }
996 return reply->writeInt32Vector(supported);
997 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800998 case CREATE_DISPLAY_EVENT_CONNECTION: {
999 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -07001000 sp<IDisplayEventConnection> connection(createDisplayEventConnection(
1001 static_cast<ISurfaceComposer::VsyncSource>(data.readInt32())));
Marco Nelissen2ea926b2014-11-14 08:01:01 -08001002 reply->writeStrongBinder(IInterface::asBinder(connection));
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001003 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001004 }
Mathias Agopiane57f2922012-08-09 16:29:12 -07001005 case CREATE_DISPLAY: {
1006 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden8dfa92f2012-09-17 18:27:17 -07001007 String8 displayName = data.readString8();
Jamie Gennisdd3cb842012-10-19 18:19:11 -07001008 bool secure = bool(data.readInt32());
1009 sp<IBinder> display(createDisplay(displayName, secure));
Mathias Agopiane57f2922012-08-09 16:29:12 -07001010 reply->writeStrongBinder(display);
1011 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001012 }
1013 case DESTROY_DISPLAY: {
1014 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1015 sp<IBinder> display = data.readStrongBinder();
1016 destroyDisplay(display);
1017 return NO_ERROR;
1018 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001019 case GET_PHYSICAL_DISPLAY_TOKEN: {
Mathias Agopiane57f2922012-08-09 16:29:12 -07001020 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001021 PhysicalDisplayId displayId = data.readUint64();
1022 sp<IBinder> display = getPhysicalDisplayToken(displayId);
Mathias Agopiane57f2922012-08-09 16:29:12 -07001023 reply->writeStrongBinder(display);
1024 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001025 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001026 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -07001027 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stoza7f7da322014-05-02 15:26:25 -07001028 Vector<DisplayInfo> configs;
Jeff Brown9d4e3d22012-08-24 20:00:51 -07001029 sp<IBinder> display = data.readStrongBinder();
Dan Stoza7f7da322014-05-02 15:26:25 -07001030 status_t result = getDisplayConfigs(display, &configs);
1031 reply->writeInt32(result);
1032 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -08001033 reply->writeUint32(static_cast<uint32_t>(configs.size()));
Dan Stoza7f7da322014-05-02 15:26:25 -07001034 for (size_t c = 0; c < configs.size(); ++c) {
1035 memcpy(reply->writeInplace(sizeof(DisplayInfo)),
1036 &configs[c], sizeof(DisplayInfo));
1037 }
1038 }
1039 return NO_ERROR;
1040 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -07001041 case GET_DISPLAY_STATS: {
1042 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1043 DisplayStatInfo stats;
1044 sp<IBinder> display = data.readStrongBinder();
1045 status_t result = getDisplayStats(display, &stats);
1046 reply->writeInt32(result);
1047 if (result == NO_ERROR) {
1048 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
1049 &stats, sizeof(DisplayStatInfo));
1050 }
1051 return NO_ERROR;
1052 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001053 case GET_ACTIVE_CONFIG: {
1054 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1055 sp<IBinder> display = data.readStrongBinder();
1056 int id = getActiveConfig(display);
1057 reply->writeInt32(id);
1058 return NO_ERROR;
1059 }
1060 case SET_ACTIVE_CONFIG: {
1061 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1062 sp<IBinder> display = data.readStrongBinder();
1063 int id = data.readInt32();
1064 status_t result = setActiveConfig(display, id);
Mathias Agopianc666cae2012-07-25 18:56:13 -07001065 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -07001066 return NO_ERROR;
1067 }
Michael Wright28f24d02016-07-12 13:30:53 -07001068 case GET_DISPLAY_COLOR_MODES: {
1069 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Lina52f0292018-03-14 17:26:31 -07001070 Vector<ColorMode> colorModes;
Michael Wright28f24d02016-07-12 13:30:53 -07001071 sp<IBinder> display = nullptr;
1072 status_t result = data.readStrongBinder(&display);
1073 if (result != NO_ERROR) {
1074 ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result);
1075 return result;
1076 }
1077 result = getDisplayColorModes(display, &colorModes);
1078 reply->writeInt32(result);
1079 if (result == NO_ERROR) {
1080 reply->writeUint32(static_cast<uint32_t>(colorModes.size()));
1081 for (size_t i = 0; i < colorModes.size(); ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -07001082 reply->writeInt32(static_cast<int32_t>(colorModes[i]));
Michael Wright28f24d02016-07-12 13:30:53 -07001083 }
1084 }
1085 return NO_ERROR;
1086 }
Daniel Solomon42d04562019-01-20 21:03:19 -08001087 case GET_DISPLAY_NATIVE_PRIMARIES: {
1088 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1089 ui::DisplayPrimaries primaries;
1090 sp<IBinder> display = nullptr;
1091
1092 status_t result = data.readStrongBinder(&display);
1093 if (result != NO_ERROR) {
1094 ALOGE("getDisplayNativePrimaries failed to readStrongBinder: %d", result);
1095 return result;
1096 }
1097
1098 result = getDisplayNativePrimaries(display, primaries);
1099 reply->writeInt32(result);
1100 if (result == NO_ERROR) {
1101 memcpy(reply->writeInplace(sizeof(ui::DisplayPrimaries)), &primaries,
1102 sizeof(ui::DisplayPrimaries));
1103 }
1104
1105 return NO_ERROR;
1106 }
Michael Wright28f24d02016-07-12 13:30:53 -07001107 case GET_ACTIVE_COLOR_MODE: {
1108 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1109 sp<IBinder> display = nullptr;
1110 status_t result = data.readStrongBinder(&display);
1111 if (result != NO_ERROR) {
1112 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1113 return result;
1114 }
Peiyong Lina52f0292018-03-14 17:26:31 -07001115 ColorMode colorMode = getActiveColorMode(display);
Michael Wright28f24d02016-07-12 13:30:53 -07001116 result = reply->writeInt32(static_cast<int32_t>(colorMode));
1117 return result;
1118 }
1119 case SET_ACTIVE_COLOR_MODE: {
1120 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1121 sp<IBinder> display = nullptr;
1122 status_t result = data.readStrongBinder(&display);
1123 if (result != NO_ERROR) {
1124 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1125 return result;
1126 }
1127 int32_t colorModeInt = 0;
1128 result = data.readInt32(&colorModeInt);
1129 if (result != NO_ERROR) {
1130 ALOGE("setActiveColorMode failed to readInt32: %d", result);
1131 return result;
1132 }
1133 result = setActiveColorMode(display,
Peiyong Lina52f0292018-03-14 17:26:31 -07001134 static_cast<ColorMode>(colorModeInt));
Michael Wright28f24d02016-07-12 13:30:53 -07001135 result = reply->writeInt32(result);
1136 return result;
1137 }
Svetoslavd85084b2014-03-20 10:28:31 -07001138 case CLEAR_ANIMATION_FRAME_STATS: {
1139 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1140 status_t result = clearAnimationFrameStats();
1141 reply->writeInt32(result);
1142 return NO_ERROR;
1143 }
1144 case GET_ANIMATION_FRAME_STATS: {
1145 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1146 FrameStats stats;
1147 status_t result = getAnimationFrameStats(&stats);
1148 reply->write(stats);
1149 reply->writeInt32(result);
1150 return NO_ERROR;
1151 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -07001152 case SET_POWER_MODE: {
1153 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1154 sp<IBinder> display = data.readStrongBinder();
1155 int32_t mode = data.readInt32();
1156 setPowerMode(display, mode);
1157 return NO_ERROR;
1158 }
Dan Stozac4f471e2016-03-24 09:31:08 -07001159 case GET_HDR_CAPABILITIES: {
1160 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1161 sp<IBinder> display = nullptr;
1162 status_t result = data.readStrongBinder(&display);
1163 if (result != NO_ERROR) {
1164 ALOGE("getHdrCapabilities failed to readStrongBinder: %d",
1165 result);
1166 return result;
1167 }
1168 HdrCapabilities capabilities;
1169 result = getHdrCapabilities(display, &capabilities);
1170 reply->writeInt32(result);
1171 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -08001172 reply->write(capabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -07001173 }
1174 return NO_ERROR;
1175 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -07001176 case ENABLE_VSYNC_INJECTIONS: {
1177 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1178 bool enable = false;
1179 status_t result = data.readBool(&enable);
1180 if (result != NO_ERROR) {
1181 ALOGE("enableVSyncInjections failed to readBool: %d", result);
1182 return result;
1183 }
1184 return enableVSyncInjections(enable);
1185 }
1186 case INJECT_VSYNC: {
1187 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1188 int64_t when = 0;
1189 status_t result = data.readInt64(&when);
1190 if (result != NO_ERROR) {
1191 ALOGE("enableVSyncInjections failed to readInt64: %d", result);
1192 return result;
1193 }
1194 return injectVSync(when);
1195 }
Kalle Raitaa099a242017-01-11 11:17:29 -08001196 case GET_LAYER_DEBUG_INFO: {
1197 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1198 std::vector<LayerDebugInfo> outLayers;
1199 status_t result = getLayerDebugInfo(&outLayers);
1200 reply->writeInt32(result);
1201 if (result == NO_ERROR)
1202 {
1203 result = reply->writeParcelableVector(outLayers);
1204 }
1205 return result;
1206 }
Peiyong Lin0256f722018-08-31 15:45:10 -07001207 case GET_COMPOSITION_PREFERENCE: {
1208 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Linc6780972018-10-28 15:24:08 -07001209 ui::Dataspace defaultDataspace;
1210 ui::PixelFormat defaultPixelFormat;
1211 ui::Dataspace wideColorGamutDataspace;
1212 ui::PixelFormat wideColorGamutPixelFormat;
1213 status_t error =
1214 getCompositionPreference(&defaultDataspace, &defaultPixelFormat,
1215 &wideColorGamutDataspace, &wideColorGamutPixelFormat);
Peiyong Lin0256f722018-08-31 15:45:10 -07001216 reply->writeInt32(error);
1217 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -07001218 reply->writeInt32(static_cast<int32_t>(defaultDataspace));
1219 reply->writeInt32(static_cast<int32_t>(defaultPixelFormat));
1220 reply->writeInt32(static_cast<int32_t>(wideColorGamutDataspace));
Peiyong Linaa3da6a2018-12-12 02:48:43 -08001221 reply->writeInt32(static_cast<int32_t>(wideColorGamutPixelFormat));
Peiyong Lin0256f722018-08-31 15:45:10 -07001222 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001223 return error;
Peiyong Lin0256f722018-08-31 15:45:10 -07001224 }
Ady Abraham37965d42018-11-01 13:43:32 -07001225 case GET_COLOR_MANAGEMENT: {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001226 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Ady Abraham37965d42018-11-01 13:43:32 -07001227 bool result;
1228 status_t error = getColorManagement(&result);
1229 if (error == NO_ERROR) {
1230 reply->writeBool(result);
1231 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001232 return error;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001233 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -07001234 case GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: {
1235 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1236
1237 sp<IBinder> display = data.readStrongBinder();
1238 ui::PixelFormat format;
1239 ui::Dataspace dataspace;
1240 uint8_t component = 0;
1241 auto result =
1242 getDisplayedContentSamplingAttributes(display, &format, &dataspace, &component);
1243 if (result == NO_ERROR) {
1244 reply->writeUint32(static_cast<uint32_t>(format));
1245 reply->writeUint32(static_cast<uint32_t>(dataspace));
1246 reply->writeUint32(static_cast<uint32_t>(component));
1247 }
1248 return result;
1249 }
Kevin DuBois74e53772018-11-19 10:52:38 -08001250 case SET_DISPLAY_CONTENT_SAMPLING_ENABLED: {
1251 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1252
1253 sp<IBinder> display = nullptr;
1254 bool enable = false;
1255 int8_t componentMask = 0;
1256 uint64_t maxFrames = 0;
1257 status_t result = data.readStrongBinder(&display);
1258 if (result != NO_ERROR) {
1259 ALOGE("setDisplayContentSamplingEnabled failure in reading Display token: %d",
1260 result);
1261 return result;
1262 }
1263
1264 result = data.readBool(&enable);
1265 if (result != NO_ERROR) {
1266 ALOGE("setDisplayContentSamplingEnabled failure in reading enable: %d", result);
1267 return result;
1268 }
1269
1270 result = data.readByte(static_cast<int8_t*>(&componentMask));
1271 if (result != NO_ERROR) {
1272 ALOGE("setDisplayContentSamplingEnabled failure in reading component mask: %d",
1273 result);
1274 return result;
1275 }
1276
1277 result = data.readUint64(&maxFrames);
1278 if (result != NO_ERROR) {
1279 ALOGE("setDisplayContentSamplingEnabled failure in reading max frames: %d", result);
1280 return result;
1281 }
1282
1283 return setDisplayContentSamplingEnabled(display, enable,
1284 static_cast<uint8_t>(componentMask), maxFrames);
1285 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001286 case GET_DISPLAYED_CONTENT_SAMPLE: {
1287 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1288
1289 sp<IBinder> display = data.readStrongBinder();
1290 uint64_t maxFrames = 0;
1291 uint64_t timestamp = 0;
1292
1293 status_t result = data.readUint64(&maxFrames);
1294 if (result != NO_ERROR) {
1295 ALOGE("getDisplayedContentSample failure in reading max frames: %d", result);
1296 return result;
1297 }
1298
1299 result = data.readUint64(&timestamp);
1300 if (result != NO_ERROR) {
1301 ALOGE("getDisplayedContentSample failure in reading timestamp: %d", result);
1302 return result;
1303 }
1304
1305 DisplayedFrameStats stats;
1306 result = getDisplayedContentSample(display, maxFrames, timestamp, &stats);
1307 if (result == NO_ERROR) {
1308 reply->writeUint64(stats.numFrames);
Kevin DuBois1d4c6a62018-12-12 13:59:46 -08001309 reply->writeUint64Vector(stats.component_0_sample);
1310 reply->writeUint64Vector(stats.component_1_sample);
1311 reply->writeUint64Vector(stats.component_2_sample);
1312 reply->writeUint64Vector(stats.component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001313 }
1314 return result;
1315 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001316 case GET_PROTECTED_CONTENT_SUPPORT: {
1317 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1318 bool result;
1319 status_t error = getProtectedContentSupport(&result);
1320 if (error == NO_ERROR) {
1321 reply->writeBool(result);
1322 }
1323 return error;
1324 }
Peiyong Lin4f3fddf2019-01-24 17:21:24 -08001325 case IS_WIDE_COLOR_DISPLAY: {
1326 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1327 sp<IBinder> display = nullptr;
1328 status_t error = data.readStrongBinder(&display);
1329 if (error != NO_ERROR) {
1330 return error;
1331 }
1332 bool result;
1333 error = isWideColorDisplay(display, &result);
1334 if (error == NO_ERROR) {
1335 reply->writeBool(result);
1336 }
1337 return error;
1338 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001339 case GET_PHYSICAL_DISPLAY_IDS: {
1340 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1341 return reply->writeUint64Vector(getPhysicalDisplayIds());
1342 }
Dan Stoza84ab9372018-12-17 15:27:57 -08001343 case ADD_REGION_SAMPLING_LISTENER: {
1344 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1345 Rect samplingArea;
1346 status_t result = data.read(samplingArea);
1347 if (result != NO_ERROR) {
1348 ALOGE("addRegionSamplingListener: Failed to read sampling area");
1349 return result;
1350 }
1351 sp<IBinder> stopLayerHandle;
1352 result = data.readNullableStrongBinder(&stopLayerHandle);
1353 if (result != NO_ERROR) {
1354 ALOGE("addRegionSamplingListener: Failed to read stop layer handle");
1355 return result;
1356 }
1357 sp<IRegionSamplingListener> listener;
1358 result = data.readNullableStrongBinder(&listener);
1359 if (result != NO_ERROR) {
1360 ALOGE("addRegionSamplingListener: Failed to read listener");
1361 return result;
1362 }
1363 return addRegionSamplingListener(samplingArea, stopLayerHandle, listener);
1364 }
1365 case REMOVE_REGION_SAMPLING_LISTENER: {
1366 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1367 sp<IRegionSamplingListener> listener;
1368 status_t result = data.readNullableStrongBinder(&listener);
1369 if (result != NO_ERROR) {
1370 ALOGE("removeRegionSamplingListener: Failed to read listener");
1371 return result;
1372 }
1373 return removeRegionSamplingListener(listener);
1374 }
Ady Abraham838de062019-02-04 10:24:03 -08001375 case SET_ALLOWED_DISPLAY_CONFIGS: {
1376 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1377 sp<IBinder> displayToken = data.readStrongBinder();
1378 std::vector<int32_t> allowedConfigs;
1379 data.readInt32Vector(&allowedConfigs);
1380 status_t result = setAllowedDisplayConfigs(displayToken, allowedConfigs);
1381 reply->writeInt32(result);
1382 return result;
1383 }
Ady Abrahamd9b3ea62019-02-26 14:08:03 -08001384 case GET_ALLOWED_DISPLAY_CONFIGS: {
1385 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1386 sp<IBinder> displayToken = data.readStrongBinder();
1387 std::vector<int32_t> allowedConfigs;
1388 status_t result = getAllowedDisplayConfigs(displayToken, &allowedConfigs);
1389 reply->writeInt32Vector(allowedConfigs);
1390 reply->writeInt32(result);
1391 return result;
1392 }
Jesse Hall6c913be2013-08-08 12:15:49 -07001393 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001394 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -07001395 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001396 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001397}
1398
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001399} // namespace android