blob: 2e9c7966541df0310519e9a29717330fd9466345 [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,
103 ISurfaceComposer::Rotation rotation) {
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));
Ana Krulec2d41e422018-07-26 12:07:43 -0700114 status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply);
115 if (result != NO_ERROR) {
116 ALOGE("captureScreen failed to transact: %d", result);
117 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000118 }
Ana Krulec2d41e422018-07-26 12:07:43 -0700119 result = reply.readInt32();
120 if (result != NO_ERROR) {
121 ALOGE("captureScreen failed to readInt32: %d", result);
122 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000123 }
124
125 *outBuffer = new GraphicBuffer();
126 reply.read(**outBuffer);
Peiyong Lin0e003c92018-09-17 11:09:51 -0700127
Ana Krulec2d41e422018-07-26 12:07:43 -0700128 return result;
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800129 }
130
chaviwa76b2712017-09-20 12:02:26 -0700131 virtual status_t captureLayers(const sp<IBinder>& layerHandleBinder,
Peiyong Lin0e003c92018-09-17 11:09:51 -0700132 sp<GraphicBuffer>* outBuffer, const ui::Dataspace reqDataspace,
133 const ui::PixelFormat reqPixelFormat, const Rect& sourceCrop,
Robert Carr578038f2018-03-09 12:25:24 -0800134 float frameScale, bool childrenOnly) {
chaviwa76b2712017-09-20 12:02:26 -0700135 Parcel data, reply;
136 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
137 data.writeStrongBinder(layerHandleBinder);
Peiyong Lin0e003c92018-09-17 11:09:51 -0700138 data.writeInt32(static_cast<int32_t>(reqDataspace));
139 data.writeInt32(static_cast<int32_t>(reqPixelFormat));
chaviw7206d492017-11-10 16:16:12 -0800140 data.write(sourceCrop);
141 data.writeFloat(frameScale);
Robert Carr578038f2018-03-09 12:25:24 -0800142 data.writeBool(childrenOnly);
Ana Krulec2d41e422018-07-26 12:07:43 -0700143 status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_LAYERS, data, &reply);
144 if (result != NO_ERROR) {
145 ALOGE("captureLayers failed to transact: %d", result);
146 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000147 }
Ana Krulec2d41e422018-07-26 12:07:43 -0700148 result = reply.readInt32();
149 if (result != NO_ERROR) {
150 ALOGE("captureLayers failed to readInt32: %d", result);
151 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000152 }
Peiyong Lin0e003c92018-09-17 11:09:51 -0700153
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000154 *outBuffer = new GraphicBuffer();
155 reply.read(**outBuffer);
156
Ana Krulec2d41e422018-07-26 12:07:43 -0700157 return result;
chaviwa76b2712017-09-20 12:02:26 -0700158 }
159
Jamie Gennis582270d2011-08-17 18:19:00 -0700160 virtual bool authenticateSurfaceTexture(
Andy McFadden2adaf042012-12-18 09:49:45 -0800161 const sp<IGraphicBufferProducer>& bufferProducer) const
Jamie Gennis134f0422011-03-08 12:18:54 -0800162 {
163 Parcel data, reply;
164 int err = NO_ERROR;
165 err = data.writeInterfaceToken(
166 ISurfaceComposer::getInterfaceDescriptor());
167 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000168 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis134f0422011-03-08 12:18:54 -0800169 "interface descriptor: %s (%d)", strerror(-err), -err);
170 return false;
171 }
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800172 err = data.writeStrongBinder(IInterface::asBinder(bufferProducer));
Jamie Gennis134f0422011-03-08 12:18:54 -0800173 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000174 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis582270d2011-08-17 18:19:00 -0700175 "strong binder to parcel: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800176 return false;
177 }
178 err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
179 &reply);
180 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000181 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700182 "performing transaction: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800183 return false;
184 }
185 int32_t result = 0;
186 err = reply.readInt32(&result);
187 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000188 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700189 "retrieving result: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800190 return false;
191 }
192 return result != 0;
193 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800194
Brian Anderson6b376712017-04-04 10:51:39 -0700195 virtual status_t getSupportedFrameTimestamps(
196 std::vector<FrameEvent>* outSupported) const {
197 if (!outSupported) {
198 return UNEXPECTED_NULL;
199 }
200 outSupported->clear();
201
202 Parcel data, reply;
203
204 status_t err = data.writeInterfaceToken(
205 ISurfaceComposer::getInterfaceDescriptor());
206 if (err != NO_ERROR) {
207 return err;
208 }
209
210 err = remote()->transact(
211 BnSurfaceComposer::GET_SUPPORTED_FRAME_TIMESTAMPS,
212 data, &reply);
213 if (err != NO_ERROR) {
214 return err;
215 }
216
217 int32_t result = 0;
218 err = reply.readInt32(&result);
219 if (err != NO_ERROR) {
220 return err;
221 }
222 if (result != NO_ERROR) {
223 return result;
224 }
225
226 std::vector<int32_t> supported;
227 err = reply.readInt32Vector(&supported);
228 if (err != NO_ERROR) {
229 return err;
230 }
231
232 outSupported->reserve(supported.size());
233 for (int32_t s : supported) {
234 outSupported->push_back(static_cast<FrameEvent>(s));
235 }
236 return NO_ERROR;
237 }
238
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700239 virtual sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource)
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800240 {
241 Parcel data, reply;
242 sp<IDisplayEventConnection> result;
243 int err = data.writeInterfaceToken(
244 ISurfaceComposer::getInterfaceDescriptor());
245 if (err != NO_ERROR) {
246 return result;
247 }
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700248 data.writeInt32(static_cast<int32_t>(vsyncSource));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800249 err = remote()->transact(
250 BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION,
251 data, &reply);
252 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000253 ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing "
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800254 "transaction: %s (%d)", strerror(-err), -err);
255 return result;
256 }
257 result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder());
258 return result;
259 }
Colin Cross8e533062012-06-07 13:17:52 -0700260
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700261 virtual sp<IBinder> createDisplay(const String8& displayName, bool secure)
Mathias Agopiane57f2922012-08-09 16:29:12 -0700262 {
263 Parcel data, reply;
264 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700265 data.writeString8(displayName);
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700266 data.writeInt32(secure ? 1 : 0);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700267 remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply);
268 return reply.readStrongBinder();
269 }
270
Jesse Hall6c913be2013-08-08 12:15:49 -0700271 virtual void destroyDisplay(const sp<IBinder>& display)
272 {
273 Parcel data, reply;
274 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
275 data.writeStrongBinder(display);
276 remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply);
277 }
278
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800279 virtual std::vector<PhysicalDisplayId> getPhysicalDisplayIds() const {
Mathias Agopiane57f2922012-08-09 16:29:12 -0700280 Parcel data, reply;
281 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800282 if (remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_IDS, data, &reply) ==
283 NO_ERROR) {
284 std::vector<PhysicalDisplayId> displayIds;
285 if (reply.readUint64Vector(&displayIds) == NO_ERROR) {
286 return displayIds;
287 }
288 }
289
290 return {};
291 }
292
293 virtual sp<IBinder> getPhysicalDisplayToken(PhysicalDisplayId displayId) const {
294 Parcel data, reply;
295 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
296 data.writeUint64(displayId);
297 remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_TOKEN, data, &reply);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700298 return reply.readStrongBinder();
299 }
300
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700301 virtual void setPowerMode(const sp<IBinder>& display, int mode)
Colin Cross8e533062012-06-07 13:17:52 -0700302 {
303 Parcel data, reply;
304 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700305 data.writeStrongBinder(display);
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700306 data.writeInt32(mode);
307 remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply);
Colin Cross8e533062012-06-07 13:17:52 -0700308 }
Mathias Agopian3094df32012-06-18 18:06:45 -0700309
Dan Stoza7f7da322014-05-02 15:26:25 -0700310 virtual status_t getDisplayConfigs(const sp<IBinder>& display,
311 Vector<DisplayInfo>* configs)
Mathias Agopianc666cae2012-07-25 18:56:13 -0700312 {
313 Parcel data, reply;
314 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700315 data.writeStrongBinder(display);
Dan Stoza7f7da322014-05-02 15:26:25 -0700316 remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply);
317 status_t result = reply.readInt32();
318 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -0800319 size_t numConfigs = reply.readUint32();
Dan Stoza7f7da322014-05-02 15:26:25 -0700320 configs->clear();
321 configs->resize(numConfigs);
322 for (size_t c = 0; c < numConfigs; ++c) {
323 memcpy(&(configs->editItemAt(c)),
324 reply.readInplace(sizeof(DisplayInfo)),
325 sizeof(DisplayInfo));
326 }
327 }
328 return result;
329 }
330
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700331 virtual status_t getDisplayStats(const sp<IBinder>& display,
332 DisplayStatInfo* stats)
333 {
334 Parcel data, reply;
335 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
336 data.writeStrongBinder(display);
337 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply);
338 status_t result = reply.readInt32();
339 if (result == NO_ERROR) {
340 memcpy(stats,
341 reply.readInplace(sizeof(DisplayStatInfo)),
342 sizeof(DisplayStatInfo));
343 }
344 return result;
345 }
346
Dan Stoza7f7da322014-05-02 15:26:25 -0700347 virtual int getActiveConfig(const sp<IBinder>& display)
348 {
349 Parcel data, reply;
350 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
351 data.writeStrongBinder(display);
352 remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply);
353 return reply.readInt32();
354 }
355
356 virtual status_t setActiveConfig(const sp<IBinder>& display, int id)
357 {
358 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700359 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
360 if (result != NO_ERROR) {
361 ALOGE("setActiveConfig failed to writeInterfaceToken: %d", result);
362 return result;
363 }
364 result = data.writeStrongBinder(display);
365 if (result != NO_ERROR) {
366 ALOGE("setActiveConfig failed to writeStrongBinder: %d", result);
367 return result;
368 }
369 result = data.writeInt32(id);
370 if (result != NO_ERROR) {
371 ALOGE("setActiveConfig failed to writeInt32: %d", result);
372 return result;
373 }
374 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply);
375 if (result != NO_ERROR) {
376 ALOGE("setActiveConfig failed to transact: %d", result);
377 return result;
378 }
Mathias Agopianc666cae2012-07-25 18:56:13 -0700379 return reply.readInt32();
380 }
Svetoslavd85084b2014-03-20 10:28:31 -0700381
Michael Wright28f24d02016-07-12 13:30:53 -0700382 virtual status_t getDisplayColorModes(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700383 Vector<ColorMode>* outColorModes) {
Michael Wright28f24d02016-07-12 13:30:53 -0700384 Parcel data, reply;
385 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
386 if (result != NO_ERROR) {
387 ALOGE("getDisplayColorModes failed to writeInterfaceToken: %d", result);
388 return result;
389 }
390 result = data.writeStrongBinder(display);
391 if (result != NO_ERROR) {
392 ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result);
393 return result;
394 }
395 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply);
396 if (result != NO_ERROR) {
397 ALOGE("getDisplayColorModes failed to transact: %d", result);
398 return result;
399 }
400 result = static_cast<status_t>(reply.readInt32());
401 if (result == NO_ERROR) {
402 size_t numModes = reply.readUint32();
403 outColorModes->clear();
404 outColorModes->resize(numModes);
405 for (size_t i = 0; i < numModes; ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -0700406 outColorModes->replaceAt(static_cast<ColorMode>(reply.readInt32()), i);
Michael Wright28f24d02016-07-12 13:30:53 -0700407 }
408 }
409 return result;
410 }
411
Daniel Solomon42d04562019-01-20 21:03:19 -0800412 virtual status_t getDisplayNativePrimaries(const sp<IBinder>& display,
413 ui::DisplayPrimaries& primaries) {
414 Parcel data, reply;
415 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
416 if (result != NO_ERROR) {
417 ALOGE("getDisplayNativePrimaries failed to writeInterfaceToken: %d", result);
418 return result;
419 }
420 result = data.writeStrongBinder(display);
421 if (result != NO_ERROR) {
422 ALOGE("getDisplayNativePrimaries failed to writeStrongBinder: %d", result);
423 return result;
424 }
425 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_NATIVE_PRIMARIES, data, &reply);
426 if (result != NO_ERROR) {
427 ALOGE("getDisplayNativePrimaries failed to transact: %d", result);
428 return result;
429 }
430 result = reply.readInt32();
431 if (result == NO_ERROR) {
432 memcpy(&primaries, reply.readInplace(sizeof(ui::DisplayPrimaries)),
433 sizeof(ui::DisplayPrimaries));
434 }
435 return result;
436 }
437
Peiyong Lina52f0292018-03-14 17:26:31 -0700438 virtual ColorMode getActiveColorMode(const sp<IBinder>& display) {
Michael Wright28f24d02016-07-12 13:30:53 -0700439 Parcel data, reply;
440 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
441 if (result != NO_ERROR) {
442 ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700443 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700444 }
445 result = data.writeStrongBinder(display);
446 if (result != NO_ERROR) {
447 ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700448 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700449 }
450 result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply);
451 if (result != NO_ERROR) {
452 ALOGE("getActiveColorMode failed to transact: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700453 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700454 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700455 return static_cast<ColorMode>(reply.readInt32());
Michael Wright28f24d02016-07-12 13:30:53 -0700456 }
457
458 virtual status_t setActiveColorMode(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700459 ColorMode colorMode) {
Michael Wright28f24d02016-07-12 13:30:53 -0700460 Parcel data, reply;
461 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
462 if (result != NO_ERROR) {
463 ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result);
464 return result;
465 }
466 result = data.writeStrongBinder(display);
467 if (result != NO_ERROR) {
468 ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result);
469 return result;
470 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700471 result = data.writeInt32(static_cast<int32_t>(colorMode));
Michael Wright28f24d02016-07-12 13:30:53 -0700472 if (result != NO_ERROR) {
473 ALOGE("setActiveColorMode failed to writeInt32: %d", result);
474 return result;
475 }
476 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply);
477 if (result != NO_ERROR) {
478 ALOGE("setActiveColorMode failed to transact: %d", result);
479 return result;
480 }
481 return static_cast<status_t>(reply.readInt32());
482 }
483
Svetoslavd85084b2014-03-20 10:28:31 -0700484 virtual status_t clearAnimationFrameStats() {
485 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700486 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
487 if (result != NO_ERROR) {
488 ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result);
489 return result;
490 }
491 result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply);
492 if (result != NO_ERROR) {
493 ALOGE("clearAnimationFrameStats failed to transact: %d", result);
494 return result;
495 }
Svetoslavd85084b2014-03-20 10:28:31 -0700496 return reply.readInt32();
497 }
498
499 virtual status_t getAnimationFrameStats(FrameStats* outStats) const {
500 Parcel data, reply;
501 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
502 remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply);
503 reply.read(*outStats);
504 return reply.readInt32();
505 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700506
507 virtual status_t getHdrCapabilities(const sp<IBinder>& display,
508 HdrCapabilities* outCapabilities) const {
509 Parcel data, reply;
510 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
511 status_t result = data.writeStrongBinder(display);
512 if (result != NO_ERROR) {
513 ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result);
514 return result;
515 }
516 result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES,
517 data, &reply);
518 if (result != NO_ERROR) {
519 ALOGE("getHdrCapabilities failed to transact: %d", result);
520 return result;
521 }
522 result = reply.readInt32();
523 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800524 result = reply.read(*outCapabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700525 }
526 return result;
527 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700528
529 virtual status_t enableVSyncInjections(bool enable) {
530 Parcel data, reply;
531 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
532 if (result != NO_ERROR) {
533 ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result);
534 return result;
535 }
536 result = data.writeBool(enable);
537 if (result != NO_ERROR) {
538 ALOGE("enableVSyncInjections failed to writeBool: %d", result);
539 return result;
540 }
541 result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS,
542 data, &reply, TF_ONE_WAY);
543 if (result != NO_ERROR) {
544 ALOGE("enableVSyncInjections failed to transact: %d", result);
545 return result;
546 }
547 return result;
548 }
549
550 virtual status_t injectVSync(nsecs_t when) {
551 Parcel data, reply;
552 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
553 if (result != NO_ERROR) {
554 ALOGE("injectVSync failed to writeInterfaceToken: %d", result);
555 return result;
556 }
557 result = data.writeInt64(when);
558 if (result != NO_ERROR) {
559 ALOGE("injectVSync failed to writeInt64: %d", result);
560 return result;
561 }
562 result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply, TF_ONE_WAY);
563 if (result != NO_ERROR) {
564 ALOGE("injectVSync failed to transact: %d", result);
565 return result;
566 }
567 return result;
568 }
569
Kalle Raitaa099a242017-01-11 11:17:29 -0800570 virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const
571 {
572 if (!outLayers) {
573 return UNEXPECTED_NULL;
574 }
575
576 Parcel data, reply;
577
578 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
579 if (err != NO_ERROR) {
580 return err;
581 }
582
583 err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply);
584 if (err != NO_ERROR) {
585 return err;
586 }
587
588 int32_t result = 0;
589 err = reply.readInt32(&result);
590 if (err != NO_ERROR) {
591 return err;
592 }
593 if (result != NO_ERROR) {
594 return result;
595 }
596
597 outLayers->clear();
598 return reply.readParcelableVector(outLayers);
599 }
Peiyong Lin0256f722018-08-31 15:45:10 -0700600
Peiyong Linc6780972018-10-28 15:24:08 -0700601 virtual status_t getCompositionPreference(ui::Dataspace* defaultDataspace,
602 ui::PixelFormat* defaultPixelFormat,
603 ui::Dataspace* wideColorGamutDataspace,
604 ui::PixelFormat* wideColorGamutPixelFormat) const {
Peiyong Lin0256f722018-08-31 15:45:10 -0700605 Parcel data, reply;
606 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
607 if (error != NO_ERROR) {
608 return error;
609 }
610 error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply);
611 if (error != NO_ERROR) {
612 return error;
613 }
614 error = static_cast<status_t>(reply.readInt32());
615 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -0700616 *defaultDataspace = static_cast<ui::Dataspace>(reply.readInt32());
617 *defaultPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
618 *wideColorGamutDataspace = static_cast<ui::Dataspace>(reply.readInt32());
619 *wideColorGamutPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
Peiyong Lin0256f722018-08-31 15:45:10 -0700620 }
621 return error;
622 }
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700623
Ady Abraham37965d42018-11-01 13:43:32 -0700624 virtual status_t getColorManagement(bool* outGetColorManagement) const {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700625 Parcel data, reply;
626 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Ady Abraham37965d42018-11-01 13:43:32 -0700627 remote()->transact(BnSurfaceComposer::GET_COLOR_MANAGEMENT, data, &reply);
628 bool result;
629 status_t err = reply.readBool(&result);
630 if (err == NO_ERROR) {
631 *outGetColorManagement = result;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700632 }
Ady Abraham37965d42018-11-01 13:43:32 -0700633 return err;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700634 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -0700635
636 virtual status_t getDisplayedContentSamplingAttributes(const sp<IBinder>& display,
637 ui::PixelFormat* outFormat,
638 ui::Dataspace* outDataspace,
639 uint8_t* outComponentMask) const {
640 if (!outFormat || !outDataspace || !outComponentMask) return BAD_VALUE;
641 Parcel data, reply;
642 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
643 data.writeStrongBinder(display);
644
645 status_t error =
646 remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES,
647 data, &reply);
648 if (error != NO_ERROR) {
649 return error;
650 }
651
652 uint32_t value = 0;
653 error = reply.readUint32(&value);
654 if (error != NO_ERROR) {
655 return error;
656 }
657 *outFormat = static_cast<ui::PixelFormat>(value);
658
659 error = reply.readUint32(&value);
660 if (error != NO_ERROR) {
661 return error;
662 }
663 *outDataspace = static_cast<ui::Dataspace>(value);
664
665 error = reply.readUint32(&value);
666 if (error != NO_ERROR) {
667 return error;
668 }
669 *outComponentMask = static_cast<uint8_t>(value);
670 return error;
671 }
Kevin DuBois74e53772018-11-19 10:52:38 -0800672
673 virtual status_t setDisplayContentSamplingEnabled(const sp<IBinder>& display, bool enable,
674 uint8_t componentMask,
675 uint64_t maxFrames) const {
676 Parcel data, reply;
677 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
678 data.writeStrongBinder(display);
679 data.writeBool(enable);
680 data.writeByte(static_cast<int8_t>(componentMask));
681 data.writeUint64(maxFrames);
682 status_t result =
683 remote()->transact(BnSurfaceComposer::SET_DISPLAY_CONTENT_SAMPLING_ENABLED, data,
684 &reply);
685 return result;
686 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700687
688 virtual status_t getDisplayedContentSample(const sp<IBinder>& display, uint64_t maxFrames,
689 uint64_t timestamp,
690 DisplayedFrameStats* outStats) const {
691 if (!outStats) return BAD_VALUE;
692
693 Parcel data, reply;
694 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
695 data.writeStrongBinder(display);
696 data.writeUint64(maxFrames);
697 data.writeUint64(timestamp);
698
699 status_t result =
700 remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLE, data, &reply);
701
702 if (result != NO_ERROR) {
703 return result;
704 }
705
706 result = reply.readUint64(&outStats->numFrames);
707 if (result != NO_ERROR) {
708 return result;
709 }
710
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800711 result = reply.readUint64Vector(&outStats->component_0_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700712 if (result != NO_ERROR) {
713 return result;
714 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800715 result = reply.readUint64Vector(&outStats->component_1_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700716 if (result != NO_ERROR) {
717 return result;
718 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800719 result = reply.readUint64Vector(&outStats->component_2_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700720 if (result != NO_ERROR) {
721 return result;
722 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800723 result = reply.readUint64Vector(&outStats->component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700724 return result;
725 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800726
727 virtual status_t getProtectedContentSupport(bool* outSupported) const {
728 Parcel data, reply;
729 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Peiyong Linb6888fa2019-01-28 13:20:58 -0800730 status_t error =
731 remote()->transact(BnSurfaceComposer::GET_PROTECTED_CONTENT_SUPPORT, data, &reply);
732 if (error != NO_ERROR) {
733 return error;
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800734 }
Peiyong Linb6888fa2019-01-28 13:20:58 -0800735 error = reply.readBool(outSupported);
736 return error;
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800737 }
Marissa Wallebc2c052019-01-16 19:16:55 -0800738
Peiyong Lin4f3fddf2019-01-24 17:21:24 -0800739 virtual status_t isWideColorDisplay(const sp<IBinder>& token,
740 bool* outIsWideColorDisplay) const {
741 Parcel data, reply;
742 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
743 if (error != NO_ERROR) {
744 return error;
745 }
746 error = data.writeStrongBinder(token);
747 if (error != NO_ERROR) {
748 return error;
749 }
750
751 error = remote()->transact(BnSurfaceComposer::IS_WIDE_COLOR_DISPLAY, data, &reply);
752 if (error != NO_ERROR) {
753 return error;
754 }
755 error = reply.readBool(outIsWideColorDisplay);
756 return error;
757 }
Dan Stoza84ab9372018-12-17 15:27:57 -0800758
759 virtual status_t addRegionSamplingListener(const Rect& samplingArea,
760 const sp<IBinder>& stopLayerHandle,
761 const sp<IRegionSamplingListener>& listener) {
762 Parcel data, reply;
763 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
764 if (error != NO_ERROR) {
765 ALOGE("addRegionSamplingListener: Failed to write interface token");
766 return error;
767 }
768 error = data.write(samplingArea);
769 if (error != NO_ERROR) {
770 ALOGE("addRegionSamplingListener: Failed to write sampling area");
771 return error;
772 }
773 error = data.writeStrongBinder(stopLayerHandle);
774 if (error != NO_ERROR) {
775 ALOGE("addRegionSamplingListener: Failed to write stop layer handle");
776 return error;
777 }
778 error = data.writeStrongBinder(IInterface::asBinder(listener));
779 if (error != NO_ERROR) {
780 ALOGE("addRegionSamplingListener: Failed to write listener");
781 return error;
782 }
783 error = remote()->transact(BnSurfaceComposer::ADD_REGION_SAMPLING_LISTENER, data, &reply);
784 if (error != NO_ERROR) {
785 ALOGE("addRegionSamplingListener: Failed to transact");
786 }
787 return error;
788 }
789
790 virtual status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) {
791 Parcel data, reply;
792 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
793 if (error != NO_ERROR) {
794 ALOGE("addRegionSamplingListener: Failed to write interface token");
795 return error;
796 }
797 error = data.writeStrongBinder(IInterface::asBinder(listener));
798 if (error != NO_ERROR) {
799 ALOGE("addRegionSamplingListener: Failed to write listener");
800 return error;
801 }
802 error = remote()->transact(BnSurfaceComposer::REMOVE_REGION_SAMPLING_LISTENER, data,
803 &reply);
804 if (error != NO_ERROR) {
805 ALOGE("addRegionSamplingListener: Failed to transact");
806 }
807 return error;
808 }
Ady Abraham838de062019-02-04 10:24:03 -0800809
810 virtual status_t setAllowedDisplayConfigs(const sp<IBinder>& displayToken,
811 const std::vector<int32_t>& allowedConfigs) {
812 Parcel data, reply;
813 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
814 if (result != NO_ERROR) {
815 ALOGE("setAllowedDisplayConfigs failed to writeInterfaceToken: %d", result);
816 return result;
817 }
818 result = data.writeStrongBinder(displayToken);
819 if (result != NO_ERROR) {
820 ALOGE("setAllowedDisplayConfigs failed to writeStrongBinder: %d", result);
821 return result;
822 }
823 result = data.writeInt32Vector(allowedConfigs);
824 if (result != NO_ERROR) {
825 ALOGE("setAllowedDisplayConfigs failed to writeInt32Vector: %d", result);
826 return result;
827 }
828 result = remote()->transact(BnSurfaceComposer::SET_ALLOWED_DISPLAY_CONFIGS, data, &reply);
829 if (result != NO_ERROR) {
830 ALOGE("setAllowedDisplayConfigs failed to transact: %d", result);
831 return result;
832 }
833 return reply.readInt32();
834 }
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800835
836 virtual status_t getAllowedDisplayConfigs(const sp<IBinder>& displayToken,
837 std::vector<int32_t>* outAllowedConfigs) {
838 if (!outAllowedConfigs) return BAD_VALUE;
839 Parcel data, reply;
840 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
841 if (result != NO_ERROR) {
842 ALOGE("getAllowedDisplayConfigs failed to writeInterfaceToken: %d", result);
843 return result;
844 }
845 result = data.writeStrongBinder(displayToken);
846 if (result != NO_ERROR) {
847 ALOGE("getAllowedDisplayConfigs failed to writeStrongBinder: %d", result);
848 return result;
849 }
850 result = remote()->transact(BnSurfaceComposer::GET_ALLOWED_DISPLAY_CONFIGS, data, &reply);
851 if (result != NO_ERROR) {
852 ALOGE("getAllowedDisplayConfigs failed to transact: %d", result);
853 return result;
854 }
855 result = reply.readInt32Vector(outAllowedConfigs);
856 if (result != NO_ERROR) {
857 ALOGE("getAllowedDisplayConfigs failed to readInt32Vector: %d", result);
858 return result;
859 }
860 return reply.readInt32();
861 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800862};
863
Dan Stozad723bd72014-11-18 10:24:03 -0800864// Out-of-line virtual method definition to trigger vtable emission in this
865// translation unit (see clang warning -Wweak-vtables)
866BpSurfaceComposer::~BpSurfaceComposer() {}
867
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800868IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
869
870// ----------------------------------------------------------------------
871
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800872status_t BnSurfaceComposer::onTransact(
873 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
874{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800875 switch(code) {
876 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700877 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800878 sp<IBinder> b = IInterface::asBinder(createConnection());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800879 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -0700880 return NO_ERROR;
881 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700882 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700883 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -0800884
885 size_t count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700886 if (count > data.dataSize()) {
887 return BAD_VALUE;
888 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700889 Vector<ComposerState> state;
890 state.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800891 for (size_t i = 0; i < count; i++) {
Marissa Wallc837b5e2018-10-12 10:04:44 -0700892 ComposerState s;
Michael Lentine8afa1c42014-10-31 11:10:13 -0700893 if (s.read(data) == BAD_VALUE) {
894 return BAD_VALUE;
895 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700896 state.add(s);
897 }
Dan Stozad723bd72014-11-18 10:24:03 -0800898
899 count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700900 if (count > data.dataSize()) {
901 return BAD_VALUE;
902 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700903 DisplayState d;
904 Vector<DisplayState> displays;
905 displays.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800906 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700907 if (d.read(data) == BAD_VALUE) {
908 return BAD_VALUE;
909 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700910 displays.add(d);
911 }
Dan Stozad723bd72014-11-18 10:24:03 -0800912
913 uint32_t stateFlags = data.readUint32();
Marissa Wall713b63f2018-10-17 15:42:43 -0700914 sp<IBinder> applyToken = data.readStrongBinder();
chaviw273171b2018-12-26 11:46:30 -0800915 InputWindowCommands inputWindowCommands;
916 inputWindowCommands.read(data);
Marissa Wall17b4e452018-12-26 16:32:34 -0800917
918 int64_t desiredPresentTime = data.readInt64();
919 setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands,
920 desiredPresentTime);
Jesse Hall6c913be2013-08-08 12:15:49 -0700921 return NO_ERROR;
922 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800923 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700924 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800925 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -0700926 return NO_ERROR;
927 }
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800928 case CAPTURE_SCREEN: {
929 CHECK_INTERFACE(ISurfaceComposer, data, reply);
930 sp<IBinder> display = data.readStrongBinder();
Peiyong Lin0e003c92018-09-17 11:09:51 -0700931 ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32());
932 ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32());
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000933 sp<GraphicBuffer> outBuffer;
Pablo Ceballos60d69222015-08-07 14:47:20 -0700934 Rect sourceCrop(Rect::EMPTY_RECT);
Dan Stozac1879002014-05-22 15:59:05 -0700935 data.read(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800936 uint32_t reqWidth = data.readUint32();
937 uint32_t reqHeight = data.readUint32();
Dan Stozac7014012014-02-14 15:03:43 -0800938 bool useIdentityTransform = static_cast<bool>(data.readInt32());
Dan Stozad723bd72014-11-18 10:24:03 -0800939 int32_t rotation = data.readInt32();
Dan Stozac7014012014-02-14 15:03:43 -0800940
Peiyong Lin0e003c92018-09-17 11:09:51 -0700941 status_t res = captureScreen(display, &outBuffer, reqDataspace, reqPixelFormat,
942 sourceCrop, reqWidth, reqHeight, useIdentityTransform,
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000943 static_cast<ISurfaceComposer::Rotation>(rotation));
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800944 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000945 if (res == NO_ERROR) {
946 reply->write(*outBuffer);
947 }
Jesse Hall6c913be2013-08-08 12:15:49 -0700948 return NO_ERROR;
949 }
chaviwa76b2712017-09-20 12:02:26 -0700950 case CAPTURE_LAYERS: {
951 CHECK_INTERFACE(ISurfaceComposer, data, reply);
952 sp<IBinder> layerHandleBinder = data.readStrongBinder();
Peiyong Lin0e003c92018-09-17 11:09:51 -0700953 ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32());
954 ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32());
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000955 sp<GraphicBuffer> outBuffer;
chaviw7206d492017-11-10 16:16:12 -0800956 Rect sourceCrop(Rect::EMPTY_RECT);
957 data.read(sourceCrop);
958 float frameScale = data.readFloat();
Robert Carr578038f2018-03-09 12:25:24 -0800959 bool childrenOnly = data.readBool();
chaviwa76b2712017-09-20 12:02:26 -0700960
Peiyong Lin0e003c92018-09-17 11:09:51 -0700961 status_t res = captureLayers(layerHandleBinder, &outBuffer, reqDataspace,
962 reqPixelFormat, sourceCrop, frameScale, childrenOnly);
chaviwa76b2712017-09-20 12:02:26 -0700963 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000964 if (res == NO_ERROR) {
965 reply->write(*outBuffer);
966 }
chaviwa76b2712017-09-20 12:02:26 -0700967 return NO_ERROR;
968 }
Jamie Gennis134f0422011-03-08 12:18:54 -0800969 case AUTHENTICATE_SURFACE: {
970 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -0800971 sp<IGraphicBufferProducer> bufferProducer =
972 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
973 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -0800974 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700975 return NO_ERROR;
976 }
Brian Anderson6b376712017-04-04 10:51:39 -0700977 case GET_SUPPORTED_FRAME_TIMESTAMPS: {
978 CHECK_INTERFACE(ISurfaceComposer, data, reply);
979 std::vector<FrameEvent> supportedTimestamps;
980 status_t result = getSupportedFrameTimestamps(&supportedTimestamps);
981 status_t err = reply->writeInt32(result);
982 if (err != NO_ERROR) {
983 return err;
984 }
985 if (result != NO_ERROR) {
986 return result;
987 }
988
989 std::vector<int32_t> supported;
990 supported.reserve(supportedTimestamps.size());
991 for (FrameEvent s : supportedTimestamps) {
992 supported.push_back(static_cast<int32_t>(s));
993 }
994 return reply->writeInt32Vector(supported);
995 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800996 case CREATE_DISPLAY_EVENT_CONNECTION: {
997 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700998 sp<IDisplayEventConnection> connection(createDisplayEventConnection(
999 static_cast<ISurfaceComposer::VsyncSource>(data.readInt32())));
Marco Nelissen2ea926b2014-11-14 08:01:01 -08001000 reply->writeStrongBinder(IInterface::asBinder(connection));
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001001 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001002 }
Mathias Agopiane57f2922012-08-09 16:29:12 -07001003 case CREATE_DISPLAY: {
1004 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden8dfa92f2012-09-17 18:27:17 -07001005 String8 displayName = data.readString8();
Jamie Gennisdd3cb842012-10-19 18:19:11 -07001006 bool secure = bool(data.readInt32());
1007 sp<IBinder> display(createDisplay(displayName, secure));
Mathias Agopiane57f2922012-08-09 16:29:12 -07001008 reply->writeStrongBinder(display);
1009 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001010 }
1011 case DESTROY_DISPLAY: {
1012 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1013 sp<IBinder> display = data.readStrongBinder();
1014 destroyDisplay(display);
1015 return NO_ERROR;
1016 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001017 case GET_PHYSICAL_DISPLAY_TOKEN: {
Mathias Agopiane57f2922012-08-09 16:29:12 -07001018 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001019 PhysicalDisplayId displayId = data.readUint64();
1020 sp<IBinder> display = getPhysicalDisplayToken(displayId);
Mathias Agopiane57f2922012-08-09 16:29:12 -07001021 reply->writeStrongBinder(display);
1022 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001023 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001024 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -07001025 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stoza7f7da322014-05-02 15:26:25 -07001026 Vector<DisplayInfo> configs;
Jeff Brown9d4e3d22012-08-24 20:00:51 -07001027 sp<IBinder> display = data.readStrongBinder();
Dan Stoza7f7da322014-05-02 15:26:25 -07001028 status_t result = getDisplayConfigs(display, &configs);
1029 reply->writeInt32(result);
1030 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -08001031 reply->writeUint32(static_cast<uint32_t>(configs.size()));
Dan Stoza7f7da322014-05-02 15:26:25 -07001032 for (size_t c = 0; c < configs.size(); ++c) {
1033 memcpy(reply->writeInplace(sizeof(DisplayInfo)),
1034 &configs[c], sizeof(DisplayInfo));
1035 }
1036 }
1037 return NO_ERROR;
1038 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -07001039 case GET_DISPLAY_STATS: {
1040 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1041 DisplayStatInfo stats;
1042 sp<IBinder> display = data.readStrongBinder();
1043 status_t result = getDisplayStats(display, &stats);
1044 reply->writeInt32(result);
1045 if (result == NO_ERROR) {
1046 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
1047 &stats, sizeof(DisplayStatInfo));
1048 }
1049 return NO_ERROR;
1050 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001051 case GET_ACTIVE_CONFIG: {
1052 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1053 sp<IBinder> display = data.readStrongBinder();
1054 int id = getActiveConfig(display);
1055 reply->writeInt32(id);
1056 return NO_ERROR;
1057 }
1058 case SET_ACTIVE_CONFIG: {
1059 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1060 sp<IBinder> display = data.readStrongBinder();
1061 int id = data.readInt32();
1062 status_t result = setActiveConfig(display, id);
Mathias Agopianc666cae2012-07-25 18:56:13 -07001063 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -07001064 return NO_ERROR;
1065 }
Michael Wright28f24d02016-07-12 13:30:53 -07001066 case GET_DISPLAY_COLOR_MODES: {
1067 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Lina52f0292018-03-14 17:26:31 -07001068 Vector<ColorMode> colorModes;
Michael Wright28f24d02016-07-12 13:30:53 -07001069 sp<IBinder> display = nullptr;
1070 status_t result = data.readStrongBinder(&display);
1071 if (result != NO_ERROR) {
1072 ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result);
1073 return result;
1074 }
1075 result = getDisplayColorModes(display, &colorModes);
1076 reply->writeInt32(result);
1077 if (result == NO_ERROR) {
1078 reply->writeUint32(static_cast<uint32_t>(colorModes.size()));
1079 for (size_t i = 0; i < colorModes.size(); ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -07001080 reply->writeInt32(static_cast<int32_t>(colorModes[i]));
Michael Wright28f24d02016-07-12 13:30:53 -07001081 }
1082 }
1083 return NO_ERROR;
1084 }
Daniel Solomon42d04562019-01-20 21:03:19 -08001085 case GET_DISPLAY_NATIVE_PRIMARIES: {
1086 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1087 ui::DisplayPrimaries primaries;
1088 sp<IBinder> display = nullptr;
1089
1090 status_t result = data.readStrongBinder(&display);
1091 if (result != NO_ERROR) {
1092 ALOGE("getDisplayNativePrimaries failed to readStrongBinder: %d", result);
1093 return result;
1094 }
1095
1096 result = getDisplayNativePrimaries(display, primaries);
1097 reply->writeInt32(result);
1098 if (result == NO_ERROR) {
1099 memcpy(reply->writeInplace(sizeof(ui::DisplayPrimaries)), &primaries,
1100 sizeof(ui::DisplayPrimaries));
1101 }
1102
1103 return NO_ERROR;
1104 }
Michael Wright28f24d02016-07-12 13:30:53 -07001105 case GET_ACTIVE_COLOR_MODE: {
1106 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1107 sp<IBinder> display = nullptr;
1108 status_t result = data.readStrongBinder(&display);
1109 if (result != NO_ERROR) {
1110 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1111 return result;
1112 }
Peiyong Lina52f0292018-03-14 17:26:31 -07001113 ColorMode colorMode = getActiveColorMode(display);
Michael Wright28f24d02016-07-12 13:30:53 -07001114 result = reply->writeInt32(static_cast<int32_t>(colorMode));
1115 return result;
1116 }
1117 case SET_ACTIVE_COLOR_MODE: {
1118 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1119 sp<IBinder> display = nullptr;
1120 status_t result = data.readStrongBinder(&display);
1121 if (result != NO_ERROR) {
1122 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1123 return result;
1124 }
1125 int32_t colorModeInt = 0;
1126 result = data.readInt32(&colorModeInt);
1127 if (result != NO_ERROR) {
1128 ALOGE("setActiveColorMode failed to readInt32: %d", result);
1129 return result;
1130 }
1131 result = setActiveColorMode(display,
Peiyong Lina52f0292018-03-14 17:26:31 -07001132 static_cast<ColorMode>(colorModeInt));
Michael Wright28f24d02016-07-12 13:30:53 -07001133 result = reply->writeInt32(result);
1134 return result;
1135 }
Svetoslavd85084b2014-03-20 10:28:31 -07001136 case CLEAR_ANIMATION_FRAME_STATS: {
1137 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1138 status_t result = clearAnimationFrameStats();
1139 reply->writeInt32(result);
1140 return NO_ERROR;
1141 }
1142 case GET_ANIMATION_FRAME_STATS: {
1143 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1144 FrameStats stats;
1145 status_t result = getAnimationFrameStats(&stats);
1146 reply->write(stats);
1147 reply->writeInt32(result);
1148 return NO_ERROR;
1149 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -07001150 case SET_POWER_MODE: {
1151 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1152 sp<IBinder> display = data.readStrongBinder();
1153 int32_t mode = data.readInt32();
1154 setPowerMode(display, mode);
1155 return NO_ERROR;
1156 }
Dan Stozac4f471e2016-03-24 09:31:08 -07001157 case GET_HDR_CAPABILITIES: {
1158 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1159 sp<IBinder> display = nullptr;
1160 status_t result = data.readStrongBinder(&display);
1161 if (result != NO_ERROR) {
1162 ALOGE("getHdrCapabilities failed to readStrongBinder: %d",
1163 result);
1164 return result;
1165 }
1166 HdrCapabilities capabilities;
1167 result = getHdrCapabilities(display, &capabilities);
1168 reply->writeInt32(result);
1169 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -08001170 reply->write(capabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -07001171 }
1172 return NO_ERROR;
1173 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -07001174 case ENABLE_VSYNC_INJECTIONS: {
1175 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1176 bool enable = false;
1177 status_t result = data.readBool(&enable);
1178 if (result != NO_ERROR) {
1179 ALOGE("enableVSyncInjections failed to readBool: %d", result);
1180 return result;
1181 }
1182 return enableVSyncInjections(enable);
1183 }
1184 case INJECT_VSYNC: {
1185 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1186 int64_t when = 0;
1187 status_t result = data.readInt64(&when);
1188 if (result != NO_ERROR) {
1189 ALOGE("enableVSyncInjections failed to readInt64: %d", result);
1190 return result;
1191 }
1192 return injectVSync(when);
1193 }
Kalle Raitaa099a242017-01-11 11:17:29 -08001194 case GET_LAYER_DEBUG_INFO: {
1195 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1196 std::vector<LayerDebugInfo> outLayers;
1197 status_t result = getLayerDebugInfo(&outLayers);
1198 reply->writeInt32(result);
1199 if (result == NO_ERROR)
1200 {
1201 result = reply->writeParcelableVector(outLayers);
1202 }
1203 return result;
1204 }
Peiyong Lin0256f722018-08-31 15:45:10 -07001205 case GET_COMPOSITION_PREFERENCE: {
1206 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Linc6780972018-10-28 15:24:08 -07001207 ui::Dataspace defaultDataspace;
1208 ui::PixelFormat defaultPixelFormat;
1209 ui::Dataspace wideColorGamutDataspace;
1210 ui::PixelFormat wideColorGamutPixelFormat;
1211 status_t error =
1212 getCompositionPreference(&defaultDataspace, &defaultPixelFormat,
1213 &wideColorGamutDataspace, &wideColorGamutPixelFormat);
Peiyong Lin0256f722018-08-31 15:45:10 -07001214 reply->writeInt32(error);
1215 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -07001216 reply->writeInt32(static_cast<int32_t>(defaultDataspace));
1217 reply->writeInt32(static_cast<int32_t>(defaultPixelFormat));
1218 reply->writeInt32(static_cast<int32_t>(wideColorGamutDataspace));
Peiyong Linaa3da6a2018-12-12 02:48:43 -08001219 reply->writeInt32(static_cast<int32_t>(wideColorGamutPixelFormat));
Peiyong Lin0256f722018-08-31 15:45:10 -07001220 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001221 return error;
Peiyong Lin0256f722018-08-31 15:45:10 -07001222 }
Ady Abraham37965d42018-11-01 13:43:32 -07001223 case GET_COLOR_MANAGEMENT: {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001224 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Ady Abraham37965d42018-11-01 13:43:32 -07001225 bool result;
1226 status_t error = getColorManagement(&result);
1227 if (error == NO_ERROR) {
1228 reply->writeBool(result);
1229 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001230 return error;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001231 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -07001232 case GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: {
1233 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1234
1235 sp<IBinder> display = data.readStrongBinder();
1236 ui::PixelFormat format;
1237 ui::Dataspace dataspace;
1238 uint8_t component = 0;
1239 auto result =
1240 getDisplayedContentSamplingAttributes(display, &format, &dataspace, &component);
1241 if (result == NO_ERROR) {
1242 reply->writeUint32(static_cast<uint32_t>(format));
1243 reply->writeUint32(static_cast<uint32_t>(dataspace));
1244 reply->writeUint32(static_cast<uint32_t>(component));
1245 }
1246 return result;
1247 }
Kevin DuBois74e53772018-11-19 10:52:38 -08001248 case SET_DISPLAY_CONTENT_SAMPLING_ENABLED: {
1249 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1250
1251 sp<IBinder> display = nullptr;
1252 bool enable = false;
1253 int8_t componentMask = 0;
1254 uint64_t maxFrames = 0;
1255 status_t result = data.readStrongBinder(&display);
1256 if (result != NO_ERROR) {
1257 ALOGE("setDisplayContentSamplingEnabled failure in reading Display token: %d",
1258 result);
1259 return result;
1260 }
1261
1262 result = data.readBool(&enable);
1263 if (result != NO_ERROR) {
1264 ALOGE("setDisplayContentSamplingEnabled failure in reading enable: %d", result);
1265 return result;
1266 }
1267
1268 result = data.readByte(static_cast<int8_t*>(&componentMask));
1269 if (result != NO_ERROR) {
1270 ALOGE("setDisplayContentSamplingEnabled failure in reading component mask: %d",
1271 result);
1272 return result;
1273 }
1274
1275 result = data.readUint64(&maxFrames);
1276 if (result != NO_ERROR) {
1277 ALOGE("setDisplayContentSamplingEnabled failure in reading max frames: %d", result);
1278 return result;
1279 }
1280
1281 return setDisplayContentSamplingEnabled(display, enable,
1282 static_cast<uint8_t>(componentMask), maxFrames);
1283 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001284 case GET_DISPLAYED_CONTENT_SAMPLE: {
1285 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1286
1287 sp<IBinder> display = data.readStrongBinder();
1288 uint64_t maxFrames = 0;
1289 uint64_t timestamp = 0;
1290
1291 status_t result = data.readUint64(&maxFrames);
1292 if (result != NO_ERROR) {
1293 ALOGE("getDisplayedContentSample failure in reading max frames: %d", result);
1294 return result;
1295 }
1296
1297 result = data.readUint64(&timestamp);
1298 if (result != NO_ERROR) {
1299 ALOGE("getDisplayedContentSample failure in reading timestamp: %d", result);
1300 return result;
1301 }
1302
1303 DisplayedFrameStats stats;
1304 result = getDisplayedContentSample(display, maxFrames, timestamp, &stats);
1305 if (result == NO_ERROR) {
1306 reply->writeUint64(stats.numFrames);
Kevin DuBois1d4c6a62018-12-12 13:59:46 -08001307 reply->writeUint64Vector(stats.component_0_sample);
1308 reply->writeUint64Vector(stats.component_1_sample);
1309 reply->writeUint64Vector(stats.component_2_sample);
1310 reply->writeUint64Vector(stats.component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001311 }
1312 return result;
1313 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001314 case GET_PROTECTED_CONTENT_SUPPORT: {
1315 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1316 bool result;
1317 status_t error = getProtectedContentSupport(&result);
1318 if (error == NO_ERROR) {
1319 reply->writeBool(result);
1320 }
1321 return error;
1322 }
Peiyong Lin4f3fddf2019-01-24 17:21:24 -08001323 case IS_WIDE_COLOR_DISPLAY: {
1324 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1325 sp<IBinder> display = nullptr;
1326 status_t error = data.readStrongBinder(&display);
1327 if (error != NO_ERROR) {
1328 return error;
1329 }
1330 bool result;
1331 error = isWideColorDisplay(display, &result);
1332 if (error == NO_ERROR) {
1333 reply->writeBool(result);
1334 }
1335 return error;
1336 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001337 case GET_PHYSICAL_DISPLAY_IDS: {
1338 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1339 return reply->writeUint64Vector(getPhysicalDisplayIds());
1340 }
Dan Stoza84ab9372018-12-17 15:27:57 -08001341 case ADD_REGION_SAMPLING_LISTENER: {
1342 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1343 Rect samplingArea;
1344 status_t result = data.read(samplingArea);
1345 if (result != NO_ERROR) {
1346 ALOGE("addRegionSamplingListener: Failed to read sampling area");
1347 return result;
1348 }
1349 sp<IBinder> stopLayerHandle;
1350 result = data.readNullableStrongBinder(&stopLayerHandle);
1351 if (result != NO_ERROR) {
1352 ALOGE("addRegionSamplingListener: Failed to read stop layer handle");
1353 return result;
1354 }
1355 sp<IRegionSamplingListener> listener;
1356 result = data.readNullableStrongBinder(&listener);
1357 if (result != NO_ERROR) {
1358 ALOGE("addRegionSamplingListener: Failed to read listener");
1359 return result;
1360 }
1361 return addRegionSamplingListener(samplingArea, stopLayerHandle, listener);
1362 }
1363 case REMOVE_REGION_SAMPLING_LISTENER: {
1364 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1365 sp<IRegionSamplingListener> listener;
1366 status_t result = data.readNullableStrongBinder(&listener);
1367 if (result != NO_ERROR) {
1368 ALOGE("removeRegionSamplingListener: Failed to read listener");
1369 return result;
1370 }
1371 return removeRegionSamplingListener(listener);
1372 }
Ady Abraham838de062019-02-04 10:24:03 -08001373 case SET_ALLOWED_DISPLAY_CONFIGS: {
1374 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1375 sp<IBinder> displayToken = data.readStrongBinder();
1376 std::vector<int32_t> allowedConfigs;
1377 data.readInt32Vector(&allowedConfigs);
1378 status_t result = setAllowedDisplayConfigs(displayToken, allowedConfigs);
1379 reply->writeInt32(result);
1380 return result;
1381 }
Ady Abrahamd9b3ea62019-02-26 14:08:03 -08001382 case GET_ALLOWED_DISPLAY_CONFIGS: {
1383 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1384 sp<IBinder> displayToken = data.readStrongBinder();
1385 std::vector<int32_t> allowedConfigs;
1386 status_t result = getAllowedDisplayConfigs(displayToken, &allowedConfigs);
1387 reply->writeInt32Vector(allowedConfigs);
1388 reply->writeInt32(result);
1389 return result;
1390 }
Jesse Hall6c913be2013-08-08 12:15:49 -07001391 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001392 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -07001393 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001394 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001395}
1396
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001397} // namespace android