blob: e230b3affbd195a135871cd126393e7ed3b5b73a [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,
106 Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
107 int32_t minLayerZ, int32_t maxLayerZ, bool useIdentityTransform,
Robert Carr9085ced2019-02-19 10:05:00 -0800108 ISurfaceComposer::Rotation rotation, bool captureSecureLayers) {
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800109 Parcel data, reply;
110 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
111 data.writeStrongBinder(display);
Dan Stozac1879002014-05-22 15:59:05 -0700112 data.write(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800113 data.writeUint32(reqWidth);
114 data.writeUint32(reqHeight);
Robert Carrae060832016-11-28 10:51:00 -0800115 data.writeInt32(minLayerZ);
116 data.writeInt32(maxLayerZ);
Dan Stozac7014012014-02-14 15:03:43 -0800117 data.writeInt32(static_cast<int32_t>(useIdentityTransform));
Riley Andrewsc3ebe662014-09-04 16:20:31 -0700118 data.writeInt32(static_cast<int32_t>(rotation));
Robert Carr9085ced2019-02-19 10:05:00 -0800119 data.writeInt32(static_cast<int32_t>(captureSecureLayers));
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000120 status_t err = remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply);
121
122 if (err != NO_ERROR) {
123 return err;
124 }
125
126 err = reply.readInt32();
127 if (err != NO_ERROR) {
128 return err;
129 }
130
131 *outBuffer = new GraphicBuffer();
132 reply.read(**outBuffer);
133 return err;
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800134 }
135
chaviwa76b2712017-09-20 12:02:26 -0700136 virtual status_t captureLayers(const sp<IBinder>& layerHandleBinder,
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000137 sp<GraphicBuffer>* outBuffer, const Rect& sourceCrop,
Robert Carr578038f2018-03-09 12:25:24 -0800138 float frameScale, bool childrenOnly) {
chaviwa76b2712017-09-20 12:02:26 -0700139 Parcel data, reply;
140 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
141 data.writeStrongBinder(layerHandleBinder);
chaviw7206d492017-11-10 16:16:12 -0800142 data.write(sourceCrop);
143 data.writeFloat(frameScale);
Robert Carr578038f2018-03-09 12:25:24 -0800144 data.writeBool(childrenOnly);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000145 status_t err = remote()->transact(BnSurfaceComposer::CAPTURE_LAYERS, data, &reply);
146
147 if (err != NO_ERROR) {
148 return err;
149 }
150
151 err = reply.readInt32();
152 if (err != NO_ERROR) {
153 return err;
154 }
155
156 *outBuffer = new GraphicBuffer();
157 reply.read(**outBuffer);
158
159 return err;
chaviwa76b2712017-09-20 12:02:26 -0700160 }
161
Jamie Gennis582270d2011-08-17 18:19:00 -0700162 virtual bool authenticateSurfaceTexture(
Andy McFadden2adaf042012-12-18 09:49:45 -0800163 const sp<IGraphicBufferProducer>& bufferProducer) const
Jamie Gennis134f0422011-03-08 12:18:54 -0800164 {
165 Parcel data, reply;
166 int err = NO_ERROR;
167 err = data.writeInterfaceToken(
168 ISurfaceComposer::getInterfaceDescriptor());
169 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000170 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis134f0422011-03-08 12:18:54 -0800171 "interface descriptor: %s (%d)", strerror(-err), -err);
172 return false;
173 }
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800174 err = data.writeStrongBinder(IInterface::asBinder(bufferProducer));
Jamie Gennis134f0422011-03-08 12:18:54 -0800175 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000176 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis582270d2011-08-17 18:19:00 -0700177 "strong binder to parcel: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800178 return false;
179 }
180 err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
181 &reply);
182 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000183 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700184 "performing transaction: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800185 return false;
186 }
187 int32_t result = 0;
188 err = reply.readInt32(&result);
189 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000190 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700191 "retrieving result: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800192 return false;
193 }
194 return result != 0;
195 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800196
Brian Anderson6b376712017-04-04 10:51:39 -0700197 virtual status_t getSupportedFrameTimestamps(
198 std::vector<FrameEvent>* outSupported) const {
199 if (!outSupported) {
200 return UNEXPECTED_NULL;
201 }
202 outSupported->clear();
203
204 Parcel data, reply;
205
206 status_t err = data.writeInterfaceToken(
207 ISurfaceComposer::getInterfaceDescriptor());
208 if (err != NO_ERROR) {
209 return err;
210 }
211
212 err = remote()->transact(
213 BnSurfaceComposer::GET_SUPPORTED_FRAME_TIMESTAMPS,
214 data, &reply);
215 if (err != NO_ERROR) {
216 return err;
217 }
218
219 int32_t result = 0;
220 err = reply.readInt32(&result);
221 if (err != NO_ERROR) {
222 return err;
223 }
224 if (result != NO_ERROR) {
225 return result;
226 }
227
228 std::vector<int32_t> supported;
229 err = reply.readInt32Vector(&supported);
230 if (err != NO_ERROR) {
231 return err;
232 }
233
234 outSupported->reserve(supported.size());
235 for (int32_t s : supported) {
236 outSupported->push_back(static_cast<FrameEvent>(s));
237 }
238 return NO_ERROR;
239 }
240
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700241 virtual sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource)
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800242 {
243 Parcel data, reply;
244 sp<IDisplayEventConnection> result;
245 int err = data.writeInterfaceToken(
246 ISurfaceComposer::getInterfaceDescriptor());
247 if (err != NO_ERROR) {
248 return result;
249 }
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700250 data.writeInt32(static_cast<int32_t>(vsyncSource));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800251 err = remote()->transact(
252 BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION,
253 data, &reply);
254 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000255 ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing "
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800256 "transaction: %s (%d)", strerror(-err), -err);
257 return result;
258 }
259 result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder());
260 return result;
261 }
Colin Cross8e533062012-06-07 13:17:52 -0700262
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700263 virtual sp<IBinder> createDisplay(const String8& displayName, bool secure)
Mathias Agopiane57f2922012-08-09 16:29:12 -0700264 {
265 Parcel data, reply;
266 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700267 data.writeString8(displayName);
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700268 data.writeInt32(secure ? 1 : 0);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700269 remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply);
270 return reply.readStrongBinder();
271 }
272
Jesse Hall6c913be2013-08-08 12:15:49 -0700273 virtual void destroyDisplay(const sp<IBinder>& display)
274 {
275 Parcel data, reply;
276 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
277 data.writeStrongBinder(display);
278 remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply);
279 }
280
Mathias Agopiane57f2922012-08-09 16:29:12 -0700281 virtual sp<IBinder> getBuiltInDisplay(int32_t id)
282 {
283 Parcel data, reply;
284 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
285 data.writeInt32(id);
286 remote()->transact(BnSurfaceComposer::GET_BUILT_IN_DISPLAY, data, &reply);
287 return reply.readStrongBinder();
288 }
289
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700290 virtual void setPowerMode(const sp<IBinder>& display, int mode)
Colin Cross8e533062012-06-07 13:17:52 -0700291 {
292 Parcel data, reply;
293 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700294 data.writeStrongBinder(display);
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700295 data.writeInt32(mode);
296 remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply);
Colin Cross8e533062012-06-07 13:17:52 -0700297 }
Mathias Agopian3094df32012-06-18 18:06:45 -0700298
Dan Stoza7f7da322014-05-02 15:26:25 -0700299 virtual status_t getDisplayConfigs(const sp<IBinder>& display,
300 Vector<DisplayInfo>* configs)
Mathias Agopianc666cae2012-07-25 18:56:13 -0700301 {
302 Parcel data, reply;
303 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700304 data.writeStrongBinder(display);
Dan Stoza7f7da322014-05-02 15:26:25 -0700305 remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply);
306 status_t result = reply.readInt32();
307 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -0800308 size_t numConfigs = reply.readUint32();
Dan Stoza7f7da322014-05-02 15:26:25 -0700309 configs->clear();
310 configs->resize(numConfigs);
311 for (size_t c = 0; c < numConfigs; ++c) {
312 memcpy(&(configs->editItemAt(c)),
313 reply.readInplace(sizeof(DisplayInfo)),
314 sizeof(DisplayInfo));
315 }
316 }
317 return result;
318 }
319
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700320 virtual status_t getDisplayStats(const sp<IBinder>& display,
321 DisplayStatInfo* stats)
322 {
323 Parcel data, reply;
324 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
325 data.writeStrongBinder(display);
326 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply);
327 status_t result = reply.readInt32();
328 if (result == NO_ERROR) {
329 memcpy(stats,
330 reply.readInplace(sizeof(DisplayStatInfo)),
331 sizeof(DisplayStatInfo));
332 }
333 return result;
334 }
335
Yiwei Zhang1d465af2018-08-21 15:15:42 -0700336 virtual status_t getDisplayViewport(const sp<IBinder>& display, Rect* outViewport) {
337 Parcel data, reply;
338 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
339 if (result != NO_ERROR) {
340 ALOGE("getDisplayViewport failed to writeInterfaceToken: %d", result);
341 return result;
342 }
343 result = data.writeStrongBinder(display);
344 if (result != NO_ERROR) {
345 ALOGE("getDisplayViewport failed to writeStrongBinder: %d", result);
346 return result;
347 }
348 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_VIEWPORT, data, &reply);
349 if (result != NO_ERROR) {
350 ALOGE("getDisplayViewport failed to transact: %d", result);
351 return result;
352 }
353 result = reply.readInt32();
354 if (result == NO_ERROR) {
355 result = reply.read(*outViewport);
356 if (result != NO_ERROR) {
357 ALOGE("getDisplayViewport failed to read: %d", result);
358 return result;
359 }
360 }
361 return result;
362 }
363
Dan Stoza7f7da322014-05-02 15:26:25 -0700364 virtual int getActiveConfig(const sp<IBinder>& display)
365 {
366 Parcel data, reply;
367 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
368 data.writeStrongBinder(display);
369 remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply);
370 return reply.readInt32();
371 }
372
373 virtual status_t setActiveConfig(const sp<IBinder>& display, int id)
374 {
375 Parcel data, reply;
376 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
377 data.writeStrongBinder(display);
378 data.writeInt32(id);
379 remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply);
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
Peiyong Lina52f0292018-03-14 17:26:31 -0700413 virtual ColorMode getActiveColorMode(const sp<IBinder>& display) {
Michael Wright28f24d02016-07-12 13:30:53 -0700414 Parcel data, reply;
415 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
416 if (result != NO_ERROR) {
417 ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700418 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700419 }
420 result = data.writeStrongBinder(display);
421 if (result != NO_ERROR) {
422 ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700423 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700424 }
425 result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply);
426 if (result != NO_ERROR) {
427 ALOGE("getActiveColorMode failed to transact: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700428 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700429 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700430 return static_cast<ColorMode>(reply.readInt32());
Michael Wright28f24d02016-07-12 13:30:53 -0700431 }
432
433 virtual status_t setActiveColorMode(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700434 ColorMode colorMode) {
Michael Wright28f24d02016-07-12 13:30:53 -0700435 Parcel data, reply;
436 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
437 if (result != NO_ERROR) {
438 ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result);
439 return result;
440 }
441 result = data.writeStrongBinder(display);
442 if (result != NO_ERROR) {
443 ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result);
444 return result;
445 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700446 result = data.writeInt32(static_cast<int32_t>(colorMode));
Michael Wright28f24d02016-07-12 13:30:53 -0700447 if (result != NO_ERROR) {
448 ALOGE("setActiveColorMode failed to writeInt32: %d", result);
449 return result;
450 }
451 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply);
452 if (result != NO_ERROR) {
453 ALOGE("setActiveColorMode failed to transact: %d", result);
454 return result;
455 }
456 return static_cast<status_t>(reply.readInt32());
457 }
458
Svetoslavd85084b2014-03-20 10:28:31 -0700459 virtual status_t clearAnimationFrameStats() {
460 Parcel data, reply;
461 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
462 remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply);
463 return reply.readInt32();
464 }
465
466 virtual status_t getAnimationFrameStats(FrameStats* outStats) const {
467 Parcel data, reply;
468 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
469 remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply);
470 reply.read(*outStats);
471 return reply.readInt32();
472 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700473
474 virtual status_t getHdrCapabilities(const sp<IBinder>& display,
475 HdrCapabilities* outCapabilities) const {
476 Parcel data, reply;
477 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
478 status_t result = data.writeStrongBinder(display);
479 if (result != NO_ERROR) {
480 ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result);
481 return result;
482 }
483 result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES,
484 data, &reply);
485 if (result != NO_ERROR) {
486 ALOGE("getHdrCapabilities failed to transact: %d", result);
487 return result;
488 }
489 result = reply.readInt32();
490 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800491 result = reply.read(*outCapabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700492 }
493 return result;
494 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700495
496 virtual status_t enableVSyncInjections(bool enable) {
497 Parcel data, reply;
498 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
499 if (result != NO_ERROR) {
500 ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result);
501 return result;
502 }
503 result = data.writeBool(enable);
504 if (result != NO_ERROR) {
505 ALOGE("enableVSyncInjections failed to writeBool: %d", result);
506 return result;
507 }
508 result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS,
509 data, &reply, TF_ONE_WAY);
510 if (result != NO_ERROR) {
511 ALOGE("enableVSyncInjections failed to transact: %d", result);
512 return result;
513 }
514 return result;
515 }
516
517 virtual status_t injectVSync(nsecs_t when) {
518 Parcel data, reply;
519 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
520 if (result != NO_ERROR) {
521 ALOGE("injectVSync failed to writeInterfaceToken: %d", result);
522 return result;
523 }
524 result = data.writeInt64(when);
525 if (result != NO_ERROR) {
526 ALOGE("injectVSync failed to writeInt64: %d", result);
527 return result;
528 }
529 result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply, TF_ONE_WAY);
530 if (result != NO_ERROR) {
531 ALOGE("injectVSync failed to transact: %d", result);
532 return result;
533 }
534 return result;
535 }
536
Kalle Raitaa099a242017-01-11 11:17:29 -0800537 virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const
538 {
539 if (!outLayers) {
540 return UNEXPECTED_NULL;
541 }
542
543 Parcel data, reply;
544
545 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
546 if (err != NO_ERROR) {
547 return err;
548 }
549
550 err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply);
551 if (err != NO_ERROR) {
552 return err;
553 }
554
555 int32_t result = 0;
556 err = reply.readInt32(&result);
557 if (err != NO_ERROR) {
558 return err;
559 }
560 if (result != NO_ERROR) {
561 return result;
562 }
563
564 outLayers->clear();
565 return reply.readParcelableVector(outLayers);
566 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800567};
568
Dan Stozad723bd72014-11-18 10:24:03 -0800569// Out-of-line virtual method definition to trigger vtable emission in this
570// translation unit (see clang warning -Wweak-vtables)
571BpSurfaceComposer::~BpSurfaceComposer() {}
572
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800573IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
574
575// ----------------------------------------------------------------------
576
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800577status_t BnSurfaceComposer::onTransact(
578 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
579{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800580 switch(code) {
581 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700582 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800583 sp<IBinder> b = IInterface::asBinder(createConnection());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800584 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -0700585 return NO_ERROR;
586 }
Robert Carr1db73f62016-12-21 12:58:51 -0800587 case CREATE_SCOPED_CONNECTION: {
588 CHECK_INTERFACE(ISurfaceComposer, data, reply);
589 sp<IGraphicBufferProducer> bufferProducer =
590 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
591 sp<IBinder> b = IInterface::asBinder(createScopedConnection(bufferProducer));
592 reply->writeStrongBinder(b);
593 return NO_ERROR;
594 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700595 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700596 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -0800597
598 size_t count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700599 if (count > data.dataSize()) {
600 return BAD_VALUE;
601 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700602 ComposerState s;
603 Vector<ComposerState> state;
604 state.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800605 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700606 if (s.read(data) == BAD_VALUE) {
607 return BAD_VALUE;
608 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700609 state.add(s);
610 }
Dan Stozad723bd72014-11-18 10:24:03 -0800611
612 count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700613 if (count > data.dataSize()) {
614 return BAD_VALUE;
615 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700616 DisplayState d;
617 Vector<DisplayState> displays;
618 displays.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800619 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700620 if (d.read(data) == BAD_VALUE) {
621 return BAD_VALUE;
622 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700623 displays.add(d);
624 }
Dan Stozad723bd72014-11-18 10:24:03 -0800625
626 uint32_t stateFlags = data.readUint32();
627 setTransactionState(state, displays, stateFlags);
Jesse Hall6c913be2013-08-08 12:15:49 -0700628 return NO_ERROR;
629 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800630 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700631 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800632 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -0700633 return NO_ERROR;
634 }
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800635 case CAPTURE_SCREEN: {
636 CHECK_INTERFACE(ISurfaceComposer, data, reply);
637 sp<IBinder> display = data.readStrongBinder();
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000638 sp<GraphicBuffer> outBuffer;
Pablo Ceballos60d69222015-08-07 14:47:20 -0700639 Rect sourceCrop(Rect::EMPTY_RECT);
Dan Stozac1879002014-05-22 15:59:05 -0700640 data.read(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800641 uint32_t reqWidth = data.readUint32();
642 uint32_t reqHeight = data.readUint32();
Robert Carrae060832016-11-28 10:51:00 -0800643 int32_t minLayerZ = data.readInt32();
644 int32_t maxLayerZ = data.readInt32();
Dan Stozac7014012014-02-14 15:03:43 -0800645 bool useIdentityTransform = static_cast<bool>(data.readInt32());
Dan Stozad723bd72014-11-18 10:24:03 -0800646 int32_t rotation = data.readInt32();
Robert Carr9085ced2019-02-19 10:05:00 -0800647 bool captureSecureLayers = static_cast<bool>(data.readInt32());
Dan Stozac7014012014-02-14 15:03:43 -0800648
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000649 status_t res = captureScreen(display, &outBuffer, sourceCrop, reqWidth, reqHeight,
650 minLayerZ, maxLayerZ, useIdentityTransform,
Robert Carr9085ced2019-02-19 10:05:00 -0800651 static_cast<ISurfaceComposer::Rotation>(rotation), captureSecureLayers);
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800652 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000653 if (res == NO_ERROR) {
654 reply->write(*outBuffer);
655 }
Jesse Hall6c913be2013-08-08 12:15:49 -0700656 return NO_ERROR;
657 }
chaviwa76b2712017-09-20 12:02:26 -0700658 case CAPTURE_LAYERS: {
659 CHECK_INTERFACE(ISurfaceComposer, data, reply);
660 sp<IBinder> layerHandleBinder = data.readStrongBinder();
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000661 sp<GraphicBuffer> outBuffer;
chaviw7206d492017-11-10 16:16:12 -0800662 Rect sourceCrop(Rect::EMPTY_RECT);
663 data.read(sourceCrop);
664 float frameScale = data.readFloat();
Robert Carr578038f2018-03-09 12:25:24 -0800665 bool childrenOnly = data.readBool();
chaviwa76b2712017-09-20 12:02:26 -0700666
Robert Carr578038f2018-03-09 12:25:24 -0800667 status_t res = captureLayers(layerHandleBinder, &outBuffer, sourceCrop, frameScale,
668 childrenOnly);
chaviwa76b2712017-09-20 12:02:26 -0700669 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000670 if (res == NO_ERROR) {
671 reply->write(*outBuffer);
672 }
chaviwa76b2712017-09-20 12:02:26 -0700673 return NO_ERROR;
674 }
Jamie Gennis134f0422011-03-08 12:18:54 -0800675 case AUTHENTICATE_SURFACE: {
676 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -0800677 sp<IGraphicBufferProducer> bufferProducer =
678 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
679 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -0800680 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700681 return NO_ERROR;
682 }
Brian Anderson6b376712017-04-04 10:51:39 -0700683 case GET_SUPPORTED_FRAME_TIMESTAMPS: {
684 CHECK_INTERFACE(ISurfaceComposer, data, reply);
685 std::vector<FrameEvent> supportedTimestamps;
686 status_t result = getSupportedFrameTimestamps(&supportedTimestamps);
687 status_t err = reply->writeInt32(result);
688 if (err != NO_ERROR) {
689 return err;
690 }
691 if (result != NO_ERROR) {
692 return result;
693 }
694
695 std::vector<int32_t> supported;
696 supported.reserve(supportedTimestamps.size());
697 for (FrameEvent s : supportedTimestamps) {
698 supported.push_back(static_cast<int32_t>(s));
699 }
700 return reply->writeInt32Vector(supported);
701 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800702 case CREATE_DISPLAY_EVENT_CONNECTION: {
703 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700704 sp<IDisplayEventConnection> connection(createDisplayEventConnection(
705 static_cast<ISurfaceComposer::VsyncSource>(data.readInt32())));
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800706 reply->writeStrongBinder(IInterface::asBinder(connection));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800707 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700708 }
Mathias Agopiane57f2922012-08-09 16:29:12 -0700709 case CREATE_DISPLAY: {
710 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700711 String8 displayName = data.readString8();
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700712 bool secure = bool(data.readInt32());
713 sp<IBinder> display(createDisplay(displayName, secure));
Mathias Agopiane57f2922012-08-09 16:29:12 -0700714 reply->writeStrongBinder(display);
715 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700716 }
717 case DESTROY_DISPLAY: {
718 CHECK_INTERFACE(ISurfaceComposer, data, reply);
719 sp<IBinder> display = data.readStrongBinder();
720 destroyDisplay(display);
721 return NO_ERROR;
722 }
Mathias Agopiane57f2922012-08-09 16:29:12 -0700723 case GET_BUILT_IN_DISPLAY: {
724 CHECK_INTERFACE(ISurfaceComposer, data, reply);
725 int32_t id = data.readInt32();
726 sp<IBinder> display(getBuiltInDisplay(id));
727 reply->writeStrongBinder(display);
728 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700729 }
Dan Stoza7f7da322014-05-02 15:26:25 -0700730 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -0700731 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stoza7f7da322014-05-02 15:26:25 -0700732 Vector<DisplayInfo> configs;
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700733 sp<IBinder> display = data.readStrongBinder();
Dan Stoza7f7da322014-05-02 15:26:25 -0700734 status_t result = getDisplayConfigs(display, &configs);
735 reply->writeInt32(result);
736 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -0800737 reply->writeUint32(static_cast<uint32_t>(configs.size()));
Dan Stoza7f7da322014-05-02 15:26:25 -0700738 for (size_t c = 0; c < configs.size(); ++c) {
739 memcpy(reply->writeInplace(sizeof(DisplayInfo)),
740 &configs[c], sizeof(DisplayInfo));
741 }
742 }
743 return NO_ERROR;
744 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700745 case GET_DISPLAY_STATS: {
746 CHECK_INTERFACE(ISurfaceComposer, data, reply);
747 DisplayStatInfo stats;
748 sp<IBinder> display = data.readStrongBinder();
749 status_t result = getDisplayStats(display, &stats);
750 reply->writeInt32(result);
751 if (result == NO_ERROR) {
752 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
753 &stats, sizeof(DisplayStatInfo));
754 }
755 return NO_ERROR;
756 }
Yiwei Zhang1d465af2018-08-21 15:15:42 -0700757 case GET_DISPLAY_VIEWPORT: {
758 CHECK_INTERFACE(ISurfaceComposer, data, reply);
759 Rect outViewport;
760 sp<IBinder> display = nullptr;
761 status_t result = data.readStrongBinder(&display);
762 if (result != NO_ERROR) {
763 ALOGE("getDisplayViewport failed to readStrongBinder: %d", result);
764 return result;
765 }
766 result = getDisplayViewport(display, &outViewport);
767 result = reply->writeInt32(result);
768 if (result == NO_ERROR) {
769 result = reply->write(outViewport);
770 if (result != NO_ERROR) {
771 ALOGE("getDisplayViewport failed to write: %d", result);
772 return result;
773 }
774 }
775 return NO_ERROR;
776 }
Dan Stoza7f7da322014-05-02 15:26:25 -0700777 case GET_ACTIVE_CONFIG: {
778 CHECK_INTERFACE(ISurfaceComposer, data, reply);
779 sp<IBinder> display = data.readStrongBinder();
780 int id = getActiveConfig(display);
781 reply->writeInt32(id);
782 return NO_ERROR;
783 }
784 case SET_ACTIVE_CONFIG: {
785 CHECK_INTERFACE(ISurfaceComposer, data, reply);
786 sp<IBinder> display = data.readStrongBinder();
787 int id = data.readInt32();
788 status_t result = setActiveConfig(display, id);
Mathias Agopianc666cae2012-07-25 18:56:13 -0700789 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700790 return NO_ERROR;
791 }
Michael Wright28f24d02016-07-12 13:30:53 -0700792 case GET_DISPLAY_COLOR_MODES: {
793 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Lina52f0292018-03-14 17:26:31 -0700794 Vector<ColorMode> colorModes;
Michael Wright28f24d02016-07-12 13:30:53 -0700795 sp<IBinder> display = nullptr;
796 status_t result = data.readStrongBinder(&display);
797 if (result != NO_ERROR) {
798 ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result);
799 return result;
800 }
801 result = getDisplayColorModes(display, &colorModes);
802 reply->writeInt32(result);
803 if (result == NO_ERROR) {
804 reply->writeUint32(static_cast<uint32_t>(colorModes.size()));
805 for (size_t i = 0; i < colorModes.size(); ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -0700806 reply->writeInt32(static_cast<int32_t>(colorModes[i]));
Michael Wright28f24d02016-07-12 13:30:53 -0700807 }
808 }
809 return NO_ERROR;
810 }
811 case GET_ACTIVE_COLOR_MODE: {
812 CHECK_INTERFACE(ISurfaceComposer, data, reply);
813 sp<IBinder> display = nullptr;
814 status_t result = data.readStrongBinder(&display);
815 if (result != NO_ERROR) {
816 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
817 return result;
818 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700819 ColorMode colorMode = getActiveColorMode(display);
Michael Wright28f24d02016-07-12 13:30:53 -0700820 result = reply->writeInt32(static_cast<int32_t>(colorMode));
821 return result;
822 }
823 case SET_ACTIVE_COLOR_MODE: {
824 CHECK_INTERFACE(ISurfaceComposer, data, reply);
825 sp<IBinder> display = nullptr;
826 status_t result = data.readStrongBinder(&display);
827 if (result != NO_ERROR) {
828 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
829 return result;
830 }
831 int32_t colorModeInt = 0;
832 result = data.readInt32(&colorModeInt);
833 if (result != NO_ERROR) {
834 ALOGE("setActiveColorMode failed to readInt32: %d", result);
835 return result;
836 }
837 result = setActiveColorMode(display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700838 static_cast<ColorMode>(colorModeInt));
Michael Wright28f24d02016-07-12 13:30:53 -0700839 result = reply->writeInt32(result);
840 return result;
841 }
Svetoslavd85084b2014-03-20 10:28:31 -0700842 case CLEAR_ANIMATION_FRAME_STATS: {
843 CHECK_INTERFACE(ISurfaceComposer, data, reply);
844 status_t result = clearAnimationFrameStats();
845 reply->writeInt32(result);
846 return NO_ERROR;
847 }
848 case GET_ANIMATION_FRAME_STATS: {
849 CHECK_INTERFACE(ISurfaceComposer, data, reply);
850 FrameStats stats;
851 status_t result = getAnimationFrameStats(&stats);
852 reply->write(stats);
853 reply->writeInt32(result);
854 return NO_ERROR;
855 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700856 case SET_POWER_MODE: {
857 CHECK_INTERFACE(ISurfaceComposer, data, reply);
858 sp<IBinder> display = data.readStrongBinder();
859 int32_t mode = data.readInt32();
860 setPowerMode(display, mode);
861 return NO_ERROR;
862 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700863 case GET_HDR_CAPABILITIES: {
864 CHECK_INTERFACE(ISurfaceComposer, data, reply);
865 sp<IBinder> display = nullptr;
866 status_t result = data.readStrongBinder(&display);
867 if (result != NO_ERROR) {
868 ALOGE("getHdrCapabilities failed to readStrongBinder: %d",
869 result);
870 return result;
871 }
872 HdrCapabilities capabilities;
873 result = getHdrCapabilities(display, &capabilities);
874 reply->writeInt32(result);
875 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800876 reply->write(capabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700877 }
878 return NO_ERROR;
879 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700880 case ENABLE_VSYNC_INJECTIONS: {
881 CHECK_INTERFACE(ISurfaceComposer, data, reply);
882 bool enable = false;
883 status_t result = data.readBool(&enable);
884 if (result != NO_ERROR) {
885 ALOGE("enableVSyncInjections failed to readBool: %d", result);
886 return result;
887 }
888 return enableVSyncInjections(enable);
889 }
890 case INJECT_VSYNC: {
891 CHECK_INTERFACE(ISurfaceComposer, data, reply);
892 int64_t when = 0;
893 status_t result = data.readInt64(&when);
894 if (result != NO_ERROR) {
895 ALOGE("enableVSyncInjections failed to readInt64: %d", result);
896 return result;
897 }
898 return injectVSync(when);
899 }
Kalle Raitaa099a242017-01-11 11:17:29 -0800900 case GET_LAYER_DEBUG_INFO: {
901 CHECK_INTERFACE(ISurfaceComposer, data, reply);
902 std::vector<LayerDebugInfo> outLayers;
903 status_t result = getLayerDebugInfo(&outLayers);
904 reply->writeInt32(result);
905 if (result == NO_ERROR)
906 {
907 result = reply->writeParcelableVector(outLayers);
908 }
909 return result;
910 }
Jesse Hall6c913be2013-08-08 12:15:49 -0700911 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700912 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -0700913 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800914 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800915}
916
917// ----------------------------------------------------------------------------
918
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800919};