blob: f99bc5307c7512e37d1402d9f9c5885b0626b139 [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,
chaviw0e3479f2018-09-10 16:49:30 -0700107 bool useIdentityTransform, ISurfaceComposer::Rotation rotation) {
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800108 Parcel data, reply;
109 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
110 data.writeStrongBinder(display);
Dan Stozac1879002014-05-22 15:59:05 -0700111 data.write(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800112 data.writeUint32(reqWidth);
113 data.writeUint32(reqHeight);
Dan Stozac7014012014-02-14 15:03:43 -0800114 data.writeInt32(static_cast<int32_t>(useIdentityTransform));
Riley Andrewsc3ebe662014-09-04 16:20:31 -0700115 data.writeInt32(static_cast<int32_t>(rotation));
Ana Krulec2d41e422018-07-26 12:07:43 -0700116 status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply);
117 if (result != NO_ERROR) {
118 ALOGE("captureScreen failed to transact: %d", result);
119 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000120 }
Ana Krulec2d41e422018-07-26 12:07:43 -0700121 result = reply.readInt32();
122 if (result != NO_ERROR) {
123 ALOGE("captureScreen failed to readInt32: %d", result);
124 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000125 }
126
127 *outBuffer = new GraphicBuffer();
128 reply.read(**outBuffer);
Ana Krulec2d41e422018-07-26 12:07:43 -0700129 return result;
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800130 }
131
chaviwa76b2712017-09-20 12:02:26 -0700132 virtual status_t captureLayers(const sp<IBinder>& layerHandleBinder,
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000133 sp<GraphicBuffer>* outBuffer, const Rect& sourceCrop,
Robert Carr578038f2018-03-09 12:25:24 -0800134 float frameScale, bool childrenOnly) {
chaviwa76b2712017-09-20 12:02:26 -0700135 Parcel data, reply;
136 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
137 data.writeStrongBinder(layerHandleBinder);
chaviw7206d492017-11-10 16:16:12 -0800138 data.write(sourceCrop);
139 data.writeFloat(frameScale);
Robert Carr578038f2018-03-09 12:25:24 -0800140 data.writeBool(childrenOnly);
Ana Krulec2d41e422018-07-26 12:07:43 -0700141 status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_LAYERS, data, &reply);
142 if (result != NO_ERROR) {
143 ALOGE("captureLayers failed to transact: %d", result);
144 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000145 }
Ana Krulec2d41e422018-07-26 12:07:43 -0700146 result = reply.readInt32();
147 if (result != NO_ERROR) {
148 ALOGE("captureLayers failed to readInt32: %d", result);
149 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000150 }
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000151 *outBuffer = new GraphicBuffer();
152 reply.read(**outBuffer);
153
Ana Krulec2d41e422018-07-26 12:07:43 -0700154 return result;
chaviwa76b2712017-09-20 12:02:26 -0700155 }
156
Jamie Gennis582270d2011-08-17 18:19:00 -0700157 virtual bool authenticateSurfaceTexture(
Andy McFadden2adaf042012-12-18 09:49:45 -0800158 const sp<IGraphicBufferProducer>& bufferProducer) const
Jamie Gennis134f0422011-03-08 12:18:54 -0800159 {
160 Parcel data, reply;
161 int err = NO_ERROR;
162 err = data.writeInterfaceToken(
163 ISurfaceComposer::getInterfaceDescriptor());
164 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000165 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis134f0422011-03-08 12:18:54 -0800166 "interface descriptor: %s (%d)", strerror(-err), -err);
167 return false;
168 }
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800169 err = data.writeStrongBinder(IInterface::asBinder(bufferProducer));
Jamie Gennis134f0422011-03-08 12:18:54 -0800170 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000171 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis582270d2011-08-17 18:19:00 -0700172 "strong binder to parcel: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800173 return false;
174 }
175 err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
176 &reply);
177 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000178 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700179 "performing transaction: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800180 return false;
181 }
182 int32_t result = 0;
183 err = reply.readInt32(&result);
184 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000185 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700186 "retrieving result: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800187 return false;
188 }
189 return result != 0;
190 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800191
Brian Anderson6b376712017-04-04 10:51:39 -0700192 virtual status_t getSupportedFrameTimestamps(
193 std::vector<FrameEvent>* outSupported) const {
194 if (!outSupported) {
195 return UNEXPECTED_NULL;
196 }
197 outSupported->clear();
198
199 Parcel data, reply;
200
201 status_t err = data.writeInterfaceToken(
202 ISurfaceComposer::getInterfaceDescriptor());
203 if (err != NO_ERROR) {
204 return err;
205 }
206
207 err = remote()->transact(
208 BnSurfaceComposer::GET_SUPPORTED_FRAME_TIMESTAMPS,
209 data, &reply);
210 if (err != NO_ERROR) {
211 return err;
212 }
213
214 int32_t result = 0;
215 err = reply.readInt32(&result);
216 if (err != NO_ERROR) {
217 return err;
218 }
219 if (result != NO_ERROR) {
220 return result;
221 }
222
223 std::vector<int32_t> supported;
224 err = reply.readInt32Vector(&supported);
225 if (err != NO_ERROR) {
226 return err;
227 }
228
229 outSupported->reserve(supported.size());
230 for (int32_t s : supported) {
231 outSupported->push_back(static_cast<FrameEvent>(s));
232 }
233 return NO_ERROR;
234 }
235
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700236 virtual sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource)
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800237 {
238 Parcel data, reply;
239 sp<IDisplayEventConnection> result;
240 int err = data.writeInterfaceToken(
241 ISurfaceComposer::getInterfaceDescriptor());
242 if (err != NO_ERROR) {
243 return result;
244 }
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700245 data.writeInt32(static_cast<int32_t>(vsyncSource));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800246 err = remote()->transact(
247 BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION,
248 data, &reply);
249 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000250 ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing "
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800251 "transaction: %s (%d)", strerror(-err), -err);
252 return result;
253 }
254 result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder());
255 return result;
256 }
Colin Cross8e533062012-06-07 13:17:52 -0700257
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700258 virtual sp<IBinder> createDisplay(const String8& displayName, bool secure)
Mathias Agopiane57f2922012-08-09 16:29:12 -0700259 {
260 Parcel data, reply;
261 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700262 data.writeString8(displayName);
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700263 data.writeInt32(secure ? 1 : 0);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700264 remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply);
265 return reply.readStrongBinder();
266 }
267
Jesse Hall6c913be2013-08-08 12:15:49 -0700268 virtual void destroyDisplay(const sp<IBinder>& display)
269 {
270 Parcel data, reply;
271 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
272 data.writeStrongBinder(display);
273 remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply);
274 }
275
Mathias Agopiane57f2922012-08-09 16:29:12 -0700276 virtual sp<IBinder> getBuiltInDisplay(int32_t id)
277 {
278 Parcel data, reply;
279 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
280 data.writeInt32(id);
281 remote()->transact(BnSurfaceComposer::GET_BUILT_IN_DISPLAY, data, &reply);
282 return reply.readStrongBinder();
283 }
284
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700285 virtual void setPowerMode(const sp<IBinder>& display, int mode)
Colin Cross8e533062012-06-07 13:17:52 -0700286 {
287 Parcel data, reply;
288 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700289 data.writeStrongBinder(display);
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700290 data.writeInt32(mode);
291 remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply);
Colin Cross8e533062012-06-07 13:17:52 -0700292 }
Mathias Agopian3094df32012-06-18 18:06:45 -0700293
Dan Stoza7f7da322014-05-02 15:26:25 -0700294 virtual status_t getDisplayConfigs(const sp<IBinder>& display,
295 Vector<DisplayInfo>* configs)
Mathias Agopianc666cae2012-07-25 18:56:13 -0700296 {
297 Parcel data, reply;
298 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700299 data.writeStrongBinder(display);
Dan Stoza7f7da322014-05-02 15:26:25 -0700300 remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply);
301 status_t result = reply.readInt32();
302 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -0800303 size_t numConfigs = reply.readUint32();
Dan Stoza7f7da322014-05-02 15:26:25 -0700304 configs->clear();
305 configs->resize(numConfigs);
306 for (size_t c = 0; c < numConfigs; ++c) {
307 memcpy(&(configs->editItemAt(c)),
308 reply.readInplace(sizeof(DisplayInfo)),
309 sizeof(DisplayInfo));
310 }
311 }
312 return result;
313 }
314
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700315 virtual status_t getDisplayStats(const sp<IBinder>& display,
316 DisplayStatInfo* stats)
317 {
318 Parcel data, reply;
319 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
320 data.writeStrongBinder(display);
321 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply);
322 status_t result = reply.readInt32();
323 if (result == NO_ERROR) {
324 memcpy(stats,
325 reply.readInplace(sizeof(DisplayStatInfo)),
326 sizeof(DisplayStatInfo));
327 }
328 return result;
329 }
330
Dan Stoza7f7da322014-05-02 15:26:25 -0700331 virtual int getActiveConfig(const sp<IBinder>& display)
332 {
333 Parcel data, reply;
334 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
335 data.writeStrongBinder(display);
336 remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply);
337 return reply.readInt32();
338 }
339
340 virtual status_t setActiveConfig(const sp<IBinder>& display, int id)
341 {
342 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700343 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
344 if (result != NO_ERROR) {
345 ALOGE("setActiveConfig failed to writeInterfaceToken: %d", result);
346 return result;
347 }
348 result = data.writeStrongBinder(display);
349 if (result != NO_ERROR) {
350 ALOGE("setActiveConfig failed to writeStrongBinder: %d", result);
351 return result;
352 }
353 result = data.writeInt32(id);
354 if (result != NO_ERROR) {
355 ALOGE("setActiveConfig failed to writeInt32: %d", result);
356 return result;
357 }
358 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply);
359 if (result != NO_ERROR) {
360 ALOGE("setActiveConfig failed to transact: %d", result);
361 return result;
362 }
Mathias Agopianc666cae2012-07-25 18:56:13 -0700363 return reply.readInt32();
364 }
Svetoslavd85084b2014-03-20 10:28:31 -0700365
Michael Wright28f24d02016-07-12 13:30:53 -0700366 virtual status_t getDisplayColorModes(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700367 Vector<ColorMode>* outColorModes) {
Michael Wright28f24d02016-07-12 13:30:53 -0700368 Parcel data, reply;
369 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
370 if (result != NO_ERROR) {
371 ALOGE("getDisplayColorModes failed to writeInterfaceToken: %d", result);
372 return result;
373 }
374 result = data.writeStrongBinder(display);
375 if (result != NO_ERROR) {
376 ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result);
377 return result;
378 }
379 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply);
380 if (result != NO_ERROR) {
381 ALOGE("getDisplayColorModes failed to transact: %d", result);
382 return result;
383 }
384 result = static_cast<status_t>(reply.readInt32());
385 if (result == NO_ERROR) {
386 size_t numModes = reply.readUint32();
387 outColorModes->clear();
388 outColorModes->resize(numModes);
389 for (size_t i = 0; i < numModes; ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -0700390 outColorModes->replaceAt(static_cast<ColorMode>(reply.readInt32()), i);
Michael Wright28f24d02016-07-12 13:30:53 -0700391 }
392 }
393 return result;
394 }
395
Peiyong Lina52f0292018-03-14 17:26:31 -0700396 virtual ColorMode getActiveColorMode(const sp<IBinder>& display) {
Michael Wright28f24d02016-07-12 13:30:53 -0700397 Parcel data, reply;
398 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
399 if (result != NO_ERROR) {
400 ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700401 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700402 }
403 result = data.writeStrongBinder(display);
404 if (result != NO_ERROR) {
405 ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700406 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700407 }
408 result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply);
409 if (result != NO_ERROR) {
410 ALOGE("getActiveColorMode failed to transact: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700411 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700412 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700413 return static_cast<ColorMode>(reply.readInt32());
Michael Wright28f24d02016-07-12 13:30:53 -0700414 }
415
416 virtual status_t setActiveColorMode(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700417 ColorMode colorMode) {
Michael Wright28f24d02016-07-12 13:30:53 -0700418 Parcel data, reply;
419 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
420 if (result != NO_ERROR) {
421 ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result);
422 return result;
423 }
424 result = data.writeStrongBinder(display);
425 if (result != NO_ERROR) {
426 ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result);
427 return result;
428 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700429 result = data.writeInt32(static_cast<int32_t>(colorMode));
Michael Wright28f24d02016-07-12 13:30:53 -0700430 if (result != NO_ERROR) {
431 ALOGE("setActiveColorMode failed to writeInt32: %d", result);
432 return result;
433 }
434 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply);
435 if (result != NO_ERROR) {
436 ALOGE("setActiveColorMode failed to transact: %d", result);
437 return result;
438 }
439 return static_cast<status_t>(reply.readInt32());
440 }
441
Svetoslavd85084b2014-03-20 10:28:31 -0700442 virtual status_t clearAnimationFrameStats() {
443 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700444 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
445 if (result != NO_ERROR) {
446 ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result);
447 return result;
448 }
449 result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply);
450 if (result != NO_ERROR) {
451 ALOGE("clearAnimationFrameStats failed to transact: %d", result);
452 return result;
453 }
Svetoslavd85084b2014-03-20 10:28:31 -0700454 return reply.readInt32();
455 }
456
457 virtual status_t getAnimationFrameStats(FrameStats* outStats) const {
458 Parcel data, reply;
459 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
460 remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply);
461 reply.read(*outStats);
462 return reply.readInt32();
463 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700464
465 virtual status_t getHdrCapabilities(const sp<IBinder>& display,
466 HdrCapabilities* outCapabilities) const {
467 Parcel data, reply;
468 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
469 status_t result = data.writeStrongBinder(display);
470 if (result != NO_ERROR) {
471 ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result);
472 return result;
473 }
474 result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES,
475 data, &reply);
476 if (result != NO_ERROR) {
477 ALOGE("getHdrCapabilities failed to transact: %d", result);
478 return result;
479 }
480 result = reply.readInt32();
481 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800482 result = reply.read(*outCapabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700483 }
484 return result;
485 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700486
487 virtual status_t enableVSyncInjections(bool enable) {
488 Parcel data, reply;
489 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
490 if (result != NO_ERROR) {
491 ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result);
492 return result;
493 }
494 result = data.writeBool(enable);
495 if (result != NO_ERROR) {
496 ALOGE("enableVSyncInjections failed to writeBool: %d", result);
497 return result;
498 }
499 result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS,
500 data, &reply, TF_ONE_WAY);
501 if (result != NO_ERROR) {
502 ALOGE("enableVSyncInjections failed to transact: %d", result);
503 return result;
504 }
505 return result;
506 }
507
508 virtual status_t injectVSync(nsecs_t when) {
509 Parcel data, reply;
510 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
511 if (result != NO_ERROR) {
512 ALOGE("injectVSync failed to writeInterfaceToken: %d", result);
513 return result;
514 }
515 result = data.writeInt64(when);
516 if (result != NO_ERROR) {
517 ALOGE("injectVSync failed to writeInt64: %d", result);
518 return result;
519 }
520 result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply, TF_ONE_WAY);
521 if (result != NO_ERROR) {
522 ALOGE("injectVSync failed to transact: %d", result);
523 return result;
524 }
525 return result;
526 }
527
Kalle Raitaa099a242017-01-11 11:17:29 -0800528 virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const
529 {
530 if (!outLayers) {
531 return UNEXPECTED_NULL;
532 }
533
534 Parcel data, reply;
535
536 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
537 if (err != NO_ERROR) {
538 return err;
539 }
540
541 err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply);
542 if (err != NO_ERROR) {
543 return err;
544 }
545
546 int32_t result = 0;
547 err = reply.readInt32(&result);
548 if (err != NO_ERROR) {
549 return err;
550 }
551 if (result != NO_ERROR) {
552 return result;
553 }
554
555 outLayers->clear();
556 return reply.readParcelableVector(outLayers);
557 }
Peiyong Lin0256f722018-08-31 15:45:10 -0700558
559 virtual status_t getCompositionPreference(ui::Dataspace* dataSpace,
560 ui::PixelFormat* pixelFormat) const {
561 Parcel data, reply;
562 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
563 if (error != NO_ERROR) {
564 return error;
565 }
566 error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply);
567 if (error != NO_ERROR) {
568 return error;
569 }
570 error = static_cast<status_t>(reply.readInt32());
571 if (error == NO_ERROR) {
572 *dataSpace = static_cast<ui::Dataspace>(reply.readInt32());
573 *pixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
574 }
575 return error;
576 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800577};
578
Dan Stozad723bd72014-11-18 10:24:03 -0800579// Out-of-line virtual method definition to trigger vtable emission in this
580// translation unit (see clang warning -Wweak-vtables)
581BpSurfaceComposer::~BpSurfaceComposer() {}
582
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800583IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
584
585// ----------------------------------------------------------------------
586
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800587status_t BnSurfaceComposer::onTransact(
588 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
589{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800590 switch(code) {
591 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700592 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800593 sp<IBinder> b = IInterface::asBinder(createConnection());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800594 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -0700595 return NO_ERROR;
596 }
Robert Carr1db73f62016-12-21 12:58:51 -0800597 case CREATE_SCOPED_CONNECTION: {
598 CHECK_INTERFACE(ISurfaceComposer, data, reply);
599 sp<IGraphicBufferProducer> bufferProducer =
600 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
601 sp<IBinder> b = IInterface::asBinder(createScopedConnection(bufferProducer));
602 reply->writeStrongBinder(b);
603 return NO_ERROR;
604 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700605 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700606 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -0800607
608 size_t count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700609 if (count > data.dataSize()) {
610 return BAD_VALUE;
611 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700612 ComposerState s;
613 Vector<ComposerState> state;
614 state.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800615 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700616 if (s.read(data) == BAD_VALUE) {
617 return BAD_VALUE;
618 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700619 state.add(s);
620 }
Dan Stozad723bd72014-11-18 10:24:03 -0800621
622 count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700623 if (count > data.dataSize()) {
624 return BAD_VALUE;
625 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700626 DisplayState d;
627 Vector<DisplayState> displays;
628 displays.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800629 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700630 if (d.read(data) == BAD_VALUE) {
631 return BAD_VALUE;
632 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700633 displays.add(d);
634 }
Dan Stozad723bd72014-11-18 10:24:03 -0800635
636 uint32_t stateFlags = data.readUint32();
637 setTransactionState(state, displays, stateFlags);
Jesse Hall6c913be2013-08-08 12:15:49 -0700638 return NO_ERROR;
639 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800640 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700641 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800642 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -0700643 return NO_ERROR;
644 }
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800645 case CAPTURE_SCREEN: {
646 CHECK_INTERFACE(ISurfaceComposer, data, reply);
647 sp<IBinder> display = data.readStrongBinder();
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000648 sp<GraphicBuffer> outBuffer;
Pablo Ceballos60d69222015-08-07 14:47:20 -0700649 Rect sourceCrop(Rect::EMPTY_RECT);
Dan Stozac1879002014-05-22 15:59:05 -0700650 data.read(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800651 uint32_t reqWidth = data.readUint32();
652 uint32_t reqHeight = data.readUint32();
Dan Stozac7014012014-02-14 15:03:43 -0800653 bool useIdentityTransform = static_cast<bool>(data.readInt32());
Dan Stozad723bd72014-11-18 10:24:03 -0800654 int32_t rotation = data.readInt32();
Dan Stozac7014012014-02-14 15:03:43 -0800655
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000656 status_t res = captureScreen(display, &outBuffer, sourceCrop, reqWidth, reqHeight,
chaviw0e3479f2018-09-10 16:49:30 -0700657 useIdentityTransform,
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000658 static_cast<ISurfaceComposer::Rotation>(rotation));
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800659 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000660 if (res == NO_ERROR) {
661 reply->write(*outBuffer);
662 }
Jesse Hall6c913be2013-08-08 12:15:49 -0700663 return NO_ERROR;
664 }
chaviwa76b2712017-09-20 12:02:26 -0700665 case CAPTURE_LAYERS: {
666 CHECK_INTERFACE(ISurfaceComposer, data, reply);
667 sp<IBinder> layerHandleBinder = data.readStrongBinder();
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000668 sp<GraphicBuffer> outBuffer;
chaviw7206d492017-11-10 16:16:12 -0800669 Rect sourceCrop(Rect::EMPTY_RECT);
670 data.read(sourceCrop);
671 float frameScale = data.readFloat();
Robert Carr578038f2018-03-09 12:25:24 -0800672 bool childrenOnly = data.readBool();
chaviwa76b2712017-09-20 12:02:26 -0700673
Robert Carr578038f2018-03-09 12:25:24 -0800674 status_t res = captureLayers(layerHandleBinder, &outBuffer, sourceCrop, frameScale,
675 childrenOnly);
chaviwa76b2712017-09-20 12:02:26 -0700676 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000677 if (res == NO_ERROR) {
678 reply->write(*outBuffer);
679 }
chaviwa76b2712017-09-20 12:02:26 -0700680 return NO_ERROR;
681 }
Jamie Gennis134f0422011-03-08 12:18:54 -0800682 case AUTHENTICATE_SURFACE: {
683 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -0800684 sp<IGraphicBufferProducer> bufferProducer =
685 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
686 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -0800687 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700688 return NO_ERROR;
689 }
Brian Anderson6b376712017-04-04 10:51:39 -0700690 case GET_SUPPORTED_FRAME_TIMESTAMPS: {
691 CHECK_INTERFACE(ISurfaceComposer, data, reply);
692 std::vector<FrameEvent> supportedTimestamps;
693 status_t result = getSupportedFrameTimestamps(&supportedTimestamps);
694 status_t err = reply->writeInt32(result);
695 if (err != NO_ERROR) {
696 return err;
697 }
698 if (result != NO_ERROR) {
699 return result;
700 }
701
702 std::vector<int32_t> supported;
703 supported.reserve(supportedTimestamps.size());
704 for (FrameEvent s : supportedTimestamps) {
705 supported.push_back(static_cast<int32_t>(s));
706 }
707 return reply->writeInt32Vector(supported);
708 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800709 case CREATE_DISPLAY_EVENT_CONNECTION: {
710 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700711 sp<IDisplayEventConnection> connection(createDisplayEventConnection(
712 static_cast<ISurfaceComposer::VsyncSource>(data.readInt32())));
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800713 reply->writeStrongBinder(IInterface::asBinder(connection));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800714 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700715 }
Mathias Agopiane57f2922012-08-09 16:29:12 -0700716 case CREATE_DISPLAY: {
717 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700718 String8 displayName = data.readString8();
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700719 bool secure = bool(data.readInt32());
720 sp<IBinder> display(createDisplay(displayName, secure));
Mathias Agopiane57f2922012-08-09 16:29:12 -0700721 reply->writeStrongBinder(display);
722 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700723 }
724 case DESTROY_DISPLAY: {
725 CHECK_INTERFACE(ISurfaceComposer, data, reply);
726 sp<IBinder> display = data.readStrongBinder();
727 destroyDisplay(display);
728 return NO_ERROR;
729 }
Mathias Agopiane57f2922012-08-09 16:29:12 -0700730 case GET_BUILT_IN_DISPLAY: {
731 CHECK_INTERFACE(ISurfaceComposer, data, reply);
732 int32_t id = data.readInt32();
733 sp<IBinder> display(getBuiltInDisplay(id));
734 reply->writeStrongBinder(display);
735 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700736 }
Dan Stoza7f7da322014-05-02 15:26:25 -0700737 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -0700738 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stoza7f7da322014-05-02 15:26:25 -0700739 Vector<DisplayInfo> configs;
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700740 sp<IBinder> display = data.readStrongBinder();
Dan Stoza7f7da322014-05-02 15:26:25 -0700741 status_t result = getDisplayConfigs(display, &configs);
742 reply->writeInt32(result);
743 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -0800744 reply->writeUint32(static_cast<uint32_t>(configs.size()));
Dan Stoza7f7da322014-05-02 15:26:25 -0700745 for (size_t c = 0; c < configs.size(); ++c) {
746 memcpy(reply->writeInplace(sizeof(DisplayInfo)),
747 &configs[c], sizeof(DisplayInfo));
748 }
749 }
750 return NO_ERROR;
751 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700752 case GET_DISPLAY_STATS: {
753 CHECK_INTERFACE(ISurfaceComposer, data, reply);
754 DisplayStatInfo stats;
755 sp<IBinder> display = data.readStrongBinder();
756 status_t result = getDisplayStats(display, &stats);
757 reply->writeInt32(result);
758 if (result == NO_ERROR) {
759 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
760 &stats, sizeof(DisplayStatInfo));
761 }
762 return NO_ERROR;
763 }
Dan Stoza7f7da322014-05-02 15:26:25 -0700764 case GET_ACTIVE_CONFIG: {
765 CHECK_INTERFACE(ISurfaceComposer, data, reply);
766 sp<IBinder> display = data.readStrongBinder();
767 int id = getActiveConfig(display);
768 reply->writeInt32(id);
769 return NO_ERROR;
770 }
771 case SET_ACTIVE_CONFIG: {
772 CHECK_INTERFACE(ISurfaceComposer, data, reply);
773 sp<IBinder> display = data.readStrongBinder();
774 int id = data.readInt32();
775 status_t result = setActiveConfig(display, id);
Mathias Agopianc666cae2012-07-25 18:56:13 -0700776 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700777 return NO_ERROR;
778 }
Michael Wright28f24d02016-07-12 13:30:53 -0700779 case GET_DISPLAY_COLOR_MODES: {
780 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Lina52f0292018-03-14 17:26:31 -0700781 Vector<ColorMode> colorModes;
Michael Wright28f24d02016-07-12 13:30:53 -0700782 sp<IBinder> display = nullptr;
783 status_t result = data.readStrongBinder(&display);
784 if (result != NO_ERROR) {
785 ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result);
786 return result;
787 }
788 result = getDisplayColorModes(display, &colorModes);
789 reply->writeInt32(result);
790 if (result == NO_ERROR) {
791 reply->writeUint32(static_cast<uint32_t>(colorModes.size()));
792 for (size_t i = 0; i < colorModes.size(); ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -0700793 reply->writeInt32(static_cast<int32_t>(colorModes[i]));
Michael Wright28f24d02016-07-12 13:30:53 -0700794 }
795 }
796 return NO_ERROR;
797 }
798 case GET_ACTIVE_COLOR_MODE: {
799 CHECK_INTERFACE(ISurfaceComposer, data, reply);
800 sp<IBinder> display = nullptr;
801 status_t result = data.readStrongBinder(&display);
802 if (result != NO_ERROR) {
803 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
804 return result;
805 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700806 ColorMode colorMode = getActiveColorMode(display);
Michael Wright28f24d02016-07-12 13:30:53 -0700807 result = reply->writeInt32(static_cast<int32_t>(colorMode));
808 return result;
809 }
810 case SET_ACTIVE_COLOR_MODE: {
811 CHECK_INTERFACE(ISurfaceComposer, data, reply);
812 sp<IBinder> display = nullptr;
813 status_t result = data.readStrongBinder(&display);
814 if (result != NO_ERROR) {
815 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
816 return result;
817 }
818 int32_t colorModeInt = 0;
819 result = data.readInt32(&colorModeInt);
820 if (result != NO_ERROR) {
821 ALOGE("setActiveColorMode failed to readInt32: %d", result);
822 return result;
823 }
824 result = setActiveColorMode(display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700825 static_cast<ColorMode>(colorModeInt));
Michael Wright28f24d02016-07-12 13:30:53 -0700826 result = reply->writeInt32(result);
827 return result;
828 }
Svetoslavd85084b2014-03-20 10:28:31 -0700829 case CLEAR_ANIMATION_FRAME_STATS: {
830 CHECK_INTERFACE(ISurfaceComposer, data, reply);
831 status_t result = clearAnimationFrameStats();
832 reply->writeInt32(result);
833 return NO_ERROR;
834 }
835 case GET_ANIMATION_FRAME_STATS: {
836 CHECK_INTERFACE(ISurfaceComposer, data, reply);
837 FrameStats stats;
838 status_t result = getAnimationFrameStats(&stats);
839 reply->write(stats);
840 reply->writeInt32(result);
841 return NO_ERROR;
842 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700843 case SET_POWER_MODE: {
844 CHECK_INTERFACE(ISurfaceComposer, data, reply);
845 sp<IBinder> display = data.readStrongBinder();
846 int32_t mode = data.readInt32();
847 setPowerMode(display, mode);
848 return NO_ERROR;
849 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700850 case GET_HDR_CAPABILITIES: {
851 CHECK_INTERFACE(ISurfaceComposer, data, reply);
852 sp<IBinder> display = nullptr;
853 status_t result = data.readStrongBinder(&display);
854 if (result != NO_ERROR) {
855 ALOGE("getHdrCapabilities failed to readStrongBinder: %d",
856 result);
857 return result;
858 }
859 HdrCapabilities capabilities;
860 result = getHdrCapabilities(display, &capabilities);
861 reply->writeInt32(result);
862 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800863 reply->write(capabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700864 }
865 return NO_ERROR;
866 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700867 case ENABLE_VSYNC_INJECTIONS: {
868 CHECK_INTERFACE(ISurfaceComposer, data, reply);
869 bool enable = false;
870 status_t result = data.readBool(&enable);
871 if (result != NO_ERROR) {
872 ALOGE("enableVSyncInjections failed to readBool: %d", result);
873 return result;
874 }
875 return enableVSyncInjections(enable);
876 }
877 case INJECT_VSYNC: {
878 CHECK_INTERFACE(ISurfaceComposer, data, reply);
879 int64_t when = 0;
880 status_t result = data.readInt64(&when);
881 if (result != NO_ERROR) {
882 ALOGE("enableVSyncInjections failed to readInt64: %d", result);
883 return result;
884 }
885 return injectVSync(when);
886 }
Kalle Raitaa099a242017-01-11 11:17:29 -0800887 case GET_LAYER_DEBUG_INFO: {
888 CHECK_INTERFACE(ISurfaceComposer, data, reply);
889 std::vector<LayerDebugInfo> outLayers;
890 status_t result = getLayerDebugInfo(&outLayers);
891 reply->writeInt32(result);
892 if (result == NO_ERROR)
893 {
894 result = reply->writeParcelableVector(outLayers);
895 }
896 return result;
897 }
Peiyong Lin0256f722018-08-31 15:45:10 -0700898 case GET_COMPOSITION_PREFERENCE: {
899 CHECK_INTERFACE(ISurfaceComposer, data, reply);
900 ui::Dataspace dataSpace;
901 ui::PixelFormat pixelFormat;
902 status_t error = getCompositionPreference(&dataSpace, &pixelFormat);
903 reply->writeInt32(error);
904 if (error == NO_ERROR) {
905 reply->writeInt32(static_cast<int32_t>(dataSpace));
906 reply->writeInt32(static_cast<int32_t>(pixelFormat));
907 }
908 return NO_ERROR;
909 }
Jesse Hall6c913be2013-08-08 12:15:49 -0700910 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700911 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -0700912 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800913 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800914}
915
916// ----------------------------------------------------------------------------
917
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800918};