blob: d2f2539e8ee2f5e217c20041772aaa190d6086c0 [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) {
795 ALOGE("addRegionSamplingListener: Failed to write interface token");
796 return error;
797 }
798 error = data.writeStrongBinder(IInterface::asBinder(listener));
799 if (error != NO_ERROR) {
800 ALOGE("addRegionSamplingListener: Failed to write listener");
801 return error;
802 }
803 error = remote()->transact(BnSurfaceComposer::REMOVE_REGION_SAMPLING_LISTENER, data,
804 &reply);
805 if (error != NO_ERROR) {
806 ALOGE("addRegionSamplingListener: Failed to transact");
807 }
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 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800836};
837
Dan Stozad723bd72014-11-18 10:24:03 -0800838// Out-of-line virtual method definition to trigger vtable emission in this
839// translation unit (see clang warning -Wweak-vtables)
840BpSurfaceComposer::~BpSurfaceComposer() {}
841
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800842IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
843
844// ----------------------------------------------------------------------
845
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800846status_t BnSurfaceComposer::onTransact(
847 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
848{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800849 switch(code) {
850 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700851 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800852 sp<IBinder> b = IInterface::asBinder(createConnection());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800853 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -0700854 return NO_ERROR;
855 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700856 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700857 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -0800858
859 size_t count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700860 if (count > data.dataSize()) {
861 return BAD_VALUE;
862 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700863 Vector<ComposerState> state;
864 state.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800865 for (size_t i = 0; i < count; i++) {
Marissa Wallc837b5e2018-10-12 10:04:44 -0700866 ComposerState s;
Michael Lentine8afa1c42014-10-31 11:10:13 -0700867 if (s.read(data) == BAD_VALUE) {
868 return BAD_VALUE;
869 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700870 state.add(s);
871 }
Dan Stozad723bd72014-11-18 10:24:03 -0800872
873 count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700874 if (count > data.dataSize()) {
875 return BAD_VALUE;
876 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700877 DisplayState d;
878 Vector<DisplayState> displays;
879 displays.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800880 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700881 if (d.read(data) == BAD_VALUE) {
882 return BAD_VALUE;
883 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700884 displays.add(d);
885 }
Dan Stozad723bd72014-11-18 10:24:03 -0800886
887 uint32_t stateFlags = data.readUint32();
Marissa Wall713b63f2018-10-17 15:42:43 -0700888 sp<IBinder> applyToken = data.readStrongBinder();
chaviw273171b2018-12-26 11:46:30 -0800889 InputWindowCommands inputWindowCommands;
890 inputWindowCommands.read(data);
Marissa Wall17b4e452018-12-26 16:32:34 -0800891
892 int64_t desiredPresentTime = data.readInt64();
893 setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands,
894 desiredPresentTime);
Jesse Hall6c913be2013-08-08 12:15:49 -0700895 return NO_ERROR;
896 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800897 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700898 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800899 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -0700900 return NO_ERROR;
901 }
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800902 case CAPTURE_SCREEN: {
903 CHECK_INTERFACE(ISurfaceComposer, data, reply);
904 sp<IBinder> display = data.readStrongBinder();
Peiyong Lin0e003c92018-09-17 11:09:51 -0700905 ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32());
906 ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32());
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000907 sp<GraphicBuffer> outBuffer;
Pablo Ceballos60d69222015-08-07 14:47:20 -0700908 Rect sourceCrop(Rect::EMPTY_RECT);
Dan Stozac1879002014-05-22 15:59:05 -0700909 data.read(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800910 uint32_t reqWidth = data.readUint32();
911 uint32_t reqHeight = data.readUint32();
Dan Stozac7014012014-02-14 15:03:43 -0800912 bool useIdentityTransform = static_cast<bool>(data.readInt32());
Dan Stozad723bd72014-11-18 10:24:03 -0800913 int32_t rotation = data.readInt32();
Robert Carrfa8855f2019-02-19 10:05:00 -0800914 bool captureSecureLayers = static_cast<bool>(data.readInt32());
Dan Stozac7014012014-02-14 15:03:43 -0800915
Peiyong Lin0e003c92018-09-17 11:09:51 -0700916 status_t res = captureScreen(display, &outBuffer, reqDataspace, reqPixelFormat,
917 sourceCrop, reqWidth, reqHeight, useIdentityTransform,
Robert Carrfa8855f2019-02-19 10:05:00 -0800918 static_cast<ISurfaceComposer::Rotation>(rotation), captureSecureLayers);
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800919 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000920 if (res == NO_ERROR) {
921 reply->write(*outBuffer);
922 }
Jesse Hall6c913be2013-08-08 12:15:49 -0700923 return NO_ERROR;
924 }
chaviwa76b2712017-09-20 12:02:26 -0700925 case CAPTURE_LAYERS: {
926 CHECK_INTERFACE(ISurfaceComposer, data, reply);
927 sp<IBinder> layerHandleBinder = data.readStrongBinder();
Peiyong Lin0e003c92018-09-17 11:09:51 -0700928 ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32());
929 ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32());
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000930 sp<GraphicBuffer> outBuffer;
chaviw7206d492017-11-10 16:16:12 -0800931 Rect sourceCrop(Rect::EMPTY_RECT);
932 data.read(sourceCrop);
933 float frameScale = data.readFloat();
Robert Carr578038f2018-03-09 12:25:24 -0800934 bool childrenOnly = data.readBool();
chaviwa76b2712017-09-20 12:02:26 -0700935
Peiyong Lin0e003c92018-09-17 11:09:51 -0700936 status_t res = captureLayers(layerHandleBinder, &outBuffer, reqDataspace,
937 reqPixelFormat, sourceCrop, frameScale, childrenOnly);
chaviwa76b2712017-09-20 12:02:26 -0700938 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000939 if (res == NO_ERROR) {
940 reply->write(*outBuffer);
941 }
chaviwa76b2712017-09-20 12:02:26 -0700942 return NO_ERROR;
943 }
Jamie Gennis134f0422011-03-08 12:18:54 -0800944 case AUTHENTICATE_SURFACE: {
945 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -0800946 sp<IGraphicBufferProducer> bufferProducer =
947 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
948 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -0800949 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700950 return NO_ERROR;
951 }
Brian Anderson6b376712017-04-04 10:51:39 -0700952 case GET_SUPPORTED_FRAME_TIMESTAMPS: {
953 CHECK_INTERFACE(ISurfaceComposer, data, reply);
954 std::vector<FrameEvent> supportedTimestamps;
955 status_t result = getSupportedFrameTimestamps(&supportedTimestamps);
956 status_t err = reply->writeInt32(result);
957 if (err != NO_ERROR) {
958 return err;
959 }
960 if (result != NO_ERROR) {
961 return result;
962 }
963
964 std::vector<int32_t> supported;
965 supported.reserve(supportedTimestamps.size());
966 for (FrameEvent s : supportedTimestamps) {
967 supported.push_back(static_cast<int32_t>(s));
968 }
969 return reply->writeInt32Vector(supported);
970 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800971 case CREATE_DISPLAY_EVENT_CONNECTION: {
972 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700973 sp<IDisplayEventConnection> connection(createDisplayEventConnection(
974 static_cast<ISurfaceComposer::VsyncSource>(data.readInt32())));
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800975 reply->writeStrongBinder(IInterface::asBinder(connection));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800976 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700977 }
Mathias Agopiane57f2922012-08-09 16:29:12 -0700978 case CREATE_DISPLAY: {
979 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700980 String8 displayName = data.readString8();
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700981 bool secure = bool(data.readInt32());
982 sp<IBinder> display(createDisplay(displayName, secure));
Mathias Agopiane57f2922012-08-09 16:29:12 -0700983 reply->writeStrongBinder(display);
984 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700985 }
986 case DESTROY_DISPLAY: {
987 CHECK_INTERFACE(ISurfaceComposer, data, reply);
988 sp<IBinder> display = data.readStrongBinder();
989 destroyDisplay(display);
990 return NO_ERROR;
991 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800992 case GET_PHYSICAL_DISPLAY_TOKEN: {
Mathias Agopiane57f2922012-08-09 16:29:12 -0700993 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800994 PhysicalDisplayId displayId = data.readUint64();
995 sp<IBinder> display = getPhysicalDisplayToken(displayId);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700996 reply->writeStrongBinder(display);
997 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700998 }
Dan Stoza7f7da322014-05-02 15:26:25 -0700999 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -07001000 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stoza7f7da322014-05-02 15:26:25 -07001001 Vector<DisplayInfo> configs;
Jeff Brown9d4e3d22012-08-24 20:00:51 -07001002 sp<IBinder> display = data.readStrongBinder();
Dan Stoza7f7da322014-05-02 15:26:25 -07001003 status_t result = getDisplayConfigs(display, &configs);
1004 reply->writeInt32(result);
1005 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -08001006 reply->writeUint32(static_cast<uint32_t>(configs.size()));
Dan Stoza7f7da322014-05-02 15:26:25 -07001007 for (size_t c = 0; c < configs.size(); ++c) {
1008 memcpy(reply->writeInplace(sizeof(DisplayInfo)),
1009 &configs[c], sizeof(DisplayInfo));
1010 }
1011 }
1012 return NO_ERROR;
1013 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -07001014 case GET_DISPLAY_STATS: {
1015 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1016 DisplayStatInfo stats;
1017 sp<IBinder> display = data.readStrongBinder();
1018 status_t result = getDisplayStats(display, &stats);
1019 reply->writeInt32(result);
1020 if (result == NO_ERROR) {
1021 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
1022 &stats, sizeof(DisplayStatInfo));
1023 }
1024 return NO_ERROR;
1025 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001026 case GET_ACTIVE_CONFIG: {
1027 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1028 sp<IBinder> display = data.readStrongBinder();
1029 int id = getActiveConfig(display);
1030 reply->writeInt32(id);
1031 return NO_ERROR;
1032 }
1033 case SET_ACTIVE_CONFIG: {
1034 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1035 sp<IBinder> display = data.readStrongBinder();
1036 int id = data.readInt32();
1037 status_t result = setActiveConfig(display, id);
Mathias Agopianc666cae2012-07-25 18:56:13 -07001038 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -07001039 return NO_ERROR;
1040 }
Michael Wright28f24d02016-07-12 13:30:53 -07001041 case GET_DISPLAY_COLOR_MODES: {
1042 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Lina52f0292018-03-14 17:26:31 -07001043 Vector<ColorMode> colorModes;
Michael Wright28f24d02016-07-12 13:30:53 -07001044 sp<IBinder> display = nullptr;
1045 status_t result = data.readStrongBinder(&display);
1046 if (result != NO_ERROR) {
1047 ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result);
1048 return result;
1049 }
1050 result = getDisplayColorModes(display, &colorModes);
1051 reply->writeInt32(result);
1052 if (result == NO_ERROR) {
1053 reply->writeUint32(static_cast<uint32_t>(colorModes.size()));
1054 for (size_t i = 0; i < colorModes.size(); ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -07001055 reply->writeInt32(static_cast<int32_t>(colorModes[i]));
Michael Wright28f24d02016-07-12 13:30:53 -07001056 }
1057 }
1058 return NO_ERROR;
1059 }
Daniel Solomon42d04562019-01-20 21:03:19 -08001060 case GET_DISPLAY_NATIVE_PRIMARIES: {
1061 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1062 ui::DisplayPrimaries primaries;
1063 sp<IBinder> display = nullptr;
1064
1065 status_t result = data.readStrongBinder(&display);
1066 if (result != NO_ERROR) {
1067 ALOGE("getDisplayNativePrimaries failed to readStrongBinder: %d", result);
1068 return result;
1069 }
1070
1071 result = getDisplayNativePrimaries(display, primaries);
1072 reply->writeInt32(result);
1073 if (result == NO_ERROR) {
1074 memcpy(reply->writeInplace(sizeof(ui::DisplayPrimaries)), &primaries,
1075 sizeof(ui::DisplayPrimaries));
1076 }
1077
1078 return NO_ERROR;
1079 }
Michael Wright28f24d02016-07-12 13:30:53 -07001080 case GET_ACTIVE_COLOR_MODE: {
1081 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1082 sp<IBinder> display = nullptr;
1083 status_t result = data.readStrongBinder(&display);
1084 if (result != NO_ERROR) {
1085 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1086 return result;
1087 }
Peiyong Lina52f0292018-03-14 17:26:31 -07001088 ColorMode colorMode = getActiveColorMode(display);
Michael Wright28f24d02016-07-12 13:30:53 -07001089 result = reply->writeInt32(static_cast<int32_t>(colorMode));
1090 return result;
1091 }
1092 case SET_ACTIVE_COLOR_MODE: {
1093 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1094 sp<IBinder> display = nullptr;
1095 status_t result = data.readStrongBinder(&display);
1096 if (result != NO_ERROR) {
1097 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1098 return result;
1099 }
1100 int32_t colorModeInt = 0;
1101 result = data.readInt32(&colorModeInt);
1102 if (result != NO_ERROR) {
1103 ALOGE("setActiveColorMode failed to readInt32: %d", result);
1104 return result;
1105 }
1106 result = setActiveColorMode(display,
Peiyong Lina52f0292018-03-14 17:26:31 -07001107 static_cast<ColorMode>(colorModeInt));
Michael Wright28f24d02016-07-12 13:30:53 -07001108 result = reply->writeInt32(result);
1109 return result;
1110 }
Svetoslavd85084b2014-03-20 10:28:31 -07001111 case CLEAR_ANIMATION_FRAME_STATS: {
1112 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1113 status_t result = clearAnimationFrameStats();
1114 reply->writeInt32(result);
1115 return NO_ERROR;
1116 }
1117 case GET_ANIMATION_FRAME_STATS: {
1118 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1119 FrameStats stats;
1120 status_t result = getAnimationFrameStats(&stats);
1121 reply->write(stats);
1122 reply->writeInt32(result);
1123 return NO_ERROR;
1124 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -07001125 case SET_POWER_MODE: {
1126 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1127 sp<IBinder> display = data.readStrongBinder();
1128 int32_t mode = data.readInt32();
1129 setPowerMode(display, mode);
1130 return NO_ERROR;
1131 }
Dan Stozac4f471e2016-03-24 09:31:08 -07001132 case GET_HDR_CAPABILITIES: {
1133 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1134 sp<IBinder> display = nullptr;
1135 status_t result = data.readStrongBinder(&display);
1136 if (result != NO_ERROR) {
1137 ALOGE("getHdrCapabilities failed to readStrongBinder: %d",
1138 result);
1139 return result;
1140 }
1141 HdrCapabilities capabilities;
1142 result = getHdrCapabilities(display, &capabilities);
1143 reply->writeInt32(result);
1144 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -08001145 reply->write(capabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -07001146 }
1147 return NO_ERROR;
1148 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -07001149 case ENABLE_VSYNC_INJECTIONS: {
1150 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1151 bool enable = false;
1152 status_t result = data.readBool(&enable);
1153 if (result != NO_ERROR) {
1154 ALOGE("enableVSyncInjections failed to readBool: %d", result);
1155 return result;
1156 }
1157 return enableVSyncInjections(enable);
1158 }
1159 case INJECT_VSYNC: {
1160 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1161 int64_t when = 0;
1162 status_t result = data.readInt64(&when);
1163 if (result != NO_ERROR) {
1164 ALOGE("enableVSyncInjections failed to readInt64: %d", result);
1165 return result;
1166 }
1167 return injectVSync(when);
1168 }
Kalle Raitaa099a242017-01-11 11:17:29 -08001169 case GET_LAYER_DEBUG_INFO: {
1170 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1171 std::vector<LayerDebugInfo> outLayers;
1172 status_t result = getLayerDebugInfo(&outLayers);
1173 reply->writeInt32(result);
1174 if (result == NO_ERROR)
1175 {
1176 result = reply->writeParcelableVector(outLayers);
1177 }
1178 return result;
1179 }
Peiyong Lin0256f722018-08-31 15:45:10 -07001180 case GET_COMPOSITION_PREFERENCE: {
1181 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Linc6780972018-10-28 15:24:08 -07001182 ui::Dataspace defaultDataspace;
1183 ui::PixelFormat defaultPixelFormat;
1184 ui::Dataspace wideColorGamutDataspace;
1185 ui::PixelFormat wideColorGamutPixelFormat;
1186 status_t error =
1187 getCompositionPreference(&defaultDataspace, &defaultPixelFormat,
1188 &wideColorGamutDataspace, &wideColorGamutPixelFormat);
Peiyong Lin0256f722018-08-31 15:45:10 -07001189 reply->writeInt32(error);
1190 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -07001191 reply->writeInt32(static_cast<int32_t>(defaultDataspace));
1192 reply->writeInt32(static_cast<int32_t>(defaultPixelFormat));
1193 reply->writeInt32(static_cast<int32_t>(wideColorGamutDataspace));
Peiyong Linaa3da6a2018-12-12 02:48:43 -08001194 reply->writeInt32(static_cast<int32_t>(wideColorGamutPixelFormat));
Peiyong Lin0256f722018-08-31 15:45:10 -07001195 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001196 return error;
Peiyong Lin0256f722018-08-31 15:45:10 -07001197 }
Ady Abraham37965d42018-11-01 13:43:32 -07001198 case GET_COLOR_MANAGEMENT: {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001199 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Ady Abraham37965d42018-11-01 13:43:32 -07001200 bool result;
1201 status_t error = getColorManagement(&result);
1202 if (error == NO_ERROR) {
1203 reply->writeBool(result);
1204 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001205 return error;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001206 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -07001207 case GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: {
1208 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1209
1210 sp<IBinder> display = data.readStrongBinder();
1211 ui::PixelFormat format;
1212 ui::Dataspace dataspace;
1213 uint8_t component = 0;
1214 auto result =
1215 getDisplayedContentSamplingAttributes(display, &format, &dataspace, &component);
1216 if (result == NO_ERROR) {
1217 reply->writeUint32(static_cast<uint32_t>(format));
1218 reply->writeUint32(static_cast<uint32_t>(dataspace));
1219 reply->writeUint32(static_cast<uint32_t>(component));
1220 }
1221 return result;
1222 }
Kevin DuBois74e53772018-11-19 10:52:38 -08001223 case SET_DISPLAY_CONTENT_SAMPLING_ENABLED: {
1224 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1225
1226 sp<IBinder> display = nullptr;
1227 bool enable = false;
1228 int8_t componentMask = 0;
1229 uint64_t maxFrames = 0;
1230 status_t result = data.readStrongBinder(&display);
1231 if (result != NO_ERROR) {
1232 ALOGE("setDisplayContentSamplingEnabled failure in reading Display token: %d",
1233 result);
1234 return result;
1235 }
1236
1237 result = data.readBool(&enable);
1238 if (result != NO_ERROR) {
1239 ALOGE("setDisplayContentSamplingEnabled failure in reading enable: %d", result);
1240 return result;
1241 }
1242
1243 result = data.readByte(static_cast<int8_t*>(&componentMask));
1244 if (result != NO_ERROR) {
1245 ALOGE("setDisplayContentSamplingEnabled failure in reading component mask: %d",
1246 result);
1247 return result;
1248 }
1249
1250 result = data.readUint64(&maxFrames);
1251 if (result != NO_ERROR) {
1252 ALOGE("setDisplayContentSamplingEnabled failure in reading max frames: %d", result);
1253 return result;
1254 }
1255
1256 return setDisplayContentSamplingEnabled(display, enable,
1257 static_cast<uint8_t>(componentMask), maxFrames);
1258 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001259 case GET_DISPLAYED_CONTENT_SAMPLE: {
1260 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1261
1262 sp<IBinder> display = data.readStrongBinder();
1263 uint64_t maxFrames = 0;
1264 uint64_t timestamp = 0;
1265
1266 status_t result = data.readUint64(&maxFrames);
1267 if (result != NO_ERROR) {
1268 ALOGE("getDisplayedContentSample failure in reading max frames: %d", result);
1269 return result;
1270 }
1271
1272 result = data.readUint64(&timestamp);
1273 if (result != NO_ERROR) {
1274 ALOGE("getDisplayedContentSample failure in reading timestamp: %d", result);
1275 return result;
1276 }
1277
1278 DisplayedFrameStats stats;
1279 result = getDisplayedContentSample(display, maxFrames, timestamp, &stats);
1280 if (result == NO_ERROR) {
1281 reply->writeUint64(stats.numFrames);
Kevin DuBois1d4c6a62018-12-12 13:59:46 -08001282 reply->writeUint64Vector(stats.component_0_sample);
1283 reply->writeUint64Vector(stats.component_1_sample);
1284 reply->writeUint64Vector(stats.component_2_sample);
1285 reply->writeUint64Vector(stats.component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001286 }
1287 return result;
1288 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001289 case GET_PROTECTED_CONTENT_SUPPORT: {
1290 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1291 bool result;
1292 status_t error = getProtectedContentSupport(&result);
1293 if (error == NO_ERROR) {
1294 reply->writeBool(result);
1295 }
1296 return error;
1297 }
Peiyong Lin4f3fddf2019-01-24 17:21:24 -08001298 case IS_WIDE_COLOR_DISPLAY: {
1299 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1300 sp<IBinder> display = nullptr;
1301 status_t error = data.readStrongBinder(&display);
1302 if (error != NO_ERROR) {
1303 return error;
1304 }
1305 bool result;
1306 error = isWideColorDisplay(display, &result);
1307 if (error == NO_ERROR) {
1308 reply->writeBool(result);
1309 }
1310 return error;
1311 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001312 case GET_PHYSICAL_DISPLAY_IDS: {
1313 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1314 return reply->writeUint64Vector(getPhysicalDisplayIds());
1315 }
Dan Stoza84ab9372018-12-17 15:27:57 -08001316 case ADD_REGION_SAMPLING_LISTENER: {
1317 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1318 Rect samplingArea;
1319 status_t result = data.read(samplingArea);
1320 if (result != NO_ERROR) {
1321 ALOGE("addRegionSamplingListener: Failed to read sampling area");
1322 return result;
1323 }
1324 sp<IBinder> stopLayerHandle;
1325 result = data.readNullableStrongBinder(&stopLayerHandle);
1326 if (result != NO_ERROR) {
1327 ALOGE("addRegionSamplingListener: Failed to read stop layer handle");
1328 return result;
1329 }
1330 sp<IRegionSamplingListener> listener;
1331 result = data.readNullableStrongBinder(&listener);
1332 if (result != NO_ERROR) {
1333 ALOGE("addRegionSamplingListener: Failed to read listener");
1334 return result;
1335 }
1336 return addRegionSamplingListener(samplingArea, stopLayerHandle, listener);
1337 }
1338 case REMOVE_REGION_SAMPLING_LISTENER: {
1339 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1340 sp<IRegionSamplingListener> listener;
1341 status_t result = data.readNullableStrongBinder(&listener);
1342 if (result != NO_ERROR) {
1343 ALOGE("removeRegionSamplingListener: Failed to read listener");
1344 return result;
1345 }
1346 return removeRegionSamplingListener(listener);
1347 }
Ady Abraham838de062019-02-04 10:24:03 -08001348 case SET_ALLOWED_DISPLAY_CONFIGS: {
1349 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1350 sp<IBinder> displayToken = data.readStrongBinder();
1351 std::vector<int32_t> allowedConfigs;
1352 data.readInt32Vector(&allowedConfigs);
1353 status_t result = setAllowedDisplayConfigs(displayToken, allowedConfigs);
1354 reply->writeInt32(result);
1355 return result;
1356 }
Jesse Hall6c913be2013-08-08 12:15:49 -07001357 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001358 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -07001359 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001360 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001361}
1362
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001363} // namespace android