blob: 247dc8d9d21abba74f890eeaabaf7faa519e546e [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>
Dan Stoza84ab9372018-12-17 15:27:57 -080029#include <gui/IRegionSamplingListener.h>
Mathias Agopian2b5dd402017-02-07 17:36:19 -080030#include <gui/ISurfaceComposer.h>
31#include <gui/ISurfaceComposerClient.h>
Kalle Raitaa099a242017-01-11 11:17:29 -080032#include <gui/LayerDebugInfo.h>
Robert Carr4cdc58f2017-08-23 14:22:20 -070033#include <gui/LayerState.h>
Mathias Agopiand0566bc2011-11-17 17:49:17 -080034
Michael Wright28f24d02016-07-12 13:30:53 -070035#include <system/graphics.h>
36
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080037#include <ui/DisplayInfo.h>
Lajos Molnar67d8bd62014-09-11 14:58:45 -070038#include <ui/DisplayStatInfo.h>
Dan Stozac4f471e2016-03-24 09:31:08 -070039#include <ui/HdrCapabilities.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080040
Jamie Gennis134f0422011-03-08 12:18:54 -080041#include <utils/Log.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -080042
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080043// ---------------------------------------------------------------------------
44
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080045namespace android {
46
Peiyong Lin9f034472018-03-28 15:29:00 -070047using ui::ColorMode;
48
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080049class BpSurfaceComposer : public BpInterface<ISurfaceComposer>
50{
51public:
Chih-Hung Hsiehe2347b72016-04-25 15:41:05 -070052 explicit BpSurfaceComposer(const sp<IBinder>& impl)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080053 : BpInterface<ISurfaceComposer>(impl)
54 {
55 }
56
Dan Stozad723bd72014-11-18 10:24:03 -080057 virtual ~BpSurfaceComposer();
58
Mathias Agopian7e27f052010-05-28 14:22:23 -070059 virtual sp<ISurfaceComposerClient> createConnection()
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080060 {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080061 Parcel data, reply;
62 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
63 remote()->transact(BnSurfaceComposer::CREATE_CONNECTION, data, &reply);
Mathias Agopian7e27f052010-05-28 14:22:23 -070064 return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080065 }
66
Marissa Wall713b63f2018-10-17 15:42:43 -070067 virtual void setTransactionState(const Vector<ComposerState>& state,
68 const Vector<DisplayState>& displays, uint32_t flags,
chaviw273171b2018-12-26 11:46:30 -080069 const sp<IBinder>& applyToken,
Marissa Wall17b4e452018-12-26 16:32:34 -080070 const InputWindowCommands& commands,
71 int64_t desiredPresentTime) {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080072 Parcel data, reply;
73 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Dan Stozad723bd72014-11-18 10:24:03 -080074
75 data.writeUint32(static_cast<uint32_t>(state.size()));
76 for (const auto& s : state) {
77 s.write(data);
Mathias Agopian698c0872011-06-28 19:09:31 -070078 }
Dan Stozad723bd72014-11-18 10:24:03 -080079
80 data.writeUint32(static_cast<uint32_t>(displays.size()));
81 for (const auto& d : displays) {
82 d.write(data);
Mathias Agopian8b33f032012-07-24 20:43:54 -070083 }
Dan Stozad723bd72014-11-18 10:24:03 -080084
85 data.writeUint32(flags);
Marissa Wall713b63f2018-10-17 15:42:43 -070086 data.writeStrongBinder(applyToken);
chaviw273171b2018-12-26 11:46:30 -080087 commands.write(data);
Marissa Wall17b4e452018-12-26 16:32:34 -080088 data.writeInt64(desiredPresentTime);
Jamie Gennisb8d69a52011-10-10 15:48:06 -070089 remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080090 }
91
92 virtual void bootFinished()
93 {
94 Parcel data, reply;
95 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
96 remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply);
97 }
98
Chavi Weingarten40482ff2017-11-30 01:51:40 +000099 virtual status_t captureScreen(const sp<IBinder>& display, sp<GraphicBuffer>* outBuffer,
Peiyong Lin0e003c92018-09-17 11:09:51 -0700100 const ui::Dataspace reqDataspace,
101 const ui::PixelFormat reqPixelFormat, Rect sourceCrop,
102 uint32_t reqWidth, uint32_t reqHeight, bool useIdentityTransform,
Robert Carrfa8855f2019-02-19 10:05:00 -0800103 ISurfaceComposer::Rotation rotation, bool captureSecureLayers) {
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800104 Parcel data, reply;
105 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
106 data.writeStrongBinder(display);
Peiyong Lin0e003c92018-09-17 11:09:51 -0700107 data.writeInt32(static_cast<int32_t>(reqDataspace));
108 data.writeInt32(static_cast<int32_t>(reqPixelFormat));
Dan Stozac1879002014-05-22 15:59:05 -0700109 data.write(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800110 data.writeUint32(reqWidth);
111 data.writeUint32(reqHeight);
Dan Stozac7014012014-02-14 15:03:43 -0800112 data.writeInt32(static_cast<int32_t>(useIdentityTransform));
Riley Andrewsc3ebe662014-09-04 16:20:31 -0700113 data.writeInt32(static_cast<int32_t>(rotation));
Robert Carrfa8855f2019-02-19 10:05:00 -0800114 data.writeInt32(static_cast<int32_t>(captureSecureLayers));
Ana Krulec2d41e422018-07-26 12:07:43 -0700115 status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply);
116 if (result != NO_ERROR) {
117 ALOGE("captureScreen failed to transact: %d", result);
118 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000119 }
Ana Krulec2d41e422018-07-26 12:07:43 -0700120 result = reply.readInt32();
121 if (result != NO_ERROR) {
122 ALOGE("captureScreen failed to readInt32: %d", result);
123 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000124 }
125
126 *outBuffer = new GraphicBuffer();
127 reply.read(**outBuffer);
Peiyong Lin0e003c92018-09-17 11:09:51 -0700128
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,
Peiyong Lin0e003c92018-09-17 11:09:51 -0700133 sp<GraphicBuffer>* outBuffer, const ui::Dataspace reqDataspace,
134 const ui::PixelFormat reqPixelFormat, const Rect& sourceCrop,
Robert Carr578038f2018-03-09 12:25:24 -0800135 float frameScale, bool childrenOnly) {
chaviwa76b2712017-09-20 12:02:26 -0700136 Parcel data, reply;
137 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
138 data.writeStrongBinder(layerHandleBinder);
Peiyong Lin0e003c92018-09-17 11:09:51 -0700139 data.writeInt32(static_cast<int32_t>(reqDataspace));
140 data.writeInt32(static_cast<int32_t>(reqPixelFormat));
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 }
Peiyong Lin0e003c92018-09-17 11:09:51 -0700154
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000155 *outBuffer = new GraphicBuffer();
156 reply.read(**outBuffer);
157
Ana Krulec2d41e422018-07-26 12:07:43 -0700158 return result;
chaviwa76b2712017-09-20 12:02:26 -0700159 }
160
Jamie Gennis582270d2011-08-17 18:19:00 -0700161 virtual bool authenticateSurfaceTexture(
Andy McFadden2adaf042012-12-18 09:49:45 -0800162 const sp<IGraphicBufferProducer>& bufferProducer) const
Jamie Gennis134f0422011-03-08 12:18:54 -0800163 {
164 Parcel data, reply;
165 int err = NO_ERROR;
166 err = data.writeInterfaceToken(
167 ISurfaceComposer::getInterfaceDescriptor());
168 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000169 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis134f0422011-03-08 12:18:54 -0800170 "interface descriptor: %s (%d)", strerror(-err), -err);
171 return false;
172 }
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800173 err = data.writeStrongBinder(IInterface::asBinder(bufferProducer));
Jamie Gennis134f0422011-03-08 12:18:54 -0800174 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000175 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis582270d2011-08-17 18:19:00 -0700176 "strong binder to parcel: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800177 return false;
178 }
179 err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
180 &reply);
181 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000182 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700183 "performing transaction: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800184 return false;
185 }
186 int32_t result = 0;
187 err = reply.readInt32(&result);
188 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000189 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700190 "retrieving result: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800191 return false;
192 }
193 return result != 0;
194 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800195
Brian Anderson6b376712017-04-04 10:51:39 -0700196 virtual status_t getSupportedFrameTimestamps(
197 std::vector<FrameEvent>* outSupported) const {
198 if (!outSupported) {
199 return UNEXPECTED_NULL;
200 }
201 outSupported->clear();
202
203 Parcel data, reply;
204
205 status_t err = data.writeInterfaceToken(
206 ISurfaceComposer::getInterfaceDescriptor());
207 if (err != NO_ERROR) {
208 return err;
209 }
210
211 err = remote()->transact(
212 BnSurfaceComposer::GET_SUPPORTED_FRAME_TIMESTAMPS,
213 data, &reply);
214 if (err != NO_ERROR) {
215 return err;
216 }
217
218 int32_t result = 0;
219 err = reply.readInt32(&result);
220 if (err != NO_ERROR) {
221 return err;
222 }
223 if (result != NO_ERROR) {
224 return result;
225 }
226
227 std::vector<int32_t> supported;
228 err = reply.readInt32Vector(&supported);
229 if (err != NO_ERROR) {
230 return err;
231 }
232
233 outSupported->reserve(supported.size());
234 for (int32_t s : supported) {
235 outSupported->push_back(static_cast<FrameEvent>(s));
236 }
237 return NO_ERROR;
238 }
239
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700240 virtual sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource)
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800241 {
242 Parcel data, reply;
243 sp<IDisplayEventConnection> result;
244 int err = data.writeInterfaceToken(
245 ISurfaceComposer::getInterfaceDescriptor());
246 if (err != NO_ERROR) {
247 return result;
248 }
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700249 data.writeInt32(static_cast<int32_t>(vsyncSource));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800250 err = remote()->transact(
251 BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION,
252 data, &reply);
253 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000254 ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing "
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800255 "transaction: %s (%d)", strerror(-err), -err);
256 return result;
257 }
258 result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder());
259 return result;
260 }
Colin Cross8e533062012-06-07 13:17:52 -0700261
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700262 virtual sp<IBinder> createDisplay(const String8& displayName, bool secure)
Mathias Agopiane57f2922012-08-09 16:29:12 -0700263 {
264 Parcel data, reply;
265 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700266 data.writeString8(displayName);
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700267 data.writeInt32(secure ? 1 : 0);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700268 remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply);
269 return reply.readStrongBinder();
270 }
271
Jesse Hall6c913be2013-08-08 12:15:49 -0700272 virtual void destroyDisplay(const sp<IBinder>& display)
273 {
274 Parcel data, reply;
275 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
276 data.writeStrongBinder(display);
277 remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply);
278 }
279
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800280 virtual std::vector<PhysicalDisplayId> getPhysicalDisplayIds() const {
Mathias Agopiane57f2922012-08-09 16:29:12 -0700281 Parcel data, reply;
282 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800283 if (remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_IDS, data, &reply) ==
284 NO_ERROR) {
285 std::vector<PhysicalDisplayId> displayIds;
286 if (reply.readUint64Vector(&displayIds) == NO_ERROR) {
287 return displayIds;
288 }
289 }
290
291 return {};
292 }
293
294 virtual sp<IBinder> getPhysicalDisplayToken(PhysicalDisplayId displayId) const {
295 Parcel data, reply;
296 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
297 data.writeUint64(displayId);
298 remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_TOKEN, data, &reply);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700299 return reply.readStrongBinder();
300 }
301
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700302 virtual void setPowerMode(const sp<IBinder>& display, int mode)
Colin Cross8e533062012-06-07 13:17:52 -0700303 {
304 Parcel data, reply;
305 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700306 data.writeStrongBinder(display);
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700307 data.writeInt32(mode);
308 remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply);
Colin Cross8e533062012-06-07 13:17:52 -0700309 }
Mathias Agopian3094df32012-06-18 18:06:45 -0700310
Dan Stoza7f7da322014-05-02 15:26:25 -0700311 virtual status_t getDisplayConfigs(const sp<IBinder>& display,
312 Vector<DisplayInfo>* configs)
Mathias Agopianc666cae2012-07-25 18:56:13 -0700313 {
314 Parcel data, reply;
315 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700316 data.writeStrongBinder(display);
Dan Stoza7f7da322014-05-02 15:26:25 -0700317 remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply);
318 status_t result = reply.readInt32();
319 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -0800320 size_t numConfigs = reply.readUint32();
Dan Stoza7f7da322014-05-02 15:26:25 -0700321 configs->clear();
322 configs->resize(numConfigs);
323 for (size_t c = 0; c < numConfigs; ++c) {
324 memcpy(&(configs->editItemAt(c)),
325 reply.readInplace(sizeof(DisplayInfo)),
326 sizeof(DisplayInfo));
327 }
328 }
329 return result;
330 }
331
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700332 virtual status_t getDisplayStats(const sp<IBinder>& display,
333 DisplayStatInfo* stats)
334 {
335 Parcel data, reply;
336 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
337 data.writeStrongBinder(display);
338 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply);
339 status_t result = reply.readInt32();
340 if (result == NO_ERROR) {
341 memcpy(stats,
342 reply.readInplace(sizeof(DisplayStatInfo)),
343 sizeof(DisplayStatInfo));
344 }
345 return result;
346 }
347
Dan Stoza7f7da322014-05-02 15:26:25 -0700348 virtual int getActiveConfig(const sp<IBinder>& display)
349 {
350 Parcel data, reply;
351 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
352 data.writeStrongBinder(display);
353 remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply);
354 return reply.readInt32();
355 }
356
357 virtual status_t setActiveConfig(const sp<IBinder>& display, int id)
358 {
359 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700360 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
361 if (result != NO_ERROR) {
362 ALOGE("setActiveConfig failed to writeInterfaceToken: %d", result);
363 return result;
364 }
365 result = data.writeStrongBinder(display);
366 if (result != NO_ERROR) {
367 ALOGE("setActiveConfig failed to writeStrongBinder: %d", result);
368 return result;
369 }
370 result = data.writeInt32(id);
371 if (result != NO_ERROR) {
372 ALOGE("setActiveConfig failed to writeInt32: %d", result);
373 return result;
374 }
375 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply);
376 if (result != NO_ERROR) {
377 ALOGE("setActiveConfig failed to transact: %d", result);
378 return result;
379 }
Mathias Agopianc666cae2012-07-25 18:56:13 -0700380 return reply.readInt32();
381 }
Svetoslavd85084b2014-03-20 10:28:31 -0700382
Michael Wright28f24d02016-07-12 13:30:53 -0700383 virtual status_t getDisplayColorModes(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700384 Vector<ColorMode>* outColorModes) {
Michael Wright28f24d02016-07-12 13:30:53 -0700385 Parcel data, reply;
386 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
387 if (result != NO_ERROR) {
388 ALOGE("getDisplayColorModes failed to writeInterfaceToken: %d", result);
389 return result;
390 }
391 result = data.writeStrongBinder(display);
392 if (result != NO_ERROR) {
393 ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result);
394 return result;
395 }
396 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply);
397 if (result != NO_ERROR) {
398 ALOGE("getDisplayColorModes failed to transact: %d", result);
399 return result;
400 }
401 result = static_cast<status_t>(reply.readInt32());
402 if (result == NO_ERROR) {
403 size_t numModes = reply.readUint32();
404 outColorModes->clear();
405 outColorModes->resize(numModes);
406 for (size_t i = 0; i < numModes; ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -0700407 outColorModes->replaceAt(static_cast<ColorMode>(reply.readInt32()), i);
Michael Wright28f24d02016-07-12 13:30:53 -0700408 }
409 }
410 return result;
411 }
412
Daniel Solomon42d04562019-01-20 21:03:19 -0800413 virtual status_t getDisplayNativePrimaries(const sp<IBinder>& display,
414 ui::DisplayPrimaries& primaries) {
415 Parcel data, reply;
416 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
417 if (result != NO_ERROR) {
418 ALOGE("getDisplayNativePrimaries failed to writeInterfaceToken: %d", result);
419 return result;
420 }
421 result = data.writeStrongBinder(display);
422 if (result != NO_ERROR) {
423 ALOGE("getDisplayNativePrimaries failed to writeStrongBinder: %d", result);
424 return result;
425 }
426 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_NATIVE_PRIMARIES, data, &reply);
427 if (result != NO_ERROR) {
428 ALOGE("getDisplayNativePrimaries failed to transact: %d", result);
429 return result;
430 }
431 result = reply.readInt32();
432 if (result == NO_ERROR) {
433 memcpy(&primaries, reply.readInplace(sizeof(ui::DisplayPrimaries)),
434 sizeof(ui::DisplayPrimaries));
435 }
436 return result;
437 }
438
Peiyong Lina52f0292018-03-14 17:26:31 -0700439 virtual ColorMode getActiveColorMode(const sp<IBinder>& display) {
Michael Wright28f24d02016-07-12 13:30:53 -0700440 Parcel data, reply;
441 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
442 if (result != NO_ERROR) {
443 ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700444 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700445 }
446 result = data.writeStrongBinder(display);
447 if (result != NO_ERROR) {
448 ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700449 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700450 }
451 result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply);
452 if (result != NO_ERROR) {
453 ALOGE("getActiveColorMode failed to transact: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700454 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700455 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700456 return static_cast<ColorMode>(reply.readInt32());
Michael Wright28f24d02016-07-12 13:30:53 -0700457 }
458
459 virtual status_t setActiveColorMode(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700460 ColorMode colorMode) {
Michael Wright28f24d02016-07-12 13:30:53 -0700461 Parcel data, reply;
462 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
463 if (result != NO_ERROR) {
464 ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result);
465 return result;
466 }
467 result = data.writeStrongBinder(display);
468 if (result != NO_ERROR) {
469 ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result);
470 return result;
471 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700472 result = data.writeInt32(static_cast<int32_t>(colorMode));
Michael Wright28f24d02016-07-12 13:30:53 -0700473 if (result != NO_ERROR) {
474 ALOGE("setActiveColorMode failed to writeInt32: %d", result);
475 return result;
476 }
477 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply);
478 if (result != NO_ERROR) {
479 ALOGE("setActiveColorMode failed to transact: %d", result);
480 return result;
481 }
482 return static_cast<status_t>(reply.readInt32());
483 }
484
Svetoslavd85084b2014-03-20 10:28:31 -0700485 virtual status_t clearAnimationFrameStats() {
486 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700487 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
488 if (result != NO_ERROR) {
489 ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result);
490 return result;
491 }
492 result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply);
493 if (result != NO_ERROR) {
494 ALOGE("clearAnimationFrameStats failed to transact: %d", result);
495 return result;
496 }
Svetoslavd85084b2014-03-20 10:28:31 -0700497 return reply.readInt32();
498 }
499
500 virtual status_t getAnimationFrameStats(FrameStats* outStats) const {
501 Parcel data, reply;
502 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
503 remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply);
504 reply.read(*outStats);
505 return reply.readInt32();
506 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700507
508 virtual status_t getHdrCapabilities(const sp<IBinder>& display,
509 HdrCapabilities* outCapabilities) const {
510 Parcel data, reply;
511 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
512 status_t result = data.writeStrongBinder(display);
513 if (result != NO_ERROR) {
514 ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result);
515 return result;
516 }
517 result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES,
518 data, &reply);
519 if (result != NO_ERROR) {
520 ALOGE("getHdrCapabilities failed to transact: %d", result);
521 return result;
522 }
523 result = reply.readInt32();
524 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800525 result = reply.read(*outCapabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700526 }
527 return result;
528 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700529
530 virtual status_t enableVSyncInjections(bool enable) {
531 Parcel data, reply;
532 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
533 if (result != NO_ERROR) {
534 ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result);
535 return result;
536 }
537 result = data.writeBool(enable);
538 if (result != NO_ERROR) {
539 ALOGE("enableVSyncInjections failed to writeBool: %d", result);
540 return result;
541 }
542 result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS,
543 data, &reply, TF_ONE_WAY);
544 if (result != NO_ERROR) {
545 ALOGE("enableVSyncInjections failed to transact: %d", result);
546 return result;
547 }
548 return result;
549 }
550
551 virtual status_t injectVSync(nsecs_t when) {
552 Parcel data, reply;
553 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
554 if (result != NO_ERROR) {
555 ALOGE("injectVSync failed to writeInterfaceToken: %d", result);
556 return result;
557 }
558 result = data.writeInt64(when);
559 if (result != NO_ERROR) {
560 ALOGE("injectVSync failed to writeInt64: %d", result);
561 return result;
562 }
563 result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply, TF_ONE_WAY);
564 if (result != NO_ERROR) {
565 ALOGE("injectVSync failed to transact: %d", result);
566 return result;
567 }
568 return result;
569 }
570
Kalle Raitaa099a242017-01-11 11:17:29 -0800571 virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const
572 {
573 if (!outLayers) {
574 return UNEXPECTED_NULL;
575 }
576
577 Parcel data, reply;
578
579 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
580 if (err != NO_ERROR) {
581 return err;
582 }
583
584 err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply);
585 if (err != NO_ERROR) {
586 return err;
587 }
588
589 int32_t result = 0;
590 err = reply.readInt32(&result);
591 if (err != NO_ERROR) {
592 return err;
593 }
594 if (result != NO_ERROR) {
595 return result;
596 }
597
598 outLayers->clear();
599 return reply.readParcelableVector(outLayers);
600 }
Peiyong Lin0256f722018-08-31 15:45:10 -0700601
Peiyong Linc6780972018-10-28 15:24:08 -0700602 virtual status_t getCompositionPreference(ui::Dataspace* defaultDataspace,
603 ui::PixelFormat* defaultPixelFormat,
604 ui::Dataspace* wideColorGamutDataspace,
605 ui::PixelFormat* wideColorGamutPixelFormat) const {
Peiyong Lin0256f722018-08-31 15:45:10 -0700606 Parcel data, reply;
607 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
608 if (error != NO_ERROR) {
609 return error;
610 }
611 error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply);
612 if (error != NO_ERROR) {
613 return error;
614 }
615 error = static_cast<status_t>(reply.readInt32());
616 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -0700617 *defaultDataspace = static_cast<ui::Dataspace>(reply.readInt32());
618 *defaultPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
619 *wideColorGamutDataspace = static_cast<ui::Dataspace>(reply.readInt32());
620 *wideColorGamutPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
Peiyong Lin0256f722018-08-31 15:45:10 -0700621 }
622 return error;
623 }
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700624
Ady Abraham37965d42018-11-01 13:43:32 -0700625 virtual status_t getColorManagement(bool* outGetColorManagement) const {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700626 Parcel data, reply;
627 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Ady Abraham37965d42018-11-01 13:43:32 -0700628 remote()->transact(BnSurfaceComposer::GET_COLOR_MANAGEMENT, data, &reply);
629 bool result;
630 status_t err = reply.readBool(&result);
631 if (err == NO_ERROR) {
632 *outGetColorManagement = result;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700633 }
Ady Abraham37965d42018-11-01 13:43:32 -0700634 return err;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700635 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -0700636
637 virtual status_t getDisplayedContentSamplingAttributes(const sp<IBinder>& display,
638 ui::PixelFormat* outFormat,
639 ui::Dataspace* outDataspace,
640 uint8_t* outComponentMask) const {
641 if (!outFormat || !outDataspace || !outComponentMask) return BAD_VALUE;
642 Parcel data, reply;
643 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
644 data.writeStrongBinder(display);
645
646 status_t error =
647 remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES,
648 data, &reply);
649 if (error != NO_ERROR) {
650 return error;
651 }
652
653 uint32_t value = 0;
654 error = reply.readUint32(&value);
655 if (error != NO_ERROR) {
656 return error;
657 }
658 *outFormat = static_cast<ui::PixelFormat>(value);
659
660 error = reply.readUint32(&value);
661 if (error != NO_ERROR) {
662 return error;
663 }
664 *outDataspace = static_cast<ui::Dataspace>(value);
665
666 error = reply.readUint32(&value);
667 if (error != NO_ERROR) {
668 return error;
669 }
670 *outComponentMask = static_cast<uint8_t>(value);
671 return error;
672 }
Kevin DuBois74e53772018-11-19 10:52:38 -0800673
674 virtual status_t setDisplayContentSamplingEnabled(const sp<IBinder>& display, bool enable,
675 uint8_t componentMask,
676 uint64_t maxFrames) const {
677 Parcel data, reply;
678 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
679 data.writeStrongBinder(display);
680 data.writeBool(enable);
681 data.writeByte(static_cast<int8_t>(componentMask));
682 data.writeUint64(maxFrames);
683 status_t result =
684 remote()->transact(BnSurfaceComposer::SET_DISPLAY_CONTENT_SAMPLING_ENABLED, data,
685 &reply);
686 return result;
687 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700688
689 virtual status_t getDisplayedContentSample(const sp<IBinder>& display, uint64_t maxFrames,
690 uint64_t timestamp,
691 DisplayedFrameStats* outStats) const {
692 if (!outStats) return BAD_VALUE;
693
694 Parcel data, reply;
695 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
696 data.writeStrongBinder(display);
697 data.writeUint64(maxFrames);
698 data.writeUint64(timestamp);
699
700 status_t result =
701 remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLE, data, &reply);
702
703 if (result != NO_ERROR) {
704 return result;
705 }
706
707 result = reply.readUint64(&outStats->numFrames);
708 if (result != NO_ERROR) {
709 return result;
710 }
711
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800712 result = reply.readUint64Vector(&outStats->component_0_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700713 if (result != NO_ERROR) {
714 return result;
715 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800716 result = reply.readUint64Vector(&outStats->component_1_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700717 if (result != NO_ERROR) {
718 return result;
719 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800720 result = reply.readUint64Vector(&outStats->component_2_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700721 if (result != NO_ERROR) {
722 return result;
723 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800724 result = reply.readUint64Vector(&outStats->component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700725 return result;
726 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800727
728 virtual status_t getProtectedContentSupport(bool* outSupported) const {
729 Parcel data, reply;
730 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Peiyong Linb6888fa2019-01-28 13:20:58 -0800731 status_t error =
732 remote()->transact(BnSurfaceComposer::GET_PROTECTED_CONTENT_SUPPORT, data, &reply);
733 if (error != NO_ERROR) {
734 return error;
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800735 }
Peiyong Linb6888fa2019-01-28 13:20:58 -0800736 error = reply.readBool(outSupported);
737 return error;
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800738 }
Marissa Wallebc2c052019-01-16 19:16:55 -0800739
Peiyong Lin4f3fddf2019-01-24 17:21:24 -0800740 virtual status_t isWideColorDisplay(const sp<IBinder>& token,
741 bool* outIsWideColorDisplay) const {
742 Parcel data, reply;
743 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
744 if (error != NO_ERROR) {
745 return error;
746 }
747 error = data.writeStrongBinder(token);
748 if (error != NO_ERROR) {
749 return error;
750 }
751
752 error = remote()->transact(BnSurfaceComposer::IS_WIDE_COLOR_DISPLAY, data, &reply);
753 if (error != NO_ERROR) {
754 return error;
755 }
756 error = reply.readBool(outIsWideColorDisplay);
757 return error;
758 }
Dan Stoza84ab9372018-12-17 15:27:57 -0800759
760 virtual status_t addRegionSamplingListener(const Rect& samplingArea,
761 const sp<IBinder>& stopLayerHandle,
762 const sp<IRegionSamplingListener>& listener) {
763 Parcel data, reply;
764 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
765 if (error != NO_ERROR) {
766 ALOGE("addRegionSamplingListener: Failed to write interface token");
767 return error;
768 }
769 error = data.write(samplingArea);
770 if (error != NO_ERROR) {
771 ALOGE("addRegionSamplingListener: Failed to write sampling area");
772 return error;
773 }
774 error = data.writeStrongBinder(stopLayerHandle);
775 if (error != NO_ERROR) {
776 ALOGE("addRegionSamplingListener: Failed to write stop layer handle");
777 return error;
778 }
779 error = data.writeStrongBinder(IInterface::asBinder(listener));
780 if (error != NO_ERROR) {
781 ALOGE("addRegionSamplingListener: Failed to write listener");
782 return error;
783 }
784 error = remote()->transact(BnSurfaceComposer::ADD_REGION_SAMPLING_LISTENER, data, &reply);
785 if (error != NO_ERROR) {
786 ALOGE("addRegionSamplingListener: Failed to transact");
787 }
788 return error;
789 }
790
791 virtual status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) {
792 Parcel data, reply;
793 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
794 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800795 ALOGE("removeRegionSamplingListener: Failed to write interface token");
Dan Stoza84ab9372018-12-17 15:27:57 -0800796 return error;
797 }
798 error = data.writeStrongBinder(IInterface::asBinder(listener));
799 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800800 ALOGE("removeRegionSamplingListener: Failed to write listener");
Dan Stoza84ab9372018-12-17 15:27:57 -0800801 return error;
802 }
803 error = remote()->transact(BnSurfaceComposer::REMOVE_REGION_SAMPLING_LISTENER, data,
804 &reply);
805 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800806 ALOGE("removeRegionSamplingListener: Failed to transact");
Dan Stoza84ab9372018-12-17 15:27:57 -0800807 }
808 return error;
809 }
Ady Abraham838de062019-02-04 10:24:03 -0800810
811 virtual status_t setAllowedDisplayConfigs(const sp<IBinder>& displayToken,
812 const std::vector<int32_t>& allowedConfigs) {
813 Parcel data, reply;
814 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
815 if (result != NO_ERROR) {
816 ALOGE("setAllowedDisplayConfigs failed to writeInterfaceToken: %d", result);
817 return result;
818 }
819 result = data.writeStrongBinder(displayToken);
820 if (result != NO_ERROR) {
821 ALOGE("setAllowedDisplayConfigs failed to writeStrongBinder: %d", result);
822 return result;
823 }
824 result = data.writeInt32Vector(allowedConfigs);
825 if (result != NO_ERROR) {
826 ALOGE("setAllowedDisplayConfigs failed to writeInt32Vector: %d", result);
827 return result;
828 }
829 result = remote()->transact(BnSurfaceComposer::SET_ALLOWED_DISPLAY_CONFIGS, data, &reply);
830 if (result != NO_ERROR) {
831 ALOGE("setAllowedDisplayConfigs failed to transact: %d", result);
832 return result;
833 }
834 return reply.readInt32();
835 }
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800836
837 virtual status_t getAllowedDisplayConfigs(const sp<IBinder>& displayToken,
838 std::vector<int32_t>* outAllowedConfigs) {
839 if (!outAllowedConfigs) return BAD_VALUE;
840 Parcel data, reply;
841 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
842 if (result != NO_ERROR) {
843 ALOGE("getAllowedDisplayConfigs failed to writeInterfaceToken: %d", result);
844 return result;
845 }
846 result = data.writeStrongBinder(displayToken);
847 if (result != NO_ERROR) {
848 ALOGE("getAllowedDisplayConfigs failed to writeStrongBinder: %d", result);
849 return result;
850 }
851 result = remote()->transact(BnSurfaceComposer::GET_ALLOWED_DISPLAY_CONFIGS, data, &reply);
852 if (result != NO_ERROR) {
853 ALOGE("getAllowedDisplayConfigs failed to transact: %d", result);
854 return result;
855 }
856 result = reply.readInt32Vector(outAllowedConfigs);
857 if (result != NO_ERROR) {
858 ALOGE("getAllowedDisplayConfigs failed to readInt32Vector: %d", result);
859 return result;
860 }
861 return reply.readInt32();
862 }
Dan Gittik57e63c52019-01-18 16:37:54 +0000863
864 virtual status_t getDisplayBrightnessSupport(const sp<IBinder>& displayToken,
865 bool* outSupport) const {
866 Parcel data, reply;
867 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
868 if (error != NO_ERROR) {
869 ALOGE("getDisplayBrightnessSupport: failed to write interface token: %d", error);
870 return error;
871 }
872 error = data.writeStrongBinder(displayToken);
873 if (error != NO_ERROR) {
874 ALOGE("getDisplayBrightnessSupport: failed to write display token: %d", error);
875 return error;
876 }
877 error = remote()->transact(BnSurfaceComposer::GET_DISPLAY_BRIGHTNESS_SUPPORT, data, &reply);
878 if (error != NO_ERROR) {
879 ALOGE("getDisplayBrightnessSupport: failed to transact: %d", error);
880 return error;
881 }
882 bool support;
883 error = reply.readBool(&support);
884 if (error != NO_ERROR) {
885 ALOGE("getDisplayBrightnessSupport: failed to read support: %d", error);
886 return error;
887 }
888 *outSupport = support;
889 return NO_ERROR;
890 }
891
892 virtual status_t setDisplayBrightness(const sp<IBinder>& displayToken, float brightness) const {
893 Parcel data, reply;
894 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
895 if (error != NO_ERROR) {
896 ALOGE("setDisplayBrightness: failed to write interface token: %d", error);
897 return error;
898 }
899 error = data.writeStrongBinder(displayToken);
900 if (error != NO_ERROR) {
901 ALOGE("setDisplayBrightness: failed to write display token: %d", error);
902 return error;
903 }
904 error = data.writeFloat(brightness);
905 if (error != NO_ERROR) {
906 ALOGE("setDisplayBrightness: failed to write brightness: %d", error);
907 return error;
908 }
909 error = remote()->transact(BnSurfaceComposer::SET_DISPLAY_BRIGHTNESS, data, &reply);
910 if (error != NO_ERROR) {
911 ALOGE("setDisplayBrightness: failed to transact: %d", error);
912 return error;
913 }
914 return NO_ERROR;
915 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800916};
917
Dan Stozad723bd72014-11-18 10:24:03 -0800918// Out-of-line virtual method definition to trigger vtable emission in this
919// translation unit (see clang warning -Wweak-vtables)
920BpSurfaceComposer::~BpSurfaceComposer() {}
921
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800922IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
923
924// ----------------------------------------------------------------------
925
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800926status_t BnSurfaceComposer::onTransact(
927 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
928{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800929 switch(code) {
930 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700931 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800932 sp<IBinder> b = IInterface::asBinder(createConnection());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800933 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -0700934 return NO_ERROR;
935 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700936 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700937 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -0800938
939 size_t count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700940 if (count > data.dataSize()) {
941 return BAD_VALUE;
942 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700943 Vector<ComposerState> state;
944 state.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800945 for (size_t i = 0; i < count; i++) {
Marissa Wallc837b5e2018-10-12 10:04:44 -0700946 ComposerState s;
Michael Lentine8afa1c42014-10-31 11:10:13 -0700947 if (s.read(data) == BAD_VALUE) {
948 return BAD_VALUE;
949 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700950 state.add(s);
951 }
Dan Stozad723bd72014-11-18 10:24:03 -0800952
953 count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700954 if (count > data.dataSize()) {
955 return BAD_VALUE;
956 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700957 DisplayState d;
958 Vector<DisplayState> displays;
959 displays.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800960 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700961 if (d.read(data) == BAD_VALUE) {
962 return BAD_VALUE;
963 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700964 displays.add(d);
965 }
Dan Stozad723bd72014-11-18 10:24:03 -0800966
967 uint32_t stateFlags = data.readUint32();
Marissa Wall713b63f2018-10-17 15:42:43 -0700968 sp<IBinder> applyToken = data.readStrongBinder();
chaviw273171b2018-12-26 11:46:30 -0800969 InputWindowCommands inputWindowCommands;
970 inputWindowCommands.read(data);
Marissa Wall17b4e452018-12-26 16:32:34 -0800971
972 int64_t desiredPresentTime = data.readInt64();
973 setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands,
974 desiredPresentTime);
Jesse Hall6c913be2013-08-08 12:15:49 -0700975 return NO_ERROR;
976 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800977 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700978 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800979 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -0700980 return NO_ERROR;
981 }
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800982 case CAPTURE_SCREEN: {
983 CHECK_INTERFACE(ISurfaceComposer, data, reply);
984 sp<IBinder> display = data.readStrongBinder();
Peiyong Lin0e003c92018-09-17 11:09:51 -0700985 ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32());
986 ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32());
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000987 sp<GraphicBuffer> outBuffer;
Pablo Ceballos60d69222015-08-07 14:47:20 -0700988 Rect sourceCrop(Rect::EMPTY_RECT);
Dan Stozac1879002014-05-22 15:59:05 -0700989 data.read(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800990 uint32_t reqWidth = data.readUint32();
991 uint32_t reqHeight = data.readUint32();
Dan Stozac7014012014-02-14 15:03:43 -0800992 bool useIdentityTransform = static_cast<bool>(data.readInt32());
Dan Stozad723bd72014-11-18 10:24:03 -0800993 int32_t rotation = data.readInt32();
Robert Carrfa8855f2019-02-19 10:05:00 -0800994 bool captureSecureLayers = static_cast<bool>(data.readInt32());
Dan Stozac7014012014-02-14 15:03:43 -0800995
Peiyong Lin0e003c92018-09-17 11:09:51 -0700996 status_t res = captureScreen(display, &outBuffer, reqDataspace, reqPixelFormat,
997 sourceCrop, reqWidth, reqHeight, useIdentityTransform,
Robert Carrfa8855f2019-02-19 10:05:00 -0800998 static_cast<ISurfaceComposer::Rotation>(rotation), captureSecureLayers);
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800999 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +00001000 if (res == NO_ERROR) {
1001 reply->write(*outBuffer);
1002 }
Jesse Hall6c913be2013-08-08 12:15:49 -07001003 return NO_ERROR;
1004 }
chaviwa76b2712017-09-20 12:02:26 -07001005 case CAPTURE_LAYERS: {
1006 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1007 sp<IBinder> layerHandleBinder = data.readStrongBinder();
Peiyong Lin0e003c92018-09-17 11:09:51 -07001008 ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32());
1009 ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32());
Chavi Weingarten40482ff2017-11-30 01:51:40 +00001010 sp<GraphicBuffer> outBuffer;
chaviw7206d492017-11-10 16:16:12 -08001011 Rect sourceCrop(Rect::EMPTY_RECT);
1012 data.read(sourceCrop);
1013 float frameScale = data.readFloat();
Robert Carr578038f2018-03-09 12:25:24 -08001014 bool childrenOnly = data.readBool();
chaviwa76b2712017-09-20 12:02:26 -07001015
Peiyong Lin0e003c92018-09-17 11:09:51 -07001016 status_t res = captureLayers(layerHandleBinder, &outBuffer, reqDataspace,
1017 reqPixelFormat, sourceCrop, frameScale, childrenOnly);
chaviwa76b2712017-09-20 12:02:26 -07001018 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +00001019 if (res == NO_ERROR) {
1020 reply->write(*outBuffer);
1021 }
chaviwa76b2712017-09-20 12:02:26 -07001022 return NO_ERROR;
1023 }
Jamie Gennis134f0422011-03-08 12:18:54 -08001024 case AUTHENTICATE_SURFACE: {
1025 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -08001026 sp<IGraphicBufferProducer> bufferProducer =
1027 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
1028 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -08001029 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -07001030 return NO_ERROR;
1031 }
Brian Anderson6b376712017-04-04 10:51:39 -07001032 case GET_SUPPORTED_FRAME_TIMESTAMPS: {
1033 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1034 std::vector<FrameEvent> supportedTimestamps;
1035 status_t result = getSupportedFrameTimestamps(&supportedTimestamps);
1036 status_t err = reply->writeInt32(result);
1037 if (err != NO_ERROR) {
1038 return err;
1039 }
1040 if (result != NO_ERROR) {
1041 return result;
1042 }
1043
1044 std::vector<int32_t> supported;
1045 supported.reserve(supportedTimestamps.size());
1046 for (FrameEvent s : supportedTimestamps) {
1047 supported.push_back(static_cast<int32_t>(s));
1048 }
1049 return reply->writeInt32Vector(supported);
1050 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001051 case CREATE_DISPLAY_EVENT_CONNECTION: {
1052 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -07001053 sp<IDisplayEventConnection> connection(createDisplayEventConnection(
1054 static_cast<ISurfaceComposer::VsyncSource>(data.readInt32())));
Marco Nelissen2ea926b2014-11-14 08:01:01 -08001055 reply->writeStrongBinder(IInterface::asBinder(connection));
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001056 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001057 }
Mathias Agopiane57f2922012-08-09 16:29:12 -07001058 case CREATE_DISPLAY: {
1059 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden8dfa92f2012-09-17 18:27:17 -07001060 String8 displayName = data.readString8();
Jamie Gennisdd3cb842012-10-19 18:19:11 -07001061 bool secure = bool(data.readInt32());
1062 sp<IBinder> display(createDisplay(displayName, secure));
Mathias Agopiane57f2922012-08-09 16:29:12 -07001063 reply->writeStrongBinder(display);
1064 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001065 }
1066 case DESTROY_DISPLAY: {
1067 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1068 sp<IBinder> display = data.readStrongBinder();
1069 destroyDisplay(display);
1070 return NO_ERROR;
1071 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001072 case GET_PHYSICAL_DISPLAY_TOKEN: {
Mathias Agopiane57f2922012-08-09 16:29:12 -07001073 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001074 PhysicalDisplayId displayId = data.readUint64();
1075 sp<IBinder> display = getPhysicalDisplayToken(displayId);
Mathias Agopiane57f2922012-08-09 16:29:12 -07001076 reply->writeStrongBinder(display);
1077 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001078 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001079 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -07001080 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stoza7f7da322014-05-02 15:26:25 -07001081 Vector<DisplayInfo> configs;
Jeff Brown9d4e3d22012-08-24 20:00:51 -07001082 sp<IBinder> display = data.readStrongBinder();
Dan Stoza7f7da322014-05-02 15:26:25 -07001083 status_t result = getDisplayConfigs(display, &configs);
1084 reply->writeInt32(result);
1085 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -08001086 reply->writeUint32(static_cast<uint32_t>(configs.size()));
Dan Stoza7f7da322014-05-02 15:26:25 -07001087 for (size_t c = 0; c < configs.size(); ++c) {
1088 memcpy(reply->writeInplace(sizeof(DisplayInfo)),
1089 &configs[c], sizeof(DisplayInfo));
1090 }
1091 }
1092 return NO_ERROR;
1093 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -07001094 case GET_DISPLAY_STATS: {
1095 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1096 DisplayStatInfo stats;
1097 sp<IBinder> display = data.readStrongBinder();
1098 status_t result = getDisplayStats(display, &stats);
1099 reply->writeInt32(result);
1100 if (result == NO_ERROR) {
1101 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
1102 &stats, sizeof(DisplayStatInfo));
1103 }
1104 return NO_ERROR;
1105 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001106 case GET_ACTIVE_CONFIG: {
1107 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1108 sp<IBinder> display = data.readStrongBinder();
1109 int id = getActiveConfig(display);
1110 reply->writeInt32(id);
1111 return NO_ERROR;
1112 }
1113 case SET_ACTIVE_CONFIG: {
1114 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1115 sp<IBinder> display = data.readStrongBinder();
1116 int id = data.readInt32();
1117 status_t result = setActiveConfig(display, id);
Mathias Agopianc666cae2012-07-25 18:56:13 -07001118 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -07001119 return NO_ERROR;
1120 }
Michael Wright28f24d02016-07-12 13:30:53 -07001121 case GET_DISPLAY_COLOR_MODES: {
1122 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Lina52f0292018-03-14 17:26:31 -07001123 Vector<ColorMode> colorModes;
Michael Wright28f24d02016-07-12 13:30:53 -07001124 sp<IBinder> display = nullptr;
1125 status_t result = data.readStrongBinder(&display);
1126 if (result != NO_ERROR) {
1127 ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result);
1128 return result;
1129 }
1130 result = getDisplayColorModes(display, &colorModes);
1131 reply->writeInt32(result);
1132 if (result == NO_ERROR) {
1133 reply->writeUint32(static_cast<uint32_t>(colorModes.size()));
1134 for (size_t i = 0; i < colorModes.size(); ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -07001135 reply->writeInt32(static_cast<int32_t>(colorModes[i]));
Michael Wright28f24d02016-07-12 13:30:53 -07001136 }
1137 }
1138 return NO_ERROR;
1139 }
Daniel Solomon42d04562019-01-20 21:03:19 -08001140 case GET_DISPLAY_NATIVE_PRIMARIES: {
1141 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1142 ui::DisplayPrimaries primaries;
1143 sp<IBinder> display = nullptr;
1144
1145 status_t result = data.readStrongBinder(&display);
1146 if (result != NO_ERROR) {
1147 ALOGE("getDisplayNativePrimaries failed to readStrongBinder: %d", result);
1148 return result;
1149 }
1150
1151 result = getDisplayNativePrimaries(display, primaries);
1152 reply->writeInt32(result);
1153 if (result == NO_ERROR) {
1154 memcpy(reply->writeInplace(sizeof(ui::DisplayPrimaries)), &primaries,
1155 sizeof(ui::DisplayPrimaries));
1156 }
1157
1158 return NO_ERROR;
1159 }
Michael Wright28f24d02016-07-12 13:30:53 -07001160 case GET_ACTIVE_COLOR_MODE: {
1161 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1162 sp<IBinder> display = nullptr;
1163 status_t result = data.readStrongBinder(&display);
1164 if (result != NO_ERROR) {
1165 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1166 return result;
1167 }
Peiyong Lina52f0292018-03-14 17:26:31 -07001168 ColorMode colorMode = getActiveColorMode(display);
Michael Wright28f24d02016-07-12 13:30:53 -07001169 result = reply->writeInt32(static_cast<int32_t>(colorMode));
1170 return result;
1171 }
1172 case SET_ACTIVE_COLOR_MODE: {
1173 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1174 sp<IBinder> display = nullptr;
1175 status_t result = data.readStrongBinder(&display);
1176 if (result != NO_ERROR) {
1177 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1178 return result;
1179 }
1180 int32_t colorModeInt = 0;
1181 result = data.readInt32(&colorModeInt);
1182 if (result != NO_ERROR) {
1183 ALOGE("setActiveColorMode failed to readInt32: %d", result);
1184 return result;
1185 }
1186 result = setActiveColorMode(display,
Peiyong Lina52f0292018-03-14 17:26:31 -07001187 static_cast<ColorMode>(colorModeInt));
Michael Wright28f24d02016-07-12 13:30:53 -07001188 result = reply->writeInt32(result);
1189 return result;
1190 }
Svetoslavd85084b2014-03-20 10:28:31 -07001191 case CLEAR_ANIMATION_FRAME_STATS: {
1192 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1193 status_t result = clearAnimationFrameStats();
1194 reply->writeInt32(result);
1195 return NO_ERROR;
1196 }
1197 case GET_ANIMATION_FRAME_STATS: {
1198 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1199 FrameStats stats;
1200 status_t result = getAnimationFrameStats(&stats);
1201 reply->write(stats);
1202 reply->writeInt32(result);
1203 return NO_ERROR;
1204 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -07001205 case SET_POWER_MODE: {
1206 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1207 sp<IBinder> display = data.readStrongBinder();
1208 int32_t mode = data.readInt32();
1209 setPowerMode(display, mode);
1210 return NO_ERROR;
1211 }
Dan Stozac4f471e2016-03-24 09:31:08 -07001212 case GET_HDR_CAPABILITIES: {
1213 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1214 sp<IBinder> display = nullptr;
1215 status_t result = data.readStrongBinder(&display);
1216 if (result != NO_ERROR) {
1217 ALOGE("getHdrCapabilities failed to readStrongBinder: %d",
1218 result);
1219 return result;
1220 }
1221 HdrCapabilities capabilities;
1222 result = getHdrCapabilities(display, &capabilities);
1223 reply->writeInt32(result);
1224 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -08001225 reply->write(capabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -07001226 }
1227 return NO_ERROR;
1228 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -07001229 case ENABLE_VSYNC_INJECTIONS: {
1230 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1231 bool enable = false;
1232 status_t result = data.readBool(&enable);
1233 if (result != NO_ERROR) {
1234 ALOGE("enableVSyncInjections failed to readBool: %d", result);
1235 return result;
1236 }
1237 return enableVSyncInjections(enable);
1238 }
1239 case INJECT_VSYNC: {
1240 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1241 int64_t when = 0;
1242 status_t result = data.readInt64(&when);
1243 if (result != NO_ERROR) {
1244 ALOGE("enableVSyncInjections failed to readInt64: %d", result);
1245 return result;
1246 }
1247 return injectVSync(when);
1248 }
Kalle Raitaa099a242017-01-11 11:17:29 -08001249 case GET_LAYER_DEBUG_INFO: {
1250 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1251 std::vector<LayerDebugInfo> outLayers;
1252 status_t result = getLayerDebugInfo(&outLayers);
1253 reply->writeInt32(result);
1254 if (result == NO_ERROR)
1255 {
1256 result = reply->writeParcelableVector(outLayers);
1257 }
1258 return result;
1259 }
Peiyong Lin0256f722018-08-31 15:45:10 -07001260 case GET_COMPOSITION_PREFERENCE: {
1261 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Linc6780972018-10-28 15:24:08 -07001262 ui::Dataspace defaultDataspace;
1263 ui::PixelFormat defaultPixelFormat;
1264 ui::Dataspace wideColorGamutDataspace;
1265 ui::PixelFormat wideColorGamutPixelFormat;
1266 status_t error =
1267 getCompositionPreference(&defaultDataspace, &defaultPixelFormat,
1268 &wideColorGamutDataspace, &wideColorGamutPixelFormat);
Peiyong Lin0256f722018-08-31 15:45:10 -07001269 reply->writeInt32(error);
1270 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -07001271 reply->writeInt32(static_cast<int32_t>(defaultDataspace));
1272 reply->writeInt32(static_cast<int32_t>(defaultPixelFormat));
1273 reply->writeInt32(static_cast<int32_t>(wideColorGamutDataspace));
Peiyong Linaa3da6a2018-12-12 02:48:43 -08001274 reply->writeInt32(static_cast<int32_t>(wideColorGamutPixelFormat));
Peiyong Lin0256f722018-08-31 15:45:10 -07001275 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001276 return error;
Peiyong Lin0256f722018-08-31 15:45:10 -07001277 }
Ady Abraham37965d42018-11-01 13:43:32 -07001278 case GET_COLOR_MANAGEMENT: {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001279 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Ady Abraham37965d42018-11-01 13:43:32 -07001280 bool result;
1281 status_t error = getColorManagement(&result);
1282 if (error == NO_ERROR) {
1283 reply->writeBool(result);
1284 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001285 return error;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001286 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -07001287 case GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: {
1288 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1289
1290 sp<IBinder> display = data.readStrongBinder();
1291 ui::PixelFormat format;
1292 ui::Dataspace dataspace;
1293 uint8_t component = 0;
1294 auto result =
1295 getDisplayedContentSamplingAttributes(display, &format, &dataspace, &component);
1296 if (result == NO_ERROR) {
1297 reply->writeUint32(static_cast<uint32_t>(format));
1298 reply->writeUint32(static_cast<uint32_t>(dataspace));
1299 reply->writeUint32(static_cast<uint32_t>(component));
1300 }
1301 return result;
1302 }
Kevin DuBois74e53772018-11-19 10:52:38 -08001303 case SET_DISPLAY_CONTENT_SAMPLING_ENABLED: {
1304 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1305
1306 sp<IBinder> display = nullptr;
1307 bool enable = false;
1308 int8_t componentMask = 0;
1309 uint64_t maxFrames = 0;
1310 status_t result = data.readStrongBinder(&display);
1311 if (result != NO_ERROR) {
1312 ALOGE("setDisplayContentSamplingEnabled failure in reading Display token: %d",
1313 result);
1314 return result;
1315 }
1316
1317 result = data.readBool(&enable);
1318 if (result != NO_ERROR) {
1319 ALOGE("setDisplayContentSamplingEnabled failure in reading enable: %d", result);
1320 return result;
1321 }
1322
1323 result = data.readByte(static_cast<int8_t*>(&componentMask));
1324 if (result != NO_ERROR) {
1325 ALOGE("setDisplayContentSamplingEnabled failure in reading component mask: %d",
1326 result);
1327 return result;
1328 }
1329
1330 result = data.readUint64(&maxFrames);
1331 if (result != NO_ERROR) {
1332 ALOGE("setDisplayContentSamplingEnabled failure in reading max frames: %d", result);
1333 return result;
1334 }
1335
1336 return setDisplayContentSamplingEnabled(display, enable,
1337 static_cast<uint8_t>(componentMask), maxFrames);
1338 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001339 case GET_DISPLAYED_CONTENT_SAMPLE: {
1340 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1341
1342 sp<IBinder> display = data.readStrongBinder();
1343 uint64_t maxFrames = 0;
1344 uint64_t timestamp = 0;
1345
1346 status_t result = data.readUint64(&maxFrames);
1347 if (result != NO_ERROR) {
1348 ALOGE("getDisplayedContentSample failure in reading max frames: %d", result);
1349 return result;
1350 }
1351
1352 result = data.readUint64(&timestamp);
1353 if (result != NO_ERROR) {
1354 ALOGE("getDisplayedContentSample failure in reading timestamp: %d", result);
1355 return result;
1356 }
1357
1358 DisplayedFrameStats stats;
1359 result = getDisplayedContentSample(display, maxFrames, timestamp, &stats);
1360 if (result == NO_ERROR) {
1361 reply->writeUint64(stats.numFrames);
Kevin DuBois1d4c6a62018-12-12 13:59:46 -08001362 reply->writeUint64Vector(stats.component_0_sample);
1363 reply->writeUint64Vector(stats.component_1_sample);
1364 reply->writeUint64Vector(stats.component_2_sample);
1365 reply->writeUint64Vector(stats.component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001366 }
1367 return result;
1368 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001369 case GET_PROTECTED_CONTENT_SUPPORT: {
1370 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1371 bool result;
1372 status_t error = getProtectedContentSupport(&result);
1373 if (error == NO_ERROR) {
1374 reply->writeBool(result);
1375 }
1376 return error;
1377 }
Peiyong Lin4f3fddf2019-01-24 17:21:24 -08001378 case IS_WIDE_COLOR_DISPLAY: {
1379 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1380 sp<IBinder> display = nullptr;
1381 status_t error = data.readStrongBinder(&display);
1382 if (error != NO_ERROR) {
1383 return error;
1384 }
1385 bool result;
1386 error = isWideColorDisplay(display, &result);
1387 if (error == NO_ERROR) {
1388 reply->writeBool(result);
1389 }
1390 return error;
1391 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001392 case GET_PHYSICAL_DISPLAY_IDS: {
1393 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1394 return reply->writeUint64Vector(getPhysicalDisplayIds());
1395 }
Dan Stoza84ab9372018-12-17 15:27:57 -08001396 case ADD_REGION_SAMPLING_LISTENER: {
1397 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1398 Rect samplingArea;
1399 status_t result = data.read(samplingArea);
1400 if (result != NO_ERROR) {
1401 ALOGE("addRegionSamplingListener: Failed to read sampling area");
1402 return result;
1403 }
1404 sp<IBinder> stopLayerHandle;
1405 result = data.readNullableStrongBinder(&stopLayerHandle);
1406 if (result != NO_ERROR) {
1407 ALOGE("addRegionSamplingListener: Failed to read stop layer handle");
1408 return result;
1409 }
1410 sp<IRegionSamplingListener> listener;
1411 result = data.readNullableStrongBinder(&listener);
1412 if (result != NO_ERROR) {
1413 ALOGE("addRegionSamplingListener: Failed to read listener");
1414 return result;
1415 }
1416 return addRegionSamplingListener(samplingArea, stopLayerHandle, listener);
1417 }
1418 case REMOVE_REGION_SAMPLING_LISTENER: {
1419 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1420 sp<IRegionSamplingListener> listener;
1421 status_t result = data.readNullableStrongBinder(&listener);
1422 if (result != NO_ERROR) {
1423 ALOGE("removeRegionSamplingListener: Failed to read listener");
1424 return result;
1425 }
1426 return removeRegionSamplingListener(listener);
1427 }
Ady Abraham838de062019-02-04 10:24:03 -08001428 case SET_ALLOWED_DISPLAY_CONFIGS: {
1429 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1430 sp<IBinder> displayToken = data.readStrongBinder();
1431 std::vector<int32_t> allowedConfigs;
1432 data.readInt32Vector(&allowedConfigs);
1433 status_t result = setAllowedDisplayConfigs(displayToken, allowedConfigs);
1434 reply->writeInt32(result);
1435 return result;
1436 }
Ady Abrahamd9b3ea62019-02-26 14:08:03 -08001437 case GET_ALLOWED_DISPLAY_CONFIGS: {
1438 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1439 sp<IBinder> displayToken = data.readStrongBinder();
1440 std::vector<int32_t> allowedConfigs;
1441 status_t result = getAllowedDisplayConfigs(displayToken, &allowedConfigs);
1442 reply->writeInt32Vector(allowedConfigs);
1443 reply->writeInt32(result);
1444 return result;
1445 }
Dan Gittik57e63c52019-01-18 16:37:54 +00001446 case GET_DISPLAY_BRIGHTNESS_SUPPORT: {
1447 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1448 sp<IBinder> displayToken;
1449 status_t error = data.readNullableStrongBinder(&displayToken);
1450 if (error != NO_ERROR) {
1451 ALOGE("getDisplayBrightnessSupport: failed to read display token: %d", error);
1452 return error;
1453 }
1454 bool support = false;
1455 error = getDisplayBrightnessSupport(displayToken, &support);
1456 reply->writeBool(support);
1457 return error;
1458 }
1459 case SET_DISPLAY_BRIGHTNESS: {
1460 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1461 sp<IBinder> displayToken;
1462 status_t error = data.readNullableStrongBinder(&displayToken);
1463 if (error != NO_ERROR) {
1464 ALOGE("setDisplayBrightness: failed to read display token: %d", error);
1465 return error;
1466 }
1467 float brightness = -1.0f;
1468 error = data.readFloat(&brightness);
1469 if (error != NO_ERROR) {
1470 ALOGE("setDisplayBrightness: failed to read brightness: %d", error);
1471 return error;
1472 }
1473 return setDisplayBrightness(displayToken, brightness);
1474 }
Jesse Hall6c913be2013-08-08 12:15:49 -07001475 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001476 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -07001477 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001478 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001479}
1480
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001481} // namespace android