blob: 09f1ed700e231c9e16da06e5c925249874be5c6c [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// tag as surfaceflinger
18#define LOG_TAG "SurfaceFlinger"
19
20#include <stdint.h>
21#include <sys/types.h>
22
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070023#include <binder/Parcel.h>
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070024#include <binder/IPCThreadState.h>
25#include <binder/IServiceManager.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080026
Mathias Agopiand0566bc2011-11-17 17:49:17 -080027#include <gui/IDisplayEventConnection.h>
Andy McFadden2adaf042012-12-18 09:49:45 -080028#include <gui/IGraphicBufferProducer.h>
Dan Stoza84ab9372018-12-17 15:27:57 -080029#include <gui/IRegionSamplingListener.h>
Mathias Agopian2b5dd402017-02-07 17:36:19 -080030#include <gui/ISurfaceComposer.h>
31#include <gui/ISurfaceComposerClient.h>
Kalle Raitaa099a242017-01-11 11:17:29 -080032#include <gui/LayerDebugInfo.h>
Robert Carr4cdc58f2017-08-23 14:22:20 -070033#include <gui/LayerState.h>
Mathias Agopiand0566bc2011-11-17 17:49:17 -080034
Michael Wright28f24d02016-07-12 13:30:53 -070035#include <system/graphics.h>
36
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080037#include <ui/DisplayInfo.h>
Lajos Molnar67d8bd62014-09-11 14:58:45 -070038#include <ui/DisplayStatInfo.h>
Dan Stozac4f471e2016-03-24 09:31:08 -070039#include <ui/HdrCapabilities.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080040
Jamie Gennis134f0422011-03-08 12:18:54 -080041#include <utils/Log.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -080042
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080043// ---------------------------------------------------------------------------
44
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080045namespace android {
46
Peiyong Lin9f034472018-03-28 15:29:00 -070047using ui::ColorMode;
48
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080049class BpSurfaceComposer : public BpInterface<ISurfaceComposer>
50{
51public:
Chih-Hung Hsiehe2347b72016-04-25 15:41:05 -070052 explicit BpSurfaceComposer(const sp<IBinder>& impl)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080053 : BpInterface<ISurfaceComposer>(impl)
54 {
55 }
56
Dan Stozad723bd72014-11-18 10:24:03 -080057 virtual ~BpSurfaceComposer();
58
Mathias Agopian7e27f052010-05-28 14:22:23 -070059 virtual sp<ISurfaceComposerClient> createConnection()
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080060 {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080061 Parcel data, reply;
62 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
63 remote()->transact(BnSurfaceComposer::CREATE_CONNECTION, data, &reply);
Mathias Agopian7e27f052010-05-28 14:22:23 -070064 return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080065 }
66
Marissa Wall713b63f2018-10-17 15:42:43 -070067 virtual void setTransactionState(const Vector<ComposerState>& state,
68 const Vector<DisplayState>& displays, uint32_t flags,
chaviw273171b2018-12-26 11:46:30 -080069 const sp<IBinder>& applyToken,
Marissa Wall17b4e452018-12-26 16:32:34 -080070 const InputWindowCommands& commands,
71 int64_t desiredPresentTime) {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080072 Parcel data, reply;
73 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Dan Stozad723bd72014-11-18 10:24:03 -080074
75 data.writeUint32(static_cast<uint32_t>(state.size()));
76 for (const auto& s : state) {
77 s.write(data);
Mathias Agopian698c0872011-06-28 19:09:31 -070078 }
Dan Stozad723bd72014-11-18 10:24:03 -080079
80 data.writeUint32(static_cast<uint32_t>(displays.size()));
81 for (const auto& d : displays) {
82 d.write(data);
Mathias Agopian8b33f032012-07-24 20:43:54 -070083 }
Dan Stozad723bd72014-11-18 10:24:03 -080084
85 data.writeUint32(flags);
Marissa Wall713b63f2018-10-17 15:42:43 -070086 data.writeStrongBinder(applyToken);
chaviw273171b2018-12-26 11:46:30 -080087 commands.write(data);
Marissa Wall17b4e452018-12-26 16:32:34 -080088 data.writeInt64(desiredPresentTime);
Jamie Gennisb8d69a52011-10-10 15:48:06 -070089 remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080090 }
91
92 virtual void bootFinished()
93 {
94 Parcel data, reply;
95 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
96 remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply);
97 }
98
Chavi Weingarten40482ff2017-11-30 01:51:40 +000099 virtual status_t captureScreen(const sp<IBinder>& display, sp<GraphicBuffer>* outBuffer,
Peiyong Lin0e003c92018-09-17 11:09:51 -0700100 const ui::Dataspace reqDataspace,
101 const ui::PixelFormat reqPixelFormat, Rect sourceCrop,
102 uint32_t reqWidth, uint32_t reqHeight, bool useIdentityTransform,
103 ISurfaceComposer::Rotation rotation) {
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800104 Parcel data, reply;
105 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
106 data.writeStrongBinder(display);
Peiyong Lin0e003c92018-09-17 11:09:51 -0700107 data.writeInt32(static_cast<int32_t>(reqDataspace));
108 data.writeInt32(static_cast<int32_t>(reqPixelFormat));
Dan Stozac1879002014-05-22 15:59:05 -0700109 data.write(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800110 data.writeUint32(reqWidth);
111 data.writeUint32(reqHeight);
Dan Stozac7014012014-02-14 15:03:43 -0800112 data.writeInt32(static_cast<int32_t>(useIdentityTransform));
Riley Andrewsc3ebe662014-09-04 16:20:31 -0700113 data.writeInt32(static_cast<int32_t>(rotation));
Ana Krulec2d41e422018-07-26 12:07:43 -0700114 status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply);
115 if (result != NO_ERROR) {
116 ALOGE("captureScreen failed to transact: %d", result);
117 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000118 }
Ana Krulec2d41e422018-07-26 12:07:43 -0700119 result = reply.readInt32();
120 if (result != NO_ERROR) {
121 ALOGE("captureScreen failed to readInt32: %d", result);
122 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000123 }
124
125 *outBuffer = new GraphicBuffer();
126 reply.read(**outBuffer);
Peiyong Lin0e003c92018-09-17 11:09:51 -0700127
Ana Krulec2d41e422018-07-26 12:07:43 -0700128 return result;
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800129 }
130
chaviwa76b2712017-09-20 12:02:26 -0700131 virtual status_t captureLayers(const sp<IBinder>& layerHandleBinder,
Peiyong Lin0e003c92018-09-17 11:09:51 -0700132 sp<GraphicBuffer>* outBuffer, const ui::Dataspace reqDataspace,
133 const ui::PixelFormat reqPixelFormat, const Rect& sourceCrop,
Robert Carr578038f2018-03-09 12:25:24 -0800134 float frameScale, bool childrenOnly) {
chaviwa76b2712017-09-20 12:02:26 -0700135 Parcel data, reply;
136 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
137 data.writeStrongBinder(layerHandleBinder);
Peiyong Lin0e003c92018-09-17 11:09:51 -0700138 data.writeInt32(static_cast<int32_t>(reqDataspace));
139 data.writeInt32(static_cast<int32_t>(reqPixelFormat));
chaviw7206d492017-11-10 16:16:12 -0800140 data.write(sourceCrop);
141 data.writeFloat(frameScale);
Robert Carr578038f2018-03-09 12:25:24 -0800142 data.writeBool(childrenOnly);
Ana Krulec2d41e422018-07-26 12:07:43 -0700143 status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_LAYERS, data, &reply);
144 if (result != NO_ERROR) {
145 ALOGE("captureLayers failed to transact: %d", result);
146 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000147 }
Ana Krulec2d41e422018-07-26 12:07:43 -0700148 result = reply.readInt32();
149 if (result != NO_ERROR) {
150 ALOGE("captureLayers failed to readInt32: %d", result);
151 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000152 }
Peiyong Lin0e003c92018-09-17 11:09:51 -0700153
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000154 *outBuffer = new GraphicBuffer();
155 reply.read(**outBuffer);
156
Ana Krulec2d41e422018-07-26 12:07:43 -0700157 return result;
chaviwa76b2712017-09-20 12:02:26 -0700158 }
159
Jamie Gennis582270d2011-08-17 18:19:00 -0700160 virtual bool authenticateSurfaceTexture(
Andy McFadden2adaf042012-12-18 09:49:45 -0800161 const sp<IGraphicBufferProducer>& bufferProducer) const
Jamie Gennis134f0422011-03-08 12:18:54 -0800162 {
163 Parcel data, reply;
164 int err = NO_ERROR;
165 err = data.writeInterfaceToken(
166 ISurfaceComposer::getInterfaceDescriptor());
167 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000168 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis134f0422011-03-08 12:18:54 -0800169 "interface descriptor: %s (%d)", strerror(-err), -err);
170 return false;
171 }
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800172 err = data.writeStrongBinder(IInterface::asBinder(bufferProducer));
Jamie Gennis134f0422011-03-08 12:18:54 -0800173 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000174 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis582270d2011-08-17 18:19:00 -0700175 "strong binder to parcel: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800176 return false;
177 }
178 err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
179 &reply);
180 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000181 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700182 "performing transaction: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800183 return false;
184 }
185 int32_t result = 0;
186 err = reply.readInt32(&result);
187 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000188 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700189 "retrieving result: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800190 return false;
191 }
192 return result != 0;
193 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800194
Brian Anderson6b376712017-04-04 10:51:39 -0700195 virtual status_t getSupportedFrameTimestamps(
196 std::vector<FrameEvent>* outSupported) const {
197 if (!outSupported) {
198 return UNEXPECTED_NULL;
199 }
200 outSupported->clear();
201
202 Parcel data, reply;
203
204 status_t err = data.writeInterfaceToken(
205 ISurfaceComposer::getInterfaceDescriptor());
206 if (err != NO_ERROR) {
207 return err;
208 }
209
210 err = remote()->transact(
211 BnSurfaceComposer::GET_SUPPORTED_FRAME_TIMESTAMPS,
212 data, &reply);
213 if (err != NO_ERROR) {
214 return err;
215 }
216
217 int32_t result = 0;
218 err = reply.readInt32(&result);
219 if (err != NO_ERROR) {
220 return err;
221 }
222 if (result != NO_ERROR) {
223 return result;
224 }
225
226 std::vector<int32_t> supported;
227 err = reply.readInt32Vector(&supported);
228 if (err != NO_ERROR) {
229 return err;
230 }
231
232 outSupported->reserve(supported.size());
233 for (int32_t s : supported) {
234 outSupported->push_back(static_cast<FrameEvent>(s));
235 }
236 return NO_ERROR;
237 }
238
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700239 virtual sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource)
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800240 {
241 Parcel data, reply;
242 sp<IDisplayEventConnection> result;
243 int err = data.writeInterfaceToken(
244 ISurfaceComposer::getInterfaceDescriptor());
245 if (err != NO_ERROR) {
246 return result;
247 }
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700248 data.writeInt32(static_cast<int32_t>(vsyncSource));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800249 err = remote()->transact(
250 BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION,
251 data, &reply);
252 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000253 ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing "
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800254 "transaction: %s (%d)", strerror(-err), -err);
255 return result;
256 }
257 result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder());
258 return result;
259 }
Colin Cross8e533062012-06-07 13:17:52 -0700260
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700261 virtual sp<IBinder> createDisplay(const String8& displayName, bool secure)
Mathias Agopiane57f2922012-08-09 16:29:12 -0700262 {
263 Parcel data, reply;
264 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700265 data.writeString8(displayName);
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700266 data.writeInt32(secure ? 1 : 0);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700267 remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply);
268 return reply.readStrongBinder();
269 }
270
Jesse Hall6c913be2013-08-08 12:15:49 -0700271 virtual void destroyDisplay(const sp<IBinder>& display)
272 {
273 Parcel data, reply;
274 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
275 data.writeStrongBinder(display);
276 remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply);
277 }
278
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800279 virtual std::vector<PhysicalDisplayId> getPhysicalDisplayIds() const {
Mathias Agopiane57f2922012-08-09 16:29:12 -0700280 Parcel data, reply;
281 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800282 if (remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_IDS, data, &reply) ==
283 NO_ERROR) {
284 std::vector<PhysicalDisplayId> displayIds;
285 if (reply.readUint64Vector(&displayIds) == NO_ERROR) {
286 return displayIds;
287 }
288 }
289
290 return {};
291 }
292
293 virtual sp<IBinder> getPhysicalDisplayToken(PhysicalDisplayId displayId) const {
294 Parcel data, reply;
295 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
296 data.writeUint64(displayId);
297 remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_TOKEN, data, &reply);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700298 return reply.readStrongBinder();
299 }
300
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700301 virtual void setPowerMode(const sp<IBinder>& display, int mode)
Colin Cross8e533062012-06-07 13:17:52 -0700302 {
303 Parcel data, reply;
304 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700305 data.writeStrongBinder(display);
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700306 data.writeInt32(mode);
307 remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply);
Colin Cross8e533062012-06-07 13:17:52 -0700308 }
Mathias Agopian3094df32012-06-18 18:06:45 -0700309
Dan Stoza7f7da322014-05-02 15:26:25 -0700310 virtual status_t getDisplayConfigs(const sp<IBinder>& display,
311 Vector<DisplayInfo>* configs)
Mathias Agopianc666cae2012-07-25 18:56:13 -0700312 {
313 Parcel data, reply;
314 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700315 data.writeStrongBinder(display);
Dan Stoza7f7da322014-05-02 15:26:25 -0700316 remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply);
317 status_t result = reply.readInt32();
318 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -0800319 size_t numConfigs = reply.readUint32();
Dan Stoza7f7da322014-05-02 15:26:25 -0700320 configs->clear();
321 configs->resize(numConfigs);
322 for (size_t c = 0; c < numConfigs; ++c) {
323 memcpy(&(configs->editItemAt(c)),
324 reply.readInplace(sizeof(DisplayInfo)),
325 sizeof(DisplayInfo));
326 }
327 }
328 return result;
329 }
330
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700331 virtual status_t getDisplayStats(const sp<IBinder>& display,
332 DisplayStatInfo* stats)
333 {
334 Parcel data, reply;
335 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
336 data.writeStrongBinder(display);
337 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply);
338 status_t result = reply.readInt32();
339 if (result == NO_ERROR) {
340 memcpy(stats,
341 reply.readInplace(sizeof(DisplayStatInfo)),
342 sizeof(DisplayStatInfo));
343 }
344 return result;
345 }
346
Dan Stoza7f7da322014-05-02 15:26:25 -0700347 virtual int getActiveConfig(const sp<IBinder>& display)
348 {
349 Parcel data, reply;
350 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
351 data.writeStrongBinder(display);
352 remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply);
353 return reply.readInt32();
354 }
355
356 virtual status_t setActiveConfig(const sp<IBinder>& display, int id)
357 {
358 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700359 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
360 if (result != NO_ERROR) {
361 ALOGE("setActiveConfig failed to writeInterfaceToken: %d", result);
362 return result;
363 }
364 result = data.writeStrongBinder(display);
365 if (result != NO_ERROR) {
366 ALOGE("setActiveConfig failed to writeStrongBinder: %d", result);
367 return result;
368 }
369 result = data.writeInt32(id);
370 if (result != NO_ERROR) {
371 ALOGE("setActiveConfig failed to writeInt32: %d", result);
372 return result;
373 }
374 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply);
375 if (result != NO_ERROR) {
376 ALOGE("setActiveConfig failed to transact: %d", result);
377 return result;
378 }
Mathias Agopianc666cae2012-07-25 18:56:13 -0700379 return reply.readInt32();
380 }
Svetoslavd85084b2014-03-20 10:28:31 -0700381
Michael Wright28f24d02016-07-12 13:30:53 -0700382 virtual status_t getDisplayColorModes(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700383 Vector<ColorMode>* outColorModes) {
Michael Wright28f24d02016-07-12 13:30:53 -0700384 Parcel data, reply;
385 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
386 if (result != NO_ERROR) {
387 ALOGE("getDisplayColorModes failed to writeInterfaceToken: %d", result);
388 return result;
389 }
390 result = data.writeStrongBinder(display);
391 if (result != NO_ERROR) {
392 ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result);
393 return result;
394 }
395 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply);
396 if (result != NO_ERROR) {
397 ALOGE("getDisplayColorModes failed to transact: %d", result);
398 return result;
399 }
400 result = static_cast<status_t>(reply.readInt32());
401 if (result == NO_ERROR) {
402 size_t numModes = reply.readUint32();
403 outColorModes->clear();
404 outColorModes->resize(numModes);
405 for (size_t i = 0; i < numModes; ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -0700406 outColorModes->replaceAt(static_cast<ColorMode>(reply.readInt32()), i);
Michael Wright28f24d02016-07-12 13:30:53 -0700407 }
408 }
409 return result;
410 }
411
Daniel Solomon42d04562019-01-20 21:03:19 -0800412 virtual status_t getDisplayNativePrimaries(const sp<IBinder>& display,
413 ui::DisplayPrimaries& primaries) {
414 Parcel data, reply;
415 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
416 if (result != NO_ERROR) {
417 ALOGE("getDisplayNativePrimaries failed to writeInterfaceToken: %d", result);
418 return result;
419 }
420 result = data.writeStrongBinder(display);
421 if (result != NO_ERROR) {
422 ALOGE("getDisplayNativePrimaries failed to writeStrongBinder: %d", result);
423 return result;
424 }
425 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_NATIVE_PRIMARIES, data, &reply);
426 if (result != NO_ERROR) {
427 ALOGE("getDisplayNativePrimaries failed to transact: %d", result);
428 return result;
429 }
430 result = reply.readInt32();
431 if (result == NO_ERROR) {
432 memcpy(&primaries, reply.readInplace(sizeof(ui::DisplayPrimaries)),
433 sizeof(ui::DisplayPrimaries));
434 }
435 return result;
436 }
437
Peiyong Lina52f0292018-03-14 17:26:31 -0700438 virtual ColorMode getActiveColorMode(const sp<IBinder>& display) {
Michael Wright28f24d02016-07-12 13:30:53 -0700439 Parcel data, reply;
440 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
441 if (result != NO_ERROR) {
442 ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700443 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700444 }
445 result = data.writeStrongBinder(display);
446 if (result != NO_ERROR) {
447 ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700448 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700449 }
450 result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply);
451 if (result != NO_ERROR) {
452 ALOGE("getActiveColorMode failed to transact: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700453 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700454 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700455 return static_cast<ColorMode>(reply.readInt32());
Michael Wright28f24d02016-07-12 13:30:53 -0700456 }
457
458 virtual status_t setActiveColorMode(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700459 ColorMode colorMode) {
Michael Wright28f24d02016-07-12 13:30:53 -0700460 Parcel data, reply;
461 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
462 if (result != NO_ERROR) {
463 ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result);
464 return result;
465 }
466 result = data.writeStrongBinder(display);
467 if (result != NO_ERROR) {
468 ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result);
469 return result;
470 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700471 result = data.writeInt32(static_cast<int32_t>(colorMode));
Michael Wright28f24d02016-07-12 13:30:53 -0700472 if (result != NO_ERROR) {
473 ALOGE("setActiveColorMode failed to writeInt32: %d", result);
474 return result;
475 }
476 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply);
477 if (result != NO_ERROR) {
478 ALOGE("setActiveColorMode failed to transact: %d", result);
479 return result;
480 }
481 return static_cast<status_t>(reply.readInt32());
482 }
483
Svetoslavd85084b2014-03-20 10:28:31 -0700484 virtual status_t clearAnimationFrameStats() {
485 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700486 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
487 if (result != NO_ERROR) {
488 ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result);
489 return result;
490 }
491 result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply);
492 if (result != NO_ERROR) {
493 ALOGE("clearAnimationFrameStats failed to transact: %d", result);
494 return result;
495 }
Svetoslavd85084b2014-03-20 10:28:31 -0700496 return reply.readInt32();
497 }
498
499 virtual status_t getAnimationFrameStats(FrameStats* outStats) const {
500 Parcel data, reply;
501 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
502 remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply);
503 reply.read(*outStats);
504 return reply.readInt32();
505 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700506
507 virtual status_t getHdrCapabilities(const sp<IBinder>& display,
508 HdrCapabilities* outCapabilities) const {
509 Parcel data, reply;
510 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
511 status_t result = data.writeStrongBinder(display);
512 if (result != NO_ERROR) {
513 ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result);
514 return result;
515 }
516 result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES,
517 data, &reply);
518 if (result != NO_ERROR) {
519 ALOGE("getHdrCapabilities failed to transact: %d", result);
520 return result;
521 }
522 result = reply.readInt32();
523 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800524 result = reply.read(*outCapabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700525 }
526 return result;
527 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700528
529 virtual status_t enableVSyncInjections(bool enable) {
530 Parcel data, reply;
531 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
532 if (result != NO_ERROR) {
533 ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result);
534 return result;
535 }
536 result = data.writeBool(enable);
537 if (result != NO_ERROR) {
538 ALOGE("enableVSyncInjections failed to writeBool: %d", result);
539 return result;
540 }
541 result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS,
542 data, &reply, TF_ONE_WAY);
543 if (result != NO_ERROR) {
544 ALOGE("enableVSyncInjections failed to transact: %d", result);
545 return result;
546 }
547 return result;
548 }
549
550 virtual status_t injectVSync(nsecs_t when) {
551 Parcel data, reply;
552 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
553 if (result != NO_ERROR) {
554 ALOGE("injectVSync failed to writeInterfaceToken: %d", result);
555 return result;
556 }
557 result = data.writeInt64(when);
558 if (result != NO_ERROR) {
559 ALOGE("injectVSync failed to writeInt64: %d", result);
560 return result;
561 }
562 result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply, TF_ONE_WAY);
563 if (result != NO_ERROR) {
564 ALOGE("injectVSync failed to transact: %d", result);
565 return result;
566 }
567 return result;
568 }
569
Kalle Raitaa099a242017-01-11 11:17:29 -0800570 virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const
571 {
572 if (!outLayers) {
573 return UNEXPECTED_NULL;
574 }
575
576 Parcel data, reply;
577
578 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
579 if (err != NO_ERROR) {
580 return err;
581 }
582
583 err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply);
584 if (err != NO_ERROR) {
585 return err;
586 }
587
588 int32_t result = 0;
589 err = reply.readInt32(&result);
590 if (err != NO_ERROR) {
591 return err;
592 }
593 if (result != NO_ERROR) {
594 return result;
595 }
596
597 outLayers->clear();
598 return reply.readParcelableVector(outLayers);
599 }
Peiyong Lin0256f722018-08-31 15:45:10 -0700600
Peiyong Linc6780972018-10-28 15:24:08 -0700601 virtual status_t getCompositionPreference(ui::Dataspace* defaultDataspace,
602 ui::PixelFormat* defaultPixelFormat,
603 ui::Dataspace* wideColorGamutDataspace,
604 ui::PixelFormat* wideColorGamutPixelFormat) const {
Peiyong Lin0256f722018-08-31 15:45:10 -0700605 Parcel data, reply;
606 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
607 if (error != NO_ERROR) {
608 return error;
609 }
610 error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply);
611 if (error != NO_ERROR) {
612 return error;
613 }
614 error = static_cast<status_t>(reply.readInt32());
615 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -0700616 *defaultDataspace = static_cast<ui::Dataspace>(reply.readInt32());
617 *defaultPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
618 *wideColorGamutDataspace = static_cast<ui::Dataspace>(reply.readInt32());
619 *wideColorGamutPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
Peiyong Lin0256f722018-08-31 15:45:10 -0700620 }
621 return error;
622 }
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700623
Ady Abraham37965d42018-11-01 13:43:32 -0700624 virtual status_t getColorManagement(bool* outGetColorManagement) const {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700625 Parcel data, reply;
626 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Ady Abraham37965d42018-11-01 13:43:32 -0700627 remote()->transact(BnSurfaceComposer::GET_COLOR_MANAGEMENT, data, &reply);
628 bool result;
629 status_t err = reply.readBool(&result);
630 if (err == NO_ERROR) {
631 *outGetColorManagement = result;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700632 }
Ady Abraham37965d42018-11-01 13:43:32 -0700633 return err;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700634 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -0700635
636 virtual status_t getDisplayedContentSamplingAttributes(const sp<IBinder>& display,
637 ui::PixelFormat* outFormat,
638 ui::Dataspace* outDataspace,
639 uint8_t* outComponentMask) const {
640 if (!outFormat || !outDataspace || !outComponentMask) return BAD_VALUE;
641 Parcel data, reply;
642 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
643 data.writeStrongBinder(display);
644
645 status_t error =
646 remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES,
647 data, &reply);
648 if (error != NO_ERROR) {
649 return error;
650 }
651
652 uint32_t value = 0;
653 error = reply.readUint32(&value);
654 if (error != NO_ERROR) {
655 return error;
656 }
657 *outFormat = static_cast<ui::PixelFormat>(value);
658
659 error = reply.readUint32(&value);
660 if (error != NO_ERROR) {
661 return error;
662 }
663 *outDataspace = static_cast<ui::Dataspace>(value);
664
665 error = reply.readUint32(&value);
666 if (error != NO_ERROR) {
667 return error;
668 }
669 *outComponentMask = static_cast<uint8_t>(value);
670 return error;
671 }
Kevin DuBois74e53772018-11-19 10:52:38 -0800672
673 virtual status_t setDisplayContentSamplingEnabled(const sp<IBinder>& display, bool enable,
674 uint8_t componentMask,
675 uint64_t maxFrames) const {
676 Parcel data, reply;
677 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
678 data.writeStrongBinder(display);
679 data.writeBool(enable);
680 data.writeByte(static_cast<int8_t>(componentMask));
681 data.writeUint64(maxFrames);
682 status_t result =
683 remote()->transact(BnSurfaceComposer::SET_DISPLAY_CONTENT_SAMPLING_ENABLED, data,
684 &reply);
685 return result;
686 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700687
688 virtual status_t getDisplayedContentSample(const sp<IBinder>& display, uint64_t maxFrames,
689 uint64_t timestamp,
690 DisplayedFrameStats* outStats) const {
691 if (!outStats) return BAD_VALUE;
692
693 Parcel data, reply;
694 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
695 data.writeStrongBinder(display);
696 data.writeUint64(maxFrames);
697 data.writeUint64(timestamp);
698
699 status_t result =
700 remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLE, data, &reply);
701
702 if (result != NO_ERROR) {
703 return result;
704 }
705
706 result = reply.readUint64(&outStats->numFrames);
707 if (result != NO_ERROR) {
708 return result;
709 }
710
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800711 result = reply.readUint64Vector(&outStats->component_0_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700712 if (result != NO_ERROR) {
713 return result;
714 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800715 result = reply.readUint64Vector(&outStats->component_1_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700716 if (result != NO_ERROR) {
717 return result;
718 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800719 result = reply.readUint64Vector(&outStats->component_2_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700720 if (result != NO_ERROR) {
721 return result;
722 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800723 result = reply.readUint64Vector(&outStats->component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700724 return result;
725 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800726
727 virtual status_t getProtectedContentSupport(bool* outSupported) const {
728 Parcel data, reply;
729 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Peiyong Linb6888fa2019-01-28 13:20:58 -0800730 status_t error =
731 remote()->transact(BnSurfaceComposer::GET_PROTECTED_CONTENT_SUPPORT, data, &reply);
732 if (error != NO_ERROR) {
733 return error;
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800734 }
Peiyong Linb6888fa2019-01-28 13:20:58 -0800735 error = reply.readBool(outSupported);
736 return error;
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800737 }
Marissa Wallebc2c052019-01-16 19:16:55 -0800738
Peiyong Lin4f3fddf2019-01-24 17:21:24 -0800739 virtual status_t isWideColorDisplay(const sp<IBinder>& token,
740 bool* outIsWideColorDisplay) const {
741 Parcel data, reply;
742 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
743 if (error != NO_ERROR) {
744 return error;
745 }
746 error = data.writeStrongBinder(token);
747 if (error != NO_ERROR) {
748 return error;
749 }
750
751 error = remote()->transact(BnSurfaceComposer::IS_WIDE_COLOR_DISPLAY, data, &reply);
752 if (error != NO_ERROR) {
753 return error;
754 }
755 error = reply.readBool(outIsWideColorDisplay);
756 return error;
757 }
Dan Stoza84ab9372018-12-17 15:27:57 -0800758
759 virtual status_t addRegionSamplingListener(const Rect& samplingArea,
760 const sp<IBinder>& stopLayerHandle,
761 const sp<IRegionSamplingListener>& listener) {
762 Parcel data, reply;
763 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
764 if (error != NO_ERROR) {
765 ALOGE("addRegionSamplingListener: Failed to write interface token");
766 return error;
767 }
768 error = data.write(samplingArea);
769 if (error != NO_ERROR) {
770 ALOGE("addRegionSamplingListener: Failed to write sampling area");
771 return error;
772 }
773 error = data.writeStrongBinder(stopLayerHandle);
774 if (error != NO_ERROR) {
775 ALOGE("addRegionSamplingListener: Failed to write stop layer handle");
776 return error;
777 }
778 error = data.writeStrongBinder(IInterface::asBinder(listener));
779 if (error != NO_ERROR) {
780 ALOGE("addRegionSamplingListener: Failed to write listener");
781 return error;
782 }
783 error = remote()->transact(BnSurfaceComposer::ADD_REGION_SAMPLING_LISTENER, data, &reply);
784 if (error != NO_ERROR) {
785 ALOGE("addRegionSamplingListener: Failed to transact");
786 }
787 return error;
788 }
789
790 virtual status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) {
791 Parcel data, reply;
792 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
793 if (error != NO_ERROR) {
794 ALOGE("addRegionSamplingListener: Failed to write interface token");
795 return error;
796 }
797 error = data.writeStrongBinder(IInterface::asBinder(listener));
798 if (error != NO_ERROR) {
799 ALOGE("addRegionSamplingListener: Failed to write listener");
800 return error;
801 }
802 error = remote()->transact(BnSurfaceComposer::REMOVE_REGION_SAMPLING_LISTENER, data,
803 &reply);
804 if (error != NO_ERROR) {
805 ALOGE("addRegionSamplingListener: Failed to transact");
806 }
807 return error;
808 }
Ady Abraham838de062019-02-04 10:24:03 -0800809
810 virtual status_t setAllowedDisplayConfigs(const sp<IBinder>& displayToken,
811 const std::vector<int32_t>& allowedConfigs) {
812 Parcel data, reply;
813 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
814 if (result != NO_ERROR) {
815 ALOGE("setAllowedDisplayConfigs failed to writeInterfaceToken: %d", result);
816 return result;
817 }
818 result = data.writeStrongBinder(displayToken);
819 if (result != NO_ERROR) {
820 ALOGE("setAllowedDisplayConfigs failed to writeStrongBinder: %d", result);
821 return result;
822 }
823 result = data.writeInt32Vector(allowedConfigs);
824 if (result != NO_ERROR) {
825 ALOGE("setAllowedDisplayConfigs failed to writeInt32Vector: %d", result);
826 return result;
827 }
828 result = remote()->transact(BnSurfaceComposer::SET_ALLOWED_DISPLAY_CONFIGS, data, &reply);
829 if (result != NO_ERROR) {
830 ALOGE("setAllowedDisplayConfigs failed to transact: %d", result);
831 return result;
832 }
833 return reply.readInt32();
834 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800835};
836
Dan Stozad723bd72014-11-18 10:24:03 -0800837// Out-of-line virtual method definition to trigger vtable emission in this
838// translation unit (see clang warning -Wweak-vtables)
839BpSurfaceComposer::~BpSurfaceComposer() {}
840
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800841IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
842
843// ----------------------------------------------------------------------
844
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800845status_t BnSurfaceComposer::onTransact(
846 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
847{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800848 switch(code) {
849 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700850 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800851 sp<IBinder> b = IInterface::asBinder(createConnection());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800852 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -0700853 return NO_ERROR;
854 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700855 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700856 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -0800857
858 size_t count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700859 if (count > data.dataSize()) {
860 return BAD_VALUE;
861 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700862 Vector<ComposerState> state;
863 state.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800864 for (size_t i = 0; i < count; i++) {
Marissa Wallc837b5e2018-10-12 10:04:44 -0700865 ComposerState s;
Michael Lentine8afa1c42014-10-31 11:10:13 -0700866 if (s.read(data) == BAD_VALUE) {
867 return BAD_VALUE;
868 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700869 state.add(s);
870 }
Dan Stozad723bd72014-11-18 10:24:03 -0800871
872 count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700873 if (count > data.dataSize()) {
874 return BAD_VALUE;
875 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700876 DisplayState d;
877 Vector<DisplayState> displays;
878 displays.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800879 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700880 if (d.read(data) == BAD_VALUE) {
881 return BAD_VALUE;
882 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700883 displays.add(d);
884 }
Dan Stozad723bd72014-11-18 10:24:03 -0800885
886 uint32_t stateFlags = data.readUint32();
Marissa Wall713b63f2018-10-17 15:42:43 -0700887 sp<IBinder> applyToken = data.readStrongBinder();
chaviw273171b2018-12-26 11:46:30 -0800888 InputWindowCommands inputWindowCommands;
889 inputWindowCommands.read(data);
Marissa Wall17b4e452018-12-26 16:32:34 -0800890
891 int64_t desiredPresentTime = data.readInt64();
892 setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands,
893 desiredPresentTime);
Jesse Hall6c913be2013-08-08 12:15:49 -0700894 return NO_ERROR;
895 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800896 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700897 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800898 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -0700899 return NO_ERROR;
900 }
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800901 case CAPTURE_SCREEN: {
902 CHECK_INTERFACE(ISurfaceComposer, data, reply);
903 sp<IBinder> display = data.readStrongBinder();
Peiyong Lin0e003c92018-09-17 11:09:51 -0700904 ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32());
905 ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32());
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000906 sp<GraphicBuffer> outBuffer;
Pablo Ceballos60d69222015-08-07 14:47:20 -0700907 Rect sourceCrop(Rect::EMPTY_RECT);
Dan Stozac1879002014-05-22 15:59:05 -0700908 data.read(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800909 uint32_t reqWidth = data.readUint32();
910 uint32_t reqHeight = data.readUint32();
Dan Stozac7014012014-02-14 15:03:43 -0800911 bool useIdentityTransform = static_cast<bool>(data.readInt32());
Dan Stozad723bd72014-11-18 10:24:03 -0800912 int32_t rotation = data.readInt32();
Dan Stozac7014012014-02-14 15:03:43 -0800913
Peiyong Lin0e003c92018-09-17 11:09:51 -0700914 status_t res = captureScreen(display, &outBuffer, reqDataspace, reqPixelFormat,
915 sourceCrop, reqWidth, reqHeight, useIdentityTransform,
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000916 static_cast<ISurfaceComposer::Rotation>(rotation));
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800917 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000918 if (res == NO_ERROR) {
919 reply->write(*outBuffer);
920 }
Jesse Hall6c913be2013-08-08 12:15:49 -0700921 return NO_ERROR;
922 }
chaviwa76b2712017-09-20 12:02:26 -0700923 case CAPTURE_LAYERS: {
924 CHECK_INTERFACE(ISurfaceComposer, data, reply);
925 sp<IBinder> layerHandleBinder = data.readStrongBinder();
Peiyong Lin0e003c92018-09-17 11:09:51 -0700926 ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32());
927 ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32());
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000928 sp<GraphicBuffer> outBuffer;
chaviw7206d492017-11-10 16:16:12 -0800929 Rect sourceCrop(Rect::EMPTY_RECT);
930 data.read(sourceCrop);
931 float frameScale = data.readFloat();
Robert Carr578038f2018-03-09 12:25:24 -0800932 bool childrenOnly = data.readBool();
chaviwa76b2712017-09-20 12:02:26 -0700933
Peiyong Lin0e003c92018-09-17 11:09:51 -0700934 status_t res = captureLayers(layerHandleBinder, &outBuffer, reqDataspace,
935 reqPixelFormat, sourceCrop, frameScale, childrenOnly);
chaviwa76b2712017-09-20 12:02:26 -0700936 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000937 if (res == NO_ERROR) {
938 reply->write(*outBuffer);
939 }
chaviwa76b2712017-09-20 12:02:26 -0700940 return NO_ERROR;
941 }
Jamie Gennis134f0422011-03-08 12:18:54 -0800942 case AUTHENTICATE_SURFACE: {
943 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -0800944 sp<IGraphicBufferProducer> bufferProducer =
945 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
946 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -0800947 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700948 return NO_ERROR;
949 }
Brian Anderson6b376712017-04-04 10:51:39 -0700950 case GET_SUPPORTED_FRAME_TIMESTAMPS: {
951 CHECK_INTERFACE(ISurfaceComposer, data, reply);
952 std::vector<FrameEvent> supportedTimestamps;
953 status_t result = getSupportedFrameTimestamps(&supportedTimestamps);
954 status_t err = reply->writeInt32(result);
955 if (err != NO_ERROR) {
956 return err;
957 }
958 if (result != NO_ERROR) {
959 return result;
960 }
961
962 std::vector<int32_t> supported;
963 supported.reserve(supportedTimestamps.size());
964 for (FrameEvent s : supportedTimestamps) {
965 supported.push_back(static_cast<int32_t>(s));
966 }
967 return reply->writeInt32Vector(supported);
968 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800969 case CREATE_DISPLAY_EVENT_CONNECTION: {
970 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700971 sp<IDisplayEventConnection> connection(createDisplayEventConnection(
972 static_cast<ISurfaceComposer::VsyncSource>(data.readInt32())));
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800973 reply->writeStrongBinder(IInterface::asBinder(connection));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800974 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700975 }
Mathias Agopiane57f2922012-08-09 16:29:12 -0700976 case CREATE_DISPLAY: {
977 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700978 String8 displayName = data.readString8();
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700979 bool secure = bool(data.readInt32());
980 sp<IBinder> display(createDisplay(displayName, secure));
Mathias Agopiane57f2922012-08-09 16:29:12 -0700981 reply->writeStrongBinder(display);
982 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700983 }
984 case DESTROY_DISPLAY: {
985 CHECK_INTERFACE(ISurfaceComposer, data, reply);
986 sp<IBinder> display = data.readStrongBinder();
987 destroyDisplay(display);
988 return NO_ERROR;
989 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800990 case GET_PHYSICAL_DISPLAY_TOKEN: {
Mathias Agopiane57f2922012-08-09 16:29:12 -0700991 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800992 PhysicalDisplayId displayId = data.readUint64();
993 sp<IBinder> display = getPhysicalDisplayToken(displayId);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700994 reply->writeStrongBinder(display);
995 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700996 }
Dan Stoza7f7da322014-05-02 15:26:25 -0700997 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -0700998 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stoza7f7da322014-05-02 15:26:25 -0700999 Vector<DisplayInfo> configs;
Jeff Brown9d4e3d22012-08-24 20:00:51 -07001000 sp<IBinder> display = data.readStrongBinder();
Dan Stoza7f7da322014-05-02 15:26:25 -07001001 status_t result = getDisplayConfigs(display, &configs);
1002 reply->writeInt32(result);
1003 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -08001004 reply->writeUint32(static_cast<uint32_t>(configs.size()));
Dan Stoza7f7da322014-05-02 15:26:25 -07001005 for (size_t c = 0; c < configs.size(); ++c) {
1006 memcpy(reply->writeInplace(sizeof(DisplayInfo)),
1007 &configs[c], sizeof(DisplayInfo));
1008 }
1009 }
1010 return NO_ERROR;
1011 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -07001012 case GET_DISPLAY_STATS: {
1013 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1014 DisplayStatInfo stats;
1015 sp<IBinder> display = data.readStrongBinder();
1016 status_t result = getDisplayStats(display, &stats);
1017 reply->writeInt32(result);
1018 if (result == NO_ERROR) {
1019 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
1020 &stats, sizeof(DisplayStatInfo));
1021 }
1022 return NO_ERROR;
1023 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001024 case GET_ACTIVE_CONFIG: {
1025 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1026 sp<IBinder> display = data.readStrongBinder();
1027 int id = getActiveConfig(display);
1028 reply->writeInt32(id);
1029 return NO_ERROR;
1030 }
1031 case SET_ACTIVE_CONFIG: {
1032 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1033 sp<IBinder> display = data.readStrongBinder();
1034 int id = data.readInt32();
1035 status_t result = setActiveConfig(display, id);
Mathias Agopianc666cae2012-07-25 18:56:13 -07001036 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -07001037 return NO_ERROR;
1038 }
Michael Wright28f24d02016-07-12 13:30:53 -07001039 case GET_DISPLAY_COLOR_MODES: {
1040 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Lina52f0292018-03-14 17:26:31 -07001041 Vector<ColorMode> colorModes;
Michael Wright28f24d02016-07-12 13:30:53 -07001042 sp<IBinder> display = nullptr;
1043 status_t result = data.readStrongBinder(&display);
1044 if (result != NO_ERROR) {
1045 ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result);
1046 return result;
1047 }
1048 result = getDisplayColorModes(display, &colorModes);
1049 reply->writeInt32(result);
1050 if (result == NO_ERROR) {
1051 reply->writeUint32(static_cast<uint32_t>(colorModes.size()));
1052 for (size_t i = 0; i < colorModes.size(); ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -07001053 reply->writeInt32(static_cast<int32_t>(colorModes[i]));
Michael Wright28f24d02016-07-12 13:30:53 -07001054 }
1055 }
1056 return NO_ERROR;
1057 }
Daniel Solomon42d04562019-01-20 21:03:19 -08001058 case GET_DISPLAY_NATIVE_PRIMARIES: {
1059 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1060 ui::DisplayPrimaries primaries;
1061 sp<IBinder> display = nullptr;
1062
1063 status_t result = data.readStrongBinder(&display);
1064 if (result != NO_ERROR) {
1065 ALOGE("getDisplayNativePrimaries failed to readStrongBinder: %d", result);
1066 return result;
1067 }
1068
1069 result = getDisplayNativePrimaries(display, primaries);
1070 reply->writeInt32(result);
1071 if (result == NO_ERROR) {
1072 memcpy(reply->writeInplace(sizeof(ui::DisplayPrimaries)), &primaries,
1073 sizeof(ui::DisplayPrimaries));
1074 }
1075
1076 return NO_ERROR;
1077 }
Michael Wright28f24d02016-07-12 13:30:53 -07001078 case GET_ACTIVE_COLOR_MODE: {
1079 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1080 sp<IBinder> display = nullptr;
1081 status_t result = data.readStrongBinder(&display);
1082 if (result != NO_ERROR) {
1083 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1084 return result;
1085 }
Peiyong Lina52f0292018-03-14 17:26:31 -07001086 ColorMode colorMode = getActiveColorMode(display);
Michael Wright28f24d02016-07-12 13:30:53 -07001087 result = reply->writeInt32(static_cast<int32_t>(colorMode));
1088 return result;
1089 }
1090 case SET_ACTIVE_COLOR_MODE: {
1091 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1092 sp<IBinder> display = nullptr;
1093 status_t result = data.readStrongBinder(&display);
1094 if (result != NO_ERROR) {
1095 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1096 return result;
1097 }
1098 int32_t colorModeInt = 0;
1099 result = data.readInt32(&colorModeInt);
1100 if (result != NO_ERROR) {
1101 ALOGE("setActiveColorMode failed to readInt32: %d", result);
1102 return result;
1103 }
1104 result = setActiveColorMode(display,
Peiyong Lina52f0292018-03-14 17:26:31 -07001105 static_cast<ColorMode>(colorModeInt));
Michael Wright28f24d02016-07-12 13:30:53 -07001106 result = reply->writeInt32(result);
1107 return result;
1108 }
Svetoslavd85084b2014-03-20 10:28:31 -07001109 case CLEAR_ANIMATION_FRAME_STATS: {
1110 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1111 status_t result = clearAnimationFrameStats();
1112 reply->writeInt32(result);
1113 return NO_ERROR;
1114 }
1115 case GET_ANIMATION_FRAME_STATS: {
1116 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1117 FrameStats stats;
1118 status_t result = getAnimationFrameStats(&stats);
1119 reply->write(stats);
1120 reply->writeInt32(result);
1121 return NO_ERROR;
1122 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -07001123 case SET_POWER_MODE: {
1124 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1125 sp<IBinder> display = data.readStrongBinder();
1126 int32_t mode = data.readInt32();
1127 setPowerMode(display, mode);
1128 return NO_ERROR;
1129 }
Dan Stozac4f471e2016-03-24 09:31:08 -07001130 case GET_HDR_CAPABILITIES: {
1131 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1132 sp<IBinder> display = nullptr;
1133 status_t result = data.readStrongBinder(&display);
1134 if (result != NO_ERROR) {
1135 ALOGE("getHdrCapabilities failed to readStrongBinder: %d",
1136 result);
1137 return result;
1138 }
1139 HdrCapabilities capabilities;
1140 result = getHdrCapabilities(display, &capabilities);
1141 reply->writeInt32(result);
1142 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -08001143 reply->write(capabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -07001144 }
1145 return NO_ERROR;
1146 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -07001147 case ENABLE_VSYNC_INJECTIONS: {
1148 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1149 bool enable = false;
1150 status_t result = data.readBool(&enable);
1151 if (result != NO_ERROR) {
1152 ALOGE("enableVSyncInjections failed to readBool: %d", result);
1153 return result;
1154 }
1155 return enableVSyncInjections(enable);
1156 }
1157 case INJECT_VSYNC: {
1158 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1159 int64_t when = 0;
1160 status_t result = data.readInt64(&when);
1161 if (result != NO_ERROR) {
1162 ALOGE("enableVSyncInjections failed to readInt64: %d", result);
1163 return result;
1164 }
1165 return injectVSync(when);
1166 }
Kalle Raitaa099a242017-01-11 11:17:29 -08001167 case GET_LAYER_DEBUG_INFO: {
1168 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1169 std::vector<LayerDebugInfo> outLayers;
1170 status_t result = getLayerDebugInfo(&outLayers);
1171 reply->writeInt32(result);
1172 if (result == NO_ERROR)
1173 {
1174 result = reply->writeParcelableVector(outLayers);
1175 }
1176 return result;
1177 }
Peiyong Lin0256f722018-08-31 15:45:10 -07001178 case GET_COMPOSITION_PREFERENCE: {
1179 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Linc6780972018-10-28 15:24:08 -07001180 ui::Dataspace defaultDataspace;
1181 ui::PixelFormat defaultPixelFormat;
1182 ui::Dataspace wideColorGamutDataspace;
1183 ui::PixelFormat wideColorGamutPixelFormat;
1184 status_t error =
1185 getCompositionPreference(&defaultDataspace, &defaultPixelFormat,
1186 &wideColorGamutDataspace, &wideColorGamutPixelFormat);
Peiyong Lin0256f722018-08-31 15:45:10 -07001187 reply->writeInt32(error);
1188 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -07001189 reply->writeInt32(static_cast<int32_t>(defaultDataspace));
1190 reply->writeInt32(static_cast<int32_t>(defaultPixelFormat));
1191 reply->writeInt32(static_cast<int32_t>(wideColorGamutDataspace));
Peiyong Linaa3da6a2018-12-12 02:48:43 -08001192 reply->writeInt32(static_cast<int32_t>(wideColorGamutPixelFormat));
Peiyong Lin0256f722018-08-31 15:45:10 -07001193 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001194 return error;
Peiyong Lin0256f722018-08-31 15:45:10 -07001195 }
Ady Abraham37965d42018-11-01 13:43:32 -07001196 case GET_COLOR_MANAGEMENT: {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001197 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Ady Abraham37965d42018-11-01 13:43:32 -07001198 bool result;
1199 status_t error = getColorManagement(&result);
1200 if (error == NO_ERROR) {
1201 reply->writeBool(result);
1202 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001203 return error;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001204 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -07001205 case GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: {
1206 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1207
1208 sp<IBinder> display = data.readStrongBinder();
1209 ui::PixelFormat format;
1210 ui::Dataspace dataspace;
1211 uint8_t component = 0;
1212 auto result =
1213 getDisplayedContentSamplingAttributes(display, &format, &dataspace, &component);
1214 if (result == NO_ERROR) {
1215 reply->writeUint32(static_cast<uint32_t>(format));
1216 reply->writeUint32(static_cast<uint32_t>(dataspace));
1217 reply->writeUint32(static_cast<uint32_t>(component));
1218 }
1219 return result;
1220 }
Kevin DuBois74e53772018-11-19 10:52:38 -08001221 case SET_DISPLAY_CONTENT_SAMPLING_ENABLED: {
1222 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1223
1224 sp<IBinder> display = nullptr;
1225 bool enable = false;
1226 int8_t componentMask = 0;
1227 uint64_t maxFrames = 0;
1228 status_t result = data.readStrongBinder(&display);
1229 if (result != NO_ERROR) {
1230 ALOGE("setDisplayContentSamplingEnabled failure in reading Display token: %d",
1231 result);
1232 return result;
1233 }
1234
1235 result = data.readBool(&enable);
1236 if (result != NO_ERROR) {
1237 ALOGE("setDisplayContentSamplingEnabled failure in reading enable: %d", result);
1238 return result;
1239 }
1240
1241 result = data.readByte(static_cast<int8_t*>(&componentMask));
1242 if (result != NO_ERROR) {
1243 ALOGE("setDisplayContentSamplingEnabled failure in reading component mask: %d",
1244 result);
1245 return result;
1246 }
1247
1248 result = data.readUint64(&maxFrames);
1249 if (result != NO_ERROR) {
1250 ALOGE("setDisplayContentSamplingEnabled failure in reading max frames: %d", result);
1251 return result;
1252 }
1253
1254 return setDisplayContentSamplingEnabled(display, enable,
1255 static_cast<uint8_t>(componentMask), maxFrames);
1256 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001257 case GET_DISPLAYED_CONTENT_SAMPLE: {
1258 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1259
1260 sp<IBinder> display = data.readStrongBinder();
1261 uint64_t maxFrames = 0;
1262 uint64_t timestamp = 0;
1263
1264 status_t result = data.readUint64(&maxFrames);
1265 if (result != NO_ERROR) {
1266 ALOGE("getDisplayedContentSample failure in reading max frames: %d", result);
1267 return result;
1268 }
1269
1270 result = data.readUint64(&timestamp);
1271 if (result != NO_ERROR) {
1272 ALOGE("getDisplayedContentSample failure in reading timestamp: %d", result);
1273 return result;
1274 }
1275
1276 DisplayedFrameStats stats;
1277 result = getDisplayedContentSample(display, maxFrames, timestamp, &stats);
1278 if (result == NO_ERROR) {
1279 reply->writeUint64(stats.numFrames);
Kevin DuBois1d4c6a62018-12-12 13:59:46 -08001280 reply->writeUint64Vector(stats.component_0_sample);
1281 reply->writeUint64Vector(stats.component_1_sample);
1282 reply->writeUint64Vector(stats.component_2_sample);
1283 reply->writeUint64Vector(stats.component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001284 }
1285 return result;
1286 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001287 case GET_PROTECTED_CONTENT_SUPPORT: {
1288 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1289 bool result;
1290 status_t error = getProtectedContentSupport(&result);
1291 if (error == NO_ERROR) {
1292 reply->writeBool(result);
1293 }
1294 return error;
1295 }
Peiyong Lin4f3fddf2019-01-24 17:21:24 -08001296 case IS_WIDE_COLOR_DISPLAY: {
1297 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1298 sp<IBinder> display = nullptr;
1299 status_t error = data.readStrongBinder(&display);
1300 if (error != NO_ERROR) {
1301 return error;
1302 }
1303 bool result;
1304 error = isWideColorDisplay(display, &result);
1305 if (error == NO_ERROR) {
1306 reply->writeBool(result);
1307 }
1308 return error;
1309 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001310 case GET_PHYSICAL_DISPLAY_IDS: {
1311 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1312 return reply->writeUint64Vector(getPhysicalDisplayIds());
1313 }
Dan Stoza84ab9372018-12-17 15:27:57 -08001314 case ADD_REGION_SAMPLING_LISTENER: {
1315 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1316 Rect samplingArea;
1317 status_t result = data.read(samplingArea);
1318 if (result != NO_ERROR) {
1319 ALOGE("addRegionSamplingListener: Failed to read sampling area");
1320 return result;
1321 }
1322 sp<IBinder> stopLayerHandle;
1323 result = data.readNullableStrongBinder(&stopLayerHandle);
1324 if (result != NO_ERROR) {
1325 ALOGE("addRegionSamplingListener: Failed to read stop layer handle");
1326 return result;
1327 }
1328 sp<IRegionSamplingListener> listener;
1329 result = data.readNullableStrongBinder(&listener);
1330 if (result != NO_ERROR) {
1331 ALOGE("addRegionSamplingListener: Failed to read listener");
1332 return result;
1333 }
1334 return addRegionSamplingListener(samplingArea, stopLayerHandle, listener);
1335 }
1336 case REMOVE_REGION_SAMPLING_LISTENER: {
1337 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1338 sp<IRegionSamplingListener> listener;
1339 status_t result = data.readNullableStrongBinder(&listener);
1340 if (result != NO_ERROR) {
1341 ALOGE("removeRegionSamplingListener: Failed to read listener");
1342 return result;
1343 }
1344 return removeRegionSamplingListener(listener);
1345 }
Ady Abraham838de062019-02-04 10:24:03 -08001346 case SET_ALLOWED_DISPLAY_CONFIGS: {
1347 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1348 sp<IBinder> displayToken = data.readStrongBinder();
1349 std::vector<int32_t> allowedConfigs;
1350 data.readInt32Vector(&allowedConfigs);
1351 status_t result = setAllowedDisplayConfigs(displayToken, allowedConfigs);
1352 reply->writeInt32(result);
1353 return result;
1354 }
Jesse Hall6c913be2013-08-08 12:15:49 -07001355 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001356 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -07001357 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001358 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001359}
1360
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001361} // namespace android