blob: 81f692d374a86b64281c8d57b844a79d2b29ff35 [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
Yiwei Zhangcd3f9e92018-08-21 15:15:42 -0700334 virtual status_t getDisplayViewport(const sp<IBinder>& display, Rect* outViewport) {
335 Parcel data, reply;
336 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
337 if (result != NO_ERROR) {
338 ALOGE("getDisplayViewport failed to writeInterfaceToken: %d", result);
339 return result;
340 }
341 result = data.writeStrongBinder(display);
342 if (result != NO_ERROR) {
343 ALOGE("getDisplayViewport failed to writeStrongBinder: %d", result);
344 return result;
345 }
346 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_VIEWPORT, data, &reply);
347 if (result != NO_ERROR) {
348 ALOGE("getDisplayViewport failed to transact: %d", result);
349 return result;
350 }
351 result = reply.readInt32();
352 if (result == NO_ERROR) {
353 result = reply.read(*outViewport);
354 if (result != NO_ERROR) {
355 ALOGE("getDisplayViewport failed to read: %d", result);
356 return result;
357 }
358 }
359 return result;
360 }
361
Dan Stoza7f7da322014-05-02 15:26:25 -0700362 virtual int getActiveConfig(const sp<IBinder>& display)
363 {
364 Parcel data, reply;
365 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
366 data.writeStrongBinder(display);
367 remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply);
368 return reply.readInt32();
369 }
370
371 virtual status_t setActiveConfig(const sp<IBinder>& display, int id)
372 {
373 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700374 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
375 if (result != NO_ERROR) {
376 ALOGE("setActiveConfig failed to writeInterfaceToken: %d", result);
377 return result;
378 }
379 result = data.writeStrongBinder(display);
380 if (result != NO_ERROR) {
381 ALOGE("setActiveConfig failed to writeStrongBinder: %d", result);
382 return result;
383 }
384 result = data.writeInt32(id);
385 if (result != NO_ERROR) {
386 ALOGE("setActiveConfig failed to writeInt32: %d", result);
387 return result;
388 }
389 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply);
390 if (result != NO_ERROR) {
391 ALOGE("setActiveConfig failed to transact: %d", result);
392 return result;
393 }
Mathias Agopianc666cae2012-07-25 18:56:13 -0700394 return reply.readInt32();
395 }
Svetoslavd85084b2014-03-20 10:28:31 -0700396
Michael Wright28f24d02016-07-12 13:30:53 -0700397 virtual status_t getDisplayColorModes(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700398 Vector<ColorMode>* outColorModes) {
Michael Wright28f24d02016-07-12 13:30:53 -0700399 Parcel data, reply;
400 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
401 if (result != NO_ERROR) {
402 ALOGE("getDisplayColorModes failed to writeInterfaceToken: %d", result);
403 return result;
404 }
405 result = data.writeStrongBinder(display);
406 if (result != NO_ERROR) {
407 ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result);
408 return result;
409 }
410 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply);
411 if (result != NO_ERROR) {
412 ALOGE("getDisplayColorModes failed to transact: %d", result);
413 return result;
414 }
415 result = static_cast<status_t>(reply.readInt32());
416 if (result == NO_ERROR) {
417 size_t numModes = reply.readUint32();
418 outColorModes->clear();
419 outColorModes->resize(numModes);
420 for (size_t i = 0; i < numModes; ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -0700421 outColorModes->replaceAt(static_cast<ColorMode>(reply.readInt32()), i);
Michael Wright28f24d02016-07-12 13:30:53 -0700422 }
423 }
424 return result;
425 }
426
Peiyong Lina52f0292018-03-14 17:26:31 -0700427 virtual ColorMode getActiveColorMode(const sp<IBinder>& display) {
Michael Wright28f24d02016-07-12 13:30:53 -0700428 Parcel data, reply;
429 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
430 if (result != NO_ERROR) {
431 ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700432 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700433 }
434 result = data.writeStrongBinder(display);
435 if (result != NO_ERROR) {
436 ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700437 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700438 }
439 result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply);
440 if (result != NO_ERROR) {
441 ALOGE("getActiveColorMode failed to transact: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700442 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700443 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700444 return static_cast<ColorMode>(reply.readInt32());
Michael Wright28f24d02016-07-12 13:30:53 -0700445 }
446
447 virtual status_t setActiveColorMode(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700448 ColorMode colorMode) {
Michael Wright28f24d02016-07-12 13:30:53 -0700449 Parcel data, reply;
450 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
451 if (result != NO_ERROR) {
452 ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result);
453 return result;
454 }
455 result = data.writeStrongBinder(display);
456 if (result != NO_ERROR) {
457 ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result);
458 return result;
459 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700460 result = data.writeInt32(static_cast<int32_t>(colorMode));
Michael Wright28f24d02016-07-12 13:30:53 -0700461 if (result != NO_ERROR) {
462 ALOGE("setActiveColorMode failed to writeInt32: %d", result);
463 return result;
464 }
465 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply);
466 if (result != NO_ERROR) {
467 ALOGE("setActiveColorMode failed to transact: %d", result);
468 return result;
469 }
470 return static_cast<status_t>(reply.readInt32());
471 }
472
Svetoslavd85084b2014-03-20 10:28:31 -0700473 virtual status_t clearAnimationFrameStats() {
474 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700475 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
476 if (result != NO_ERROR) {
477 ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result);
478 return result;
479 }
480 result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply);
481 if (result != NO_ERROR) {
482 ALOGE("clearAnimationFrameStats failed to transact: %d", result);
483 return result;
484 }
Svetoslavd85084b2014-03-20 10:28:31 -0700485 return reply.readInt32();
486 }
487
488 virtual status_t getAnimationFrameStats(FrameStats* outStats) const {
489 Parcel data, reply;
490 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
491 remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply);
492 reply.read(*outStats);
493 return reply.readInt32();
494 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700495
496 virtual status_t getHdrCapabilities(const sp<IBinder>& display,
497 HdrCapabilities* outCapabilities) const {
498 Parcel data, reply;
499 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
500 status_t result = data.writeStrongBinder(display);
501 if (result != NO_ERROR) {
502 ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result);
503 return result;
504 }
505 result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES,
506 data, &reply);
507 if (result != NO_ERROR) {
508 ALOGE("getHdrCapabilities failed to transact: %d", result);
509 return result;
510 }
511 result = reply.readInt32();
512 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800513 result = reply.read(*outCapabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700514 }
515 return result;
516 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700517
518 virtual status_t enableVSyncInjections(bool enable) {
519 Parcel data, reply;
520 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
521 if (result != NO_ERROR) {
522 ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result);
523 return result;
524 }
525 result = data.writeBool(enable);
526 if (result != NO_ERROR) {
527 ALOGE("enableVSyncInjections failed to writeBool: %d", result);
528 return result;
529 }
530 result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS,
531 data, &reply, TF_ONE_WAY);
532 if (result != NO_ERROR) {
533 ALOGE("enableVSyncInjections failed to transact: %d", result);
534 return result;
535 }
536 return result;
537 }
538
539 virtual status_t injectVSync(nsecs_t when) {
540 Parcel data, reply;
541 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
542 if (result != NO_ERROR) {
543 ALOGE("injectVSync failed to writeInterfaceToken: %d", result);
544 return result;
545 }
546 result = data.writeInt64(when);
547 if (result != NO_ERROR) {
548 ALOGE("injectVSync failed to writeInt64: %d", result);
549 return result;
550 }
551 result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply, TF_ONE_WAY);
552 if (result != NO_ERROR) {
553 ALOGE("injectVSync failed to transact: %d", result);
554 return result;
555 }
556 return result;
557 }
558
Kalle Raitaa099a242017-01-11 11:17:29 -0800559 virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const
560 {
561 if (!outLayers) {
562 return UNEXPECTED_NULL;
563 }
564
565 Parcel data, reply;
566
567 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
568 if (err != NO_ERROR) {
569 return err;
570 }
571
572 err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply);
573 if (err != NO_ERROR) {
574 return err;
575 }
576
577 int32_t result = 0;
578 err = reply.readInt32(&result);
579 if (err != NO_ERROR) {
580 return err;
581 }
582 if (result != NO_ERROR) {
583 return result;
584 }
585
586 outLayers->clear();
587 return reply.readParcelableVector(outLayers);
588 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800589};
590
Dan Stozad723bd72014-11-18 10:24:03 -0800591// Out-of-line virtual method definition to trigger vtable emission in this
592// translation unit (see clang warning -Wweak-vtables)
593BpSurfaceComposer::~BpSurfaceComposer() {}
594
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800595IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
596
597// ----------------------------------------------------------------------
598
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800599status_t BnSurfaceComposer::onTransact(
600 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
601{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800602 switch(code) {
603 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700604 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800605 sp<IBinder> b = IInterface::asBinder(createConnection());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800606 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -0700607 return NO_ERROR;
608 }
Robert Carr1db73f62016-12-21 12:58:51 -0800609 case CREATE_SCOPED_CONNECTION: {
610 CHECK_INTERFACE(ISurfaceComposer, data, reply);
611 sp<IGraphicBufferProducer> bufferProducer =
612 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
613 sp<IBinder> b = IInterface::asBinder(createScopedConnection(bufferProducer));
614 reply->writeStrongBinder(b);
615 return NO_ERROR;
616 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700617 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700618 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -0800619
620 size_t count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700621 if (count > data.dataSize()) {
622 return BAD_VALUE;
623 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700624 ComposerState s;
625 Vector<ComposerState> state;
626 state.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800627 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700628 if (s.read(data) == BAD_VALUE) {
629 return BAD_VALUE;
630 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700631 state.add(s);
632 }
Dan Stozad723bd72014-11-18 10:24:03 -0800633
634 count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700635 if (count > data.dataSize()) {
636 return BAD_VALUE;
637 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700638 DisplayState d;
639 Vector<DisplayState> displays;
640 displays.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800641 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700642 if (d.read(data) == BAD_VALUE) {
643 return BAD_VALUE;
644 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700645 displays.add(d);
646 }
Dan Stozad723bd72014-11-18 10:24:03 -0800647
648 uint32_t stateFlags = data.readUint32();
649 setTransactionState(state, displays, stateFlags);
Jesse Hall6c913be2013-08-08 12:15:49 -0700650 return NO_ERROR;
651 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800652 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700653 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800654 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -0700655 return NO_ERROR;
656 }
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800657 case CAPTURE_SCREEN: {
658 CHECK_INTERFACE(ISurfaceComposer, data, reply);
659 sp<IBinder> display = data.readStrongBinder();
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000660 sp<GraphicBuffer> outBuffer;
Pablo Ceballos60d69222015-08-07 14:47:20 -0700661 Rect sourceCrop(Rect::EMPTY_RECT);
Dan Stozac1879002014-05-22 15:59:05 -0700662 data.read(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800663 uint32_t reqWidth = data.readUint32();
664 uint32_t reqHeight = data.readUint32();
Robert Carrae060832016-11-28 10:51:00 -0800665 int32_t minLayerZ = data.readInt32();
666 int32_t maxLayerZ = data.readInt32();
Dan Stozac7014012014-02-14 15:03:43 -0800667 bool useIdentityTransform = static_cast<bool>(data.readInt32());
Dan Stozad723bd72014-11-18 10:24:03 -0800668 int32_t rotation = data.readInt32();
Dan Stozac7014012014-02-14 15:03:43 -0800669
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000670 status_t res = captureScreen(display, &outBuffer, sourceCrop, reqWidth, reqHeight,
671 minLayerZ, maxLayerZ, useIdentityTransform,
672 static_cast<ISurfaceComposer::Rotation>(rotation));
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800673 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000674 if (res == NO_ERROR) {
675 reply->write(*outBuffer);
676 }
Jesse Hall6c913be2013-08-08 12:15:49 -0700677 return NO_ERROR;
678 }
chaviwa76b2712017-09-20 12:02:26 -0700679 case CAPTURE_LAYERS: {
680 CHECK_INTERFACE(ISurfaceComposer, data, reply);
681 sp<IBinder> layerHandleBinder = data.readStrongBinder();
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000682 sp<GraphicBuffer> outBuffer;
chaviw7206d492017-11-10 16:16:12 -0800683 Rect sourceCrop(Rect::EMPTY_RECT);
684 data.read(sourceCrop);
685 float frameScale = data.readFloat();
Robert Carr578038f2018-03-09 12:25:24 -0800686 bool childrenOnly = data.readBool();
chaviwa76b2712017-09-20 12:02:26 -0700687
Robert Carr578038f2018-03-09 12:25:24 -0800688 status_t res = captureLayers(layerHandleBinder, &outBuffer, sourceCrop, frameScale,
689 childrenOnly);
chaviwa76b2712017-09-20 12:02:26 -0700690 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000691 if (res == NO_ERROR) {
692 reply->write(*outBuffer);
693 }
chaviwa76b2712017-09-20 12:02:26 -0700694 return NO_ERROR;
695 }
Jamie Gennis134f0422011-03-08 12:18:54 -0800696 case AUTHENTICATE_SURFACE: {
697 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -0800698 sp<IGraphicBufferProducer> bufferProducer =
699 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
700 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -0800701 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700702 return NO_ERROR;
703 }
Brian Anderson6b376712017-04-04 10:51:39 -0700704 case GET_SUPPORTED_FRAME_TIMESTAMPS: {
705 CHECK_INTERFACE(ISurfaceComposer, data, reply);
706 std::vector<FrameEvent> supportedTimestamps;
707 status_t result = getSupportedFrameTimestamps(&supportedTimestamps);
708 status_t err = reply->writeInt32(result);
709 if (err != NO_ERROR) {
710 return err;
711 }
712 if (result != NO_ERROR) {
713 return result;
714 }
715
716 std::vector<int32_t> supported;
717 supported.reserve(supportedTimestamps.size());
718 for (FrameEvent s : supportedTimestamps) {
719 supported.push_back(static_cast<int32_t>(s));
720 }
721 return reply->writeInt32Vector(supported);
722 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800723 case CREATE_DISPLAY_EVENT_CONNECTION: {
724 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700725 sp<IDisplayEventConnection> connection(createDisplayEventConnection(
726 static_cast<ISurfaceComposer::VsyncSource>(data.readInt32())));
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800727 reply->writeStrongBinder(IInterface::asBinder(connection));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800728 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700729 }
Mathias Agopiane57f2922012-08-09 16:29:12 -0700730 case CREATE_DISPLAY: {
731 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700732 String8 displayName = data.readString8();
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700733 bool secure = bool(data.readInt32());
734 sp<IBinder> display(createDisplay(displayName, secure));
Mathias Agopiane57f2922012-08-09 16:29:12 -0700735 reply->writeStrongBinder(display);
736 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700737 }
738 case DESTROY_DISPLAY: {
739 CHECK_INTERFACE(ISurfaceComposer, data, reply);
740 sp<IBinder> display = data.readStrongBinder();
741 destroyDisplay(display);
742 return NO_ERROR;
743 }
Mathias Agopiane57f2922012-08-09 16:29:12 -0700744 case GET_BUILT_IN_DISPLAY: {
745 CHECK_INTERFACE(ISurfaceComposer, data, reply);
746 int32_t id = data.readInt32();
747 sp<IBinder> display(getBuiltInDisplay(id));
748 reply->writeStrongBinder(display);
749 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700750 }
Dan Stoza7f7da322014-05-02 15:26:25 -0700751 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -0700752 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stoza7f7da322014-05-02 15:26:25 -0700753 Vector<DisplayInfo> configs;
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700754 sp<IBinder> display = data.readStrongBinder();
Dan Stoza7f7da322014-05-02 15:26:25 -0700755 status_t result = getDisplayConfigs(display, &configs);
756 reply->writeInt32(result);
757 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -0800758 reply->writeUint32(static_cast<uint32_t>(configs.size()));
Dan Stoza7f7da322014-05-02 15:26:25 -0700759 for (size_t c = 0; c < configs.size(); ++c) {
760 memcpy(reply->writeInplace(sizeof(DisplayInfo)),
761 &configs[c], sizeof(DisplayInfo));
762 }
763 }
764 return NO_ERROR;
765 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700766 case GET_DISPLAY_STATS: {
767 CHECK_INTERFACE(ISurfaceComposer, data, reply);
768 DisplayStatInfo stats;
769 sp<IBinder> display = data.readStrongBinder();
770 status_t result = getDisplayStats(display, &stats);
771 reply->writeInt32(result);
772 if (result == NO_ERROR) {
773 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
774 &stats, sizeof(DisplayStatInfo));
775 }
776 return NO_ERROR;
777 }
Yiwei Zhangcd3f9e92018-08-21 15:15:42 -0700778 case GET_DISPLAY_VIEWPORT: {
779 CHECK_INTERFACE(ISurfaceComposer, data, reply);
780 Rect outViewport;
781 sp<IBinder> display = nullptr;
782 status_t result = data.readStrongBinder(&display);
783 if (result != NO_ERROR) {
784 ALOGE("getDisplayViewport failed to readStrongBinder: %d", result);
785 return result;
786 }
787 result = getDisplayViewport(display, &outViewport);
788 result = reply->writeInt32(result);
789 if (result == NO_ERROR) {
790 result = reply->write(outViewport);
791 if (result != NO_ERROR) {
792 ALOGE("getDisplayViewport failed to write: %d", result);
793 return result;
794 }
795 }
796 return NO_ERROR;
797 }
Dan Stoza7f7da322014-05-02 15:26:25 -0700798 case GET_ACTIVE_CONFIG: {
799 CHECK_INTERFACE(ISurfaceComposer, data, reply);
800 sp<IBinder> display = data.readStrongBinder();
801 int id = getActiveConfig(display);
802 reply->writeInt32(id);
803 return NO_ERROR;
804 }
805 case SET_ACTIVE_CONFIG: {
806 CHECK_INTERFACE(ISurfaceComposer, data, reply);
807 sp<IBinder> display = data.readStrongBinder();
808 int id = data.readInt32();
809 status_t result = setActiveConfig(display, id);
Mathias Agopianc666cae2012-07-25 18:56:13 -0700810 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700811 return NO_ERROR;
812 }
Michael Wright28f24d02016-07-12 13:30:53 -0700813 case GET_DISPLAY_COLOR_MODES: {
814 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Lina52f0292018-03-14 17:26:31 -0700815 Vector<ColorMode> colorModes;
Michael Wright28f24d02016-07-12 13:30:53 -0700816 sp<IBinder> display = nullptr;
817 status_t result = data.readStrongBinder(&display);
818 if (result != NO_ERROR) {
819 ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result);
820 return result;
821 }
822 result = getDisplayColorModes(display, &colorModes);
823 reply->writeInt32(result);
824 if (result == NO_ERROR) {
825 reply->writeUint32(static_cast<uint32_t>(colorModes.size()));
826 for (size_t i = 0; i < colorModes.size(); ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -0700827 reply->writeInt32(static_cast<int32_t>(colorModes[i]));
Michael Wright28f24d02016-07-12 13:30:53 -0700828 }
829 }
830 return NO_ERROR;
831 }
832 case GET_ACTIVE_COLOR_MODE: {
833 CHECK_INTERFACE(ISurfaceComposer, data, reply);
834 sp<IBinder> display = nullptr;
835 status_t result = data.readStrongBinder(&display);
836 if (result != NO_ERROR) {
837 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
838 return result;
839 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700840 ColorMode colorMode = getActiveColorMode(display);
Michael Wright28f24d02016-07-12 13:30:53 -0700841 result = reply->writeInt32(static_cast<int32_t>(colorMode));
842 return result;
843 }
844 case SET_ACTIVE_COLOR_MODE: {
845 CHECK_INTERFACE(ISurfaceComposer, data, reply);
846 sp<IBinder> display = nullptr;
847 status_t result = data.readStrongBinder(&display);
848 if (result != NO_ERROR) {
849 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
850 return result;
851 }
852 int32_t colorModeInt = 0;
853 result = data.readInt32(&colorModeInt);
854 if (result != NO_ERROR) {
855 ALOGE("setActiveColorMode failed to readInt32: %d", result);
856 return result;
857 }
858 result = setActiveColorMode(display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700859 static_cast<ColorMode>(colorModeInt));
Michael Wright28f24d02016-07-12 13:30:53 -0700860 result = reply->writeInt32(result);
861 return result;
862 }
Svetoslavd85084b2014-03-20 10:28:31 -0700863 case CLEAR_ANIMATION_FRAME_STATS: {
864 CHECK_INTERFACE(ISurfaceComposer, data, reply);
865 status_t result = clearAnimationFrameStats();
866 reply->writeInt32(result);
867 return NO_ERROR;
868 }
869 case GET_ANIMATION_FRAME_STATS: {
870 CHECK_INTERFACE(ISurfaceComposer, data, reply);
871 FrameStats stats;
872 status_t result = getAnimationFrameStats(&stats);
873 reply->write(stats);
874 reply->writeInt32(result);
875 return NO_ERROR;
876 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700877 case SET_POWER_MODE: {
878 CHECK_INTERFACE(ISurfaceComposer, data, reply);
879 sp<IBinder> display = data.readStrongBinder();
880 int32_t mode = data.readInt32();
881 setPowerMode(display, mode);
882 return NO_ERROR;
883 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700884 case GET_HDR_CAPABILITIES: {
885 CHECK_INTERFACE(ISurfaceComposer, data, reply);
886 sp<IBinder> display = nullptr;
887 status_t result = data.readStrongBinder(&display);
888 if (result != NO_ERROR) {
889 ALOGE("getHdrCapabilities failed to readStrongBinder: %d",
890 result);
891 return result;
892 }
893 HdrCapabilities capabilities;
894 result = getHdrCapabilities(display, &capabilities);
895 reply->writeInt32(result);
896 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800897 reply->write(capabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700898 }
899 return NO_ERROR;
900 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700901 case ENABLE_VSYNC_INJECTIONS: {
902 CHECK_INTERFACE(ISurfaceComposer, data, reply);
903 bool enable = false;
904 status_t result = data.readBool(&enable);
905 if (result != NO_ERROR) {
906 ALOGE("enableVSyncInjections failed to readBool: %d", result);
907 return result;
908 }
909 return enableVSyncInjections(enable);
910 }
911 case INJECT_VSYNC: {
912 CHECK_INTERFACE(ISurfaceComposer, data, reply);
913 int64_t when = 0;
914 status_t result = data.readInt64(&when);
915 if (result != NO_ERROR) {
916 ALOGE("enableVSyncInjections failed to readInt64: %d", result);
917 return result;
918 }
919 return injectVSync(when);
920 }
Kalle Raitaa099a242017-01-11 11:17:29 -0800921 case GET_LAYER_DEBUG_INFO: {
922 CHECK_INTERFACE(ISurfaceComposer, data, reply);
923 std::vector<LayerDebugInfo> outLayers;
924 status_t result = getLayerDebugInfo(&outLayers);
925 reply->writeInt32(result);
926 if (result == NO_ERROR)
927 {
928 result = reply->writeParcelableVector(outLayers);
929 }
930 return result;
931 }
Jesse Hall6c913be2013-08-08 12:15:49 -0700932 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700933 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -0700934 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800935 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800936}
937
938// ----------------------------------------------------------------------------
939
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800940};