blob: 08fbfffd0385399b507b2217f0c32c052a6ebf1c [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 }
Peiyong Lin0256f722018-08-31 15:45:10 -0700561
562 virtual status_t getCompositionPreference(ui::Dataspace* dataSpace,
563 ui::PixelFormat* pixelFormat) const {
564 Parcel data, reply;
565 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
566 if (error != NO_ERROR) {
567 return error;
568 }
569 error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply);
570 if (error != NO_ERROR) {
571 return error;
572 }
573 error = static_cast<status_t>(reply.readInt32());
574 if (error == NO_ERROR) {
575 *dataSpace = static_cast<ui::Dataspace>(reply.readInt32());
576 *pixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
577 }
578 return error;
579 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800580};
581
Dan Stozad723bd72014-11-18 10:24:03 -0800582// Out-of-line virtual method definition to trigger vtable emission in this
583// translation unit (see clang warning -Wweak-vtables)
584BpSurfaceComposer::~BpSurfaceComposer() {}
585
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800586IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
587
588// ----------------------------------------------------------------------
589
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800590status_t BnSurfaceComposer::onTransact(
591 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
592{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800593 switch(code) {
594 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700595 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800596 sp<IBinder> b = IInterface::asBinder(createConnection());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800597 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -0700598 return NO_ERROR;
599 }
Robert Carr1db73f62016-12-21 12:58:51 -0800600 case CREATE_SCOPED_CONNECTION: {
601 CHECK_INTERFACE(ISurfaceComposer, data, reply);
602 sp<IGraphicBufferProducer> bufferProducer =
603 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
604 sp<IBinder> b = IInterface::asBinder(createScopedConnection(bufferProducer));
605 reply->writeStrongBinder(b);
606 return NO_ERROR;
607 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700608 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700609 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -0800610
611 size_t count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700612 if (count > data.dataSize()) {
613 return BAD_VALUE;
614 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700615 ComposerState s;
616 Vector<ComposerState> state;
617 state.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800618 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700619 if (s.read(data) == BAD_VALUE) {
620 return BAD_VALUE;
621 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700622 state.add(s);
623 }
Dan Stozad723bd72014-11-18 10:24:03 -0800624
625 count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700626 if (count > data.dataSize()) {
627 return BAD_VALUE;
628 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700629 DisplayState d;
630 Vector<DisplayState> displays;
631 displays.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800632 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700633 if (d.read(data) == BAD_VALUE) {
634 return BAD_VALUE;
635 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700636 displays.add(d);
637 }
Dan Stozad723bd72014-11-18 10:24:03 -0800638
639 uint32_t stateFlags = data.readUint32();
640 setTransactionState(state, displays, stateFlags);
Jesse Hall6c913be2013-08-08 12:15:49 -0700641 return NO_ERROR;
642 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800643 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700644 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800645 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -0700646 return NO_ERROR;
647 }
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800648 case CAPTURE_SCREEN: {
649 CHECK_INTERFACE(ISurfaceComposer, data, reply);
650 sp<IBinder> display = data.readStrongBinder();
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000651 sp<GraphicBuffer> outBuffer;
Pablo Ceballos60d69222015-08-07 14:47:20 -0700652 Rect sourceCrop(Rect::EMPTY_RECT);
Dan Stozac1879002014-05-22 15:59:05 -0700653 data.read(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800654 uint32_t reqWidth = data.readUint32();
655 uint32_t reqHeight = data.readUint32();
Robert Carrae060832016-11-28 10:51:00 -0800656 int32_t minLayerZ = data.readInt32();
657 int32_t maxLayerZ = data.readInt32();
Dan Stozac7014012014-02-14 15:03:43 -0800658 bool useIdentityTransform = static_cast<bool>(data.readInt32());
Dan Stozad723bd72014-11-18 10:24:03 -0800659 int32_t rotation = data.readInt32();
Dan Stozac7014012014-02-14 15:03:43 -0800660
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000661 status_t res = captureScreen(display, &outBuffer, sourceCrop, reqWidth, reqHeight,
662 minLayerZ, maxLayerZ, useIdentityTransform,
663 static_cast<ISurfaceComposer::Rotation>(rotation));
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800664 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000665 if (res == NO_ERROR) {
666 reply->write(*outBuffer);
667 }
Jesse Hall6c913be2013-08-08 12:15:49 -0700668 return NO_ERROR;
669 }
chaviwa76b2712017-09-20 12:02:26 -0700670 case CAPTURE_LAYERS: {
671 CHECK_INTERFACE(ISurfaceComposer, data, reply);
672 sp<IBinder> layerHandleBinder = data.readStrongBinder();
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000673 sp<GraphicBuffer> outBuffer;
chaviw7206d492017-11-10 16:16:12 -0800674 Rect sourceCrop(Rect::EMPTY_RECT);
675 data.read(sourceCrop);
676 float frameScale = data.readFloat();
Robert Carr578038f2018-03-09 12:25:24 -0800677 bool childrenOnly = data.readBool();
chaviwa76b2712017-09-20 12:02:26 -0700678
Robert Carr578038f2018-03-09 12:25:24 -0800679 status_t res = captureLayers(layerHandleBinder, &outBuffer, sourceCrop, frameScale,
680 childrenOnly);
chaviwa76b2712017-09-20 12:02:26 -0700681 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000682 if (res == NO_ERROR) {
683 reply->write(*outBuffer);
684 }
chaviwa76b2712017-09-20 12:02:26 -0700685 return NO_ERROR;
686 }
Jamie Gennis134f0422011-03-08 12:18:54 -0800687 case AUTHENTICATE_SURFACE: {
688 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -0800689 sp<IGraphicBufferProducer> bufferProducer =
690 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
691 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -0800692 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700693 return NO_ERROR;
694 }
Brian Anderson6b376712017-04-04 10:51:39 -0700695 case GET_SUPPORTED_FRAME_TIMESTAMPS: {
696 CHECK_INTERFACE(ISurfaceComposer, data, reply);
697 std::vector<FrameEvent> supportedTimestamps;
698 status_t result = getSupportedFrameTimestamps(&supportedTimestamps);
699 status_t err = reply->writeInt32(result);
700 if (err != NO_ERROR) {
701 return err;
702 }
703 if (result != NO_ERROR) {
704 return result;
705 }
706
707 std::vector<int32_t> supported;
708 supported.reserve(supportedTimestamps.size());
709 for (FrameEvent s : supportedTimestamps) {
710 supported.push_back(static_cast<int32_t>(s));
711 }
712 return reply->writeInt32Vector(supported);
713 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800714 case CREATE_DISPLAY_EVENT_CONNECTION: {
715 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700716 sp<IDisplayEventConnection> connection(createDisplayEventConnection(
717 static_cast<ISurfaceComposer::VsyncSource>(data.readInt32())));
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800718 reply->writeStrongBinder(IInterface::asBinder(connection));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800719 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700720 }
Mathias Agopiane57f2922012-08-09 16:29:12 -0700721 case CREATE_DISPLAY: {
722 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700723 String8 displayName = data.readString8();
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700724 bool secure = bool(data.readInt32());
725 sp<IBinder> display(createDisplay(displayName, secure));
Mathias Agopiane57f2922012-08-09 16:29:12 -0700726 reply->writeStrongBinder(display);
727 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700728 }
729 case DESTROY_DISPLAY: {
730 CHECK_INTERFACE(ISurfaceComposer, data, reply);
731 sp<IBinder> display = data.readStrongBinder();
732 destroyDisplay(display);
733 return NO_ERROR;
734 }
Mathias Agopiane57f2922012-08-09 16:29:12 -0700735 case GET_BUILT_IN_DISPLAY: {
736 CHECK_INTERFACE(ISurfaceComposer, data, reply);
737 int32_t id = data.readInt32();
738 sp<IBinder> display(getBuiltInDisplay(id));
739 reply->writeStrongBinder(display);
740 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700741 }
Dan Stoza7f7da322014-05-02 15:26:25 -0700742 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -0700743 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stoza7f7da322014-05-02 15:26:25 -0700744 Vector<DisplayInfo> configs;
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700745 sp<IBinder> display = data.readStrongBinder();
Dan Stoza7f7da322014-05-02 15:26:25 -0700746 status_t result = getDisplayConfigs(display, &configs);
747 reply->writeInt32(result);
748 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -0800749 reply->writeUint32(static_cast<uint32_t>(configs.size()));
Dan Stoza7f7da322014-05-02 15:26:25 -0700750 for (size_t c = 0; c < configs.size(); ++c) {
751 memcpy(reply->writeInplace(sizeof(DisplayInfo)),
752 &configs[c], sizeof(DisplayInfo));
753 }
754 }
755 return NO_ERROR;
756 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700757 case GET_DISPLAY_STATS: {
758 CHECK_INTERFACE(ISurfaceComposer, data, reply);
759 DisplayStatInfo stats;
760 sp<IBinder> display = data.readStrongBinder();
761 status_t result = getDisplayStats(display, &stats);
762 reply->writeInt32(result);
763 if (result == NO_ERROR) {
764 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
765 &stats, sizeof(DisplayStatInfo));
766 }
767 return NO_ERROR;
768 }
Dan Stoza7f7da322014-05-02 15:26:25 -0700769 case GET_ACTIVE_CONFIG: {
770 CHECK_INTERFACE(ISurfaceComposer, data, reply);
771 sp<IBinder> display = data.readStrongBinder();
772 int id = getActiveConfig(display);
773 reply->writeInt32(id);
774 return NO_ERROR;
775 }
776 case SET_ACTIVE_CONFIG: {
777 CHECK_INTERFACE(ISurfaceComposer, data, reply);
778 sp<IBinder> display = data.readStrongBinder();
779 int id = data.readInt32();
780 status_t result = setActiveConfig(display, id);
Mathias Agopianc666cae2012-07-25 18:56:13 -0700781 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700782 return NO_ERROR;
783 }
Michael Wright28f24d02016-07-12 13:30:53 -0700784 case GET_DISPLAY_COLOR_MODES: {
785 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Lina52f0292018-03-14 17:26:31 -0700786 Vector<ColorMode> colorModes;
Michael Wright28f24d02016-07-12 13:30:53 -0700787 sp<IBinder> display = nullptr;
788 status_t result = data.readStrongBinder(&display);
789 if (result != NO_ERROR) {
790 ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result);
791 return result;
792 }
793 result = getDisplayColorModes(display, &colorModes);
794 reply->writeInt32(result);
795 if (result == NO_ERROR) {
796 reply->writeUint32(static_cast<uint32_t>(colorModes.size()));
797 for (size_t i = 0; i < colorModes.size(); ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -0700798 reply->writeInt32(static_cast<int32_t>(colorModes[i]));
Michael Wright28f24d02016-07-12 13:30:53 -0700799 }
800 }
801 return NO_ERROR;
802 }
803 case GET_ACTIVE_COLOR_MODE: {
804 CHECK_INTERFACE(ISurfaceComposer, data, reply);
805 sp<IBinder> display = nullptr;
806 status_t result = data.readStrongBinder(&display);
807 if (result != NO_ERROR) {
808 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
809 return result;
810 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700811 ColorMode colorMode = getActiveColorMode(display);
Michael Wright28f24d02016-07-12 13:30:53 -0700812 result = reply->writeInt32(static_cast<int32_t>(colorMode));
813 return result;
814 }
815 case SET_ACTIVE_COLOR_MODE: {
816 CHECK_INTERFACE(ISurfaceComposer, data, reply);
817 sp<IBinder> display = nullptr;
818 status_t result = data.readStrongBinder(&display);
819 if (result != NO_ERROR) {
820 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
821 return result;
822 }
823 int32_t colorModeInt = 0;
824 result = data.readInt32(&colorModeInt);
825 if (result != NO_ERROR) {
826 ALOGE("setActiveColorMode failed to readInt32: %d", result);
827 return result;
828 }
829 result = setActiveColorMode(display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700830 static_cast<ColorMode>(colorModeInt));
Michael Wright28f24d02016-07-12 13:30:53 -0700831 result = reply->writeInt32(result);
832 return result;
833 }
Svetoslavd85084b2014-03-20 10:28:31 -0700834 case CLEAR_ANIMATION_FRAME_STATS: {
835 CHECK_INTERFACE(ISurfaceComposer, data, reply);
836 status_t result = clearAnimationFrameStats();
837 reply->writeInt32(result);
838 return NO_ERROR;
839 }
840 case GET_ANIMATION_FRAME_STATS: {
841 CHECK_INTERFACE(ISurfaceComposer, data, reply);
842 FrameStats stats;
843 status_t result = getAnimationFrameStats(&stats);
844 reply->write(stats);
845 reply->writeInt32(result);
846 return NO_ERROR;
847 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700848 case SET_POWER_MODE: {
849 CHECK_INTERFACE(ISurfaceComposer, data, reply);
850 sp<IBinder> display = data.readStrongBinder();
851 int32_t mode = data.readInt32();
852 setPowerMode(display, mode);
853 return NO_ERROR;
854 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700855 case GET_HDR_CAPABILITIES: {
856 CHECK_INTERFACE(ISurfaceComposer, data, reply);
857 sp<IBinder> display = nullptr;
858 status_t result = data.readStrongBinder(&display);
859 if (result != NO_ERROR) {
860 ALOGE("getHdrCapabilities failed to readStrongBinder: %d",
861 result);
862 return result;
863 }
864 HdrCapabilities capabilities;
865 result = getHdrCapabilities(display, &capabilities);
866 reply->writeInt32(result);
867 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800868 reply->write(capabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700869 }
870 return NO_ERROR;
871 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700872 case ENABLE_VSYNC_INJECTIONS: {
873 CHECK_INTERFACE(ISurfaceComposer, data, reply);
874 bool enable = false;
875 status_t result = data.readBool(&enable);
876 if (result != NO_ERROR) {
877 ALOGE("enableVSyncInjections failed to readBool: %d", result);
878 return result;
879 }
880 return enableVSyncInjections(enable);
881 }
882 case INJECT_VSYNC: {
883 CHECK_INTERFACE(ISurfaceComposer, data, reply);
884 int64_t when = 0;
885 status_t result = data.readInt64(&when);
886 if (result != NO_ERROR) {
887 ALOGE("enableVSyncInjections failed to readInt64: %d", result);
888 return result;
889 }
890 return injectVSync(when);
891 }
Kalle Raitaa099a242017-01-11 11:17:29 -0800892 case GET_LAYER_DEBUG_INFO: {
893 CHECK_INTERFACE(ISurfaceComposer, data, reply);
894 std::vector<LayerDebugInfo> outLayers;
895 status_t result = getLayerDebugInfo(&outLayers);
896 reply->writeInt32(result);
897 if (result == NO_ERROR)
898 {
899 result = reply->writeParcelableVector(outLayers);
900 }
901 return result;
902 }
Peiyong Lin0256f722018-08-31 15:45:10 -0700903 case GET_COMPOSITION_PREFERENCE: {
904 CHECK_INTERFACE(ISurfaceComposer, data, reply);
905 ui::Dataspace dataSpace;
906 ui::PixelFormat pixelFormat;
907 status_t error = getCompositionPreference(&dataSpace, &pixelFormat);
908 reply->writeInt32(error);
909 if (error == NO_ERROR) {
910 reply->writeInt32(static_cast<int32_t>(dataSpace));
911 reply->writeInt32(static_cast<int32_t>(pixelFormat));
912 }
913 return NO_ERROR;
914 }
Jesse Hall6c913be2013-08-08 12:15:49 -0700915 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700916 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -0700917 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800918 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800919}
920
921// ----------------------------------------------------------------------------
922
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800923};