blob: d34fe3b0ba5589c59ff9deac6a15ddc993b5791f [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,
Valerie Hau9dab9732019-08-20 09:29:25 -070072 const client_cache_t& uncacheBuffer, bool hasListenerCallbacks,
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);
Steven Moreland9d4ce9b2019-07-17 15:23:38 -070091 data.writeStrongBinder(uncacheBuffer.token.promote());
Marissa Wall947d34e2019-03-29 14:03:53 -070092 data.writeUint64(uncacheBuffer.id);
Valerie Hau9dab9732019-08-20 09:29:25 -070093 data.writeBool(hasListenerCallbacks);
Marissa Wall3dad52d2019-03-22 14:03:19 -070094
95 if (data.writeVectorSize(listenerCallbacks) == NO_ERROR) {
96 for (const auto& [listener, callbackIds] : listenerCallbacks) {
Valerie Hau5de3ad22019-08-20 07:47:43 -070097 data.writeStrongBinder(listener);
Marissa Wall3dad52d2019-03-22 14:03:19 -070098 data.writeInt64Vector(callbackIds);
99 }
100 }
101
Jamie Gennisb8d69a52011-10-10 15:48:06 -0700102 remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800103 }
104
105 virtual void bootFinished()
106 {
107 Parcel data, reply;
108 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
109 remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply);
110 }
111
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000112 virtual status_t captureScreen(const sp<IBinder>& display, sp<GraphicBuffer>* outBuffer,
Dominik Laskowski718f9602019-11-09 20:01:35 -0800113 bool& outCapturedSecureLayers, ui::Dataspace reqDataspace,
114 ui::PixelFormat reqPixelFormat, const Rect& sourceCrop,
Peiyong Lin0e003c92018-09-17 11:09:51 -0700115 uint32_t reqWidth, uint32_t reqHeight, bool useIdentityTransform,
Dominik Laskowski718f9602019-11-09 20:01:35 -0800116 ui::Rotation rotation, bool captureSecureLayers) {
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800117 Parcel data, reply;
118 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
119 data.writeStrongBinder(display);
Peiyong Lin0e003c92018-09-17 11:09:51 -0700120 data.writeInt32(static_cast<int32_t>(reqDataspace));
121 data.writeInt32(static_cast<int32_t>(reqPixelFormat));
Dan Stozac1879002014-05-22 15:59:05 -0700122 data.write(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800123 data.writeUint32(reqWidth);
124 data.writeUint32(reqHeight);
Dan Stozac7014012014-02-14 15:03:43 -0800125 data.writeInt32(static_cast<int32_t>(useIdentityTransform));
Riley Andrewsc3ebe662014-09-04 16:20:31 -0700126 data.writeInt32(static_cast<int32_t>(rotation));
Robert Carrfa8855f2019-02-19 10:05:00 -0800127 data.writeInt32(static_cast<int32_t>(captureSecureLayers));
Ana Krulec2d41e422018-07-26 12:07:43 -0700128 status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply);
129 if (result != NO_ERROR) {
130 ALOGE("captureScreen failed to transact: %d", result);
131 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000132 }
Ana Krulec2d41e422018-07-26 12:07:43 -0700133 result = reply.readInt32();
134 if (result != NO_ERROR) {
135 ALOGE("captureScreen failed to readInt32: %d", result);
136 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000137 }
138
139 *outBuffer = new GraphicBuffer();
140 reply.read(**outBuffer);
Robert Carr108b2c72019-04-02 16:32:58 -0700141 outCapturedSecureLayers = reply.readBool();
Peiyong Lin0e003c92018-09-17 11:09:51 -0700142
Ana Krulec2d41e422018-07-26 12:07:43 -0700143 return result;
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800144 }
145
chaviw93df2ea2019-04-30 16:45:12 -0700146 virtual status_t captureScreen(uint64_t displayOrLayerStack, ui::Dataspace* outDataspace,
147 sp<GraphicBuffer>* outBuffer) {
148 Parcel data, reply;
149 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
150 data.writeUint64(displayOrLayerStack);
151 status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN_BY_ID, data, &reply);
152 if (result != NO_ERROR) {
153 ALOGE("captureScreen failed to transact: %d", result);
154 return result;
155 }
156 result = reply.readInt32();
157 if (result != NO_ERROR) {
158 ALOGE("captureScreen failed to readInt32: %d", result);
159 return result;
160 }
161
162 *outDataspace = static_cast<ui::Dataspace>(reply.readInt32());
163 *outBuffer = new GraphicBuffer();
164 reply.read(**outBuffer);
165 return result;
166 }
167
Robert Carr866455f2019-04-02 16:28:26 -0700168 virtual status_t captureLayers(
169 const sp<IBinder>& layerHandleBinder, sp<GraphicBuffer>* outBuffer,
170 const ui::Dataspace reqDataspace, const ui::PixelFormat reqPixelFormat,
171 const Rect& sourceCrop,
172 const std::unordered_set<sp<IBinder>, SpHash<IBinder>>& excludeLayers, float frameScale,
173 bool childrenOnly) {
chaviwa76b2712017-09-20 12:02:26 -0700174 Parcel data, reply;
175 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
176 data.writeStrongBinder(layerHandleBinder);
Peiyong Lin0e003c92018-09-17 11:09:51 -0700177 data.writeInt32(static_cast<int32_t>(reqDataspace));
178 data.writeInt32(static_cast<int32_t>(reqPixelFormat));
chaviw7206d492017-11-10 16:16:12 -0800179 data.write(sourceCrop);
Robert Carr866455f2019-04-02 16:28:26 -0700180 data.writeInt32(excludeLayers.size());
181 for (auto el : excludeLayers) {
182 data.writeStrongBinder(el);
183 }
chaviw7206d492017-11-10 16:16:12 -0800184 data.writeFloat(frameScale);
Robert Carr578038f2018-03-09 12:25:24 -0800185 data.writeBool(childrenOnly);
Ana Krulec2d41e422018-07-26 12:07:43 -0700186 status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_LAYERS, data, &reply);
187 if (result != NO_ERROR) {
188 ALOGE("captureLayers failed to transact: %d", result);
189 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000190 }
Ana Krulec2d41e422018-07-26 12:07:43 -0700191 result = reply.readInt32();
192 if (result != NO_ERROR) {
193 ALOGE("captureLayers failed to readInt32: %d", result);
194 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000195 }
Peiyong Lin0e003c92018-09-17 11:09:51 -0700196
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000197 *outBuffer = new GraphicBuffer();
198 reply.read(**outBuffer);
199
Ana Krulec2d41e422018-07-26 12:07:43 -0700200 return result;
chaviwa76b2712017-09-20 12:02:26 -0700201 }
202
Jamie Gennis582270d2011-08-17 18:19:00 -0700203 virtual bool authenticateSurfaceTexture(
Andy McFadden2adaf042012-12-18 09:49:45 -0800204 const sp<IGraphicBufferProducer>& bufferProducer) const
Jamie Gennis134f0422011-03-08 12:18:54 -0800205 {
206 Parcel data, reply;
207 int err = NO_ERROR;
208 err = data.writeInterfaceToken(
209 ISurfaceComposer::getInterfaceDescriptor());
210 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000211 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis134f0422011-03-08 12:18:54 -0800212 "interface descriptor: %s (%d)", strerror(-err), -err);
213 return false;
214 }
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800215 err = data.writeStrongBinder(IInterface::asBinder(bufferProducer));
Jamie Gennis134f0422011-03-08 12:18:54 -0800216 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000217 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis582270d2011-08-17 18:19:00 -0700218 "strong binder to parcel: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800219 return false;
220 }
221 err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
222 &reply);
223 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000224 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700225 "performing transaction: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800226 return false;
227 }
228 int32_t result = 0;
229 err = reply.readInt32(&result);
230 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000231 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700232 "retrieving result: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800233 return false;
234 }
235 return result != 0;
236 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800237
Brian Anderson6b376712017-04-04 10:51:39 -0700238 virtual status_t getSupportedFrameTimestamps(
239 std::vector<FrameEvent>* outSupported) const {
240 if (!outSupported) {
241 return UNEXPECTED_NULL;
242 }
243 outSupported->clear();
244
245 Parcel data, reply;
246
247 status_t err = data.writeInterfaceToken(
248 ISurfaceComposer::getInterfaceDescriptor());
249 if (err != NO_ERROR) {
250 return err;
251 }
252
253 err = remote()->transact(
254 BnSurfaceComposer::GET_SUPPORTED_FRAME_TIMESTAMPS,
255 data, &reply);
256 if (err != NO_ERROR) {
257 return err;
258 }
259
260 int32_t result = 0;
261 err = reply.readInt32(&result);
262 if (err != NO_ERROR) {
263 return err;
264 }
265 if (result != NO_ERROR) {
266 return result;
267 }
268
269 std::vector<int32_t> supported;
270 err = reply.readInt32Vector(&supported);
271 if (err != NO_ERROR) {
272 return err;
273 }
274
275 outSupported->reserve(supported.size());
276 for (int32_t s : supported) {
277 outSupported->push_back(static_cast<FrameEvent>(s));
278 }
279 return NO_ERROR;
280 }
281
Ady Abraham0f4a1b12019-06-04 16:04:04 -0700282 virtual sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource,
283 ConfigChanged configChanged) {
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800284 Parcel data, reply;
285 sp<IDisplayEventConnection> result;
286 int err = data.writeInterfaceToken(
287 ISurfaceComposer::getInterfaceDescriptor());
288 if (err != NO_ERROR) {
289 return result;
290 }
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700291 data.writeInt32(static_cast<int32_t>(vsyncSource));
Ady Abraham0f4a1b12019-06-04 16:04:04 -0700292 data.writeInt32(static_cast<int32_t>(configChanged));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800293 err = remote()->transact(
294 BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION,
295 data, &reply);
296 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000297 ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing "
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800298 "transaction: %s (%d)", strerror(-err), -err);
299 return result;
300 }
301 result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder());
302 return result;
303 }
Colin Cross8e533062012-06-07 13:17:52 -0700304
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700305 virtual sp<IBinder> createDisplay(const String8& displayName, bool secure)
Mathias Agopiane57f2922012-08-09 16:29:12 -0700306 {
307 Parcel data, reply;
308 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700309 data.writeString8(displayName);
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700310 data.writeInt32(secure ? 1 : 0);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700311 remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply);
312 return reply.readStrongBinder();
313 }
314
Jesse Hall6c913be2013-08-08 12:15:49 -0700315 virtual void destroyDisplay(const sp<IBinder>& display)
316 {
317 Parcel data, reply;
318 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
319 data.writeStrongBinder(display);
320 remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply);
321 }
322
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800323 virtual std::vector<PhysicalDisplayId> getPhysicalDisplayIds() const {
Mathias Agopiane57f2922012-08-09 16:29:12 -0700324 Parcel data, reply;
325 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800326 if (remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_IDS, data, &reply) ==
327 NO_ERROR) {
328 std::vector<PhysicalDisplayId> displayIds;
329 if (reply.readUint64Vector(&displayIds) == NO_ERROR) {
330 return displayIds;
331 }
332 }
333
334 return {};
335 }
336
337 virtual sp<IBinder> getPhysicalDisplayToken(PhysicalDisplayId displayId) const {
338 Parcel data, reply;
339 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
340 data.writeUint64(displayId);
341 remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_TOKEN, data, &reply);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700342 return reply.readStrongBinder();
343 }
344
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700345 virtual void setPowerMode(const sp<IBinder>& display, int mode)
Colin Cross8e533062012-06-07 13:17:52 -0700346 {
347 Parcel data, reply;
348 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700349 data.writeStrongBinder(display);
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700350 data.writeInt32(mode);
351 remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply);
Colin Cross8e533062012-06-07 13:17:52 -0700352 }
Mathias Agopian3094df32012-06-18 18:06:45 -0700353
Dan Stoza7f7da322014-05-02 15:26:25 -0700354 virtual status_t getDisplayConfigs(const sp<IBinder>& display,
355 Vector<DisplayInfo>* configs)
Mathias Agopianc666cae2012-07-25 18:56:13 -0700356 {
357 Parcel data, reply;
358 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700359 data.writeStrongBinder(display);
Dan Stoza7f7da322014-05-02 15:26:25 -0700360 remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply);
361 status_t result = reply.readInt32();
362 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -0800363 size_t numConfigs = reply.readUint32();
Dan Stoza7f7da322014-05-02 15:26:25 -0700364 configs->clear();
365 configs->resize(numConfigs);
366 for (size_t c = 0; c < numConfigs; ++c) {
367 memcpy(&(configs->editItemAt(c)),
368 reply.readInplace(sizeof(DisplayInfo)),
369 sizeof(DisplayInfo));
370 }
371 }
372 return result;
373 }
374
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700375 virtual status_t getDisplayStats(const sp<IBinder>& display,
376 DisplayStatInfo* stats)
377 {
378 Parcel data, reply;
379 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
380 data.writeStrongBinder(display);
381 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply);
382 status_t result = reply.readInt32();
383 if (result == NO_ERROR) {
384 memcpy(stats,
385 reply.readInplace(sizeof(DisplayStatInfo)),
386 sizeof(DisplayStatInfo));
387 }
388 return result;
389 }
390
Dan Stoza7f7da322014-05-02 15:26:25 -0700391 virtual int getActiveConfig(const sp<IBinder>& display)
392 {
393 Parcel data, reply;
394 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
395 data.writeStrongBinder(display);
396 remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply);
397 return reply.readInt32();
398 }
399
400 virtual status_t setActiveConfig(const sp<IBinder>& display, int id)
401 {
402 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700403 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
404 if (result != NO_ERROR) {
405 ALOGE("setActiveConfig failed to writeInterfaceToken: %d", result);
406 return result;
407 }
408 result = data.writeStrongBinder(display);
409 if (result != NO_ERROR) {
410 ALOGE("setActiveConfig failed to writeStrongBinder: %d", result);
411 return result;
412 }
413 result = data.writeInt32(id);
414 if (result != NO_ERROR) {
415 ALOGE("setActiveConfig failed to writeInt32: %d", result);
416 return result;
417 }
418 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply);
419 if (result != NO_ERROR) {
420 ALOGE("setActiveConfig failed to transact: %d", result);
421 return result;
422 }
Mathias Agopianc666cae2012-07-25 18:56:13 -0700423 return reply.readInt32();
424 }
Svetoslavd85084b2014-03-20 10:28:31 -0700425
Michael Wright28f24d02016-07-12 13:30:53 -0700426 virtual status_t getDisplayColorModes(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700427 Vector<ColorMode>* outColorModes) {
Michael Wright28f24d02016-07-12 13:30:53 -0700428 Parcel data, reply;
429 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
430 if (result != NO_ERROR) {
431 ALOGE("getDisplayColorModes failed to writeInterfaceToken: %d", result);
432 return result;
433 }
434 result = data.writeStrongBinder(display);
435 if (result != NO_ERROR) {
436 ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result);
437 return result;
438 }
439 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply);
440 if (result != NO_ERROR) {
441 ALOGE("getDisplayColorModes failed to transact: %d", result);
442 return result;
443 }
444 result = static_cast<status_t>(reply.readInt32());
445 if (result == NO_ERROR) {
446 size_t numModes = reply.readUint32();
447 outColorModes->clear();
448 outColorModes->resize(numModes);
449 for (size_t i = 0; i < numModes; ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -0700450 outColorModes->replaceAt(static_cast<ColorMode>(reply.readInt32()), i);
Michael Wright28f24d02016-07-12 13:30:53 -0700451 }
452 }
453 return result;
454 }
455
Daniel Solomon42d04562019-01-20 21:03:19 -0800456 virtual status_t getDisplayNativePrimaries(const sp<IBinder>& display,
457 ui::DisplayPrimaries& primaries) {
458 Parcel data, reply;
459 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
460 if (result != NO_ERROR) {
461 ALOGE("getDisplayNativePrimaries failed to writeInterfaceToken: %d", result);
462 return result;
463 }
464 result = data.writeStrongBinder(display);
465 if (result != NO_ERROR) {
466 ALOGE("getDisplayNativePrimaries failed to writeStrongBinder: %d", result);
467 return result;
468 }
469 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_NATIVE_PRIMARIES, data, &reply);
470 if (result != NO_ERROR) {
471 ALOGE("getDisplayNativePrimaries failed to transact: %d", result);
472 return result;
473 }
474 result = reply.readInt32();
475 if (result == NO_ERROR) {
476 memcpy(&primaries, reply.readInplace(sizeof(ui::DisplayPrimaries)),
477 sizeof(ui::DisplayPrimaries));
478 }
479 return result;
480 }
481
Peiyong Lina52f0292018-03-14 17:26:31 -0700482 virtual ColorMode getActiveColorMode(const sp<IBinder>& display) {
Michael Wright28f24d02016-07-12 13:30:53 -0700483 Parcel data, reply;
484 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
485 if (result != NO_ERROR) {
486 ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700487 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700488 }
489 result = data.writeStrongBinder(display);
490 if (result != NO_ERROR) {
491 ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700492 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700493 }
494 result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply);
495 if (result != NO_ERROR) {
496 ALOGE("getActiveColorMode failed to transact: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700497 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700498 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700499 return static_cast<ColorMode>(reply.readInt32());
Michael Wright28f24d02016-07-12 13:30:53 -0700500 }
501
502 virtual status_t setActiveColorMode(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700503 ColorMode colorMode) {
Michael Wright28f24d02016-07-12 13:30:53 -0700504 Parcel data, reply;
505 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
506 if (result != NO_ERROR) {
507 ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result);
508 return result;
509 }
510 result = data.writeStrongBinder(display);
511 if (result != NO_ERROR) {
512 ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result);
513 return result;
514 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700515 result = data.writeInt32(static_cast<int32_t>(colorMode));
Michael Wright28f24d02016-07-12 13:30:53 -0700516 if (result != NO_ERROR) {
517 ALOGE("setActiveColorMode failed to writeInt32: %d", result);
518 return result;
519 }
520 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply);
521 if (result != NO_ERROR) {
522 ALOGE("setActiveColorMode failed to transact: %d", result);
523 return result;
524 }
525 return static_cast<status_t>(reply.readInt32());
526 }
527
Galia Peycheva5492cb52019-10-30 14:13:16 +0100528 virtual status_t getAutoLowLatencyModeSupport(const sp<IBinder>& display,
529 bool* outSupport) const {
530 Parcel data, reply;
531 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
532 status_t result = data.writeStrongBinder(display);
533 if (result != NO_ERROR) {
534 ALOGE("getAutoLowLatencyModeSupport failed to writeStrongBinder: %d", result);
535 return result;
536 }
537 result = remote()->transact(BnSurfaceComposer::GET_AUTO_LOW_LATENCY_MODE_SUPPORT, data,
538 &reply);
539 if (result != NO_ERROR) {
540 ALOGE("getAutoLowLatencyModeSupport failed to transact: %d", result);
541 return result;
542 }
543 return reply.readBool(outSupport);
544 }
545
546 virtual void setAutoLowLatencyMode(const sp<IBinder>& display, bool on) {
547 Parcel data, reply;
548 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
549 if (result != NO_ERROR) {
550 ALOGE("setAutoLowLatencyMode failed to writeInterfaceToken: %d", result);
551 return;
552 }
553
554 result = data.writeStrongBinder(display);
555 if (result != NO_ERROR) {
556 ALOGE("setAutoLowLatencyMode failed to writeStrongBinder: %d", result);
557 return;
558 }
559 result = data.writeBool(on);
560 if (result != NO_ERROR) {
561 ALOGE("setAutoLowLatencyMode failed to writeBool: %d", result);
562 return;
563 }
564 result = remote()->transact(BnSurfaceComposer::SET_AUTO_LOW_LATENCY_MODE, data, &reply);
565 if (result != NO_ERROR) {
566 ALOGE("setAutoLowLatencyMode failed to transact: %d", result);
567 return;
568 }
569 }
570
571 virtual status_t getGameContentTypeSupport(const sp<IBinder>& display, bool* outSupport) const {
572 Parcel data, reply;
573 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
574 status_t result = data.writeStrongBinder(display);
575 if (result != NO_ERROR) {
576 ALOGE("getGameContentTypeSupport failed to writeStrongBinder: %d", result);
577 return result;
578 }
579 result = remote()->transact(BnSurfaceComposer::GET_GAME_CONTENT_TYPE_SUPPORT, data, &reply);
580 if (result != NO_ERROR) {
581 ALOGE("getGameContentTypeSupport failed to transact: %d", result);
582 return result;
583 }
584 return reply.readBool(outSupport);
585 }
586
587 virtual void setGameContentType(const sp<IBinder>& display, bool on) {
588 Parcel data, reply;
589 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
590 if (result != NO_ERROR) {
591 ALOGE("setGameContentType failed to writeInterfaceToken: %d", result);
592 return;
593 }
594 result = data.writeStrongBinder(display);
595 if (result != NO_ERROR) {
596 ALOGE("setGameContentType failed to writeStrongBinder: %d", result);
597 return;
598 }
599 result = data.writeBool(on);
600 if (result != NO_ERROR) {
601 ALOGE("setGameContentType failed to writeBool: %d", result);
602 return;
603 }
604 result = remote()->transact(BnSurfaceComposer::SET_GAME_CONTENT_TYPE, data, &reply);
605 if (result != NO_ERROR) {
606 ALOGE("setGameContentType failed to transact: %d", result);
607 }
608 }
609
Svetoslavd85084b2014-03-20 10:28:31 -0700610 virtual status_t clearAnimationFrameStats() {
611 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700612 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
613 if (result != NO_ERROR) {
614 ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result);
615 return result;
616 }
617 result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply);
618 if (result != NO_ERROR) {
619 ALOGE("clearAnimationFrameStats failed to transact: %d", result);
620 return result;
621 }
Svetoslavd85084b2014-03-20 10:28:31 -0700622 return reply.readInt32();
623 }
624
625 virtual status_t getAnimationFrameStats(FrameStats* outStats) const {
626 Parcel data, reply;
627 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
628 remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply);
629 reply.read(*outStats);
630 return reply.readInt32();
631 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700632
633 virtual status_t getHdrCapabilities(const sp<IBinder>& display,
634 HdrCapabilities* outCapabilities) const {
635 Parcel data, reply;
636 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
637 status_t result = data.writeStrongBinder(display);
638 if (result != NO_ERROR) {
639 ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result);
640 return result;
641 }
642 result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES,
643 data, &reply);
644 if (result != NO_ERROR) {
645 ALOGE("getHdrCapabilities failed to transact: %d", result);
646 return result;
647 }
648 result = reply.readInt32();
649 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800650 result = reply.read(*outCapabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700651 }
652 return result;
653 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700654
655 virtual status_t enableVSyncInjections(bool enable) {
656 Parcel data, reply;
657 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
658 if (result != NO_ERROR) {
659 ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result);
660 return result;
661 }
662 result = data.writeBool(enable);
663 if (result != NO_ERROR) {
664 ALOGE("enableVSyncInjections failed to writeBool: %d", result);
665 return result;
666 }
Steven Moreland366eb422019-04-01 19:22:32 -0700667 result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS, data, &reply,
668 IBinder::FLAG_ONEWAY);
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700669 if (result != NO_ERROR) {
670 ALOGE("enableVSyncInjections failed to transact: %d", result);
671 return result;
672 }
673 return result;
674 }
675
676 virtual status_t injectVSync(nsecs_t when) {
677 Parcel data, reply;
678 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
679 if (result != NO_ERROR) {
680 ALOGE("injectVSync failed to writeInterfaceToken: %d", result);
681 return result;
682 }
683 result = data.writeInt64(when);
684 if (result != NO_ERROR) {
685 ALOGE("injectVSync failed to writeInt64: %d", result);
686 return result;
687 }
Steven Moreland366eb422019-04-01 19:22:32 -0700688 result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply,
689 IBinder::FLAG_ONEWAY);
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700690 if (result != NO_ERROR) {
691 ALOGE("injectVSync failed to transact: %d", result);
692 return result;
693 }
694 return result;
695 }
696
Kalle Raitaa099a242017-01-11 11:17:29 -0800697 virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const
698 {
699 if (!outLayers) {
700 return UNEXPECTED_NULL;
701 }
702
703 Parcel data, reply;
704
705 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
706 if (err != NO_ERROR) {
707 return err;
708 }
709
710 err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply);
711 if (err != NO_ERROR) {
712 return err;
713 }
714
715 int32_t result = 0;
716 err = reply.readInt32(&result);
717 if (err != NO_ERROR) {
718 return err;
719 }
720 if (result != NO_ERROR) {
721 return result;
722 }
723
724 outLayers->clear();
725 return reply.readParcelableVector(outLayers);
726 }
Peiyong Lin0256f722018-08-31 15:45:10 -0700727
Peiyong Linc6780972018-10-28 15:24:08 -0700728 virtual status_t getCompositionPreference(ui::Dataspace* defaultDataspace,
729 ui::PixelFormat* defaultPixelFormat,
730 ui::Dataspace* wideColorGamutDataspace,
731 ui::PixelFormat* wideColorGamutPixelFormat) const {
Peiyong Lin0256f722018-08-31 15:45:10 -0700732 Parcel data, reply;
733 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
734 if (error != NO_ERROR) {
735 return error;
736 }
737 error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply);
738 if (error != NO_ERROR) {
739 return error;
740 }
741 error = static_cast<status_t>(reply.readInt32());
742 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -0700743 *defaultDataspace = static_cast<ui::Dataspace>(reply.readInt32());
744 *defaultPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
745 *wideColorGamutDataspace = static_cast<ui::Dataspace>(reply.readInt32());
746 *wideColorGamutPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
Peiyong Lin0256f722018-08-31 15:45:10 -0700747 }
748 return error;
749 }
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700750
Ady Abraham37965d42018-11-01 13:43:32 -0700751 virtual status_t getColorManagement(bool* outGetColorManagement) const {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700752 Parcel data, reply;
753 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Ady Abraham37965d42018-11-01 13:43:32 -0700754 remote()->transact(BnSurfaceComposer::GET_COLOR_MANAGEMENT, data, &reply);
755 bool result;
756 status_t err = reply.readBool(&result);
757 if (err == NO_ERROR) {
758 *outGetColorManagement = result;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700759 }
Ady Abraham37965d42018-11-01 13:43:32 -0700760 return err;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700761 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -0700762
763 virtual status_t getDisplayedContentSamplingAttributes(const sp<IBinder>& display,
764 ui::PixelFormat* outFormat,
765 ui::Dataspace* outDataspace,
766 uint8_t* outComponentMask) const {
767 if (!outFormat || !outDataspace || !outComponentMask) return BAD_VALUE;
768 Parcel data, reply;
769 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
770 data.writeStrongBinder(display);
771
772 status_t error =
773 remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES,
774 data, &reply);
775 if (error != NO_ERROR) {
776 return error;
777 }
778
779 uint32_t value = 0;
780 error = reply.readUint32(&value);
781 if (error != NO_ERROR) {
782 return error;
783 }
784 *outFormat = static_cast<ui::PixelFormat>(value);
785
786 error = reply.readUint32(&value);
787 if (error != NO_ERROR) {
788 return error;
789 }
790 *outDataspace = static_cast<ui::Dataspace>(value);
791
792 error = reply.readUint32(&value);
793 if (error != NO_ERROR) {
794 return error;
795 }
796 *outComponentMask = static_cast<uint8_t>(value);
797 return error;
798 }
Kevin DuBois74e53772018-11-19 10:52:38 -0800799
800 virtual status_t setDisplayContentSamplingEnabled(const sp<IBinder>& display, bool enable,
801 uint8_t componentMask,
802 uint64_t maxFrames) const {
803 Parcel data, reply;
804 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
805 data.writeStrongBinder(display);
806 data.writeBool(enable);
807 data.writeByte(static_cast<int8_t>(componentMask));
808 data.writeUint64(maxFrames);
809 status_t result =
810 remote()->transact(BnSurfaceComposer::SET_DISPLAY_CONTENT_SAMPLING_ENABLED, data,
811 &reply);
812 return result;
813 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700814
815 virtual status_t getDisplayedContentSample(const sp<IBinder>& display, uint64_t maxFrames,
816 uint64_t timestamp,
817 DisplayedFrameStats* outStats) const {
818 if (!outStats) return BAD_VALUE;
819
820 Parcel data, reply;
821 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
822 data.writeStrongBinder(display);
823 data.writeUint64(maxFrames);
824 data.writeUint64(timestamp);
825
826 status_t result =
827 remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLE, data, &reply);
828
829 if (result != NO_ERROR) {
830 return result;
831 }
832
833 result = reply.readUint64(&outStats->numFrames);
834 if (result != NO_ERROR) {
835 return result;
836 }
837
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800838 result = reply.readUint64Vector(&outStats->component_0_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700839 if (result != NO_ERROR) {
840 return result;
841 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800842 result = reply.readUint64Vector(&outStats->component_1_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700843 if (result != NO_ERROR) {
844 return result;
845 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800846 result = reply.readUint64Vector(&outStats->component_2_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700847 if (result != NO_ERROR) {
848 return result;
849 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800850 result = reply.readUint64Vector(&outStats->component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700851 return result;
852 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800853
854 virtual status_t getProtectedContentSupport(bool* outSupported) const {
855 Parcel data, reply;
856 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Peiyong Linb6888fa2019-01-28 13:20:58 -0800857 status_t error =
858 remote()->transact(BnSurfaceComposer::GET_PROTECTED_CONTENT_SUPPORT, data, &reply);
859 if (error != NO_ERROR) {
860 return error;
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800861 }
Peiyong Linb6888fa2019-01-28 13:20:58 -0800862 error = reply.readBool(outSupported);
863 return error;
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800864 }
Marissa Wallebc2c052019-01-16 19:16:55 -0800865
Peiyong Lin4f3fddf2019-01-24 17:21:24 -0800866 virtual status_t isWideColorDisplay(const sp<IBinder>& token,
867 bool* outIsWideColorDisplay) const {
868 Parcel data, reply;
869 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
870 if (error != NO_ERROR) {
871 return error;
872 }
873 error = data.writeStrongBinder(token);
874 if (error != NO_ERROR) {
875 return error;
876 }
877
878 error = remote()->transact(BnSurfaceComposer::IS_WIDE_COLOR_DISPLAY, data, &reply);
879 if (error != NO_ERROR) {
880 return error;
881 }
882 error = reply.readBool(outIsWideColorDisplay);
883 return error;
884 }
Dan Stoza84ab9372018-12-17 15:27:57 -0800885
886 virtual status_t addRegionSamplingListener(const Rect& samplingArea,
887 const sp<IBinder>& stopLayerHandle,
888 const sp<IRegionSamplingListener>& listener) {
889 Parcel data, reply;
890 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
891 if (error != NO_ERROR) {
892 ALOGE("addRegionSamplingListener: Failed to write interface token");
893 return error;
894 }
895 error = data.write(samplingArea);
896 if (error != NO_ERROR) {
897 ALOGE("addRegionSamplingListener: Failed to write sampling area");
898 return error;
899 }
900 error = data.writeStrongBinder(stopLayerHandle);
901 if (error != NO_ERROR) {
902 ALOGE("addRegionSamplingListener: Failed to write stop layer handle");
903 return error;
904 }
905 error = data.writeStrongBinder(IInterface::asBinder(listener));
906 if (error != NO_ERROR) {
907 ALOGE("addRegionSamplingListener: Failed to write listener");
908 return error;
909 }
910 error = remote()->transact(BnSurfaceComposer::ADD_REGION_SAMPLING_LISTENER, data, &reply);
911 if (error != NO_ERROR) {
912 ALOGE("addRegionSamplingListener: Failed to transact");
913 }
914 return error;
915 }
916
917 virtual status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) {
918 Parcel data, reply;
919 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
920 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800921 ALOGE("removeRegionSamplingListener: Failed to write interface token");
Dan Stoza84ab9372018-12-17 15:27:57 -0800922 return error;
923 }
924 error = data.writeStrongBinder(IInterface::asBinder(listener));
925 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800926 ALOGE("removeRegionSamplingListener: Failed to write listener");
Dan Stoza84ab9372018-12-17 15:27:57 -0800927 return error;
928 }
929 error = remote()->transact(BnSurfaceComposer::REMOVE_REGION_SAMPLING_LISTENER, data,
930 &reply);
931 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800932 ALOGE("removeRegionSamplingListener: Failed to transact");
Dan Stoza84ab9372018-12-17 15:27:57 -0800933 }
934 return error;
935 }
Ady Abraham838de062019-02-04 10:24:03 -0800936
Ana Krulec0782b882019-10-15 17:34:54 -0700937 virtual status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100938 int32_t defaultConfig, float minRefreshRate,
Ana Krulec0782b882019-10-15 17:34:54 -0700939 float maxRefreshRate) {
940 Parcel data, reply;
941 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
942 if (result != NO_ERROR) {
943 ALOGE("setDesiredDisplayConfigSpecs: failed to writeInterfaceToken: %d", result);
944 return result;
945 }
946 result = data.writeStrongBinder(displayToken);
947 if (result != NO_ERROR) {
948 ALOGE("setDesiredDisplayConfigSpecs: failed to write display token: %d", result);
949 return result;
950 }
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100951 result = data.writeInt32(defaultConfig);
Ana Krulec0782b882019-10-15 17:34:54 -0700952 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100953 ALOGE("setDesiredDisplayConfigSpecs failed to write defaultConfig: %d", result);
Ana Krulec0782b882019-10-15 17:34:54 -0700954 return result;
955 }
956 result = data.writeFloat(minRefreshRate);
957 if (result != NO_ERROR) {
958 ALOGE("setDesiredDisplayConfigSpecs failed to write minRefreshRate: %d", result);
959 return result;
960 }
961 result = data.writeFloat(maxRefreshRate);
962 if (result != NO_ERROR) {
963 ALOGE("setDesiredDisplayConfigSpecs failed to write maxRefreshRate: %d", result);
964 return result;
965 }
966
967 result = remote()->transact(BnSurfaceComposer::SET_DESIRED_DISPLAY_CONFIG_SPECS, data,
968 &reply);
969 if (result != NO_ERROR) {
970 ALOGE("setDesiredDisplayConfigSpecs failed to transact: %d", result);
971 return result;
972 }
973 return reply.readInt32();
974 }
975
Ana Krulec234bb162019-11-10 22:55:55 +0100976 virtual status_t getDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100977 int32_t* outDefaultConfig,
Ana Krulec234bb162019-11-10 22:55:55 +0100978 float* outMinRefreshRate,
979 float* outMaxRefreshRate) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100980 if (!outDefaultConfig || !outMinRefreshRate || !outMaxRefreshRate) return BAD_VALUE;
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800981 Parcel data, reply;
982 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
983 if (result != NO_ERROR) {
Ana Krulec234bb162019-11-10 22:55:55 +0100984 ALOGE("getDesiredDisplayConfigSpecs failed to writeInterfaceToken: %d", result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800985 return result;
986 }
987 result = data.writeStrongBinder(displayToken);
988 if (result != NO_ERROR) {
Ana Krulec234bb162019-11-10 22:55:55 +0100989 ALOGE("getDesiredDisplayConfigSpecs failed to writeStrongBinder: %d", result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800990 return result;
991 }
Ana Krulec234bb162019-11-10 22:55:55 +0100992 result = remote()->transact(BnSurfaceComposer::GET_DESIRED_DISPLAY_CONFIG_SPECS, data,
993 &reply);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800994 if (result != NO_ERROR) {
Ana Krulec234bb162019-11-10 22:55:55 +0100995 ALOGE("getDesiredDisplayConfigSpecs failed to transact: %d", result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800996 return result;
997 }
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100998 result = reply.readInt32(outDefaultConfig);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800999 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001000 ALOGE("getDesiredDisplayConfigSpecs failed to read defaultConfig: %d", result);
Ana Krulec234bb162019-11-10 22:55:55 +01001001 return result;
1002 }
1003 result = reply.readFloat(outMinRefreshRate);
1004 if (result != NO_ERROR) {
1005 ALOGE("getDesiredDisplayConfigSpecs failed to read minRefreshRate: %d", result);
1006 return result;
1007 }
1008 result = reply.readFloat(outMaxRefreshRate);
1009 if (result != NO_ERROR) {
1010 ALOGE("getDesiredDisplayConfigSpecs failed to read maxRefreshRate: %d", result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -08001011 return result;
1012 }
1013 return reply.readInt32();
1014 }
Dan Gittik57e63c52019-01-18 16:37:54 +00001015
1016 virtual status_t getDisplayBrightnessSupport(const sp<IBinder>& displayToken,
1017 bool* outSupport) const {
1018 Parcel data, reply;
1019 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1020 if (error != NO_ERROR) {
1021 ALOGE("getDisplayBrightnessSupport: failed to write interface token: %d", error);
1022 return error;
1023 }
1024 error = data.writeStrongBinder(displayToken);
1025 if (error != NO_ERROR) {
1026 ALOGE("getDisplayBrightnessSupport: failed to write display token: %d", error);
1027 return error;
1028 }
1029 error = remote()->transact(BnSurfaceComposer::GET_DISPLAY_BRIGHTNESS_SUPPORT, data, &reply);
1030 if (error != NO_ERROR) {
1031 ALOGE("getDisplayBrightnessSupport: failed to transact: %d", error);
1032 return error;
1033 }
1034 bool support;
1035 error = reply.readBool(&support);
1036 if (error != NO_ERROR) {
1037 ALOGE("getDisplayBrightnessSupport: failed to read support: %d", error);
1038 return error;
1039 }
1040 *outSupport = support;
1041 return NO_ERROR;
1042 }
1043
1044 virtual status_t setDisplayBrightness(const sp<IBinder>& displayToken, float brightness) const {
1045 Parcel data, reply;
1046 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1047 if (error != NO_ERROR) {
1048 ALOGE("setDisplayBrightness: failed to write interface token: %d", error);
1049 return error;
1050 }
1051 error = data.writeStrongBinder(displayToken);
1052 if (error != NO_ERROR) {
1053 ALOGE("setDisplayBrightness: failed to write display token: %d", error);
1054 return error;
1055 }
1056 error = data.writeFloat(brightness);
1057 if (error != NO_ERROR) {
1058 ALOGE("setDisplayBrightness: failed to write brightness: %d", error);
1059 return error;
1060 }
1061 error = remote()->transact(BnSurfaceComposer::SET_DISPLAY_BRIGHTNESS, data, &reply);
1062 if (error != NO_ERROR) {
1063 ALOGE("setDisplayBrightness: failed to transact: %d", error);
1064 return error;
1065 }
1066 return NO_ERROR;
1067 }
Ady Abraham8532d012019-05-08 14:50:56 -07001068
1069 virtual status_t notifyPowerHint(int32_t hintId) {
1070 Parcel data, reply;
1071 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1072 if (error != NO_ERROR) {
1073 ALOGE("notifyPowerHint: failed to write interface token: %d", error);
1074 return error;
1075 }
1076 error = data.writeInt32(hintId);
1077 if (error != NO_ERROR) {
1078 ALOGE("notifyPowerHint: failed to write hintId: %d", error);
1079 return error;
1080 }
1081 error = remote()->transact(BnSurfaceComposer::NOTIFY_POWER_HINT, data, &reply,
1082 IBinder::FLAG_ONEWAY);
1083 if (error != NO_ERROR) {
1084 ALOGE("notifyPowerHint: failed to transact: %d", error);
1085 return error;
1086 }
1087 return NO_ERROR;
1088 }
Vishnu Nairb13bb952019-11-15 10:24:08 -08001089
1090 virtual status_t setGlobalShadowSettings(const half4& ambientColor, const half4& spotColor,
1091 float lightPosY, float lightPosZ, float lightRadius) {
1092 Parcel data, reply;
1093 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1094 if (error != NO_ERROR) {
1095 ALOGE("setGlobalShadowSettings: failed to write interface token: %d", error);
1096 return error;
1097 }
1098
1099 std::vector<float> shadowConfig = {ambientColor.r, ambientColor.g, ambientColor.b,
1100 ambientColor.a, spotColor.r, spotColor.g,
1101 spotColor.b, spotColor.a, lightPosY,
1102 lightPosZ, lightRadius};
1103
1104 error = data.writeFloatVector(shadowConfig);
1105 if (error != NO_ERROR) {
1106 ALOGE("setGlobalShadowSettings: failed to write shadowConfig: %d", error);
1107 return error;
1108 }
1109
1110 error = remote()->transact(BnSurfaceComposer::SET_GLOBAL_SHADOW_SETTINGS, data, &reply,
1111 IBinder::FLAG_ONEWAY);
1112 if (error != NO_ERROR) {
1113 ALOGE("setGlobalShadowSettings: failed to transact: %d", error);
1114 return error;
1115 }
1116 return NO_ERROR;
1117 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001118};
1119
Dan Stozad723bd72014-11-18 10:24:03 -08001120// Out-of-line virtual method definition to trigger vtable emission in this
1121// translation unit (see clang warning -Wweak-vtables)
1122BpSurfaceComposer::~BpSurfaceComposer() {}
1123
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001124IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
1125
1126// ----------------------------------------------------------------------
1127
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001128status_t BnSurfaceComposer::onTransact(
1129 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
1130{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001131 switch(code) {
1132 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001133 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -08001134 sp<IBinder> b = IInterface::asBinder(createConnection());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001135 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -07001136 return NO_ERROR;
1137 }
Mathias Agopian698c0872011-06-28 19:09:31 -07001138 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001139 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -08001140
1141 size_t count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -07001142 if (count > data.dataSize()) {
1143 return BAD_VALUE;
1144 }
Mathias Agopian698c0872011-06-28 19:09:31 -07001145 Vector<ComposerState> state;
1146 state.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -08001147 for (size_t i = 0; i < count; i++) {
Marissa Wallc837b5e2018-10-12 10:04:44 -07001148 ComposerState s;
Michael Lentine8afa1c42014-10-31 11:10:13 -07001149 if (s.read(data) == BAD_VALUE) {
1150 return BAD_VALUE;
1151 }
Mathias Agopian698c0872011-06-28 19:09:31 -07001152 state.add(s);
1153 }
Dan Stozad723bd72014-11-18 10:24:03 -08001154
1155 count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -07001156 if (count > data.dataSize()) {
1157 return BAD_VALUE;
1158 }
Mathias Agopian8b33f032012-07-24 20:43:54 -07001159 DisplayState d;
1160 Vector<DisplayState> displays;
1161 displays.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -08001162 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -07001163 if (d.read(data) == BAD_VALUE) {
1164 return BAD_VALUE;
1165 }
Mathias Agopian8b33f032012-07-24 20:43:54 -07001166 displays.add(d);
1167 }
Dan Stozad723bd72014-11-18 10:24:03 -08001168
1169 uint32_t stateFlags = data.readUint32();
Marissa Wall713b63f2018-10-17 15:42:43 -07001170 sp<IBinder> applyToken = data.readStrongBinder();
chaviw273171b2018-12-26 11:46:30 -08001171 InputWindowCommands inputWindowCommands;
1172 inputWindowCommands.read(data);
Marissa Wall17b4e452018-12-26 16:32:34 -08001173
1174 int64_t desiredPresentTime = data.readInt64();
Marissa Wall78b72202019-03-15 14:58:34 -07001175
Marissa Wall947d34e2019-03-29 14:03:53 -07001176 client_cache_t uncachedBuffer;
Steven Moreland9d4ce9b2019-07-17 15:23:38 -07001177 uncachedBuffer.token = data.readStrongBinder();
Marissa Wall947d34e2019-03-29 14:03:53 -07001178 uncachedBuffer.id = data.readUint64();
Marissa Wall78b72202019-03-15 14:58:34 -07001179
Valerie Hau9dab9732019-08-20 09:29:25 -07001180 bool hasListenerCallbacks = data.readBool();
1181
Marissa Wall3dad52d2019-03-22 14:03:19 -07001182 std::vector<ListenerCallbacks> listenerCallbacks;
1183 int32_t listenersSize = data.readInt32();
1184 for (int32_t i = 0; i < listenersSize; i++) {
Valerie Hau5de3ad22019-08-20 07:47:43 -07001185 auto listener = data.readStrongBinder();
Marissa Wall3dad52d2019-03-22 14:03:19 -07001186 std::vector<CallbackId> callbackIds;
1187 data.readInt64Vector(&callbackIds);
1188 listenerCallbacks.emplace_back(listener, callbackIds);
1189 }
Marissa Wall17b4e452018-12-26 16:32:34 -08001190 setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands,
Valerie Hau9dab9732019-08-20 09:29:25 -07001191 desiredPresentTime, uncachedBuffer, hasListenerCallbacks,
1192 listenerCallbacks);
Jesse Hall6c913be2013-08-08 12:15:49 -07001193 return NO_ERROR;
1194 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001195 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001196 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001197 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -07001198 return NO_ERROR;
1199 }
Mathias Agopian2a9fc492013-03-01 13:42:57 -08001200 case CAPTURE_SCREEN: {
1201 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1202 sp<IBinder> display = data.readStrongBinder();
Peiyong Lin0e003c92018-09-17 11:09:51 -07001203 ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32());
1204 ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32());
Chavi Weingarten40482ff2017-11-30 01:51:40 +00001205 sp<GraphicBuffer> outBuffer;
Pablo Ceballos60d69222015-08-07 14:47:20 -07001206 Rect sourceCrop(Rect::EMPTY_RECT);
Dan Stozac1879002014-05-22 15:59:05 -07001207 data.read(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -08001208 uint32_t reqWidth = data.readUint32();
1209 uint32_t reqHeight = data.readUint32();
Dan Stozac7014012014-02-14 15:03:43 -08001210 bool useIdentityTransform = static_cast<bool>(data.readInt32());
Dan Stozad723bd72014-11-18 10:24:03 -08001211 int32_t rotation = data.readInt32();
Robert Carrfa8855f2019-02-19 10:05:00 -08001212 bool captureSecureLayers = static_cast<bool>(data.readInt32());
Dan Stozac7014012014-02-14 15:03:43 -08001213
Robert Carr108b2c72019-04-02 16:32:58 -07001214 bool capturedSecureLayers = false;
1215 status_t res = captureScreen(display, &outBuffer, capturedSecureLayers, reqDataspace,
1216 reqPixelFormat, sourceCrop, reqWidth, reqHeight,
Dominik Laskowski718f9602019-11-09 20:01:35 -08001217 useIdentityTransform, ui::toRotation(rotation),
Robert Carr108b2c72019-04-02 16:32:58 -07001218 captureSecureLayers);
1219
Mathias Agopian2a9fc492013-03-01 13:42:57 -08001220 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +00001221 if (res == NO_ERROR) {
1222 reply->write(*outBuffer);
Robert Carr108b2c72019-04-02 16:32:58 -07001223 reply->writeBool(capturedSecureLayers);
Chavi Weingarten40482ff2017-11-30 01:51:40 +00001224 }
Jesse Hall6c913be2013-08-08 12:15:49 -07001225 return NO_ERROR;
1226 }
chaviw93df2ea2019-04-30 16:45:12 -07001227 case CAPTURE_SCREEN_BY_ID: {
1228 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1229 uint64_t displayOrLayerStack = data.readUint64();
1230 ui::Dataspace outDataspace = ui::Dataspace::V0_SRGB;
1231 sp<GraphicBuffer> outBuffer;
1232 status_t res = captureScreen(displayOrLayerStack, &outDataspace, &outBuffer);
1233 reply->writeInt32(res);
1234 if (res == NO_ERROR) {
1235 reply->writeInt32(static_cast<int32_t>(outDataspace));
1236 reply->write(*outBuffer);
1237 }
1238 return NO_ERROR;
1239 }
chaviwa76b2712017-09-20 12:02:26 -07001240 case CAPTURE_LAYERS: {
1241 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1242 sp<IBinder> layerHandleBinder = data.readStrongBinder();
Peiyong Lin0e003c92018-09-17 11:09:51 -07001243 ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32());
1244 ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32());
Chavi Weingarten40482ff2017-11-30 01:51:40 +00001245 sp<GraphicBuffer> outBuffer;
chaviw7206d492017-11-10 16:16:12 -08001246 Rect sourceCrop(Rect::EMPTY_RECT);
1247 data.read(sourceCrop);
Robert Carr866455f2019-04-02 16:28:26 -07001248
1249 std::unordered_set<sp<IBinder>, SpHash<IBinder>> excludeHandles;
1250 int numExcludeHandles = data.readInt32();
1251 excludeHandles.reserve(numExcludeHandles);
1252 for (int i = 0; i < numExcludeHandles; i++) {
1253 excludeHandles.emplace(data.readStrongBinder());
1254 }
1255
chaviw7206d492017-11-10 16:16:12 -08001256 float frameScale = data.readFloat();
Robert Carr578038f2018-03-09 12:25:24 -08001257 bool childrenOnly = data.readBool();
chaviwa76b2712017-09-20 12:02:26 -07001258
Robert Carr866455f2019-04-02 16:28:26 -07001259 status_t res =
1260 captureLayers(layerHandleBinder, &outBuffer, reqDataspace, reqPixelFormat,
1261 sourceCrop, excludeHandles, frameScale, childrenOnly);
chaviwa76b2712017-09-20 12:02:26 -07001262 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +00001263 if (res == NO_ERROR) {
1264 reply->write(*outBuffer);
1265 }
chaviwa76b2712017-09-20 12:02:26 -07001266 return NO_ERROR;
1267 }
Jamie Gennis134f0422011-03-08 12:18:54 -08001268 case AUTHENTICATE_SURFACE: {
1269 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -08001270 sp<IGraphicBufferProducer> bufferProducer =
1271 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
1272 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -08001273 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -07001274 return NO_ERROR;
1275 }
Brian Anderson6b376712017-04-04 10:51:39 -07001276 case GET_SUPPORTED_FRAME_TIMESTAMPS: {
1277 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1278 std::vector<FrameEvent> supportedTimestamps;
1279 status_t result = getSupportedFrameTimestamps(&supportedTimestamps);
1280 status_t err = reply->writeInt32(result);
1281 if (err != NO_ERROR) {
1282 return err;
1283 }
1284 if (result != NO_ERROR) {
1285 return result;
1286 }
1287
1288 std::vector<int32_t> supported;
1289 supported.reserve(supportedTimestamps.size());
1290 for (FrameEvent s : supportedTimestamps) {
1291 supported.push_back(static_cast<int32_t>(s));
1292 }
1293 return reply->writeInt32Vector(supported);
1294 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001295 case CREATE_DISPLAY_EVENT_CONNECTION: {
1296 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Ady Abraham0f4a1b12019-06-04 16:04:04 -07001297 auto vsyncSource = static_cast<ISurfaceComposer::VsyncSource>(data.readInt32());
1298 auto configChanged = static_cast<ISurfaceComposer::ConfigChanged>(data.readInt32());
1299
1300 sp<IDisplayEventConnection> connection(
1301 createDisplayEventConnection(vsyncSource, configChanged));
Marco Nelissen2ea926b2014-11-14 08:01:01 -08001302 reply->writeStrongBinder(IInterface::asBinder(connection));
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001303 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001304 }
Mathias Agopiane57f2922012-08-09 16:29:12 -07001305 case CREATE_DISPLAY: {
1306 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden8dfa92f2012-09-17 18:27:17 -07001307 String8 displayName = data.readString8();
Jamie Gennisdd3cb842012-10-19 18:19:11 -07001308 bool secure = bool(data.readInt32());
1309 sp<IBinder> display(createDisplay(displayName, secure));
Mathias Agopiane57f2922012-08-09 16:29:12 -07001310 reply->writeStrongBinder(display);
1311 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001312 }
1313 case DESTROY_DISPLAY: {
1314 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1315 sp<IBinder> display = data.readStrongBinder();
1316 destroyDisplay(display);
1317 return NO_ERROR;
1318 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001319 case GET_PHYSICAL_DISPLAY_TOKEN: {
Mathias Agopiane57f2922012-08-09 16:29:12 -07001320 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001321 PhysicalDisplayId displayId = data.readUint64();
1322 sp<IBinder> display = getPhysicalDisplayToken(displayId);
Mathias Agopiane57f2922012-08-09 16:29:12 -07001323 reply->writeStrongBinder(display);
1324 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001325 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001326 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -07001327 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stoza7f7da322014-05-02 15:26:25 -07001328 Vector<DisplayInfo> configs;
Jeff Brown9d4e3d22012-08-24 20:00:51 -07001329 sp<IBinder> display = data.readStrongBinder();
Dan Stoza7f7da322014-05-02 15:26:25 -07001330 status_t result = getDisplayConfigs(display, &configs);
1331 reply->writeInt32(result);
1332 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -08001333 reply->writeUint32(static_cast<uint32_t>(configs.size()));
Dan Stoza7f7da322014-05-02 15:26:25 -07001334 for (size_t c = 0; c < configs.size(); ++c) {
1335 memcpy(reply->writeInplace(sizeof(DisplayInfo)),
1336 &configs[c], sizeof(DisplayInfo));
1337 }
1338 }
1339 return NO_ERROR;
1340 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -07001341 case GET_DISPLAY_STATS: {
1342 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1343 DisplayStatInfo stats;
1344 sp<IBinder> display = data.readStrongBinder();
1345 status_t result = getDisplayStats(display, &stats);
1346 reply->writeInt32(result);
1347 if (result == NO_ERROR) {
1348 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
1349 &stats, sizeof(DisplayStatInfo));
1350 }
1351 return NO_ERROR;
1352 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001353 case GET_ACTIVE_CONFIG: {
1354 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1355 sp<IBinder> display = data.readStrongBinder();
1356 int id = getActiveConfig(display);
1357 reply->writeInt32(id);
1358 return NO_ERROR;
1359 }
1360 case SET_ACTIVE_CONFIG: {
1361 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1362 sp<IBinder> display = data.readStrongBinder();
1363 int id = data.readInt32();
1364 status_t result = setActiveConfig(display, id);
Mathias Agopianc666cae2012-07-25 18:56:13 -07001365 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -07001366 return NO_ERROR;
1367 }
Michael Wright28f24d02016-07-12 13:30:53 -07001368 case GET_DISPLAY_COLOR_MODES: {
1369 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Lina52f0292018-03-14 17:26:31 -07001370 Vector<ColorMode> colorModes;
Michael Wright28f24d02016-07-12 13:30:53 -07001371 sp<IBinder> display = nullptr;
1372 status_t result = data.readStrongBinder(&display);
1373 if (result != NO_ERROR) {
1374 ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result);
1375 return result;
1376 }
1377 result = getDisplayColorModes(display, &colorModes);
1378 reply->writeInt32(result);
1379 if (result == NO_ERROR) {
1380 reply->writeUint32(static_cast<uint32_t>(colorModes.size()));
1381 for (size_t i = 0; i < colorModes.size(); ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -07001382 reply->writeInt32(static_cast<int32_t>(colorModes[i]));
Michael Wright28f24d02016-07-12 13:30:53 -07001383 }
1384 }
1385 return NO_ERROR;
1386 }
Daniel Solomon42d04562019-01-20 21:03:19 -08001387 case GET_DISPLAY_NATIVE_PRIMARIES: {
1388 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1389 ui::DisplayPrimaries primaries;
1390 sp<IBinder> display = nullptr;
1391
1392 status_t result = data.readStrongBinder(&display);
1393 if (result != NO_ERROR) {
1394 ALOGE("getDisplayNativePrimaries failed to readStrongBinder: %d", result);
1395 return result;
1396 }
1397
1398 result = getDisplayNativePrimaries(display, primaries);
1399 reply->writeInt32(result);
1400 if (result == NO_ERROR) {
1401 memcpy(reply->writeInplace(sizeof(ui::DisplayPrimaries)), &primaries,
1402 sizeof(ui::DisplayPrimaries));
1403 }
1404
1405 return NO_ERROR;
1406 }
Michael Wright28f24d02016-07-12 13:30:53 -07001407 case GET_ACTIVE_COLOR_MODE: {
1408 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1409 sp<IBinder> display = nullptr;
1410 status_t result = data.readStrongBinder(&display);
1411 if (result != NO_ERROR) {
1412 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1413 return result;
1414 }
Peiyong Lina52f0292018-03-14 17:26:31 -07001415 ColorMode colorMode = getActiveColorMode(display);
Michael Wright28f24d02016-07-12 13:30:53 -07001416 result = reply->writeInt32(static_cast<int32_t>(colorMode));
1417 return result;
1418 }
1419 case SET_ACTIVE_COLOR_MODE: {
1420 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1421 sp<IBinder> display = nullptr;
1422 status_t result = data.readStrongBinder(&display);
1423 if (result != NO_ERROR) {
1424 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1425 return result;
1426 }
1427 int32_t colorModeInt = 0;
1428 result = data.readInt32(&colorModeInt);
1429 if (result != NO_ERROR) {
1430 ALOGE("setActiveColorMode failed to readInt32: %d", result);
1431 return result;
1432 }
1433 result = setActiveColorMode(display,
Peiyong Lina52f0292018-03-14 17:26:31 -07001434 static_cast<ColorMode>(colorModeInt));
Michael Wright28f24d02016-07-12 13:30:53 -07001435 result = reply->writeInt32(result);
1436 return result;
1437 }
Galia Peycheva5492cb52019-10-30 14:13:16 +01001438
1439 case GET_AUTO_LOW_LATENCY_MODE_SUPPORT: {
1440 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1441 sp<IBinder> display = nullptr;
1442 status_t result = data.readStrongBinder(&display);
1443 if (result != NO_ERROR) {
1444 ALOGE("getAutoLowLatencyModeSupport failed to readStrongBinder: %d", result);
1445 return result;
1446 }
1447 bool supported = false;
1448 result = getAutoLowLatencyModeSupport(display, &supported);
1449 if (result == NO_ERROR) {
1450 result = reply->writeBool(supported);
1451 }
1452 return result;
1453 }
1454
1455 case SET_AUTO_LOW_LATENCY_MODE: {
1456 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1457 sp<IBinder> display = nullptr;
1458 status_t result = data.readStrongBinder(&display);
1459 if (result != NO_ERROR) {
1460 ALOGE("setAutoLowLatencyMode failed to readStrongBinder: %d", result);
1461 return result;
1462 }
1463 bool setAllm = false;
1464 result = data.readBool(&setAllm);
1465 if (result != NO_ERROR) {
1466 ALOGE("setAutoLowLatencyMode failed to readBool: %d", result);
1467 return result;
1468 }
1469 setAutoLowLatencyMode(display, setAllm);
1470 return result;
1471 }
1472
1473 case GET_GAME_CONTENT_TYPE_SUPPORT: {
1474 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1475 sp<IBinder> display = nullptr;
1476 status_t result = data.readStrongBinder(&display);
1477 if (result != NO_ERROR) {
1478 ALOGE("getGameContentTypeSupport failed to readStrongBinder: %d", result);
1479 return result;
1480 }
1481 bool supported = false;
1482 result = getGameContentTypeSupport(display, &supported);
1483 if (result == NO_ERROR) {
1484 result = reply->writeBool(supported);
1485 }
1486 return result;
1487 }
1488
1489 case SET_GAME_CONTENT_TYPE: {
1490 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1491 sp<IBinder> display = nullptr;
1492 status_t result = data.readStrongBinder(&display);
1493 if (result != NO_ERROR) {
1494 ALOGE("setGameContentType failed to readStrongBinder: %d", result);
1495 return result;
1496 }
1497 bool setGameContentTypeOn = false;
1498 result = data.readBool(&setGameContentTypeOn);
1499 if (result != NO_ERROR) {
1500 ALOGE("setGameContentType failed to readBool: %d", result);
1501 return result;
1502 }
1503 setGameContentType(display, setGameContentTypeOn);
1504 return result;
1505 }
1506
Svetoslavd85084b2014-03-20 10:28:31 -07001507 case CLEAR_ANIMATION_FRAME_STATS: {
1508 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1509 status_t result = clearAnimationFrameStats();
1510 reply->writeInt32(result);
1511 return NO_ERROR;
1512 }
1513 case GET_ANIMATION_FRAME_STATS: {
1514 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1515 FrameStats stats;
1516 status_t result = getAnimationFrameStats(&stats);
1517 reply->write(stats);
1518 reply->writeInt32(result);
1519 return NO_ERROR;
1520 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -07001521 case SET_POWER_MODE: {
1522 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1523 sp<IBinder> display = data.readStrongBinder();
1524 int32_t mode = data.readInt32();
1525 setPowerMode(display, mode);
1526 return NO_ERROR;
1527 }
Dan Stozac4f471e2016-03-24 09:31:08 -07001528 case GET_HDR_CAPABILITIES: {
1529 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1530 sp<IBinder> display = nullptr;
1531 status_t result = data.readStrongBinder(&display);
1532 if (result != NO_ERROR) {
1533 ALOGE("getHdrCapabilities failed to readStrongBinder: %d",
1534 result);
1535 return result;
1536 }
1537 HdrCapabilities capabilities;
1538 result = getHdrCapabilities(display, &capabilities);
1539 reply->writeInt32(result);
1540 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -08001541 reply->write(capabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -07001542 }
1543 return NO_ERROR;
1544 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -07001545 case ENABLE_VSYNC_INJECTIONS: {
1546 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1547 bool enable = false;
1548 status_t result = data.readBool(&enable);
1549 if (result != NO_ERROR) {
1550 ALOGE("enableVSyncInjections failed to readBool: %d", result);
1551 return result;
1552 }
1553 return enableVSyncInjections(enable);
1554 }
1555 case INJECT_VSYNC: {
1556 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1557 int64_t when = 0;
1558 status_t result = data.readInt64(&when);
1559 if (result != NO_ERROR) {
1560 ALOGE("enableVSyncInjections failed to readInt64: %d", result);
1561 return result;
1562 }
1563 return injectVSync(when);
1564 }
Kalle Raitaa099a242017-01-11 11:17:29 -08001565 case GET_LAYER_DEBUG_INFO: {
1566 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1567 std::vector<LayerDebugInfo> outLayers;
1568 status_t result = getLayerDebugInfo(&outLayers);
1569 reply->writeInt32(result);
1570 if (result == NO_ERROR)
1571 {
1572 result = reply->writeParcelableVector(outLayers);
1573 }
1574 return result;
1575 }
Peiyong Lin0256f722018-08-31 15:45:10 -07001576 case GET_COMPOSITION_PREFERENCE: {
1577 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Linc6780972018-10-28 15:24:08 -07001578 ui::Dataspace defaultDataspace;
1579 ui::PixelFormat defaultPixelFormat;
1580 ui::Dataspace wideColorGamutDataspace;
1581 ui::PixelFormat wideColorGamutPixelFormat;
1582 status_t error =
1583 getCompositionPreference(&defaultDataspace, &defaultPixelFormat,
1584 &wideColorGamutDataspace, &wideColorGamutPixelFormat);
Peiyong Lin0256f722018-08-31 15:45:10 -07001585 reply->writeInt32(error);
1586 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -07001587 reply->writeInt32(static_cast<int32_t>(defaultDataspace));
1588 reply->writeInt32(static_cast<int32_t>(defaultPixelFormat));
1589 reply->writeInt32(static_cast<int32_t>(wideColorGamutDataspace));
Peiyong Linaa3da6a2018-12-12 02:48:43 -08001590 reply->writeInt32(static_cast<int32_t>(wideColorGamutPixelFormat));
Peiyong Lin0256f722018-08-31 15:45:10 -07001591 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001592 return error;
Peiyong Lin0256f722018-08-31 15:45:10 -07001593 }
Ady Abraham37965d42018-11-01 13:43:32 -07001594 case GET_COLOR_MANAGEMENT: {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001595 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Ady Abraham37965d42018-11-01 13:43:32 -07001596 bool result;
1597 status_t error = getColorManagement(&result);
1598 if (error == NO_ERROR) {
1599 reply->writeBool(result);
1600 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001601 return error;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001602 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -07001603 case GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: {
1604 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1605
1606 sp<IBinder> display = data.readStrongBinder();
1607 ui::PixelFormat format;
1608 ui::Dataspace dataspace;
1609 uint8_t component = 0;
1610 auto result =
1611 getDisplayedContentSamplingAttributes(display, &format, &dataspace, &component);
1612 if (result == NO_ERROR) {
1613 reply->writeUint32(static_cast<uint32_t>(format));
1614 reply->writeUint32(static_cast<uint32_t>(dataspace));
1615 reply->writeUint32(static_cast<uint32_t>(component));
1616 }
1617 return result;
1618 }
Kevin DuBois74e53772018-11-19 10:52:38 -08001619 case SET_DISPLAY_CONTENT_SAMPLING_ENABLED: {
1620 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1621
1622 sp<IBinder> display = nullptr;
1623 bool enable = false;
1624 int8_t componentMask = 0;
1625 uint64_t maxFrames = 0;
1626 status_t result = data.readStrongBinder(&display);
1627 if (result != NO_ERROR) {
1628 ALOGE("setDisplayContentSamplingEnabled failure in reading Display token: %d",
1629 result);
1630 return result;
1631 }
1632
1633 result = data.readBool(&enable);
1634 if (result != NO_ERROR) {
1635 ALOGE("setDisplayContentSamplingEnabled failure in reading enable: %d", result);
1636 return result;
1637 }
1638
1639 result = data.readByte(static_cast<int8_t*>(&componentMask));
1640 if (result != NO_ERROR) {
1641 ALOGE("setDisplayContentSamplingEnabled failure in reading component mask: %d",
1642 result);
1643 return result;
1644 }
1645
1646 result = data.readUint64(&maxFrames);
1647 if (result != NO_ERROR) {
1648 ALOGE("setDisplayContentSamplingEnabled failure in reading max frames: %d", result);
1649 return result;
1650 }
1651
1652 return setDisplayContentSamplingEnabled(display, enable,
1653 static_cast<uint8_t>(componentMask), maxFrames);
1654 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001655 case GET_DISPLAYED_CONTENT_SAMPLE: {
1656 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1657
1658 sp<IBinder> display = data.readStrongBinder();
1659 uint64_t maxFrames = 0;
1660 uint64_t timestamp = 0;
1661
1662 status_t result = data.readUint64(&maxFrames);
1663 if (result != NO_ERROR) {
1664 ALOGE("getDisplayedContentSample failure in reading max frames: %d", result);
1665 return result;
1666 }
1667
1668 result = data.readUint64(&timestamp);
1669 if (result != NO_ERROR) {
1670 ALOGE("getDisplayedContentSample failure in reading timestamp: %d", result);
1671 return result;
1672 }
1673
1674 DisplayedFrameStats stats;
1675 result = getDisplayedContentSample(display, maxFrames, timestamp, &stats);
1676 if (result == NO_ERROR) {
1677 reply->writeUint64(stats.numFrames);
Kevin DuBois1d4c6a62018-12-12 13:59:46 -08001678 reply->writeUint64Vector(stats.component_0_sample);
1679 reply->writeUint64Vector(stats.component_1_sample);
1680 reply->writeUint64Vector(stats.component_2_sample);
1681 reply->writeUint64Vector(stats.component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001682 }
1683 return result;
1684 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001685 case GET_PROTECTED_CONTENT_SUPPORT: {
1686 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1687 bool result;
1688 status_t error = getProtectedContentSupport(&result);
1689 if (error == NO_ERROR) {
1690 reply->writeBool(result);
1691 }
1692 return error;
1693 }
Peiyong Lin4f3fddf2019-01-24 17:21:24 -08001694 case IS_WIDE_COLOR_DISPLAY: {
1695 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1696 sp<IBinder> display = nullptr;
1697 status_t error = data.readStrongBinder(&display);
1698 if (error != NO_ERROR) {
1699 return error;
1700 }
1701 bool result;
1702 error = isWideColorDisplay(display, &result);
1703 if (error == NO_ERROR) {
1704 reply->writeBool(result);
1705 }
1706 return error;
1707 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001708 case GET_PHYSICAL_DISPLAY_IDS: {
1709 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1710 return reply->writeUint64Vector(getPhysicalDisplayIds());
1711 }
Dan Stoza84ab9372018-12-17 15:27:57 -08001712 case ADD_REGION_SAMPLING_LISTENER: {
1713 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1714 Rect samplingArea;
1715 status_t result = data.read(samplingArea);
1716 if (result != NO_ERROR) {
1717 ALOGE("addRegionSamplingListener: Failed to read sampling area");
1718 return result;
1719 }
1720 sp<IBinder> stopLayerHandle;
1721 result = data.readNullableStrongBinder(&stopLayerHandle);
1722 if (result != NO_ERROR) {
1723 ALOGE("addRegionSamplingListener: Failed to read stop layer handle");
1724 return result;
1725 }
1726 sp<IRegionSamplingListener> listener;
1727 result = data.readNullableStrongBinder(&listener);
1728 if (result != NO_ERROR) {
1729 ALOGE("addRegionSamplingListener: Failed to read listener");
1730 return result;
1731 }
1732 return addRegionSamplingListener(samplingArea, stopLayerHandle, listener);
1733 }
1734 case REMOVE_REGION_SAMPLING_LISTENER: {
1735 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1736 sp<IRegionSamplingListener> listener;
1737 status_t result = data.readNullableStrongBinder(&listener);
1738 if (result != NO_ERROR) {
1739 ALOGE("removeRegionSamplingListener: Failed to read listener");
1740 return result;
1741 }
1742 return removeRegionSamplingListener(listener);
1743 }
Ana Krulec0782b882019-10-15 17:34:54 -07001744 case SET_DESIRED_DISPLAY_CONFIG_SPECS: {
1745 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1746 sp<IBinder> displayToken = data.readStrongBinder();
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001747 int32_t defaultConfig;
1748 status_t result = data.readInt32(&defaultConfig);
Ana Krulec0782b882019-10-15 17:34:54 -07001749 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001750 ALOGE("setDesiredDisplayConfigSpecs: failed to read defaultConfig: %d", result);
Ana Krulec0782b882019-10-15 17:34:54 -07001751 return result;
1752 }
1753 float minRefreshRate;
1754 result = data.readFloat(&minRefreshRate);
1755 if (result != NO_ERROR) {
1756 ALOGE("setDesiredDisplayConfigSpecs: failed to read minRefreshRate: %d", result);
1757 return result;
1758 }
1759 float maxRefreshRate;
1760 result = data.readFloat(&maxRefreshRate);
1761 if (result != NO_ERROR) {
1762 ALOGE("setDesiredDisplayConfigSpecs: failed to read maxRefreshRate: %d", result);
1763 return result;
1764 }
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001765 result = setDesiredDisplayConfigSpecs(displayToken, defaultConfig, minRefreshRate,
Ana Krulec0782b882019-10-15 17:34:54 -07001766 maxRefreshRate);
1767 if (result != NO_ERROR) {
1768 ALOGE("setDesiredDisplayConfigSpecs: failed to call setDesiredDisplayConfigSpecs: "
1769 "%d",
1770 result);
1771 return result;
1772 }
1773 reply->writeInt32(result);
1774 return result;
1775 }
Ana Krulec234bb162019-11-10 22:55:55 +01001776 case GET_DESIRED_DISPLAY_CONFIG_SPECS: {
1777 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1778 sp<IBinder> displayToken = data.readStrongBinder();
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001779 int32_t defaultConfig;
Ana Krulec234bb162019-11-10 22:55:55 +01001780 float minRefreshRate;
1781 float maxRefreshRate;
1782
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001783 status_t result = getDesiredDisplayConfigSpecs(displayToken, &defaultConfig,
Ana Krulec234bb162019-11-10 22:55:55 +01001784 &minRefreshRate, &maxRefreshRate);
1785 if (result != NO_ERROR) {
1786 ALOGE("getDesiredDisplayConfigSpecs: failed to get getDesiredDisplayConfigSpecs: "
1787 "%d",
1788 result);
1789 return result;
1790 }
1791
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001792 result = reply->writeInt32(defaultConfig);
Ana Krulec234bb162019-11-10 22:55:55 +01001793 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001794 ALOGE("getDesiredDisplayConfigSpecs: failed to write defaultConfig: %d", result);
Ana Krulec234bb162019-11-10 22:55:55 +01001795 return result;
1796 }
1797 result = reply->writeFloat(minRefreshRate);
1798 if (result != NO_ERROR) {
1799 ALOGE("getDesiredDisplayConfigSpecs: failed to write minRefreshRate: %d", result);
1800 return result;
1801 }
1802 result = reply->writeFloat(maxRefreshRate);
1803 if (result != NO_ERROR) {
1804 ALOGE("getDesiredDisplayConfigSpecs: failed to write maxRefreshRate: %d", result);
1805 return result;
1806 }
1807 reply->writeInt32(result);
1808 return result;
1809 }
Dan Gittik57e63c52019-01-18 16:37:54 +00001810 case GET_DISPLAY_BRIGHTNESS_SUPPORT: {
1811 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1812 sp<IBinder> displayToken;
1813 status_t error = data.readNullableStrongBinder(&displayToken);
1814 if (error != NO_ERROR) {
1815 ALOGE("getDisplayBrightnessSupport: failed to read display token: %d", error);
1816 return error;
1817 }
1818 bool support = false;
1819 error = getDisplayBrightnessSupport(displayToken, &support);
1820 reply->writeBool(support);
1821 return error;
1822 }
1823 case SET_DISPLAY_BRIGHTNESS: {
1824 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1825 sp<IBinder> displayToken;
1826 status_t error = data.readNullableStrongBinder(&displayToken);
1827 if (error != NO_ERROR) {
1828 ALOGE("setDisplayBrightness: failed to read display token: %d", error);
1829 return error;
1830 }
1831 float brightness = -1.0f;
1832 error = data.readFloat(&brightness);
1833 if (error != NO_ERROR) {
1834 ALOGE("setDisplayBrightness: failed to read brightness: %d", error);
1835 return error;
1836 }
1837 return setDisplayBrightness(displayToken, brightness);
1838 }
Ady Abraham8532d012019-05-08 14:50:56 -07001839 case NOTIFY_POWER_HINT: {
1840 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1841 int32_t hintId;
1842 status_t error = data.readInt32(&hintId);
1843 if (error != NO_ERROR) {
1844 ALOGE("notifyPowerHint: failed to read hintId: %d", error);
1845 return error;
1846 }
1847 return notifyPowerHint(hintId);
1848 }
Vishnu Nairb13bb952019-11-15 10:24:08 -08001849 case SET_GLOBAL_SHADOW_SETTINGS: {
1850 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1851
1852 std::vector<float> shadowConfig;
1853 status_t error = data.readFloatVector(&shadowConfig);
1854 if (error != NO_ERROR || shadowConfig.size() != 11) {
1855 ALOGE("setGlobalShadowSettings: failed to read shadowConfig: %d", error);
1856 return error;
1857 }
1858
1859 half4 ambientColor = {shadowConfig[0], shadowConfig[1], shadowConfig[2],
1860 shadowConfig[3]};
1861 half4 spotColor = {shadowConfig[4], shadowConfig[5], shadowConfig[6], shadowConfig[7]};
1862 float lightPosY = shadowConfig[8];
1863 float lightPosZ = shadowConfig[9];
1864 float lightRadius = shadowConfig[10];
1865 return setGlobalShadowSettings(ambientColor, spotColor, lightPosY, lightPosZ,
1866 lightRadius);
1867 }
Jesse Hall6c913be2013-08-08 12:15:49 -07001868 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001869 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -07001870 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001871 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001872}
1873
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001874} // namespace android