blob: a8b1a4c7afeb091ac4aa98ae6f1a424d196a0c17 [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,
Marissa Wall78b72202019-03-15 14:58:34 -070071 int64_t desiredPresentTime,
Marissa Wall947d34e2019-03-29 14:03:53 -070072 const client_cache_t& uncacheBuffer,
Marissa Wall3dad52d2019-03-22 14:03:19 -070073 const std::vector<ListenerCallbacks>& listenerCallbacks) {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080074 Parcel data, reply;
75 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Dan Stozad723bd72014-11-18 10:24:03 -080076
77 data.writeUint32(static_cast<uint32_t>(state.size()));
78 for (const auto& s : state) {
79 s.write(data);
Mathias Agopian698c0872011-06-28 19:09:31 -070080 }
Dan Stozad723bd72014-11-18 10:24:03 -080081
82 data.writeUint32(static_cast<uint32_t>(displays.size()));
83 for (const auto& d : displays) {
84 d.write(data);
Mathias Agopian8b33f032012-07-24 20:43:54 -070085 }
Dan Stozad723bd72014-11-18 10:24:03 -080086
87 data.writeUint32(flags);
Marissa Wall713b63f2018-10-17 15:42:43 -070088 data.writeStrongBinder(applyToken);
chaviw273171b2018-12-26 11:46:30 -080089 commands.write(data);
Marissa Wall17b4e452018-12-26 16:32:34 -080090 data.writeInt64(desiredPresentTime);
Marissa Wall947d34e2019-03-29 14:03:53 -070091 data.writeWeakBinder(uncacheBuffer.token);
92 data.writeUint64(uncacheBuffer.id);
Marissa Wall3dad52d2019-03-22 14:03:19 -070093
94 if (data.writeVectorSize(listenerCallbacks) == NO_ERROR) {
95 for (const auto& [listener, callbackIds] : listenerCallbacks) {
96 data.writeStrongBinder(IInterface::asBinder(listener));
97 data.writeInt64Vector(callbackIds);
98 }
99 }
100
Jamie Gennisb8d69a52011-10-10 15:48:06 -0700101 remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800102 }
103
104 virtual void bootFinished()
105 {
106 Parcel data, reply;
107 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
108 remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply);
109 }
110
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000111 virtual status_t captureScreen(const sp<IBinder>& display, sp<GraphicBuffer>* outBuffer,
Robert Carr108b2c72019-04-02 16:32:58 -0700112 bool& outCapturedSecureLayers, const ui::Dataspace reqDataspace,
Peiyong Lin0e003c92018-09-17 11:09:51 -0700113 const ui::PixelFormat reqPixelFormat, Rect sourceCrop,
114 uint32_t reqWidth, uint32_t reqHeight, bool useIdentityTransform,
Robert Carrfa8855f2019-02-19 10:05:00 -0800115 ISurfaceComposer::Rotation rotation, bool captureSecureLayers) {
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800116 Parcel data, reply;
117 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
118 data.writeStrongBinder(display);
Peiyong Lin0e003c92018-09-17 11:09:51 -0700119 data.writeInt32(static_cast<int32_t>(reqDataspace));
120 data.writeInt32(static_cast<int32_t>(reqPixelFormat));
Dan Stozac1879002014-05-22 15:59:05 -0700121 data.write(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800122 data.writeUint32(reqWidth);
123 data.writeUint32(reqHeight);
Dan Stozac7014012014-02-14 15:03:43 -0800124 data.writeInt32(static_cast<int32_t>(useIdentityTransform));
Riley Andrewsc3ebe662014-09-04 16:20:31 -0700125 data.writeInt32(static_cast<int32_t>(rotation));
Robert Carrfa8855f2019-02-19 10:05:00 -0800126 data.writeInt32(static_cast<int32_t>(captureSecureLayers));
Ana Krulec2d41e422018-07-26 12:07:43 -0700127 status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply);
128 if (result != NO_ERROR) {
129 ALOGE("captureScreen failed to transact: %d", result);
130 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000131 }
Ana Krulec2d41e422018-07-26 12:07:43 -0700132 result = reply.readInt32();
133 if (result != NO_ERROR) {
134 ALOGE("captureScreen failed to readInt32: %d", result);
135 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000136 }
137
138 *outBuffer = new GraphicBuffer();
139 reply.read(**outBuffer);
Robert Carr108b2c72019-04-02 16:32:58 -0700140 outCapturedSecureLayers = reply.readBool();
Peiyong Lin0e003c92018-09-17 11:09:51 -0700141
Ana Krulec2d41e422018-07-26 12:07:43 -0700142 return result;
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800143 }
144
Robert Carr866455f2019-04-02 16:28:26 -0700145 virtual status_t captureLayers(
146 const sp<IBinder>& layerHandleBinder, sp<GraphicBuffer>* outBuffer,
147 const ui::Dataspace reqDataspace, const ui::PixelFormat reqPixelFormat,
148 const Rect& sourceCrop,
149 const std::unordered_set<sp<IBinder>, SpHash<IBinder>>& excludeLayers, float frameScale,
150 bool childrenOnly) {
chaviwa76b2712017-09-20 12:02:26 -0700151 Parcel data, reply;
152 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
153 data.writeStrongBinder(layerHandleBinder);
Peiyong Lin0e003c92018-09-17 11:09:51 -0700154 data.writeInt32(static_cast<int32_t>(reqDataspace));
155 data.writeInt32(static_cast<int32_t>(reqPixelFormat));
chaviw7206d492017-11-10 16:16:12 -0800156 data.write(sourceCrop);
Robert Carr866455f2019-04-02 16:28:26 -0700157 data.writeInt32(excludeLayers.size());
158 for (auto el : excludeLayers) {
159 data.writeStrongBinder(el);
160 }
chaviw7206d492017-11-10 16:16:12 -0800161 data.writeFloat(frameScale);
Robert Carr578038f2018-03-09 12:25:24 -0800162 data.writeBool(childrenOnly);
Ana Krulec2d41e422018-07-26 12:07:43 -0700163 status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_LAYERS, data, &reply);
164 if (result != NO_ERROR) {
165 ALOGE("captureLayers failed to transact: %d", result);
166 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000167 }
Ana Krulec2d41e422018-07-26 12:07:43 -0700168 result = reply.readInt32();
169 if (result != NO_ERROR) {
170 ALOGE("captureLayers failed to readInt32: %d", result);
171 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000172 }
Peiyong Lin0e003c92018-09-17 11:09:51 -0700173
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000174 *outBuffer = new GraphicBuffer();
175 reply.read(**outBuffer);
176
Ana Krulec2d41e422018-07-26 12:07:43 -0700177 return result;
chaviwa76b2712017-09-20 12:02:26 -0700178 }
179
Jamie Gennis582270d2011-08-17 18:19:00 -0700180 virtual bool authenticateSurfaceTexture(
Andy McFadden2adaf042012-12-18 09:49:45 -0800181 const sp<IGraphicBufferProducer>& bufferProducer) const
Jamie Gennis134f0422011-03-08 12:18:54 -0800182 {
183 Parcel data, reply;
184 int err = NO_ERROR;
185 err = data.writeInterfaceToken(
186 ISurfaceComposer::getInterfaceDescriptor());
187 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000188 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis134f0422011-03-08 12:18:54 -0800189 "interface descriptor: %s (%d)", strerror(-err), -err);
190 return false;
191 }
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800192 err = data.writeStrongBinder(IInterface::asBinder(bufferProducer));
Jamie Gennis134f0422011-03-08 12:18:54 -0800193 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000194 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis582270d2011-08-17 18:19:00 -0700195 "strong binder to parcel: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800196 return false;
197 }
198 err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
199 &reply);
200 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000201 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700202 "performing transaction: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800203 return false;
204 }
205 int32_t result = 0;
206 err = reply.readInt32(&result);
207 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000208 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700209 "retrieving result: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800210 return false;
211 }
212 return result != 0;
213 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800214
Brian Anderson6b376712017-04-04 10:51:39 -0700215 virtual status_t getSupportedFrameTimestamps(
216 std::vector<FrameEvent>* outSupported) const {
217 if (!outSupported) {
218 return UNEXPECTED_NULL;
219 }
220 outSupported->clear();
221
222 Parcel data, reply;
223
224 status_t err = data.writeInterfaceToken(
225 ISurfaceComposer::getInterfaceDescriptor());
226 if (err != NO_ERROR) {
227 return err;
228 }
229
230 err = remote()->transact(
231 BnSurfaceComposer::GET_SUPPORTED_FRAME_TIMESTAMPS,
232 data, &reply);
233 if (err != NO_ERROR) {
234 return err;
235 }
236
237 int32_t result = 0;
238 err = reply.readInt32(&result);
239 if (err != NO_ERROR) {
240 return err;
241 }
242 if (result != NO_ERROR) {
243 return result;
244 }
245
246 std::vector<int32_t> supported;
247 err = reply.readInt32Vector(&supported);
248 if (err != NO_ERROR) {
249 return err;
250 }
251
252 outSupported->reserve(supported.size());
253 for (int32_t s : supported) {
254 outSupported->push_back(static_cast<FrameEvent>(s));
255 }
256 return NO_ERROR;
257 }
258
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700259 virtual sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource)
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800260 {
261 Parcel data, reply;
262 sp<IDisplayEventConnection> result;
263 int err = data.writeInterfaceToken(
264 ISurfaceComposer::getInterfaceDescriptor());
265 if (err != NO_ERROR) {
266 return result;
267 }
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700268 data.writeInt32(static_cast<int32_t>(vsyncSource));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800269 err = remote()->transact(
270 BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION,
271 data, &reply);
272 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000273 ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing "
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800274 "transaction: %s (%d)", strerror(-err), -err);
275 return result;
276 }
277 result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder());
278 return result;
279 }
Colin Cross8e533062012-06-07 13:17:52 -0700280
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700281 virtual sp<IBinder> createDisplay(const String8& displayName, bool secure)
Mathias Agopiane57f2922012-08-09 16:29:12 -0700282 {
283 Parcel data, reply;
284 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700285 data.writeString8(displayName);
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700286 data.writeInt32(secure ? 1 : 0);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700287 remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply);
288 return reply.readStrongBinder();
289 }
290
Jesse Hall6c913be2013-08-08 12:15:49 -0700291 virtual void destroyDisplay(const sp<IBinder>& display)
292 {
293 Parcel data, reply;
294 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
295 data.writeStrongBinder(display);
296 remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply);
297 }
298
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800299 virtual std::vector<PhysicalDisplayId> getPhysicalDisplayIds() const {
Mathias Agopiane57f2922012-08-09 16:29:12 -0700300 Parcel data, reply;
301 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800302 if (remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_IDS, data, &reply) ==
303 NO_ERROR) {
304 std::vector<PhysicalDisplayId> displayIds;
305 if (reply.readUint64Vector(&displayIds) == NO_ERROR) {
306 return displayIds;
307 }
308 }
309
310 return {};
311 }
312
313 virtual sp<IBinder> getPhysicalDisplayToken(PhysicalDisplayId displayId) const {
314 Parcel data, reply;
315 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
316 data.writeUint64(displayId);
317 remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_TOKEN, data, &reply);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700318 return reply.readStrongBinder();
319 }
320
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700321 virtual void setPowerMode(const sp<IBinder>& display, int mode)
Colin Cross8e533062012-06-07 13:17:52 -0700322 {
323 Parcel data, reply;
324 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700325 data.writeStrongBinder(display);
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700326 data.writeInt32(mode);
327 remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply);
Colin Cross8e533062012-06-07 13:17:52 -0700328 }
Mathias Agopian3094df32012-06-18 18:06:45 -0700329
Dan Stoza7f7da322014-05-02 15:26:25 -0700330 virtual status_t getDisplayConfigs(const sp<IBinder>& display,
331 Vector<DisplayInfo>* configs)
Mathias Agopianc666cae2012-07-25 18:56:13 -0700332 {
333 Parcel data, reply;
334 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700335 data.writeStrongBinder(display);
Dan Stoza7f7da322014-05-02 15:26:25 -0700336 remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply);
337 status_t result = reply.readInt32();
338 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -0800339 size_t numConfigs = reply.readUint32();
Dan Stoza7f7da322014-05-02 15:26:25 -0700340 configs->clear();
341 configs->resize(numConfigs);
342 for (size_t c = 0; c < numConfigs; ++c) {
343 memcpy(&(configs->editItemAt(c)),
344 reply.readInplace(sizeof(DisplayInfo)),
345 sizeof(DisplayInfo));
346 }
347 }
348 return result;
349 }
350
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700351 virtual status_t getDisplayStats(const sp<IBinder>& display,
352 DisplayStatInfo* stats)
353 {
354 Parcel data, reply;
355 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
356 data.writeStrongBinder(display);
357 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply);
358 status_t result = reply.readInt32();
359 if (result == NO_ERROR) {
360 memcpy(stats,
361 reply.readInplace(sizeof(DisplayStatInfo)),
362 sizeof(DisplayStatInfo));
363 }
364 return result;
365 }
366
Dan Stoza7f7da322014-05-02 15:26:25 -0700367 virtual int getActiveConfig(const sp<IBinder>& display)
368 {
369 Parcel data, reply;
370 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
371 data.writeStrongBinder(display);
372 remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply);
373 return reply.readInt32();
374 }
375
376 virtual status_t setActiveConfig(const sp<IBinder>& display, int id)
377 {
378 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700379 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
380 if (result != NO_ERROR) {
381 ALOGE("setActiveConfig failed to writeInterfaceToken: %d", result);
382 return result;
383 }
384 result = data.writeStrongBinder(display);
385 if (result != NO_ERROR) {
386 ALOGE("setActiveConfig failed to writeStrongBinder: %d", result);
387 return result;
388 }
389 result = data.writeInt32(id);
390 if (result != NO_ERROR) {
391 ALOGE("setActiveConfig failed to writeInt32: %d", result);
392 return result;
393 }
394 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply);
395 if (result != NO_ERROR) {
396 ALOGE("setActiveConfig failed to transact: %d", result);
397 return result;
398 }
Mathias Agopianc666cae2012-07-25 18:56:13 -0700399 return reply.readInt32();
400 }
Svetoslavd85084b2014-03-20 10:28:31 -0700401
Michael Wright28f24d02016-07-12 13:30:53 -0700402 virtual status_t getDisplayColorModes(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700403 Vector<ColorMode>* outColorModes) {
Michael Wright28f24d02016-07-12 13:30:53 -0700404 Parcel data, reply;
405 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
406 if (result != NO_ERROR) {
407 ALOGE("getDisplayColorModes failed to writeInterfaceToken: %d", result);
408 return result;
409 }
410 result = data.writeStrongBinder(display);
411 if (result != NO_ERROR) {
412 ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result);
413 return result;
414 }
415 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply);
416 if (result != NO_ERROR) {
417 ALOGE("getDisplayColorModes failed to transact: %d", result);
418 return result;
419 }
420 result = static_cast<status_t>(reply.readInt32());
421 if (result == NO_ERROR) {
422 size_t numModes = reply.readUint32();
423 outColorModes->clear();
424 outColorModes->resize(numModes);
425 for (size_t i = 0; i < numModes; ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -0700426 outColorModes->replaceAt(static_cast<ColorMode>(reply.readInt32()), i);
Michael Wright28f24d02016-07-12 13:30:53 -0700427 }
428 }
429 return result;
430 }
431
Daniel Solomon42d04562019-01-20 21:03:19 -0800432 virtual status_t getDisplayNativePrimaries(const sp<IBinder>& display,
433 ui::DisplayPrimaries& primaries) {
434 Parcel data, reply;
435 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
436 if (result != NO_ERROR) {
437 ALOGE("getDisplayNativePrimaries failed to writeInterfaceToken: %d", result);
438 return result;
439 }
440 result = data.writeStrongBinder(display);
441 if (result != NO_ERROR) {
442 ALOGE("getDisplayNativePrimaries failed to writeStrongBinder: %d", result);
443 return result;
444 }
445 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_NATIVE_PRIMARIES, data, &reply);
446 if (result != NO_ERROR) {
447 ALOGE("getDisplayNativePrimaries failed to transact: %d", result);
448 return result;
449 }
450 result = reply.readInt32();
451 if (result == NO_ERROR) {
452 memcpy(&primaries, reply.readInplace(sizeof(ui::DisplayPrimaries)),
453 sizeof(ui::DisplayPrimaries));
454 }
455 return result;
456 }
457
Peiyong Lina52f0292018-03-14 17:26:31 -0700458 virtual ColorMode getActiveColorMode(const sp<IBinder>& display) {
Michael Wright28f24d02016-07-12 13:30:53 -0700459 Parcel data, reply;
460 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
461 if (result != NO_ERROR) {
462 ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700463 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700464 }
465 result = data.writeStrongBinder(display);
466 if (result != NO_ERROR) {
467 ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700468 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700469 }
470 result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply);
471 if (result != NO_ERROR) {
472 ALOGE("getActiveColorMode failed to transact: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700473 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700474 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700475 return static_cast<ColorMode>(reply.readInt32());
Michael Wright28f24d02016-07-12 13:30:53 -0700476 }
477
478 virtual status_t setActiveColorMode(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700479 ColorMode colorMode) {
Michael Wright28f24d02016-07-12 13:30:53 -0700480 Parcel data, reply;
481 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
482 if (result != NO_ERROR) {
483 ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result);
484 return result;
485 }
486 result = data.writeStrongBinder(display);
487 if (result != NO_ERROR) {
488 ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result);
489 return result;
490 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700491 result = data.writeInt32(static_cast<int32_t>(colorMode));
Michael Wright28f24d02016-07-12 13:30:53 -0700492 if (result != NO_ERROR) {
493 ALOGE("setActiveColorMode failed to writeInt32: %d", result);
494 return result;
495 }
496 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply);
497 if (result != NO_ERROR) {
498 ALOGE("setActiveColorMode failed to transact: %d", result);
499 return result;
500 }
501 return static_cast<status_t>(reply.readInt32());
502 }
503
Svetoslavd85084b2014-03-20 10:28:31 -0700504 virtual status_t clearAnimationFrameStats() {
505 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700506 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
507 if (result != NO_ERROR) {
508 ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result);
509 return result;
510 }
511 result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply);
512 if (result != NO_ERROR) {
513 ALOGE("clearAnimationFrameStats failed to transact: %d", result);
514 return result;
515 }
Svetoslavd85084b2014-03-20 10:28:31 -0700516 return reply.readInt32();
517 }
518
519 virtual status_t getAnimationFrameStats(FrameStats* outStats) const {
520 Parcel data, reply;
521 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
522 remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply);
523 reply.read(*outStats);
524 return reply.readInt32();
525 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700526
527 virtual status_t getHdrCapabilities(const sp<IBinder>& display,
528 HdrCapabilities* outCapabilities) const {
529 Parcel data, reply;
530 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
531 status_t result = data.writeStrongBinder(display);
532 if (result != NO_ERROR) {
533 ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result);
534 return result;
535 }
536 result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES,
537 data, &reply);
538 if (result != NO_ERROR) {
539 ALOGE("getHdrCapabilities failed to transact: %d", result);
540 return result;
541 }
542 result = reply.readInt32();
543 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800544 result = reply.read(*outCapabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700545 }
546 return result;
547 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700548
549 virtual status_t enableVSyncInjections(bool enable) {
550 Parcel data, reply;
551 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
552 if (result != NO_ERROR) {
553 ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result);
554 return result;
555 }
556 result = data.writeBool(enable);
557 if (result != NO_ERROR) {
558 ALOGE("enableVSyncInjections failed to writeBool: %d", result);
559 return result;
560 }
Steven Moreland366eb422019-04-01 19:22:32 -0700561 result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS, data, &reply,
562 IBinder::FLAG_ONEWAY);
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700563 if (result != NO_ERROR) {
564 ALOGE("enableVSyncInjections failed to transact: %d", result);
565 return result;
566 }
567 return result;
568 }
569
570 virtual status_t injectVSync(nsecs_t when) {
571 Parcel data, reply;
572 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
573 if (result != NO_ERROR) {
574 ALOGE("injectVSync failed to writeInterfaceToken: %d", result);
575 return result;
576 }
577 result = data.writeInt64(when);
578 if (result != NO_ERROR) {
579 ALOGE("injectVSync failed to writeInt64: %d", result);
580 return result;
581 }
Steven Moreland366eb422019-04-01 19:22:32 -0700582 result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply,
583 IBinder::FLAG_ONEWAY);
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700584 if (result != NO_ERROR) {
585 ALOGE("injectVSync failed to transact: %d", result);
586 return result;
587 }
588 return result;
589 }
590
Kalle Raitaa099a242017-01-11 11:17:29 -0800591 virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const
592 {
593 if (!outLayers) {
594 return UNEXPECTED_NULL;
595 }
596
597 Parcel data, reply;
598
599 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
600 if (err != NO_ERROR) {
601 return err;
602 }
603
604 err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply);
605 if (err != NO_ERROR) {
606 return err;
607 }
608
609 int32_t result = 0;
610 err = reply.readInt32(&result);
611 if (err != NO_ERROR) {
612 return err;
613 }
614 if (result != NO_ERROR) {
615 return result;
616 }
617
618 outLayers->clear();
619 return reply.readParcelableVector(outLayers);
620 }
Peiyong Lin0256f722018-08-31 15:45:10 -0700621
Peiyong Linc6780972018-10-28 15:24:08 -0700622 virtual status_t getCompositionPreference(ui::Dataspace* defaultDataspace,
623 ui::PixelFormat* defaultPixelFormat,
624 ui::Dataspace* wideColorGamutDataspace,
625 ui::PixelFormat* wideColorGamutPixelFormat) const {
Peiyong Lin0256f722018-08-31 15:45:10 -0700626 Parcel data, reply;
627 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
628 if (error != NO_ERROR) {
629 return error;
630 }
631 error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply);
632 if (error != NO_ERROR) {
633 return error;
634 }
635 error = static_cast<status_t>(reply.readInt32());
636 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -0700637 *defaultDataspace = static_cast<ui::Dataspace>(reply.readInt32());
638 *defaultPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
639 *wideColorGamutDataspace = static_cast<ui::Dataspace>(reply.readInt32());
640 *wideColorGamutPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
Peiyong Lin0256f722018-08-31 15:45:10 -0700641 }
642 return error;
643 }
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700644
Ady Abraham37965d42018-11-01 13:43:32 -0700645 virtual status_t getColorManagement(bool* outGetColorManagement) const {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700646 Parcel data, reply;
647 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Ady Abraham37965d42018-11-01 13:43:32 -0700648 remote()->transact(BnSurfaceComposer::GET_COLOR_MANAGEMENT, data, &reply);
649 bool result;
650 status_t err = reply.readBool(&result);
651 if (err == NO_ERROR) {
652 *outGetColorManagement = result;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700653 }
Ady Abraham37965d42018-11-01 13:43:32 -0700654 return err;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700655 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -0700656
657 virtual status_t getDisplayedContentSamplingAttributes(const sp<IBinder>& display,
658 ui::PixelFormat* outFormat,
659 ui::Dataspace* outDataspace,
660 uint8_t* outComponentMask) const {
661 if (!outFormat || !outDataspace || !outComponentMask) return BAD_VALUE;
662 Parcel data, reply;
663 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
664 data.writeStrongBinder(display);
665
666 status_t error =
667 remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES,
668 data, &reply);
669 if (error != NO_ERROR) {
670 return error;
671 }
672
673 uint32_t value = 0;
674 error = reply.readUint32(&value);
675 if (error != NO_ERROR) {
676 return error;
677 }
678 *outFormat = static_cast<ui::PixelFormat>(value);
679
680 error = reply.readUint32(&value);
681 if (error != NO_ERROR) {
682 return error;
683 }
684 *outDataspace = static_cast<ui::Dataspace>(value);
685
686 error = reply.readUint32(&value);
687 if (error != NO_ERROR) {
688 return error;
689 }
690 *outComponentMask = static_cast<uint8_t>(value);
691 return error;
692 }
Kevin DuBois74e53772018-11-19 10:52:38 -0800693
694 virtual status_t setDisplayContentSamplingEnabled(const sp<IBinder>& display, bool enable,
695 uint8_t componentMask,
696 uint64_t maxFrames) const {
697 Parcel data, reply;
698 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
699 data.writeStrongBinder(display);
700 data.writeBool(enable);
701 data.writeByte(static_cast<int8_t>(componentMask));
702 data.writeUint64(maxFrames);
703 status_t result =
704 remote()->transact(BnSurfaceComposer::SET_DISPLAY_CONTENT_SAMPLING_ENABLED, data,
705 &reply);
706 return result;
707 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700708
709 virtual status_t getDisplayedContentSample(const sp<IBinder>& display, uint64_t maxFrames,
710 uint64_t timestamp,
711 DisplayedFrameStats* outStats) const {
712 if (!outStats) return BAD_VALUE;
713
714 Parcel data, reply;
715 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
716 data.writeStrongBinder(display);
717 data.writeUint64(maxFrames);
718 data.writeUint64(timestamp);
719
720 status_t result =
721 remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLE, data, &reply);
722
723 if (result != NO_ERROR) {
724 return result;
725 }
726
727 result = reply.readUint64(&outStats->numFrames);
728 if (result != NO_ERROR) {
729 return result;
730 }
731
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800732 result = reply.readUint64Vector(&outStats->component_0_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700733 if (result != NO_ERROR) {
734 return result;
735 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800736 result = reply.readUint64Vector(&outStats->component_1_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700737 if (result != NO_ERROR) {
738 return result;
739 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800740 result = reply.readUint64Vector(&outStats->component_2_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700741 if (result != NO_ERROR) {
742 return result;
743 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800744 result = reply.readUint64Vector(&outStats->component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700745 return result;
746 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800747
748 virtual status_t getProtectedContentSupport(bool* outSupported) const {
749 Parcel data, reply;
750 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Peiyong Linb6888fa2019-01-28 13:20:58 -0800751 status_t error =
752 remote()->transact(BnSurfaceComposer::GET_PROTECTED_CONTENT_SUPPORT, data, &reply);
753 if (error != NO_ERROR) {
754 return error;
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800755 }
Peiyong Linb6888fa2019-01-28 13:20:58 -0800756 error = reply.readBool(outSupported);
757 return error;
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800758 }
Marissa Wallebc2c052019-01-16 19:16:55 -0800759
Peiyong Lin4f3fddf2019-01-24 17:21:24 -0800760 virtual status_t isWideColorDisplay(const sp<IBinder>& token,
761 bool* outIsWideColorDisplay) const {
762 Parcel data, reply;
763 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
764 if (error != NO_ERROR) {
765 return error;
766 }
767 error = data.writeStrongBinder(token);
768 if (error != NO_ERROR) {
769 return error;
770 }
771
772 error = remote()->transact(BnSurfaceComposer::IS_WIDE_COLOR_DISPLAY, data, &reply);
773 if (error != NO_ERROR) {
774 return error;
775 }
776 error = reply.readBool(outIsWideColorDisplay);
777 return error;
778 }
Dan Stoza84ab9372018-12-17 15:27:57 -0800779
780 virtual status_t addRegionSamplingListener(const Rect& samplingArea,
781 const sp<IBinder>& stopLayerHandle,
782 const sp<IRegionSamplingListener>& listener) {
783 Parcel data, reply;
784 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
785 if (error != NO_ERROR) {
786 ALOGE("addRegionSamplingListener: Failed to write interface token");
787 return error;
788 }
789 error = data.write(samplingArea);
790 if (error != NO_ERROR) {
791 ALOGE("addRegionSamplingListener: Failed to write sampling area");
792 return error;
793 }
794 error = data.writeStrongBinder(stopLayerHandle);
795 if (error != NO_ERROR) {
796 ALOGE("addRegionSamplingListener: Failed to write stop layer handle");
797 return error;
798 }
799 error = data.writeStrongBinder(IInterface::asBinder(listener));
800 if (error != NO_ERROR) {
801 ALOGE("addRegionSamplingListener: Failed to write listener");
802 return error;
803 }
804 error = remote()->transact(BnSurfaceComposer::ADD_REGION_SAMPLING_LISTENER, data, &reply);
805 if (error != NO_ERROR) {
806 ALOGE("addRegionSamplingListener: Failed to transact");
807 }
808 return error;
809 }
810
811 virtual status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) {
812 Parcel data, reply;
813 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
814 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800815 ALOGE("removeRegionSamplingListener: Failed to write interface token");
Dan Stoza84ab9372018-12-17 15:27:57 -0800816 return error;
817 }
818 error = data.writeStrongBinder(IInterface::asBinder(listener));
819 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800820 ALOGE("removeRegionSamplingListener: Failed to write listener");
Dan Stoza84ab9372018-12-17 15:27:57 -0800821 return error;
822 }
823 error = remote()->transact(BnSurfaceComposer::REMOVE_REGION_SAMPLING_LISTENER, data,
824 &reply);
825 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800826 ALOGE("removeRegionSamplingListener: Failed to transact");
Dan Stoza84ab9372018-12-17 15:27:57 -0800827 }
828 return error;
829 }
Ady Abraham838de062019-02-04 10:24:03 -0800830
831 virtual status_t setAllowedDisplayConfigs(const sp<IBinder>& displayToken,
832 const std::vector<int32_t>& allowedConfigs) {
833 Parcel data, reply;
834 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
835 if (result != NO_ERROR) {
836 ALOGE("setAllowedDisplayConfigs failed to writeInterfaceToken: %d", result);
837 return result;
838 }
839 result = data.writeStrongBinder(displayToken);
840 if (result != NO_ERROR) {
841 ALOGE("setAllowedDisplayConfigs failed to writeStrongBinder: %d", result);
842 return result;
843 }
844 result = data.writeInt32Vector(allowedConfigs);
845 if (result != NO_ERROR) {
846 ALOGE("setAllowedDisplayConfigs failed to writeInt32Vector: %d", result);
847 return result;
848 }
849 result = remote()->transact(BnSurfaceComposer::SET_ALLOWED_DISPLAY_CONFIGS, data, &reply);
850 if (result != NO_ERROR) {
851 ALOGE("setAllowedDisplayConfigs failed to transact: %d", result);
852 return result;
853 }
854 return reply.readInt32();
855 }
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800856
857 virtual status_t getAllowedDisplayConfigs(const sp<IBinder>& displayToken,
858 std::vector<int32_t>* outAllowedConfigs) {
859 if (!outAllowedConfigs) return BAD_VALUE;
860 Parcel data, reply;
861 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
862 if (result != NO_ERROR) {
863 ALOGE("getAllowedDisplayConfigs failed to writeInterfaceToken: %d", result);
864 return result;
865 }
866 result = data.writeStrongBinder(displayToken);
867 if (result != NO_ERROR) {
868 ALOGE("getAllowedDisplayConfigs failed to writeStrongBinder: %d", result);
869 return result;
870 }
871 result = remote()->transact(BnSurfaceComposer::GET_ALLOWED_DISPLAY_CONFIGS, data, &reply);
872 if (result != NO_ERROR) {
873 ALOGE("getAllowedDisplayConfigs failed to transact: %d", result);
874 return result;
875 }
876 result = reply.readInt32Vector(outAllowedConfigs);
877 if (result != NO_ERROR) {
878 ALOGE("getAllowedDisplayConfigs failed to readInt32Vector: %d", result);
879 return result;
880 }
881 return reply.readInt32();
882 }
Dan Gittik57e63c52019-01-18 16:37:54 +0000883
884 virtual status_t getDisplayBrightnessSupport(const sp<IBinder>& displayToken,
885 bool* outSupport) const {
886 Parcel data, reply;
887 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
888 if (error != NO_ERROR) {
889 ALOGE("getDisplayBrightnessSupport: failed to write interface token: %d", error);
890 return error;
891 }
892 error = data.writeStrongBinder(displayToken);
893 if (error != NO_ERROR) {
894 ALOGE("getDisplayBrightnessSupport: failed to write display token: %d", error);
895 return error;
896 }
897 error = remote()->transact(BnSurfaceComposer::GET_DISPLAY_BRIGHTNESS_SUPPORT, data, &reply);
898 if (error != NO_ERROR) {
899 ALOGE("getDisplayBrightnessSupport: failed to transact: %d", error);
900 return error;
901 }
902 bool support;
903 error = reply.readBool(&support);
904 if (error != NO_ERROR) {
905 ALOGE("getDisplayBrightnessSupport: failed to read support: %d", error);
906 return error;
907 }
908 *outSupport = support;
909 return NO_ERROR;
910 }
911
912 virtual status_t setDisplayBrightness(const sp<IBinder>& displayToken, float brightness) const {
913 Parcel data, reply;
914 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
915 if (error != NO_ERROR) {
916 ALOGE("setDisplayBrightness: failed to write interface token: %d", error);
917 return error;
918 }
919 error = data.writeStrongBinder(displayToken);
920 if (error != NO_ERROR) {
921 ALOGE("setDisplayBrightness: failed to write display token: %d", error);
922 return error;
923 }
924 error = data.writeFloat(brightness);
925 if (error != NO_ERROR) {
926 ALOGE("setDisplayBrightness: failed to write brightness: %d", error);
927 return error;
928 }
929 error = remote()->transact(BnSurfaceComposer::SET_DISPLAY_BRIGHTNESS, data, &reply);
930 if (error != NO_ERROR) {
931 ALOGE("setDisplayBrightness: failed to transact: %d", error);
932 return error;
933 }
934 return NO_ERROR;
935 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800936};
937
Dan Stozad723bd72014-11-18 10:24:03 -0800938// Out-of-line virtual method definition to trigger vtable emission in this
939// translation unit (see clang warning -Wweak-vtables)
940BpSurfaceComposer::~BpSurfaceComposer() {}
941
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800942IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
943
944// ----------------------------------------------------------------------
945
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800946status_t BnSurfaceComposer::onTransact(
947 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
948{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800949 switch(code) {
950 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700951 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800952 sp<IBinder> b = IInterface::asBinder(createConnection());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800953 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -0700954 return NO_ERROR;
955 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700956 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700957 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -0800958
959 size_t count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700960 if (count > data.dataSize()) {
961 return BAD_VALUE;
962 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700963 Vector<ComposerState> state;
964 state.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800965 for (size_t i = 0; i < count; i++) {
Marissa Wallc837b5e2018-10-12 10:04:44 -0700966 ComposerState s;
Michael Lentine8afa1c42014-10-31 11:10:13 -0700967 if (s.read(data) == BAD_VALUE) {
968 return BAD_VALUE;
969 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700970 state.add(s);
971 }
Dan Stozad723bd72014-11-18 10:24:03 -0800972
973 count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700974 if (count > data.dataSize()) {
975 return BAD_VALUE;
976 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700977 DisplayState d;
978 Vector<DisplayState> displays;
979 displays.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800980 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700981 if (d.read(data) == BAD_VALUE) {
982 return BAD_VALUE;
983 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700984 displays.add(d);
985 }
Dan Stozad723bd72014-11-18 10:24:03 -0800986
987 uint32_t stateFlags = data.readUint32();
Marissa Wall713b63f2018-10-17 15:42:43 -0700988 sp<IBinder> applyToken = data.readStrongBinder();
chaviw273171b2018-12-26 11:46:30 -0800989 InputWindowCommands inputWindowCommands;
990 inputWindowCommands.read(data);
Marissa Wall17b4e452018-12-26 16:32:34 -0800991
992 int64_t desiredPresentTime = data.readInt64();
Marissa Wall78b72202019-03-15 14:58:34 -0700993
Marissa Wall947d34e2019-03-29 14:03:53 -0700994 client_cache_t uncachedBuffer;
995 uncachedBuffer.token = data.readWeakBinder();
996 uncachedBuffer.id = data.readUint64();
Marissa Wall78b72202019-03-15 14:58:34 -0700997
Marissa Wall3dad52d2019-03-22 14:03:19 -0700998 std::vector<ListenerCallbacks> listenerCallbacks;
999 int32_t listenersSize = data.readInt32();
1000 for (int32_t i = 0; i < listenersSize; i++) {
1001 auto listener =
1002 interface_cast<ITransactionCompletedListener>(data.readStrongBinder());
1003 std::vector<CallbackId> callbackIds;
1004 data.readInt64Vector(&callbackIds);
1005 listenerCallbacks.emplace_back(listener, callbackIds);
1006 }
1007
Marissa Wall17b4e452018-12-26 16:32:34 -08001008 setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands,
Marissa Wall3dad52d2019-03-22 14:03:19 -07001009 desiredPresentTime, uncachedBuffer, listenerCallbacks);
Jesse Hall6c913be2013-08-08 12:15:49 -07001010 return NO_ERROR;
1011 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001012 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001013 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001014 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -07001015 return NO_ERROR;
1016 }
Mathias Agopian2a9fc492013-03-01 13:42:57 -08001017 case CAPTURE_SCREEN: {
1018 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1019 sp<IBinder> display = data.readStrongBinder();
Peiyong Lin0e003c92018-09-17 11:09:51 -07001020 ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32());
1021 ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32());
Chavi Weingarten40482ff2017-11-30 01:51:40 +00001022 sp<GraphicBuffer> outBuffer;
Pablo Ceballos60d69222015-08-07 14:47:20 -07001023 Rect sourceCrop(Rect::EMPTY_RECT);
Dan Stozac1879002014-05-22 15:59:05 -07001024 data.read(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -08001025 uint32_t reqWidth = data.readUint32();
1026 uint32_t reqHeight = data.readUint32();
Dan Stozac7014012014-02-14 15:03:43 -08001027 bool useIdentityTransform = static_cast<bool>(data.readInt32());
Dan Stozad723bd72014-11-18 10:24:03 -08001028 int32_t rotation = data.readInt32();
Robert Carrfa8855f2019-02-19 10:05:00 -08001029 bool captureSecureLayers = static_cast<bool>(data.readInt32());
Dan Stozac7014012014-02-14 15:03:43 -08001030
Robert Carr108b2c72019-04-02 16:32:58 -07001031 bool capturedSecureLayers = false;
1032 status_t res = captureScreen(display, &outBuffer, capturedSecureLayers, reqDataspace,
1033 reqPixelFormat, sourceCrop, reqWidth, reqHeight,
1034 useIdentityTransform,
1035 static_cast<ISurfaceComposer::Rotation>(rotation),
1036 captureSecureLayers);
1037
Mathias Agopian2a9fc492013-03-01 13:42:57 -08001038 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +00001039 if (res == NO_ERROR) {
1040 reply->write(*outBuffer);
Robert Carr108b2c72019-04-02 16:32:58 -07001041 reply->writeBool(capturedSecureLayers);
Chavi Weingarten40482ff2017-11-30 01:51:40 +00001042 }
Jesse Hall6c913be2013-08-08 12:15:49 -07001043 return NO_ERROR;
1044 }
chaviwa76b2712017-09-20 12:02:26 -07001045 case CAPTURE_LAYERS: {
1046 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1047 sp<IBinder> layerHandleBinder = data.readStrongBinder();
Peiyong Lin0e003c92018-09-17 11:09:51 -07001048 ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32());
1049 ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32());
Chavi Weingarten40482ff2017-11-30 01:51:40 +00001050 sp<GraphicBuffer> outBuffer;
chaviw7206d492017-11-10 16:16:12 -08001051 Rect sourceCrop(Rect::EMPTY_RECT);
1052 data.read(sourceCrop);
Robert Carr866455f2019-04-02 16:28:26 -07001053
1054 std::unordered_set<sp<IBinder>, SpHash<IBinder>> excludeHandles;
1055 int numExcludeHandles = data.readInt32();
1056 excludeHandles.reserve(numExcludeHandles);
1057 for (int i = 0; i < numExcludeHandles; i++) {
1058 excludeHandles.emplace(data.readStrongBinder());
1059 }
1060
chaviw7206d492017-11-10 16:16:12 -08001061 float frameScale = data.readFloat();
Robert Carr578038f2018-03-09 12:25:24 -08001062 bool childrenOnly = data.readBool();
chaviwa76b2712017-09-20 12:02:26 -07001063
Robert Carr866455f2019-04-02 16:28:26 -07001064 status_t res =
1065 captureLayers(layerHandleBinder, &outBuffer, reqDataspace, reqPixelFormat,
1066 sourceCrop, excludeHandles, frameScale, childrenOnly);
chaviwa76b2712017-09-20 12:02:26 -07001067 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +00001068 if (res == NO_ERROR) {
1069 reply->write(*outBuffer);
1070 }
chaviwa76b2712017-09-20 12:02:26 -07001071 return NO_ERROR;
1072 }
Jamie Gennis134f0422011-03-08 12:18:54 -08001073 case AUTHENTICATE_SURFACE: {
1074 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -08001075 sp<IGraphicBufferProducer> bufferProducer =
1076 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
1077 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -08001078 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -07001079 return NO_ERROR;
1080 }
Brian Anderson6b376712017-04-04 10:51:39 -07001081 case GET_SUPPORTED_FRAME_TIMESTAMPS: {
1082 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1083 std::vector<FrameEvent> supportedTimestamps;
1084 status_t result = getSupportedFrameTimestamps(&supportedTimestamps);
1085 status_t err = reply->writeInt32(result);
1086 if (err != NO_ERROR) {
1087 return err;
1088 }
1089 if (result != NO_ERROR) {
1090 return result;
1091 }
1092
1093 std::vector<int32_t> supported;
1094 supported.reserve(supportedTimestamps.size());
1095 for (FrameEvent s : supportedTimestamps) {
1096 supported.push_back(static_cast<int32_t>(s));
1097 }
1098 return reply->writeInt32Vector(supported);
1099 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001100 case CREATE_DISPLAY_EVENT_CONNECTION: {
1101 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -07001102 sp<IDisplayEventConnection> connection(createDisplayEventConnection(
1103 static_cast<ISurfaceComposer::VsyncSource>(data.readInt32())));
Marco Nelissen2ea926b2014-11-14 08:01:01 -08001104 reply->writeStrongBinder(IInterface::asBinder(connection));
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001105 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001106 }
Mathias Agopiane57f2922012-08-09 16:29:12 -07001107 case CREATE_DISPLAY: {
1108 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden8dfa92f2012-09-17 18:27:17 -07001109 String8 displayName = data.readString8();
Jamie Gennisdd3cb842012-10-19 18:19:11 -07001110 bool secure = bool(data.readInt32());
1111 sp<IBinder> display(createDisplay(displayName, secure));
Mathias Agopiane57f2922012-08-09 16:29:12 -07001112 reply->writeStrongBinder(display);
1113 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001114 }
1115 case DESTROY_DISPLAY: {
1116 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1117 sp<IBinder> display = data.readStrongBinder();
1118 destroyDisplay(display);
1119 return NO_ERROR;
1120 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001121 case GET_PHYSICAL_DISPLAY_TOKEN: {
Mathias Agopiane57f2922012-08-09 16:29:12 -07001122 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001123 PhysicalDisplayId displayId = data.readUint64();
1124 sp<IBinder> display = getPhysicalDisplayToken(displayId);
Mathias Agopiane57f2922012-08-09 16:29:12 -07001125 reply->writeStrongBinder(display);
1126 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001127 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001128 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -07001129 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stoza7f7da322014-05-02 15:26:25 -07001130 Vector<DisplayInfo> configs;
Jeff Brown9d4e3d22012-08-24 20:00:51 -07001131 sp<IBinder> display = data.readStrongBinder();
Dan Stoza7f7da322014-05-02 15:26:25 -07001132 status_t result = getDisplayConfigs(display, &configs);
1133 reply->writeInt32(result);
1134 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -08001135 reply->writeUint32(static_cast<uint32_t>(configs.size()));
Dan Stoza7f7da322014-05-02 15:26:25 -07001136 for (size_t c = 0; c < configs.size(); ++c) {
1137 memcpy(reply->writeInplace(sizeof(DisplayInfo)),
1138 &configs[c], sizeof(DisplayInfo));
1139 }
1140 }
1141 return NO_ERROR;
1142 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -07001143 case GET_DISPLAY_STATS: {
1144 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1145 DisplayStatInfo stats;
1146 sp<IBinder> display = data.readStrongBinder();
1147 status_t result = getDisplayStats(display, &stats);
1148 reply->writeInt32(result);
1149 if (result == NO_ERROR) {
1150 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
1151 &stats, sizeof(DisplayStatInfo));
1152 }
1153 return NO_ERROR;
1154 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001155 case GET_ACTIVE_CONFIG: {
1156 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1157 sp<IBinder> display = data.readStrongBinder();
1158 int id = getActiveConfig(display);
1159 reply->writeInt32(id);
1160 return NO_ERROR;
1161 }
1162 case SET_ACTIVE_CONFIG: {
1163 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1164 sp<IBinder> display = data.readStrongBinder();
1165 int id = data.readInt32();
1166 status_t result = setActiveConfig(display, id);
Mathias Agopianc666cae2012-07-25 18:56:13 -07001167 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -07001168 return NO_ERROR;
1169 }
Michael Wright28f24d02016-07-12 13:30:53 -07001170 case GET_DISPLAY_COLOR_MODES: {
1171 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Lina52f0292018-03-14 17:26:31 -07001172 Vector<ColorMode> colorModes;
Michael Wright28f24d02016-07-12 13:30:53 -07001173 sp<IBinder> display = nullptr;
1174 status_t result = data.readStrongBinder(&display);
1175 if (result != NO_ERROR) {
1176 ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result);
1177 return result;
1178 }
1179 result = getDisplayColorModes(display, &colorModes);
1180 reply->writeInt32(result);
1181 if (result == NO_ERROR) {
1182 reply->writeUint32(static_cast<uint32_t>(colorModes.size()));
1183 for (size_t i = 0; i < colorModes.size(); ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -07001184 reply->writeInt32(static_cast<int32_t>(colorModes[i]));
Michael Wright28f24d02016-07-12 13:30:53 -07001185 }
1186 }
1187 return NO_ERROR;
1188 }
Daniel Solomon42d04562019-01-20 21:03:19 -08001189 case GET_DISPLAY_NATIVE_PRIMARIES: {
1190 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1191 ui::DisplayPrimaries primaries;
1192 sp<IBinder> display = nullptr;
1193
1194 status_t result = data.readStrongBinder(&display);
1195 if (result != NO_ERROR) {
1196 ALOGE("getDisplayNativePrimaries failed to readStrongBinder: %d", result);
1197 return result;
1198 }
1199
1200 result = getDisplayNativePrimaries(display, primaries);
1201 reply->writeInt32(result);
1202 if (result == NO_ERROR) {
1203 memcpy(reply->writeInplace(sizeof(ui::DisplayPrimaries)), &primaries,
1204 sizeof(ui::DisplayPrimaries));
1205 }
1206
1207 return NO_ERROR;
1208 }
Michael Wright28f24d02016-07-12 13:30:53 -07001209 case GET_ACTIVE_COLOR_MODE: {
1210 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1211 sp<IBinder> display = nullptr;
1212 status_t result = data.readStrongBinder(&display);
1213 if (result != NO_ERROR) {
1214 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1215 return result;
1216 }
Peiyong Lina52f0292018-03-14 17:26:31 -07001217 ColorMode colorMode = getActiveColorMode(display);
Michael Wright28f24d02016-07-12 13:30:53 -07001218 result = reply->writeInt32(static_cast<int32_t>(colorMode));
1219 return result;
1220 }
1221 case SET_ACTIVE_COLOR_MODE: {
1222 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1223 sp<IBinder> display = nullptr;
1224 status_t result = data.readStrongBinder(&display);
1225 if (result != NO_ERROR) {
1226 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1227 return result;
1228 }
1229 int32_t colorModeInt = 0;
1230 result = data.readInt32(&colorModeInt);
1231 if (result != NO_ERROR) {
1232 ALOGE("setActiveColorMode failed to readInt32: %d", result);
1233 return result;
1234 }
1235 result = setActiveColorMode(display,
Peiyong Lina52f0292018-03-14 17:26:31 -07001236 static_cast<ColorMode>(colorModeInt));
Michael Wright28f24d02016-07-12 13:30:53 -07001237 result = reply->writeInt32(result);
1238 return result;
1239 }
Svetoslavd85084b2014-03-20 10:28:31 -07001240 case CLEAR_ANIMATION_FRAME_STATS: {
1241 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1242 status_t result = clearAnimationFrameStats();
1243 reply->writeInt32(result);
1244 return NO_ERROR;
1245 }
1246 case GET_ANIMATION_FRAME_STATS: {
1247 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1248 FrameStats stats;
1249 status_t result = getAnimationFrameStats(&stats);
1250 reply->write(stats);
1251 reply->writeInt32(result);
1252 return NO_ERROR;
1253 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -07001254 case SET_POWER_MODE: {
1255 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1256 sp<IBinder> display = data.readStrongBinder();
1257 int32_t mode = data.readInt32();
1258 setPowerMode(display, mode);
1259 return NO_ERROR;
1260 }
Dan Stozac4f471e2016-03-24 09:31:08 -07001261 case GET_HDR_CAPABILITIES: {
1262 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1263 sp<IBinder> display = nullptr;
1264 status_t result = data.readStrongBinder(&display);
1265 if (result != NO_ERROR) {
1266 ALOGE("getHdrCapabilities failed to readStrongBinder: %d",
1267 result);
1268 return result;
1269 }
1270 HdrCapabilities capabilities;
1271 result = getHdrCapabilities(display, &capabilities);
1272 reply->writeInt32(result);
1273 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -08001274 reply->write(capabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -07001275 }
1276 return NO_ERROR;
1277 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -07001278 case ENABLE_VSYNC_INJECTIONS: {
1279 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1280 bool enable = false;
1281 status_t result = data.readBool(&enable);
1282 if (result != NO_ERROR) {
1283 ALOGE("enableVSyncInjections failed to readBool: %d", result);
1284 return result;
1285 }
1286 return enableVSyncInjections(enable);
1287 }
1288 case INJECT_VSYNC: {
1289 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1290 int64_t when = 0;
1291 status_t result = data.readInt64(&when);
1292 if (result != NO_ERROR) {
1293 ALOGE("enableVSyncInjections failed to readInt64: %d", result);
1294 return result;
1295 }
1296 return injectVSync(when);
1297 }
Kalle Raitaa099a242017-01-11 11:17:29 -08001298 case GET_LAYER_DEBUG_INFO: {
1299 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1300 std::vector<LayerDebugInfo> outLayers;
1301 status_t result = getLayerDebugInfo(&outLayers);
1302 reply->writeInt32(result);
1303 if (result == NO_ERROR)
1304 {
1305 result = reply->writeParcelableVector(outLayers);
1306 }
1307 return result;
1308 }
Peiyong Lin0256f722018-08-31 15:45:10 -07001309 case GET_COMPOSITION_PREFERENCE: {
1310 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Linc6780972018-10-28 15:24:08 -07001311 ui::Dataspace defaultDataspace;
1312 ui::PixelFormat defaultPixelFormat;
1313 ui::Dataspace wideColorGamutDataspace;
1314 ui::PixelFormat wideColorGamutPixelFormat;
1315 status_t error =
1316 getCompositionPreference(&defaultDataspace, &defaultPixelFormat,
1317 &wideColorGamutDataspace, &wideColorGamutPixelFormat);
Peiyong Lin0256f722018-08-31 15:45:10 -07001318 reply->writeInt32(error);
1319 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -07001320 reply->writeInt32(static_cast<int32_t>(defaultDataspace));
1321 reply->writeInt32(static_cast<int32_t>(defaultPixelFormat));
1322 reply->writeInt32(static_cast<int32_t>(wideColorGamutDataspace));
Peiyong Linaa3da6a2018-12-12 02:48:43 -08001323 reply->writeInt32(static_cast<int32_t>(wideColorGamutPixelFormat));
Peiyong Lin0256f722018-08-31 15:45:10 -07001324 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001325 return error;
Peiyong Lin0256f722018-08-31 15:45:10 -07001326 }
Ady Abraham37965d42018-11-01 13:43:32 -07001327 case GET_COLOR_MANAGEMENT: {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001328 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Ady Abraham37965d42018-11-01 13:43:32 -07001329 bool result;
1330 status_t error = getColorManagement(&result);
1331 if (error == NO_ERROR) {
1332 reply->writeBool(result);
1333 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001334 return error;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001335 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -07001336 case GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: {
1337 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1338
1339 sp<IBinder> display = data.readStrongBinder();
1340 ui::PixelFormat format;
1341 ui::Dataspace dataspace;
1342 uint8_t component = 0;
1343 auto result =
1344 getDisplayedContentSamplingAttributes(display, &format, &dataspace, &component);
1345 if (result == NO_ERROR) {
1346 reply->writeUint32(static_cast<uint32_t>(format));
1347 reply->writeUint32(static_cast<uint32_t>(dataspace));
1348 reply->writeUint32(static_cast<uint32_t>(component));
1349 }
1350 return result;
1351 }
Kevin DuBois74e53772018-11-19 10:52:38 -08001352 case SET_DISPLAY_CONTENT_SAMPLING_ENABLED: {
1353 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1354
1355 sp<IBinder> display = nullptr;
1356 bool enable = false;
1357 int8_t componentMask = 0;
1358 uint64_t maxFrames = 0;
1359 status_t result = data.readStrongBinder(&display);
1360 if (result != NO_ERROR) {
1361 ALOGE("setDisplayContentSamplingEnabled failure in reading Display token: %d",
1362 result);
1363 return result;
1364 }
1365
1366 result = data.readBool(&enable);
1367 if (result != NO_ERROR) {
1368 ALOGE("setDisplayContentSamplingEnabled failure in reading enable: %d", result);
1369 return result;
1370 }
1371
1372 result = data.readByte(static_cast<int8_t*>(&componentMask));
1373 if (result != NO_ERROR) {
1374 ALOGE("setDisplayContentSamplingEnabled failure in reading component mask: %d",
1375 result);
1376 return result;
1377 }
1378
1379 result = data.readUint64(&maxFrames);
1380 if (result != NO_ERROR) {
1381 ALOGE("setDisplayContentSamplingEnabled failure in reading max frames: %d", result);
1382 return result;
1383 }
1384
1385 return setDisplayContentSamplingEnabled(display, enable,
1386 static_cast<uint8_t>(componentMask), maxFrames);
1387 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001388 case GET_DISPLAYED_CONTENT_SAMPLE: {
1389 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1390
1391 sp<IBinder> display = data.readStrongBinder();
1392 uint64_t maxFrames = 0;
1393 uint64_t timestamp = 0;
1394
1395 status_t result = data.readUint64(&maxFrames);
1396 if (result != NO_ERROR) {
1397 ALOGE("getDisplayedContentSample failure in reading max frames: %d", result);
1398 return result;
1399 }
1400
1401 result = data.readUint64(&timestamp);
1402 if (result != NO_ERROR) {
1403 ALOGE("getDisplayedContentSample failure in reading timestamp: %d", result);
1404 return result;
1405 }
1406
1407 DisplayedFrameStats stats;
1408 result = getDisplayedContentSample(display, maxFrames, timestamp, &stats);
1409 if (result == NO_ERROR) {
1410 reply->writeUint64(stats.numFrames);
Kevin DuBois1d4c6a62018-12-12 13:59:46 -08001411 reply->writeUint64Vector(stats.component_0_sample);
1412 reply->writeUint64Vector(stats.component_1_sample);
1413 reply->writeUint64Vector(stats.component_2_sample);
1414 reply->writeUint64Vector(stats.component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001415 }
1416 return result;
1417 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001418 case GET_PROTECTED_CONTENT_SUPPORT: {
1419 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1420 bool result;
1421 status_t error = getProtectedContentSupport(&result);
1422 if (error == NO_ERROR) {
1423 reply->writeBool(result);
1424 }
1425 return error;
1426 }
Peiyong Lin4f3fddf2019-01-24 17:21:24 -08001427 case IS_WIDE_COLOR_DISPLAY: {
1428 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1429 sp<IBinder> display = nullptr;
1430 status_t error = data.readStrongBinder(&display);
1431 if (error != NO_ERROR) {
1432 return error;
1433 }
1434 bool result;
1435 error = isWideColorDisplay(display, &result);
1436 if (error == NO_ERROR) {
1437 reply->writeBool(result);
1438 }
1439 return error;
1440 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001441 case GET_PHYSICAL_DISPLAY_IDS: {
1442 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1443 return reply->writeUint64Vector(getPhysicalDisplayIds());
1444 }
Dan Stoza84ab9372018-12-17 15:27:57 -08001445 case ADD_REGION_SAMPLING_LISTENER: {
1446 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1447 Rect samplingArea;
1448 status_t result = data.read(samplingArea);
1449 if (result != NO_ERROR) {
1450 ALOGE("addRegionSamplingListener: Failed to read sampling area");
1451 return result;
1452 }
1453 sp<IBinder> stopLayerHandle;
1454 result = data.readNullableStrongBinder(&stopLayerHandle);
1455 if (result != NO_ERROR) {
1456 ALOGE("addRegionSamplingListener: Failed to read stop layer handle");
1457 return result;
1458 }
1459 sp<IRegionSamplingListener> listener;
1460 result = data.readNullableStrongBinder(&listener);
1461 if (result != NO_ERROR) {
1462 ALOGE("addRegionSamplingListener: Failed to read listener");
1463 return result;
1464 }
1465 return addRegionSamplingListener(samplingArea, stopLayerHandle, listener);
1466 }
1467 case REMOVE_REGION_SAMPLING_LISTENER: {
1468 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1469 sp<IRegionSamplingListener> listener;
1470 status_t result = data.readNullableStrongBinder(&listener);
1471 if (result != NO_ERROR) {
1472 ALOGE("removeRegionSamplingListener: Failed to read listener");
1473 return result;
1474 }
1475 return removeRegionSamplingListener(listener);
1476 }
Ady Abraham838de062019-02-04 10:24:03 -08001477 case SET_ALLOWED_DISPLAY_CONFIGS: {
1478 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1479 sp<IBinder> displayToken = data.readStrongBinder();
1480 std::vector<int32_t> allowedConfigs;
1481 data.readInt32Vector(&allowedConfigs);
1482 status_t result = setAllowedDisplayConfigs(displayToken, allowedConfigs);
1483 reply->writeInt32(result);
1484 return result;
1485 }
Ady Abrahamd9b3ea62019-02-26 14:08:03 -08001486 case GET_ALLOWED_DISPLAY_CONFIGS: {
1487 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1488 sp<IBinder> displayToken = data.readStrongBinder();
1489 std::vector<int32_t> allowedConfigs;
1490 status_t result = getAllowedDisplayConfigs(displayToken, &allowedConfigs);
1491 reply->writeInt32Vector(allowedConfigs);
1492 reply->writeInt32(result);
1493 return result;
1494 }
Dan Gittik57e63c52019-01-18 16:37:54 +00001495 case GET_DISPLAY_BRIGHTNESS_SUPPORT: {
1496 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1497 sp<IBinder> displayToken;
1498 status_t error = data.readNullableStrongBinder(&displayToken);
1499 if (error != NO_ERROR) {
1500 ALOGE("getDisplayBrightnessSupport: failed to read display token: %d", error);
1501 return error;
1502 }
1503 bool support = false;
1504 error = getDisplayBrightnessSupport(displayToken, &support);
1505 reply->writeBool(support);
1506 return error;
1507 }
1508 case SET_DISPLAY_BRIGHTNESS: {
1509 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1510 sp<IBinder> displayToken;
1511 status_t error = data.readNullableStrongBinder(&displayToken);
1512 if (error != NO_ERROR) {
1513 ALOGE("setDisplayBrightness: failed to read display token: %d", error);
1514 return error;
1515 }
1516 float brightness = -1.0f;
1517 error = data.readFloat(&brightness);
1518 if (error != NO_ERROR) {
1519 ALOGE("setDisplayBrightness: failed to read brightness: %d", error);
1520 return error;
1521 }
1522 return setDisplayBrightness(displayToken, brightness);
1523 }
Jesse Hall6c913be2013-08-08 12:15:49 -07001524 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001525 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -07001526 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001527 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001528}
1529
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001530} // namespace android