blob: 7f9668fc2cb7570dd3edffd4e930d17978d57b02 [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 Lin9f034472018-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,
108 ISurfaceComposer::Rotation rotation) {
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));
Ana Krulec2d41e422018-07-26 12:07:43 -0700119 status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply);
120 if (result != NO_ERROR) {
121 ALOGE("captureScreen failed to transact: %d", result);
122 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000123 }
Ana Krulec2d41e422018-07-26 12:07:43 -0700124 result = reply.readInt32();
125 if (result != NO_ERROR) {
126 ALOGE("captureScreen failed to readInt32: %d", result);
127 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000128 }
129
130 *outBuffer = new GraphicBuffer();
131 reply.read(**outBuffer);
Ana Krulec2d41e422018-07-26 12:07:43 -0700132 return result;
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800133 }
134
chaviwa76b2712017-09-20 12:02:26 -0700135 virtual status_t captureLayers(const sp<IBinder>& layerHandleBinder,
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000136 sp<GraphicBuffer>* outBuffer, const Rect& sourceCrop,
Robert Carr578038f2018-03-09 12:25:24 -0800137 float frameScale, bool childrenOnly) {
chaviwa76b2712017-09-20 12:02:26 -0700138 Parcel data, reply;
139 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
140 data.writeStrongBinder(layerHandleBinder);
chaviw7206d492017-11-10 16:16:12 -0800141 data.write(sourceCrop);
142 data.writeFloat(frameScale);
Robert Carr578038f2018-03-09 12:25:24 -0800143 data.writeBool(childrenOnly);
Ana Krulec2d41e422018-07-26 12:07:43 -0700144 status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_LAYERS, data, &reply);
145 if (result != NO_ERROR) {
146 ALOGE("captureLayers failed to transact: %d", result);
147 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000148 }
Ana Krulec2d41e422018-07-26 12:07:43 -0700149 result = reply.readInt32();
150 if (result != NO_ERROR) {
151 ALOGE("captureLayers failed to readInt32: %d", result);
152 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000153 }
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000154 *outBuffer = new GraphicBuffer();
155 reply.read(**outBuffer);
156
Ana Krulec2d41e422018-07-26 12:07:43 -0700157 return result;
chaviwa76b2712017-09-20 12:02:26 -0700158 }
159
Jamie Gennis582270d2011-08-17 18:19:00 -0700160 virtual bool authenticateSurfaceTexture(
Andy McFadden2adaf042012-12-18 09:49:45 -0800161 const sp<IGraphicBufferProducer>& bufferProducer) const
Jamie Gennis134f0422011-03-08 12:18:54 -0800162 {
163 Parcel data, reply;
164 int err = NO_ERROR;
165 err = data.writeInterfaceToken(
166 ISurfaceComposer::getInterfaceDescriptor());
167 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000168 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis134f0422011-03-08 12:18:54 -0800169 "interface descriptor: %s (%d)", strerror(-err), -err);
170 return false;
171 }
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800172 err = data.writeStrongBinder(IInterface::asBinder(bufferProducer));
Jamie Gennis134f0422011-03-08 12:18:54 -0800173 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000174 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis582270d2011-08-17 18:19:00 -0700175 "strong binder to parcel: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800176 return false;
177 }
178 err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
179 &reply);
180 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000181 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700182 "performing transaction: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800183 return false;
184 }
185 int32_t result = 0;
186 err = reply.readInt32(&result);
187 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000188 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700189 "retrieving result: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800190 return false;
191 }
192 return result != 0;
193 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800194
Brian Anderson6b376712017-04-04 10:51:39 -0700195 virtual status_t getSupportedFrameTimestamps(
196 std::vector<FrameEvent>* outSupported) const {
197 if (!outSupported) {
198 return UNEXPECTED_NULL;
199 }
200 outSupported->clear();
201
202 Parcel data, reply;
203
204 status_t err = data.writeInterfaceToken(
205 ISurfaceComposer::getInterfaceDescriptor());
206 if (err != NO_ERROR) {
207 return err;
208 }
209
210 err = remote()->transact(
211 BnSurfaceComposer::GET_SUPPORTED_FRAME_TIMESTAMPS,
212 data, &reply);
213 if (err != NO_ERROR) {
214 return err;
215 }
216
217 int32_t result = 0;
218 err = reply.readInt32(&result);
219 if (err != NO_ERROR) {
220 return err;
221 }
222 if (result != NO_ERROR) {
223 return result;
224 }
225
226 std::vector<int32_t> supported;
227 err = reply.readInt32Vector(&supported);
228 if (err != NO_ERROR) {
229 return err;
230 }
231
232 outSupported->reserve(supported.size());
233 for (int32_t s : supported) {
234 outSupported->push_back(static_cast<FrameEvent>(s));
235 }
236 return NO_ERROR;
237 }
238
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700239 virtual sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource)
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800240 {
241 Parcel data, reply;
242 sp<IDisplayEventConnection> result;
243 int err = data.writeInterfaceToken(
244 ISurfaceComposer::getInterfaceDescriptor());
245 if (err != NO_ERROR) {
246 return result;
247 }
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700248 data.writeInt32(static_cast<int32_t>(vsyncSource));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800249 err = remote()->transact(
250 BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION,
251 data, &reply);
252 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000253 ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing "
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800254 "transaction: %s (%d)", strerror(-err), -err);
255 return result;
256 }
257 result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder());
258 return result;
259 }
Colin Cross8e533062012-06-07 13:17:52 -0700260
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700261 virtual sp<IBinder> createDisplay(const String8& displayName, bool secure)
Mathias Agopiane57f2922012-08-09 16:29:12 -0700262 {
263 Parcel data, reply;
264 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700265 data.writeString8(displayName);
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700266 data.writeInt32(secure ? 1 : 0);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700267 remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply);
268 return reply.readStrongBinder();
269 }
270
Jesse Hall6c913be2013-08-08 12:15:49 -0700271 virtual void destroyDisplay(const sp<IBinder>& display)
272 {
273 Parcel data, reply;
274 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
275 data.writeStrongBinder(display);
276 remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply);
277 }
278
Mathias Agopiane57f2922012-08-09 16:29:12 -0700279 virtual sp<IBinder> getBuiltInDisplay(int32_t id)
280 {
281 Parcel data, reply;
282 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
283 data.writeInt32(id);
284 remote()->transact(BnSurfaceComposer::GET_BUILT_IN_DISPLAY, data, &reply);
285 return reply.readStrongBinder();
286 }
287
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700288 virtual void setPowerMode(const sp<IBinder>& display, int mode)
Colin Cross8e533062012-06-07 13:17:52 -0700289 {
290 Parcel data, reply;
291 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700292 data.writeStrongBinder(display);
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700293 data.writeInt32(mode);
294 remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply);
Colin Cross8e533062012-06-07 13:17:52 -0700295 }
Mathias Agopian3094df32012-06-18 18:06:45 -0700296
Dan Stoza7f7da322014-05-02 15:26:25 -0700297 virtual status_t getDisplayConfigs(const sp<IBinder>& display,
298 Vector<DisplayInfo>* configs)
Mathias Agopianc666cae2012-07-25 18:56:13 -0700299 {
300 Parcel data, reply;
301 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700302 data.writeStrongBinder(display);
Dan Stoza7f7da322014-05-02 15:26:25 -0700303 remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply);
304 status_t result = reply.readInt32();
305 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -0800306 size_t numConfigs = reply.readUint32();
Dan Stoza7f7da322014-05-02 15:26:25 -0700307 configs->clear();
308 configs->resize(numConfigs);
309 for (size_t c = 0; c < numConfigs; ++c) {
310 memcpy(&(configs->editItemAt(c)),
311 reply.readInplace(sizeof(DisplayInfo)),
312 sizeof(DisplayInfo));
313 }
314 }
315 return result;
316 }
317
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700318 virtual status_t getDisplayStats(const sp<IBinder>& display,
319 DisplayStatInfo* stats)
320 {
321 Parcel data, reply;
322 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
323 data.writeStrongBinder(display);
324 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply);
325 status_t result = reply.readInt32();
326 if (result == NO_ERROR) {
327 memcpy(stats,
328 reply.readInplace(sizeof(DisplayStatInfo)),
329 sizeof(DisplayStatInfo));
330 }
331 return result;
332 }
333
Dan Stoza7f7da322014-05-02 15:26:25 -0700334 virtual int getActiveConfig(const sp<IBinder>& display)
335 {
336 Parcel data, reply;
337 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
338 data.writeStrongBinder(display);
339 remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply);
340 return reply.readInt32();
341 }
342
343 virtual status_t setActiveConfig(const sp<IBinder>& display, int id)
344 {
345 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700346 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
347 if (result != NO_ERROR) {
348 ALOGE("setActiveConfig failed to writeInterfaceToken: %d", result);
349 return result;
350 }
351 result = data.writeStrongBinder(display);
352 if (result != NO_ERROR) {
353 ALOGE("setActiveConfig failed to writeStrongBinder: %d", result);
354 return result;
355 }
356 result = data.writeInt32(id);
357 if (result != NO_ERROR) {
358 ALOGE("setActiveConfig failed to writeInt32: %d", result);
359 return result;
360 }
361 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply);
362 if (result != NO_ERROR) {
363 ALOGE("setActiveConfig failed to transact: %d", result);
364 return result;
365 }
Mathias Agopianc666cae2012-07-25 18:56:13 -0700366 return reply.readInt32();
367 }
Svetoslavd85084b2014-03-20 10:28:31 -0700368
Michael Wright28f24d02016-07-12 13:30:53 -0700369 virtual status_t getDisplayColorModes(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700370 Vector<ColorMode>* outColorModes) {
Michael Wright28f24d02016-07-12 13:30:53 -0700371 Parcel data, reply;
372 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
373 if (result != NO_ERROR) {
374 ALOGE("getDisplayColorModes failed to writeInterfaceToken: %d", result);
375 return result;
376 }
377 result = data.writeStrongBinder(display);
378 if (result != NO_ERROR) {
379 ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result);
380 return result;
381 }
382 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply);
383 if (result != NO_ERROR) {
384 ALOGE("getDisplayColorModes failed to transact: %d", result);
385 return result;
386 }
387 result = static_cast<status_t>(reply.readInt32());
388 if (result == NO_ERROR) {
389 size_t numModes = reply.readUint32();
390 outColorModes->clear();
391 outColorModes->resize(numModes);
392 for (size_t i = 0; i < numModes; ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -0700393 outColorModes->replaceAt(static_cast<ColorMode>(reply.readInt32()), i);
Michael Wright28f24d02016-07-12 13:30:53 -0700394 }
395 }
396 return result;
397 }
398
Peiyong Lina52f0292018-03-14 17:26:31 -0700399 virtual ColorMode getActiveColorMode(const sp<IBinder>& display) {
Michael Wright28f24d02016-07-12 13:30:53 -0700400 Parcel data, reply;
401 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
402 if (result != NO_ERROR) {
403 ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700404 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700405 }
406 result = data.writeStrongBinder(display);
407 if (result != NO_ERROR) {
408 ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700409 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700410 }
411 result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply);
412 if (result != NO_ERROR) {
413 ALOGE("getActiveColorMode failed to transact: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700414 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700415 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700416 return static_cast<ColorMode>(reply.readInt32());
Michael Wright28f24d02016-07-12 13:30:53 -0700417 }
418
419 virtual status_t setActiveColorMode(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700420 ColorMode colorMode) {
Michael Wright28f24d02016-07-12 13:30:53 -0700421 Parcel data, reply;
422 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
423 if (result != NO_ERROR) {
424 ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result);
425 return result;
426 }
427 result = data.writeStrongBinder(display);
428 if (result != NO_ERROR) {
429 ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result);
430 return result;
431 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700432 result = data.writeInt32(static_cast<int32_t>(colorMode));
Michael Wright28f24d02016-07-12 13:30:53 -0700433 if (result != NO_ERROR) {
434 ALOGE("setActiveColorMode failed to writeInt32: %d", result);
435 return result;
436 }
437 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply);
438 if (result != NO_ERROR) {
439 ALOGE("setActiveColorMode failed to transact: %d", result);
440 return result;
441 }
442 return static_cast<status_t>(reply.readInt32());
443 }
444
Svetoslavd85084b2014-03-20 10:28:31 -0700445 virtual status_t clearAnimationFrameStats() {
446 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700447 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
448 if (result != NO_ERROR) {
449 ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result);
450 return result;
451 }
452 result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply);
453 if (result != NO_ERROR) {
454 ALOGE("clearAnimationFrameStats failed to transact: %d", result);
455 return result;
456 }
Svetoslavd85084b2014-03-20 10:28:31 -0700457 return reply.readInt32();
458 }
459
460 virtual status_t getAnimationFrameStats(FrameStats* outStats) const {
461 Parcel data, reply;
462 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
463 remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply);
464 reply.read(*outStats);
465 return reply.readInt32();
466 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700467
468 virtual status_t getHdrCapabilities(const sp<IBinder>& display,
469 HdrCapabilities* outCapabilities) const {
470 Parcel data, reply;
471 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
472 status_t result = data.writeStrongBinder(display);
473 if (result != NO_ERROR) {
474 ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result);
475 return result;
476 }
477 result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES,
478 data, &reply);
479 if (result != NO_ERROR) {
480 ALOGE("getHdrCapabilities failed to transact: %d", result);
481 return result;
482 }
483 result = reply.readInt32();
484 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800485 result = reply.read(*outCapabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700486 }
487 return result;
488 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700489
490 virtual status_t enableVSyncInjections(bool enable) {
491 Parcel data, reply;
492 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
493 if (result != NO_ERROR) {
494 ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result);
495 return result;
496 }
497 result = data.writeBool(enable);
498 if (result != NO_ERROR) {
499 ALOGE("enableVSyncInjections failed to writeBool: %d", result);
500 return result;
501 }
502 result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS,
503 data, &reply, TF_ONE_WAY);
504 if (result != NO_ERROR) {
505 ALOGE("enableVSyncInjections failed to transact: %d", result);
506 return result;
507 }
508 return result;
509 }
510
511 virtual status_t injectVSync(nsecs_t when) {
512 Parcel data, reply;
513 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
514 if (result != NO_ERROR) {
515 ALOGE("injectVSync failed to writeInterfaceToken: %d", result);
516 return result;
517 }
518 result = data.writeInt64(when);
519 if (result != NO_ERROR) {
520 ALOGE("injectVSync failed to writeInt64: %d", result);
521 return result;
522 }
523 result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply, TF_ONE_WAY);
524 if (result != NO_ERROR) {
525 ALOGE("injectVSync failed to transact: %d", result);
526 return result;
527 }
528 return result;
529 }
530
Kalle Raitaa099a242017-01-11 11:17:29 -0800531 virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const
532 {
533 if (!outLayers) {
534 return UNEXPECTED_NULL;
535 }
536
537 Parcel data, reply;
538
539 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
540 if (err != NO_ERROR) {
541 return err;
542 }
543
544 err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply);
545 if (err != NO_ERROR) {
546 return err;
547 }
548
549 int32_t result = 0;
550 err = reply.readInt32(&result);
551 if (err != NO_ERROR) {
552 return err;
553 }
554 if (result != NO_ERROR) {
555 return result;
556 }
557
558 outLayers->clear();
559 return reply.readParcelableVector(outLayers);
560 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800561};
562
Dan Stozad723bd72014-11-18 10:24:03 -0800563// Out-of-line virtual method definition to trigger vtable emission in this
564// translation unit (see clang warning -Wweak-vtables)
565BpSurfaceComposer::~BpSurfaceComposer() {}
566
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800567IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
568
569// ----------------------------------------------------------------------
570
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800571status_t BnSurfaceComposer::onTransact(
572 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
573{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800574 switch(code) {
575 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700576 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800577 sp<IBinder> b = IInterface::asBinder(createConnection());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800578 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -0700579 return NO_ERROR;
580 }
Robert Carr1db73f62016-12-21 12:58:51 -0800581 case CREATE_SCOPED_CONNECTION: {
582 CHECK_INTERFACE(ISurfaceComposer, data, reply);
583 sp<IGraphicBufferProducer> bufferProducer =
584 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
585 sp<IBinder> b = IInterface::asBinder(createScopedConnection(bufferProducer));
586 reply->writeStrongBinder(b);
587 return NO_ERROR;
588 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700589 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700590 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -0800591
592 size_t count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700593 if (count > data.dataSize()) {
594 return BAD_VALUE;
595 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700596 ComposerState s;
597 Vector<ComposerState> state;
598 state.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800599 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700600 if (s.read(data) == BAD_VALUE) {
601 return BAD_VALUE;
602 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700603 state.add(s);
604 }
Dan Stozad723bd72014-11-18 10:24:03 -0800605
606 count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700607 if (count > data.dataSize()) {
608 return BAD_VALUE;
609 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700610 DisplayState d;
611 Vector<DisplayState> displays;
612 displays.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800613 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700614 if (d.read(data) == BAD_VALUE) {
615 return BAD_VALUE;
616 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700617 displays.add(d);
618 }
Dan Stozad723bd72014-11-18 10:24:03 -0800619
620 uint32_t stateFlags = data.readUint32();
621 setTransactionState(state, displays, stateFlags);
Jesse Hall6c913be2013-08-08 12:15:49 -0700622 return NO_ERROR;
623 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800624 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700625 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800626 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -0700627 return NO_ERROR;
628 }
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800629 case CAPTURE_SCREEN: {
630 CHECK_INTERFACE(ISurfaceComposer, data, reply);
631 sp<IBinder> display = data.readStrongBinder();
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000632 sp<GraphicBuffer> outBuffer;
Pablo Ceballos60d69222015-08-07 14:47:20 -0700633 Rect sourceCrop(Rect::EMPTY_RECT);
Dan Stozac1879002014-05-22 15:59:05 -0700634 data.read(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800635 uint32_t reqWidth = data.readUint32();
636 uint32_t reqHeight = data.readUint32();
Robert Carrae060832016-11-28 10:51:00 -0800637 int32_t minLayerZ = data.readInt32();
638 int32_t maxLayerZ = data.readInt32();
Dan Stozac7014012014-02-14 15:03:43 -0800639 bool useIdentityTransform = static_cast<bool>(data.readInt32());
Dan Stozad723bd72014-11-18 10:24:03 -0800640 int32_t rotation = data.readInt32();
Dan Stozac7014012014-02-14 15:03:43 -0800641
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000642 status_t res = captureScreen(display, &outBuffer, sourceCrop, reqWidth, reqHeight,
643 minLayerZ, maxLayerZ, useIdentityTransform,
644 static_cast<ISurfaceComposer::Rotation>(rotation));
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800645 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000646 if (res == NO_ERROR) {
647 reply->write(*outBuffer);
648 }
Jesse Hall6c913be2013-08-08 12:15:49 -0700649 return NO_ERROR;
650 }
chaviwa76b2712017-09-20 12:02:26 -0700651 case CAPTURE_LAYERS: {
652 CHECK_INTERFACE(ISurfaceComposer, data, reply);
653 sp<IBinder> layerHandleBinder = data.readStrongBinder();
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000654 sp<GraphicBuffer> outBuffer;
chaviw7206d492017-11-10 16:16:12 -0800655 Rect sourceCrop(Rect::EMPTY_RECT);
656 data.read(sourceCrop);
657 float frameScale = data.readFloat();
Robert Carr578038f2018-03-09 12:25:24 -0800658 bool childrenOnly = data.readBool();
chaviwa76b2712017-09-20 12:02:26 -0700659
Robert Carr578038f2018-03-09 12:25:24 -0800660 status_t res = captureLayers(layerHandleBinder, &outBuffer, sourceCrop, frameScale,
661 childrenOnly);
chaviwa76b2712017-09-20 12:02:26 -0700662 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000663 if (res == NO_ERROR) {
664 reply->write(*outBuffer);
665 }
chaviwa76b2712017-09-20 12:02:26 -0700666 return NO_ERROR;
667 }
Jamie Gennis134f0422011-03-08 12:18:54 -0800668 case AUTHENTICATE_SURFACE: {
669 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -0800670 sp<IGraphicBufferProducer> bufferProducer =
671 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
672 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -0800673 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700674 return NO_ERROR;
675 }
Brian Anderson6b376712017-04-04 10:51:39 -0700676 case GET_SUPPORTED_FRAME_TIMESTAMPS: {
677 CHECK_INTERFACE(ISurfaceComposer, data, reply);
678 std::vector<FrameEvent> supportedTimestamps;
679 status_t result = getSupportedFrameTimestamps(&supportedTimestamps);
680 status_t err = reply->writeInt32(result);
681 if (err != NO_ERROR) {
682 return err;
683 }
684 if (result != NO_ERROR) {
685 return result;
686 }
687
688 std::vector<int32_t> supported;
689 supported.reserve(supportedTimestamps.size());
690 for (FrameEvent s : supportedTimestamps) {
691 supported.push_back(static_cast<int32_t>(s));
692 }
693 return reply->writeInt32Vector(supported);
694 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800695 case CREATE_DISPLAY_EVENT_CONNECTION: {
696 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700697 sp<IDisplayEventConnection> connection(createDisplayEventConnection(
698 static_cast<ISurfaceComposer::VsyncSource>(data.readInt32())));
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800699 reply->writeStrongBinder(IInterface::asBinder(connection));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800700 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700701 }
Mathias Agopiane57f2922012-08-09 16:29:12 -0700702 case CREATE_DISPLAY: {
703 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700704 String8 displayName = data.readString8();
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700705 bool secure = bool(data.readInt32());
706 sp<IBinder> display(createDisplay(displayName, secure));
Mathias Agopiane57f2922012-08-09 16:29:12 -0700707 reply->writeStrongBinder(display);
708 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700709 }
710 case DESTROY_DISPLAY: {
711 CHECK_INTERFACE(ISurfaceComposer, data, reply);
712 sp<IBinder> display = data.readStrongBinder();
713 destroyDisplay(display);
714 return NO_ERROR;
715 }
Mathias Agopiane57f2922012-08-09 16:29:12 -0700716 case GET_BUILT_IN_DISPLAY: {
717 CHECK_INTERFACE(ISurfaceComposer, data, reply);
718 int32_t id = data.readInt32();
719 sp<IBinder> display(getBuiltInDisplay(id));
720 reply->writeStrongBinder(display);
721 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700722 }
Dan Stoza7f7da322014-05-02 15:26:25 -0700723 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -0700724 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stoza7f7da322014-05-02 15:26:25 -0700725 Vector<DisplayInfo> configs;
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700726 sp<IBinder> display = data.readStrongBinder();
Dan Stoza7f7da322014-05-02 15:26:25 -0700727 status_t result = getDisplayConfigs(display, &configs);
728 reply->writeInt32(result);
729 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -0800730 reply->writeUint32(static_cast<uint32_t>(configs.size()));
Dan Stoza7f7da322014-05-02 15:26:25 -0700731 for (size_t c = 0; c < configs.size(); ++c) {
732 memcpy(reply->writeInplace(sizeof(DisplayInfo)),
733 &configs[c], sizeof(DisplayInfo));
734 }
735 }
736 return NO_ERROR;
737 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700738 case GET_DISPLAY_STATS: {
739 CHECK_INTERFACE(ISurfaceComposer, data, reply);
740 DisplayStatInfo stats;
741 sp<IBinder> display = data.readStrongBinder();
742 status_t result = getDisplayStats(display, &stats);
743 reply->writeInt32(result);
744 if (result == NO_ERROR) {
745 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
746 &stats, sizeof(DisplayStatInfo));
747 }
748 return NO_ERROR;
749 }
Dan Stoza7f7da322014-05-02 15:26:25 -0700750 case GET_ACTIVE_CONFIG: {
751 CHECK_INTERFACE(ISurfaceComposer, data, reply);
752 sp<IBinder> display = data.readStrongBinder();
753 int id = getActiveConfig(display);
754 reply->writeInt32(id);
755 return NO_ERROR;
756 }
757 case SET_ACTIVE_CONFIG: {
758 CHECK_INTERFACE(ISurfaceComposer, data, reply);
759 sp<IBinder> display = data.readStrongBinder();
760 int id = data.readInt32();
761 status_t result = setActiveConfig(display, id);
Mathias Agopianc666cae2012-07-25 18:56:13 -0700762 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700763 return NO_ERROR;
764 }
Michael Wright28f24d02016-07-12 13:30:53 -0700765 case GET_DISPLAY_COLOR_MODES: {
766 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Lina52f0292018-03-14 17:26:31 -0700767 Vector<ColorMode> colorModes;
Michael Wright28f24d02016-07-12 13:30:53 -0700768 sp<IBinder> display = nullptr;
769 status_t result = data.readStrongBinder(&display);
770 if (result != NO_ERROR) {
771 ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result);
772 return result;
773 }
774 result = getDisplayColorModes(display, &colorModes);
775 reply->writeInt32(result);
776 if (result == NO_ERROR) {
777 reply->writeUint32(static_cast<uint32_t>(colorModes.size()));
778 for (size_t i = 0; i < colorModes.size(); ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -0700779 reply->writeInt32(static_cast<int32_t>(colorModes[i]));
Michael Wright28f24d02016-07-12 13:30:53 -0700780 }
781 }
782 return NO_ERROR;
783 }
784 case GET_ACTIVE_COLOR_MODE: {
785 CHECK_INTERFACE(ISurfaceComposer, data, reply);
786 sp<IBinder> display = nullptr;
787 status_t result = data.readStrongBinder(&display);
788 if (result != NO_ERROR) {
789 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
790 return result;
791 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700792 ColorMode colorMode = getActiveColorMode(display);
Michael Wright28f24d02016-07-12 13:30:53 -0700793 result = reply->writeInt32(static_cast<int32_t>(colorMode));
794 return result;
795 }
796 case SET_ACTIVE_COLOR_MODE: {
797 CHECK_INTERFACE(ISurfaceComposer, data, reply);
798 sp<IBinder> display = nullptr;
799 status_t result = data.readStrongBinder(&display);
800 if (result != NO_ERROR) {
801 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
802 return result;
803 }
804 int32_t colorModeInt = 0;
805 result = data.readInt32(&colorModeInt);
806 if (result != NO_ERROR) {
807 ALOGE("setActiveColorMode failed to readInt32: %d", result);
808 return result;
809 }
810 result = setActiveColorMode(display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700811 static_cast<ColorMode>(colorModeInt));
Michael Wright28f24d02016-07-12 13:30:53 -0700812 result = reply->writeInt32(result);
813 return result;
814 }
Svetoslavd85084b2014-03-20 10:28:31 -0700815 case CLEAR_ANIMATION_FRAME_STATS: {
816 CHECK_INTERFACE(ISurfaceComposer, data, reply);
817 status_t result = clearAnimationFrameStats();
818 reply->writeInt32(result);
819 return NO_ERROR;
820 }
821 case GET_ANIMATION_FRAME_STATS: {
822 CHECK_INTERFACE(ISurfaceComposer, data, reply);
823 FrameStats stats;
824 status_t result = getAnimationFrameStats(&stats);
825 reply->write(stats);
826 reply->writeInt32(result);
827 return NO_ERROR;
828 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700829 case SET_POWER_MODE: {
830 CHECK_INTERFACE(ISurfaceComposer, data, reply);
831 sp<IBinder> display = data.readStrongBinder();
832 int32_t mode = data.readInt32();
833 setPowerMode(display, mode);
834 return NO_ERROR;
835 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700836 case GET_HDR_CAPABILITIES: {
837 CHECK_INTERFACE(ISurfaceComposer, data, reply);
838 sp<IBinder> display = nullptr;
839 status_t result = data.readStrongBinder(&display);
840 if (result != NO_ERROR) {
841 ALOGE("getHdrCapabilities failed to readStrongBinder: %d",
842 result);
843 return result;
844 }
845 HdrCapabilities capabilities;
846 result = getHdrCapabilities(display, &capabilities);
847 reply->writeInt32(result);
848 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800849 reply->write(capabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700850 }
851 return NO_ERROR;
852 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700853 case ENABLE_VSYNC_INJECTIONS: {
854 CHECK_INTERFACE(ISurfaceComposer, data, reply);
855 bool enable = false;
856 status_t result = data.readBool(&enable);
857 if (result != NO_ERROR) {
858 ALOGE("enableVSyncInjections failed to readBool: %d", result);
859 return result;
860 }
861 return enableVSyncInjections(enable);
862 }
863 case INJECT_VSYNC: {
864 CHECK_INTERFACE(ISurfaceComposer, data, reply);
865 int64_t when = 0;
866 status_t result = data.readInt64(&when);
867 if (result != NO_ERROR) {
868 ALOGE("enableVSyncInjections failed to readInt64: %d", result);
869 return result;
870 }
871 return injectVSync(when);
872 }
Kalle Raitaa099a242017-01-11 11:17:29 -0800873 case GET_LAYER_DEBUG_INFO: {
874 CHECK_INTERFACE(ISurfaceComposer, data, reply);
875 std::vector<LayerDebugInfo> outLayers;
876 status_t result = getLayerDebugInfo(&outLayers);
877 reply->writeInt32(result);
878 if (result == NO_ERROR)
879 {
880 result = reply->writeParcelableVector(outLayers);
881 }
882 return result;
883 }
Jesse Hall6c913be2013-08-08 12:15:49 -0700884 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700885 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -0700886 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800887 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800888}
889
890// ----------------------------------------------------------------------------
891
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800892};