blob: cec86e2a04546f95b0f12effe39f286ffd822522 [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>
Mathias Agopian2b5dd402017-02-07 17:36:19 -080029#include <gui/ISurfaceComposer.h>
30#include <gui/ISurfaceComposerClient.h>
Kalle Raitaa099a242017-01-11 11:17:29 -080031#include <gui/LayerDebugInfo.h>
Robert Carr4cdc58f2017-08-23 14:22:20 -070032#include <gui/LayerState.h>
Mathias Agopiand0566bc2011-11-17 17:49:17 -080033
Michael Wright28f24d02016-07-12 13:30:53 -070034#include <system/graphics.h>
35
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080036#include <ui/DisplayInfo.h>
Lajos Molnar67d8bd62014-09-11 14:58:45 -070037#include <ui/DisplayStatInfo.h>
Dan Stozac4f471e2016-03-24 09:31:08 -070038#include <ui/HdrCapabilities.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080039
Jamie Gennis134f0422011-03-08 12:18:54 -080040#include <utils/Log.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -080041
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080042// ---------------------------------------------------------------------------
43
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080044namespace android {
45
Peiyong Linfd997e02018-03-28 15:29:00 -070046using ui::ColorMode;
47
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080048class BpSurfaceComposer : public BpInterface<ISurfaceComposer>
49{
50public:
Chih-Hung Hsiehe2347b72016-04-25 15:41:05 -070051 explicit BpSurfaceComposer(const sp<IBinder>& impl)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080052 : BpInterface<ISurfaceComposer>(impl)
53 {
54 }
55
Dan Stozad723bd72014-11-18 10:24:03 -080056 virtual ~BpSurfaceComposer();
57
Mathias Agopian7e27f052010-05-28 14:22:23 -070058 virtual sp<ISurfaceComposerClient> createConnection()
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080059 {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080060 Parcel data, reply;
61 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
62 remote()->transact(BnSurfaceComposer::CREATE_CONNECTION, data, &reply);
Mathias Agopian7e27f052010-05-28 14:22:23 -070063 return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080064 }
65
Robert Carr1db73f62016-12-21 12:58:51 -080066 virtual sp<ISurfaceComposerClient> createScopedConnection(
67 const sp<IGraphicBufferProducer>& parent)
68 {
69 Parcel data, reply;
70 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
71 data.writeStrongBinder(IInterface::asBinder(parent));
72 remote()->transact(BnSurfaceComposer::CREATE_SCOPED_CONNECTION, data, &reply);
73 return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder());
74 }
75
Mathias Agopian8b33f032012-07-24 20:43:54 -070076 virtual void setTransactionState(
77 const Vector<ComposerState>& state,
78 const Vector<DisplayState>& displays,
79 uint32_t flags)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080080 {
81 Parcel data, reply;
82 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Dan Stozad723bd72014-11-18 10:24:03 -080083
84 data.writeUint32(static_cast<uint32_t>(state.size()));
85 for (const auto& s : state) {
86 s.write(data);
Mathias Agopian698c0872011-06-28 19:09:31 -070087 }
Dan Stozad723bd72014-11-18 10:24:03 -080088
89 data.writeUint32(static_cast<uint32_t>(displays.size()));
90 for (const auto& d : displays) {
91 d.write(data);
Mathias Agopian8b33f032012-07-24 20:43:54 -070092 }
Dan Stozad723bd72014-11-18 10:24:03 -080093
94 data.writeUint32(flags);
Jamie Gennisb8d69a52011-10-10 15:48:06 -070095 remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080096 }
97
98 virtual void bootFinished()
99 {
100 Parcel data, reply;
101 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
102 remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply);
103 }
104
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000105 virtual status_t captureScreen(const sp<IBinder>& display, sp<GraphicBuffer>* outBuffer,
Robert Carr0283c732019-04-02 16:32:58 -0700106 bool& outCapturedSecureLayers,
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000107 Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
108 int32_t minLayerZ, int32_t maxLayerZ, bool useIdentityTransform,
Robert Carr9085ced2019-02-19 10:05:00 -0800109 ISurfaceComposer::Rotation rotation, bool captureSecureLayers) {
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800110 Parcel data, reply;
111 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
112 data.writeStrongBinder(display);
Dan Stozac1879002014-05-22 15:59:05 -0700113 data.write(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800114 data.writeUint32(reqWidth);
115 data.writeUint32(reqHeight);
Robert Carrae060832016-11-28 10:51:00 -0800116 data.writeInt32(minLayerZ);
117 data.writeInt32(maxLayerZ);
Dan Stozac7014012014-02-14 15:03:43 -0800118 data.writeInt32(static_cast<int32_t>(useIdentityTransform));
Riley Andrewsc3ebe662014-09-04 16:20:31 -0700119 data.writeInt32(static_cast<int32_t>(rotation));
Robert Carr9085ced2019-02-19 10:05:00 -0800120 data.writeInt32(static_cast<int32_t>(captureSecureLayers));
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000121 status_t err = remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply);
122
123 if (err != NO_ERROR) {
124 return err;
125 }
126
127 err = reply.readInt32();
128 if (err != NO_ERROR) {
129 return err;
130 }
131
132 *outBuffer = new GraphicBuffer();
133 reply.read(**outBuffer);
Robert Carr0283c732019-04-02 16:32:58 -0700134 outCapturedSecureLayers = reply.readBool();
135
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000136 return err;
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800137 }
138
chaviwa76b2712017-09-20 12:02:26 -0700139 virtual status_t captureLayers(const sp<IBinder>& layerHandleBinder,
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000140 sp<GraphicBuffer>* outBuffer, const Rect& sourceCrop,
Robert Carr578038f2018-03-09 12:25:24 -0800141 float frameScale, bool childrenOnly) {
chaviwa76b2712017-09-20 12:02:26 -0700142 Parcel data, reply;
143 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
144 data.writeStrongBinder(layerHandleBinder);
chaviw7206d492017-11-10 16:16:12 -0800145 data.write(sourceCrop);
146 data.writeFloat(frameScale);
Robert Carr578038f2018-03-09 12:25:24 -0800147 data.writeBool(childrenOnly);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000148 status_t err = remote()->transact(BnSurfaceComposer::CAPTURE_LAYERS, data, &reply);
149
150 if (err != NO_ERROR) {
151 return err;
152 }
153
154 err = reply.readInt32();
155 if (err != NO_ERROR) {
156 return err;
157 }
158
159 *outBuffer = new GraphicBuffer();
160 reply.read(**outBuffer);
161
162 return err;
chaviwa76b2712017-09-20 12:02:26 -0700163 }
164
Jamie Gennis582270d2011-08-17 18:19:00 -0700165 virtual bool authenticateSurfaceTexture(
Andy McFadden2adaf042012-12-18 09:49:45 -0800166 const sp<IGraphicBufferProducer>& bufferProducer) const
Jamie Gennis134f0422011-03-08 12:18:54 -0800167 {
168 Parcel data, reply;
169 int err = NO_ERROR;
170 err = data.writeInterfaceToken(
171 ISurfaceComposer::getInterfaceDescriptor());
172 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000173 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis134f0422011-03-08 12:18:54 -0800174 "interface descriptor: %s (%d)", strerror(-err), -err);
175 return false;
176 }
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800177 err = data.writeStrongBinder(IInterface::asBinder(bufferProducer));
Jamie Gennis134f0422011-03-08 12:18:54 -0800178 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000179 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis582270d2011-08-17 18:19:00 -0700180 "strong binder to parcel: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800181 return false;
182 }
183 err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
184 &reply);
185 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000186 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700187 "performing transaction: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800188 return false;
189 }
190 int32_t result = 0;
191 err = reply.readInt32(&result);
192 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000193 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700194 "retrieving result: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800195 return false;
196 }
197 return result != 0;
198 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800199
Brian Anderson6b376712017-04-04 10:51:39 -0700200 virtual status_t getSupportedFrameTimestamps(
201 std::vector<FrameEvent>* outSupported) const {
202 if (!outSupported) {
203 return UNEXPECTED_NULL;
204 }
205 outSupported->clear();
206
207 Parcel data, reply;
208
209 status_t err = data.writeInterfaceToken(
210 ISurfaceComposer::getInterfaceDescriptor());
211 if (err != NO_ERROR) {
212 return err;
213 }
214
215 err = remote()->transact(
216 BnSurfaceComposer::GET_SUPPORTED_FRAME_TIMESTAMPS,
217 data, &reply);
218 if (err != NO_ERROR) {
219 return err;
220 }
221
222 int32_t result = 0;
223 err = reply.readInt32(&result);
224 if (err != NO_ERROR) {
225 return err;
226 }
227 if (result != NO_ERROR) {
228 return result;
229 }
230
231 std::vector<int32_t> supported;
232 err = reply.readInt32Vector(&supported);
233 if (err != NO_ERROR) {
234 return err;
235 }
236
237 outSupported->reserve(supported.size());
238 for (int32_t s : supported) {
239 outSupported->push_back(static_cast<FrameEvent>(s));
240 }
241 return NO_ERROR;
242 }
243
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700244 virtual sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource)
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800245 {
246 Parcel data, reply;
247 sp<IDisplayEventConnection> result;
248 int err = data.writeInterfaceToken(
249 ISurfaceComposer::getInterfaceDescriptor());
250 if (err != NO_ERROR) {
251 return result;
252 }
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700253 data.writeInt32(static_cast<int32_t>(vsyncSource));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800254 err = remote()->transact(
255 BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION,
256 data, &reply);
257 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000258 ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing "
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800259 "transaction: %s (%d)", strerror(-err), -err);
260 return result;
261 }
262 result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder());
263 return result;
264 }
Colin Cross8e533062012-06-07 13:17:52 -0700265
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700266 virtual sp<IBinder> createDisplay(const String8& displayName, bool secure)
Mathias Agopiane57f2922012-08-09 16:29:12 -0700267 {
268 Parcel data, reply;
269 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700270 data.writeString8(displayName);
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700271 data.writeInt32(secure ? 1 : 0);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700272 remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply);
273 return reply.readStrongBinder();
274 }
275
Jesse Hall6c913be2013-08-08 12:15:49 -0700276 virtual void destroyDisplay(const sp<IBinder>& display)
277 {
278 Parcel data, reply;
279 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
280 data.writeStrongBinder(display);
281 remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply);
282 }
283
Mathias Agopiane57f2922012-08-09 16:29:12 -0700284 virtual sp<IBinder> getBuiltInDisplay(int32_t id)
285 {
286 Parcel data, reply;
287 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
288 data.writeInt32(id);
289 remote()->transact(BnSurfaceComposer::GET_BUILT_IN_DISPLAY, data, &reply);
290 return reply.readStrongBinder();
291 }
292
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700293 virtual void setPowerMode(const sp<IBinder>& display, int mode)
Colin Cross8e533062012-06-07 13:17:52 -0700294 {
295 Parcel data, reply;
296 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700297 data.writeStrongBinder(display);
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700298 data.writeInt32(mode);
299 remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply);
Colin Cross8e533062012-06-07 13:17:52 -0700300 }
Mathias Agopian3094df32012-06-18 18:06:45 -0700301
Dan Stoza7f7da322014-05-02 15:26:25 -0700302 virtual status_t getDisplayConfigs(const sp<IBinder>& display,
303 Vector<DisplayInfo>* configs)
Mathias Agopianc666cae2012-07-25 18:56:13 -0700304 {
305 Parcel data, reply;
306 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700307 data.writeStrongBinder(display);
Dan Stoza7f7da322014-05-02 15:26:25 -0700308 remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply);
309 status_t result = reply.readInt32();
310 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -0800311 size_t numConfigs = reply.readUint32();
Dan Stoza7f7da322014-05-02 15:26:25 -0700312 configs->clear();
313 configs->resize(numConfigs);
314 for (size_t c = 0; c < numConfigs; ++c) {
315 memcpy(&(configs->editItemAt(c)),
316 reply.readInplace(sizeof(DisplayInfo)),
317 sizeof(DisplayInfo));
318 }
319 }
320 return result;
321 }
322
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700323 virtual status_t getDisplayStats(const sp<IBinder>& display,
324 DisplayStatInfo* stats)
325 {
326 Parcel data, reply;
327 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
328 data.writeStrongBinder(display);
329 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply);
330 status_t result = reply.readInt32();
331 if (result == NO_ERROR) {
332 memcpy(stats,
333 reply.readInplace(sizeof(DisplayStatInfo)),
334 sizeof(DisplayStatInfo));
335 }
336 return result;
337 }
338
Yiwei Zhang1d465af2018-08-21 15:15:42 -0700339 virtual status_t getDisplayViewport(const sp<IBinder>& display, Rect* outViewport) {
340 Parcel data, reply;
341 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
342 if (result != NO_ERROR) {
343 ALOGE("getDisplayViewport failed to writeInterfaceToken: %d", result);
344 return result;
345 }
346 result = data.writeStrongBinder(display);
347 if (result != NO_ERROR) {
348 ALOGE("getDisplayViewport failed to writeStrongBinder: %d", result);
349 return result;
350 }
351 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_VIEWPORT, data, &reply);
352 if (result != NO_ERROR) {
353 ALOGE("getDisplayViewport failed to transact: %d", result);
354 return result;
355 }
356 result = reply.readInt32();
357 if (result == NO_ERROR) {
358 result = reply.read(*outViewport);
359 if (result != NO_ERROR) {
360 ALOGE("getDisplayViewport failed to read: %d", result);
361 return result;
362 }
363 }
364 return result;
365 }
366
Dan Stoza7f7da322014-05-02 15:26:25 -0700367 virtual int getActiveConfig(const sp<IBinder>& display)
368 {
369 Parcel data, reply;
370 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
371 data.writeStrongBinder(display);
372 remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply);
373 return reply.readInt32();
374 }
375
376 virtual status_t setActiveConfig(const sp<IBinder>& display, int id)
377 {
378 Parcel data, reply;
379 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
380 data.writeStrongBinder(display);
381 data.writeInt32(id);
382 remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply);
Mathias Agopianc666cae2012-07-25 18:56:13 -0700383 return reply.readInt32();
384 }
Svetoslavd85084b2014-03-20 10:28:31 -0700385
Michael Wright28f24d02016-07-12 13:30:53 -0700386 virtual status_t getDisplayColorModes(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700387 Vector<ColorMode>* outColorModes) {
Michael Wright28f24d02016-07-12 13:30:53 -0700388 Parcel data, reply;
389 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
390 if (result != NO_ERROR) {
391 ALOGE("getDisplayColorModes failed to writeInterfaceToken: %d", result);
392 return result;
393 }
394 result = data.writeStrongBinder(display);
395 if (result != NO_ERROR) {
396 ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result);
397 return result;
398 }
399 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply);
400 if (result != NO_ERROR) {
401 ALOGE("getDisplayColorModes failed to transact: %d", result);
402 return result;
403 }
404 result = static_cast<status_t>(reply.readInt32());
405 if (result == NO_ERROR) {
406 size_t numModes = reply.readUint32();
407 outColorModes->clear();
408 outColorModes->resize(numModes);
409 for (size_t i = 0; i < numModes; ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -0700410 outColorModes->replaceAt(static_cast<ColorMode>(reply.readInt32()), i);
Michael Wright28f24d02016-07-12 13:30:53 -0700411 }
412 }
413 return result;
414 }
415
Peiyong Lina52f0292018-03-14 17:26:31 -0700416 virtual ColorMode getActiveColorMode(const sp<IBinder>& display) {
Michael Wright28f24d02016-07-12 13:30:53 -0700417 Parcel data, reply;
418 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
419 if (result != NO_ERROR) {
420 ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700421 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700422 }
423 result = data.writeStrongBinder(display);
424 if (result != NO_ERROR) {
425 ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700426 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700427 }
428 result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply);
429 if (result != NO_ERROR) {
430 ALOGE("getActiveColorMode failed to transact: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700431 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700432 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700433 return static_cast<ColorMode>(reply.readInt32());
Michael Wright28f24d02016-07-12 13:30:53 -0700434 }
435
436 virtual status_t setActiveColorMode(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700437 ColorMode colorMode) {
Michael Wright28f24d02016-07-12 13:30:53 -0700438 Parcel data, reply;
439 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
440 if (result != NO_ERROR) {
441 ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result);
442 return result;
443 }
444 result = data.writeStrongBinder(display);
445 if (result != NO_ERROR) {
446 ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result);
447 return result;
448 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700449 result = data.writeInt32(static_cast<int32_t>(colorMode));
Michael Wright28f24d02016-07-12 13:30:53 -0700450 if (result != NO_ERROR) {
451 ALOGE("setActiveColorMode failed to writeInt32: %d", result);
452 return result;
453 }
454 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply);
455 if (result != NO_ERROR) {
456 ALOGE("setActiveColorMode failed to transact: %d", result);
457 return result;
458 }
459 return static_cast<status_t>(reply.readInt32());
460 }
461
Svetoslavd85084b2014-03-20 10:28:31 -0700462 virtual status_t clearAnimationFrameStats() {
463 Parcel data, reply;
464 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
465 remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply);
466 return reply.readInt32();
467 }
468
469 virtual status_t getAnimationFrameStats(FrameStats* outStats) const {
470 Parcel data, reply;
471 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
472 remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply);
473 reply.read(*outStats);
474 return reply.readInt32();
475 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700476
477 virtual status_t getHdrCapabilities(const sp<IBinder>& display,
478 HdrCapabilities* outCapabilities) const {
479 Parcel data, reply;
480 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
481 status_t result = data.writeStrongBinder(display);
482 if (result != NO_ERROR) {
483 ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result);
484 return result;
485 }
486 result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES,
487 data, &reply);
488 if (result != NO_ERROR) {
489 ALOGE("getHdrCapabilities failed to transact: %d", result);
490 return result;
491 }
492 result = reply.readInt32();
493 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800494 result = reply.read(*outCapabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700495 }
496 return result;
497 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700498
499 virtual status_t enableVSyncInjections(bool enable) {
500 Parcel data, reply;
501 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
502 if (result != NO_ERROR) {
503 ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result);
504 return result;
505 }
506 result = data.writeBool(enable);
507 if (result != NO_ERROR) {
508 ALOGE("enableVSyncInjections failed to writeBool: %d", result);
509 return result;
510 }
511 result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS,
512 data, &reply, TF_ONE_WAY);
513 if (result != NO_ERROR) {
514 ALOGE("enableVSyncInjections failed to transact: %d", result);
515 return result;
516 }
517 return result;
518 }
519
520 virtual status_t injectVSync(nsecs_t when) {
521 Parcel data, reply;
522 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
523 if (result != NO_ERROR) {
524 ALOGE("injectVSync failed to writeInterfaceToken: %d", result);
525 return result;
526 }
527 result = data.writeInt64(when);
528 if (result != NO_ERROR) {
529 ALOGE("injectVSync failed to writeInt64: %d", result);
530 return result;
531 }
532 result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply, TF_ONE_WAY);
533 if (result != NO_ERROR) {
534 ALOGE("injectVSync failed to transact: %d", result);
535 return result;
536 }
537 return result;
538 }
539
Kalle Raitaa099a242017-01-11 11:17:29 -0800540 virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const
541 {
542 if (!outLayers) {
543 return UNEXPECTED_NULL;
544 }
545
546 Parcel data, reply;
547
548 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
549 if (err != NO_ERROR) {
550 return err;
551 }
552
553 err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply);
554 if (err != NO_ERROR) {
555 return err;
556 }
557
558 int32_t result = 0;
559 err = reply.readInt32(&result);
560 if (err != NO_ERROR) {
561 return err;
562 }
563 if (result != NO_ERROR) {
564 return result;
565 }
566
567 outLayers->clear();
568 return reply.readParcelableVector(outLayers);
569 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800570};
571
Dan Stozad723bd72014-11-18 10:24:03 -0800572// Out-of-line virtual method definition to trigger vtable emission in this
573// translation unit (see clang warning -Wweak-vtables)
574BpSurfaceComposer::~BpSurfaceComposer() {}
575
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800576IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
577
578// ----------------------------------------------------------------------
579
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800580status_t BnSurfaceComposer::onTransact(
581 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
582{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800583 switch(code) {
584 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700585 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800586 sp<IBinder> b = IInterface::asBinder(createConnection());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800587 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -0700588 return NO_ERROR;
589 }
Robert Carr1db73f62016-12-21 12:58:51 -0800590 case CREATE_SCOPED_CONNECTION: {
591 CHECK_INTERFACE(ISurfaceComposer, data, reply);
592 sp<IGraphicBufferProducer> bufferProducer =
593 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
594 sp<IBinder> b = IInterface::asBinder(createScopedConnection(bufferProducer));
595 reply->writeStrongBinder(b);
596 return NO_ERROR;
597 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700598 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700599 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -0800600
601 size_t count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700602 if (count > data.dataSize()) {
603 return BAD_VALUE;
604 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700605 ComposerState s;
606 Vector<ComposerState> state;
607 state.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800608 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700609 if (s.read(data) == BAD_VALUE) {
610 return BAD_VALUE;
611 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700612 state.add(s);
613 }
Dan Stozad723bd72014-11-18 10:24:03 -0800614
615 count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700616 if (count > data.dataSize()) {
617 return BAD_VALUE;
618 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700619 DisplayState d;
620 Vector<DisplayState> displays;
621 displays.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800622 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700623 if (d.read(data) == BAD_VALUE) {
624 return BAD_VALUE;
625 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700626 displays.add(d);
627 }
Dan Stozad723bd72014-11-18 10:24:03 -0800628
629 uint32_t stateFlags = data.readUint32();
630 setTransactionState(state, displays, stateFlags);
Jesse Hall6c913be2013-08-08 12:15:49 -0700631 return NO_ERROR;
632 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800633 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700634 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800635 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -0700636 return NO_ERROR;
637 }
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800638 case CAPTURE_SCREEN: {
639 CHECK_INTERFACE(ISurfaceComposer, data, reply);
640 sp<IBinder> display = data.readStrongBinder();
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000641 sp<GraphicBuffer> outBuffer;
Pablo Ceballos60d69222015-08-07 14:47:20 -0700642 Rect sourceCrop(Rect::EMPTY_RECT);
Dan Stozac1879002014-05-22 15:59:05 -0700643 data.read(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800644 uint32_t reqWidth = data.readUint32();
645 uint32_t reqHeight = data.readUint32();
Robert Carrae060832016-11-28 10:51:00 -0800646 int32_t minLayerZ = data.readInt32();
647 int32_t maxLayerZ = data.readInt32();
Dan Stozac7014012014-02-14 15:03:43 -0800648 bool useIdentityTransform = static_cast<bool>(data.readInt32());
Dan Stozad723bd72014-11-18 10:24:03 -0800649 int32_t rotation = data.readInt32();
Robert Carr9085ced2019-02-19 10:05:00 -0800650 bool captureSecureLayers = static_cast<bool>(data.readInt32());
Dan Stozac7014012014-02-14 15:03:43 -0800651
Robert Carr0283c732019-04-02 16:32:58 -0700652 bool capturedSecureLayers = false;
653 status_t res = captureScreen(display, &outBuffer, capturedSecureLayers, sourceCrop, reqWidth,
654 reqHeight, minLayerZ, maxLayerZ, useIdentityTransform,
Robert Carr9085ced2019-02-19 10:05:00 -0800655 static_cast<ISurfaceComposer::Rotation>(rotation), captureSecureLayers);
Robert Carr0283c732019-04-02 16:32:58 -0700656
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800657 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000658 if (res == NO_ERROR) {
659 reply->write(*outBuffer);
Robert Carr0283c732019-04-02 16:32:58 -0700660 reply->writeBool(capturedSecureLayers);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000661 }
Jesse Hall6c913be2013-08-08 12:15:49 -0700662 return NO_ERROR;
663 }
chaviwa76b2712017-09-20 12:02:26 -0700664 case CAPTURE_LAYERS: {
665 CHECK_INTERFACE(ISurfaceComposer, data, reply);
666 sp<IBinder> layerHandleBinder = data.readStrongBinder();
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000667 sp<GraphicBuffer> outBuffer;
chaviw7206d492017-11-10 16:16:12 -0800668 Rect sourceCrop(Rect::EMPTY_RECT);
669 data.read(sourceCrop);
670 float frameScale = data.readFloat();
Robert Carr578038f2018-03-09 12:25:24 -0800671 bool childrenOnly = data.readBool();
chaviwa76b2712017-09-20 12:02:26 -0700672
Robert Carr578038f2018-03-09 12:25:24 -0800673 status_t res = captureLayers(layerHandleBinder, &outBuffer, sourceCrop, frameScale,
674 childrenOnly);
chaviwa76b2712017-09-20 12:02:26 -0700675 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000676 if (res == NO_ERROR) {
677 reply->write(*outBuffer);
678 }
chaviwa76b2712017-09-20 12:02:26 -0700679 return NO_ERROR;
680 }
Jamie Gennis134f0422011-03-08 12:18:54 -0800681 case AUTHENTICATE_SURFACE: {
682 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -0800683 sp<IGraphicBufferProducer> bufferProducer =
684 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
685 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -0800686 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700687 return NO_ERROR;
688 }
Brian Anderson6b376712017-04-04 10:51:39 -0700689 case GET_SUPPORTED_FRAME_TIMESTAMPS: {
690 CHECK_INTERFACE(ISurfaceComposer, data, reply);
691 std::vector<FrameEvent> supportedTimestamps;
692 status_t result = getSupportedFrameTimestamps(&supportedTimestamps);
693 status_t err = reply->writeInt32(result);
694 if (err != NO_ERROR) {
695 return err;
696 }
697 if (result != NO_ERROR) {
698 return result;
699 }
700
701 std::vector<int32_t> supported;
702 supported.reserve(supportedTimestamps.size());
703 for (FrameEvent s : supportedTimestamps) {
704 supported.push_back(static_cast<int32_t>(s));
705 }
706 return reply->writeInt32Vector(supported);
707 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800708 case CREATE_DISPLAY_EVENT_CONNECTION: {
709 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700710 sp<IDisplayEventConnection> connection(createDisplayEventConnection(
711 static_cast<ISurfaceComposer::VsyncSource>(data.readInt32())));
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800712 reply->writeStrongBinder(IInterface::asBinder(connection));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800713 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700714 }
Mathias Agopiane57f2922012-08-09 16:29:12 -0700715 case CREATE_DISPLAY: {
716 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700717 String8 displayName = data.readString8();
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700718 bool secure = bool(data.readInt32());
719 sp<IBinder> display(createDisplay(displayName, secure));
Mathias Agopiane57f2922012-08-09 16:29:12 -0700720 reply->writeStrongBinder(display);
721 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700722 }
723 case DESTROY_DISPLAY: {
724 CHECK_INTERFACE(ISurfaceComposer, data, reply);
725 sp<IBinder> display = data.readStrongBinder();
726 destroyDisplay(display);
727 return NO_ERROR;
728 }
Mathias Agopiane57f2922012-08-09 16:29:12 -0700729 case GET_BUILT_IN_DISPLAY: {
730 CHECK_INTERFACE(ISurfaceComposer, data, reply);
731 int32_t id = data.readInt32();
732 sp<IBinder> display(getBuiltInDisplay(id));
733 reply->writeStrongBinder(display);
734 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700735 }
Dan Stoza7f7da322014-05-02 15:26:25 -0700736 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -0700737 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stoza7f7da322014-05-02 15:26:25 -0700738 Vector<DisplayInfo> configs;
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700739 sp<IBinder> display = data.readStrongBinder();
Dan Stoza7f7da322014-05-02 15:26:25 -0700740 status_t result = getDisplayConfigs(display, &configs);
741 reply->writeInt32(result);
742 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -0800743 reply->writeUint32(static_cast<uint32_t>(configs.size()));
Dan Stoza7f7da322014-05-02 15:26:25 -0700744 for (size_t c = 0; c < configs.size(); ++c) {
745 memcpy(reply->writeInplace(sizeof(DisplayInfo)),
746 &configs[c], sizeof(DisplayInfo));
747 }
748 }
749 return NO_ERROR;
750 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700751 case GET_DISPLAY_STATS: {
752 CHECK_INTERFACE(ISurfaceComposer, data, reply);
753 DisplayStatInfo stats;
754 sp<IBinder> display = data.readStrongBinder();
755 status_t result = getDisplayStats(display, &stats);
756 reply->writeInt32(result);
757 if (result == NO_ERROR) {
758 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
759 &stats, sizeof(DisplayStatInfo));
760 }
761 return NO_ERROR;
762 }
Yiwei Zhang1d465af2018-08-21 15:15:42 -0700763 case GET_DISPLAY_VIEWPORT: {
764 CHECK_INTERFACE(ISurfaceComposer, data, reply);
765 Rect outViewport;
766 sp<IBinder> display = nullptr;
767 status_t result = data.readStrongBinder(&display);
768 if (result != NO_ERROR) {
769 ALOGE("getDisplayViewport failed to readStrongBinder: %d", result);
770 return result;
771 }
772 result = getDisplayViewport(display, &outViewport);
773 result = reply->writeInt32(result);
774 if (result == NO_ERROR) {
775 result = reply->write(outViewport);
776 if (result != NO_ERROR) {
777 ALOGE("getDisplayViewport failed to write: %d", result);
778 return result;
779 }
780 }
781 return NO_ERROR;
782 }
Dan Stoza7f7da322014-05-02 15:26:25 -0700783 case GET_ACTIVE_CONFIG: {
784 CHECK_INTERFACE(ISurfaceComposer, data, reply);
785 sp<IBinder> display = data.readStrongBinder();
786 int id = getActiveConfig(display);
787 reply->writeInt32(id);
788 return NO_ERROR;
789 }
790 case SET_ACTIVE_CONFIG: {
791 CHECK_INTERFACE(ISurfaceComposer, data, reply);
792 sp<IBinder> display = data.readStrongBinder();
793 int id = data.readInt32();
794 status_t result = setActiveConfig(display, id);
Mathias Agopianc666cae2012-07-25 18:56:13 -0700795 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700796 return NO_ERROR;
797 }
Michael Wright28f24d02016-07-12 13:30:53 -0700798 case GET_DISPLAY_COLOR_MODES: {
799 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Lina52f0292018-03-14 17:26:31 -0700800 Vector<ColorMode> colorModes;
Michael Wright28f24d02016-07-12 13:30:53 -0700801 sp<IBinder> display = nullptr;
802 status_t result = data.readStrongBinder(&display);
803 if (result != NO_ERROR) {
804 ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result);
805 return result;
806 }
807 result = getDisplayColorModes(display, &colorModes);
808 reply->writeInt32(result);
809 if (result == NO_ERROR) {
810 reply->writeUint32(static_cast<uint32_t>(colorModes.size()));
811 for (size_t i = 0; i < colorModes.size(); ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -0700812 reply->writeInt32(static_cast<int32_t>(colorModes[i]));
Michael Wright28f24d02016-07-12 13:30:53 -0700813 }
814 }
815 return NO_ERROR;
816 }
817 case GET_ACTIVE_COLOR_MODE: {
818 CHECK_INTERFACE(ISurfaceComposer, data, reply);
819 sp<IBinder> display = nullptr;
820 status_t result = data.readStrongBinder(&display);
821 if (result != NO_ERROR) {
822 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
823 return result;
824 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700825 ColorMode colorMode = getActiveColorMode(display);
Michael Wright28f24d02016-07-12 13:30:53 -0700826 result = reply->writeInt32(static_cast<int32_t>(colorMode));
827 return result;
828 }
829 case SET_ACTIVE_COLOR_MODE: {
830 CHECK_INTERFACE(ISurfaceComposer, data, reply);
831 sp<IBinder> display = nullptr;
832 status_t result = data.readStrongBinder(&display);
833 if (result != NO_ERROR) {
834 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
835 return result;
836 }
837 int32_t colorModeInt = 0;
838 result = data.readInt32(&colorModeInt);
839 if (result != NO_ERROR) {
840 ALOGE("setActiveColorMode failed to readInt32: %d", result);
841 return result;
842 }
843 result = setActiveColorMode(display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700844 static_cast<ColorMode>(colorModeInt));
Michael Wright28f24d02016-07-12 13:30:53 -0700845 result = reply->writeInt32(result);
846 return result;
847 }
Svetoslavd85084b2014-03-20 10:28:31 -0700848 case CLEAR_ANIMATION_FRAME_STATS: {
849 CHECK_INTERFACE(ISurfaceComposer, data, reply);
850 status_t result = clearAnimationFrameStats();
851 reply->writeInt32(result);
852 return NO_ERROR;
853 }
854 case GET_ANIMATION_FRAME_STATS: {
855 CHECK_INTERFACE(ISurfaceComposer, data, reply);
856 FrameStats stats;
857 status_t result = getAnimationFrameStats(&stats);
858 reply->write(stats);
859 reply->writeInt32(result);
860 return NO_ERROR;
861 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700862 case SET_POWER_MODE: {
863 CHECK_INTERFACE(ISurfaceComposer, data, reply);
864 sp<IBinder> display = data.readStrongBinder();
865 int32_t mode = data.readInt32();
866 setPowerMode(display, mode);
867 return NO_ERROR;
868 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700869 case GET_HDR_CAPABILITIES: {
870 CHECK_INTERFACE(ISurfaceComposer, data, reply);
871 sp<IBinder> display = nullptr;
872 status_t result = data.readStrongBinder(&display);
873 if (result != NO_ERROR) {
874 ALOGE("getHdrCapabilities failed to readStrongBinder: %d",
875 result);
876 return result;
877 }
878 HdrCapabilities capabilities;
879 result = getHdrCapabilities(display, &capabilities);
880 reply->writeInt32(result);
881 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800882 reply->write(capabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700883 }
884 return NO_ERROR;
885 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700886 case ENABLE_VSYNC_INJECTIONS: {
887 CHECK_INTERFACE(ISurfaceComposer, data, reply);
888 bool enable = false;
889 status_t result = data.readBool(&enable);
890 if (result != NO_ERROR) {
891 ALOGE("enableVSyncInjections failed to readBool: %d", result);
892 return result;
893 }
894 return enableVSyncInjections(enable);
895 }
896 case INJECT_VSYNC: {
897 CHECK_INTERFACE(ISurfaceComposer, data, reply);
898 int64_t when = 0;
899 status_t result = data.readInt64(&when);
900 if (result != NO_ERROR) {
901 ALOGE("enableVSyncInjections failed to readInt64: %d", result);
902 return result;
903 }
904 return injectVSync(when);
905 }
Kalle Raitaa099a242017-01-11 11:17:29 -0800906 case GET_LAYER_DEBUG_INFO: {
907 CHECK_INTERFACE(ISurfaceComposer, data, reply);
908 std::vector<LayerDebugInfo> outLayers;
909 status_t result = getLayerDebugInfo(&outLayers);
910 reply->writeInt32(result);
911 if (result == NO_ERROR)
912 {
913 result = reply->writeParcelableVector(outLayers);
914 }
915 return result;
916 }
Jesse Hall6c913be2013-08-08 12:15:49 -0700917 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700918 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -0700919 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800920 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800921}
922
923// ----------------------------------------------------------------------------
924
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800925};