blob: 8aaa4365cbed284bf5eb259c5028002a579f9b02 [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 }
Steven Moreland366eb422019-04-01 19:22:32 -0700511 result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS, data, &reply,
512 IBinder::FLAG_ONEWAY);
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700513 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 }
Steven Moreland366eb422019-04-01 19:22:32 -0700532 result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply,
533 IBinder::FLAG_ONEWAY);
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700534 if (result != NO_ERROR) {
535 ALOGE("injectVSync failed to transact: %d", result);
536 return result;
537 }
538 return result;
539 }
540
Kalle Raitaa099a242017-01-11 11:17:29 -0800541 virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const
542 {
543 if (!outLayers) {
544 return UNEXPECTED_NULL;
545 }
546
547 Parcel data, reply;
548
549 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
550 if (err != NO_ERROR) {
551 return err;
552 }
553
554 err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply);
555 if (err != NO_ERROR) {
556 return err;
557 }
558
559 int32_t result = 0;
560 err = reply.readInt32(&result);
561 if (err != NO_ERROR) {
562 return err;
563 }
564 if (result != NO_ERROR) {
565 return result;
566 }
567
568 outLayers->clear();
569 return reply.readParcelableVector(outLayers);
570 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800571};
572
Dan Stozad723bd72014-11-18 10:24:03 -0800573// Out-of-line virtual method definition to trigger vtable emission in this
574// translation unit (see clang warning -Wweak-vtables)
575BpSurfaceComposer::~BpSurfaceComposer() {}
576
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800577IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
578
579// ----------------------------------------------------------------------
580
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800581status_t BnSurfaceComposer::onTransact(
582 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
583{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800584 switch(code) {
585 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700586 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800587 sp<IBinder> b = IInterface::asBinder(createConnection());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800588 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -0700589 return NO_ERROR;
590 }
Robert Carr1db73f62016-12-21 12:58:51 -0800591 case CREATE_SCOPED_CONNECTION: {
592 CHECK_INTERFACE(ISurfaceComposer, data, reply);
593 sp<IGraphicBufferProducer> bufferProducer =
594 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
595 sp<IBinder> b = IInterface::asBinder(createScopedConnection(bufferProducer));
596 reply->writeStrongBinder(b);
597 return NO_ERROR;
598 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700599 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700600 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -0800601
602 size_t count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700603 if (count > data.dataSize()) {
604 return BAD_VALUE;
605 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700606 ComposerState s;
607 Vector<ComposerState> state;
608 state.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800609 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700610 if (s.read(data) == BAD_VALUE) {
611 return BAD_VALUE;
612 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700613 state.add(s);
614 }
Dan Stozad723bd72014-11-18 10:24:03 -0800615
616 count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700617 if (count > data.dataSize()) {
618 return BAD_VALUE;
619 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700620 DisplayState d;
621 Vector<DisplayState> displays;
622 displays.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800623 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700624 if (d.read(data) == BAD_VALUE) {
625 return BAD_VALUE;
626 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700627 displays.add(d);
628 }
Dan Stozad723bd72014-11-18 10:24:03 -0800629
630 uint32_t stateFlags = data.readUint32();
631 setTransactionState(state, displays, stateFlags);
Jesse Hall6c913be2013-08-08 12:15:49 -0700632 return NO_ERROR;
633 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800634 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700635 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800636 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -0700637 return NO_ERROR;
638 }
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800639 case CAPTURE_SCREEN: {
640 CHECK_INTERFACE(ISurfaceComposer, data, reply);
641 sp<IBinder> display = data.readStrongBinder();
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000642 sp<GraphicBuffer> outBuffer;
Pablo Ceballos60d69222015-08-07 14:47:20 -0700643 Rect sourceCrop(Rect::EMPTY_RECT);
Dan Stozac1879002014-05-22 15:59:05 -0700644 data.read(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800645 uint32_t reqWidth = data.readUint32();
646 uint32_t reqHeight = data.readUint32();
Robert Carrae060832016-11-28 10:51:00 -0800647 int32_t minLayerZ = data.readInt32();
648 int32_t maxLayerZ = data.readInt32();
Dan Stozac7014012014-02-14 15:03:43 -0800649 bool useIdentityTransform = static_cast<bool>(data.readInt32());
Dan Stozad723bd72014-11-18 10:24:03 -0800650 int32_t rotation = data.readInt32();
Robert Carr9085ced2019-02-19 10:05:00 -0800651 bool captureSecureLayers = static_cast<bool>(data.readInt32());
Dan Stozac7014012014-02-14 15:03:43 -0800652
Robert Carr0283c732019-04-02 16:32:58 -0700653 bool capturedSecureLayers = false;
654 status_t res = captureScreen(display, &outBuffer, capturedSecureLayers, sourceCrop, reqWidth,
655 reqHeight, minLayerZ, maxLayerZ, useIdentityTransform,
Robert Carr9085ced2019-02-19 10:05:00 -0800656 static_cast<ISurfaceComposer::Rotation>(rotation), captureSecureLayers);
Robert Carr0283c732019-04-02 16:32:58 -0700657
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800658 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000659 if (res == NO_ERROR) {
660 reply->write(*outBuffer);
Robert Carr0283c732019-04-02 16:32:58 -0700661 reply->writeBool(capturedSecureLayers);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000662 }
Jesse Hall6c913be2013-08-08 12:15:49 -0700663 return NO_ERROR;
664 }
chaviwa76b2712017-09-20 12:02:26 -0700665 case CAPTURE_LAYERS: {
666 CHECK_INTERFACE(ISurfaceComposer, data, reply);
667 sp<IBinder> layerHandleBinder = data.readStrongBinder();
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000668 sp<GraphicBuffer> outBuffer;
chaviw7206d492017-11-10 16:16:12 -0800669 Rect sourceCrop(Rect::EMPTY_RECT);
670 data.read(sourceCrop);
671 float frameScale = data.readFloat();
Robert Carr578038f2018-03-09 12:25:24 -0800672 bool childrenOnly = data.readBool();
chaviwa76b2712017-09-20 12:02:26 -0700673
Robert Carr578038f2018-03-09 12:25:24 -0800674 status_t res = captureLayers(layerHandleBinder, &outBuffer, sourceCrop, frameScale,
675 childrenOnly);
chaviwa76b2712017-09-20 12:02:26 -0700676 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000677 if (res == NO_ERROR) {
678 reply->write(*outBuffer);
679 }
chaviwa76b2712017-09-20 12:02:26 -0700680 return NO_ERROR;
681 }
Jamie Gennis134f0422011-03-08 12:18:54 -0800682 case AUTHENTICATE_SURFACE: {
683 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -0800684 sp<IGraphicBufferProducer> bufferProducer =
685 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
686 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -0800687 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700688 return NO_ERROR;
689 }
Brian Anderson6b376712017-04-04 10:51:39 -0700690 case GET_SUPPORTED_FRAME_TIMESTAMPS: {
691 CHECK_INTERFACE(ISurfaceComposer, data, reply);
692 std::vector<FrameEvent> supportedTimestamps;
693 status_t result = getSupportedFrameTimestamps(&supportedTimestamps);
694 status_t err = reply->writeInt32(result);
695 if (err != NO_ERROR) {
696 return err;
697 }
698 if (result != NO_ERROR) {
699 return result;
700 }
701
702 std::vector<int32_t> supported;
703 supported.reserve(supportedTimestamps.size());
704 for (FrameEvent s : supportedTimestamps) {
705 supported.push_back(static_cast<int32_t>(s));
706 }
707 return reply->writeInt32Vector(supported);
708 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800709 case CREATE_DISPLAY_EVENT_CONNECTION: {
710 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700711 sp<IDisplayEventConnection> connection(createDisplayEventConnection(
712 static_cast<ISurfaceComposer::VsyncSource>(data.readInt32())));
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800713 reply->writeStrongBinder(IInterface::asBinder(connection));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800714 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700715 }
Mathias Agopiane57f2922012-08-09 16:29:12 -0700716 case CREATE_DISPLAY: {
717 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700718 String8 displayName = data.readString8();
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700719 bool secure = bool(data.readInt32());
720 sp<IBinder> display(createDisplay(displayName, secure));
Mathias Agopiane57f2922012-08-09 16:29:12 -0700721 reply->writeStrongBinder(display);
722 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700723 }
724 case DESTROY_DISPLAY: {
725 CHECK_INTERFACE(ISurfaceComposer, data, reply);
726 sp<IBinder> display = data.readStrongBinder();
727 destroyDisplay(display);
728 return NO_ERROR;
729 }
Mathias Agopiane57f2922012-08-09 16:29:12 -0700730 case GET_BUILT_IN_DISPLAY: {
731 CHECK_INTERFACE(ISurfaceComposer, data, reply);
732 int32_t id = data.readInt32();
733 sp<IBinder> display(getBuiltInDisplay(id));
734 reply->writeStrongBinder(display);
735 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700736 }
Dan Stoza7f7da322014-05-02 15:26:25 -0700737 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -0700738 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stoza7f7da322014-05-02 15:26:25 -0700739 Vector<DisplayInfo> configs;
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700740 sp<IBinder> display = data.readStrongBinder();
Dan Stoza7f7da322014-05-02 15:26:25 -0700741 status_t result = getDisplayConfigs(display, &configs);
742 reply->writeInt32(result);
743 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -0800744 reply->writeUint32(static_cast<uint32_t>(configs.size()));
Dan Stoza7f7da322014-05-02 15:26:25 -0700745 for (size_t c = 0; c < configs.size(); ++c) {
746 memcpy(reply->writeInplace(sizeof(DisplayInfo)),
747 &configs[c], sizeof(DisplayInfo));
748 }
749 }
750 return NO_ERROR;
751 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700752 case GET_DISPLAY_STATS: {
753 CHECK_INTERFACE(ISurfaceComposer, data, reply);
754 DisplayStatInfo stats;
755 sp<IBinder> display = data.readStrongBinder();
756 status_t result = getDisplayStats(display, &stats);
757 reply->writeInt32(result);
758 if (result == NO_ERROR) {
759 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
760 &stats, sizeof(DisplayStatInfo));
761 }
762 return NO_ERROR;
763 }
Yiwei Zhang1d465af2018-08-21 15:15:42 -0700764 case GET_DISPLAY_VIEWPORT: {
765 CHECK_INTERFACE(ISurfaceComposer, data, reply);
766 Rect outViewport;
767 sp<IBinder> display = nullptr;
768 status_t result = data.readStrongBinder(&display);
769 if (result != NO_ERROR) {
770 ALOGE("getDisplayViewport failed to readStrongBinder: %d", result);
771 return result;
772 }
773 result = getDisplayViewport(display, &outViewport);
774 result = reply->writeInt32(result);
775 if (result == NO_ERROR) {
776 result = reply->write(outViewport);
777 if (result != NO_ERROR) {
778 ALOGE("getDisplayViewport failed to write: %d", result);
779 return result;
780 }
781 }
782 return NO_ERROR;
783 }
Dan Stoza7f7da322014-05-02 15:26:25 -0700784 case GET_ACTIVE_CONFIG: {
785 CHECK_INTERFACE(ISurfaceComposer, data, reply);
786 sp<IBinder> display = data.readStrongBinder();
787 int id = getActiveConfig(display);
788 reply->writeInt32(id);
789 return NO_ERROR;
790 }
791 case SET_ACTIVE_CONFIG: {
792 CHECK_INTERFACE(ISurfaceComposer, data, reply);
793 sp<IBinder> display = data.readStrongBinder();
794 int id = data.readInt32();
795 status_t result = setActiveConfig(display, id);
Mathias Agopianc666cae2012-07-25 18:56:13 -0700796 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700797 return NO_ERROR;
798 }
Michael Wright28f24d02016-07-12 13:30:53 -0700799 case GET_DISPLAY_COLOR_MODES: {
800 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Lina52f0292018-03-14 17:26:31 -0700801 Vector<ColorMode> colorModes;
Michael Wright28f24d02016-07-12 13:30:53 -0700802 sp<IBinder> display = nullptr;
803 status_t result = data.readStrongBinder(&display);
804 if (result != NO_ERROR) {
805 ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result);
806 return result;
807 }
808 result = getDisplayColorModes(display, &colorModes);
809 reply->writeInt32(result);
810 if (result == NO_ERROR) {
811 reply->writeUint32(static_cast<uint32_t>(colorModes.size()));
812 for (size_t i = 0; i < colorModes.size(); ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -0700813 reply->writeInt32(static_cast<int32_t>(colorModes[i]));
Michael Wright28f24d02016-07-12 13:30:53 -0700814 }
815 }
816 return NO_ERROR;
817 }
818 case GET_ACTIVE_COLOR_MODE: {
819 CHECK_INTERFACE(ISurfaceComposer, data, reply);
820 sp<IBinder> display = nullptr;
821 status_t result = data.readStrongBinder(&display);
822 if (result != NO_ERROR) {
823 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
824 return result;
825 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700826 ColorMode colorMode = getActiveColorMode(display);
Michael Wright28f24d02016-07-12 13:30:53 -0700827 result = reply->writeInt32(static_cast<int32_t>(colorMode));
828 return result;
829 }
830 case SET_ACTIVE_COLOR_MODE: {
831 CHECK_INTERFACE(ISurfaceComposer, data, reply);
832 sp<IBinder> display = nullptr;
833 status_t result = data.readStrongBinder(&display);
834 if (result != NO_ERROR) {
835 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
836 return result;
837 }
838 int32_t colorModeInt = 0;
839 result = data.readInt32(&colorModeInt);
840 if (result != NO_ERROR) {
841 ALOGE("setActiveColorMode failed to readInt32: %d", result);
842 return result;
843 }
844 result = setActiveColorMode(display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700845 static_cast<ColorMode>(colorModeInt));
Michael Wright28f24d02016-07-12 13:30:53 -0700846 result = reply->writeInt32(result);
847 return result;
848 }
Svetoslavd85084b2014-03-20 10:28:31 -0700849 case CLEAR_ANIMATION_FRAME_STATS: {
850 CHECK_INTERFACE(ISurfaceComposer, data, reply);
851 status_t result = clearAnimationFrameStats();
852 reply->writeInt32(result);
853 return NO_ERROR;
854 }
855 case GET_ANIMATION_FRAME_STATS: {
856 CHECK_INTERFACE(ISurfaceComposer, data, reply);
857 FrameStats stats;
858 status_t result = getAnimationFrameStats(&stats);
859 reply->write(stats);
860 reply->writeInt32(result);
861 return NO_ERROR;
862 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700863 case SET_POWER_MODE: {
864 CHECK_INTERFACE(ISurfaceComposer, data, reply);
865 sp<IBinder> display = data.readStrongBinder();
866 int32_t mode = data.readInt32();
867 setPowerMode(display, mode);
868 return NO_ERROR;
869 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700870 case GET_HDR_CAPABILITIES: {
871 CHECK_INTERFACE(ISurfaceComposer, data, reply);
872 sp<IBinder> display = nullptr;
873 status_t result = data.readStrongBinder(&display);
874 if (result != NO_ERROR) {
875 ALOGE("getHdrCapabilities failed to readStrongBinder: %d",
876 result);
877 return result;
878 }
879 HdrCapabilities capabilities;
880 result = getHdrCapabilities(display, &capabilities);
881 reply->writeInt32(result);
882 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800883 reply->write(capabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700884 }
885 return NO_ERROR;
886 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700887 case ENABLE_VSYNC_INJECTIONS: {
888 CHECK_INTERFACE(ISurfaceComposer, data, reply);
889 bool enable = false;
890 status_t result = data.readBool(&enable);
891 if (result != NO_ERROR) {
892 ALOGE("enableVSyncInjections failed to readBool: %d", result);
893 return result;
894 }
895 return enableVSyncInjections(enable);
896 }
897 case INJECT_VSYNC: {
898 CHECK_INTERFACE(ISurfaceComposer, data, reply);
899 int64_t when = 0;
900 status_t result = data.readInt64(&when);
901 if (result != NO_ERROR) {
902 ALOGE("enableVSyncInjections failed to readInt64: %d", result);
903 return result;
904 }
905 return injectVSync(when);
906 }
Kalle Raitaa099a242017-01-11 11:17:29 -0800907 case GET_LAYER_DEBUG_INFO: {
908 CHECK_INTERFACE(ISurfaceComposer, data, reply);
909 std::vector<LayerDebugInfo> outLayers;
910 status_t result = getLayerDebugInfo(&outLayers);
911 reply->writeInt32(result);
912 if (result == NO_ERROR)
913 {
914 result = reply->writeParcelableVector(outLayers);
915 }
916 return result;
917 }
Jesse Hall6c913be2013-08-08 12:15:49 -0700918 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700919 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -0700920 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800921 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800922}
923
924// ----------------------------------------------------------------------------
925
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800926};