blob: a8b4fa82265bc8b2a7f6b42bbf355ed2f101bf42 [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>
24#include <binder/IMemory.h>
25#include <binder/IPCThreadState.h>
26#include <binder/IServiceManager.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080027
Mathias Agopiand0566bc2011-11-17 17:49:17 -080028#include <gui/BitTube.h>
29#include <gui/IDisplayEventConnection.h>
Mathias Agopian90ac7992012-02-25 18:48:35 -080030#include <gui/ISurfaceComposer.h>
Andy McFadden2adaf042012-12-18 09:49:45 -080031#include <gui/IGraphicBufferProducer.h>
Mathias Agopian90ac7992012-02-25 18:48:35 -080032
33#include <private/gui/LayerState.h>
Mathias Agopiand0566bc2011-11-17 17:49:17 -080034
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080035#include <ui/DisplayInfo.h>
Lajos Molnar67d8bd62014-09-11 14:58:45 -070036#include <ui/DisplayStatInfo.h>
Dan Stozac4f471e2016-03-24 09:31:08 -070037#include <ui/HdrCapabilities.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080038
Jamie Gennis134f0422011-03-08 12:18:54 -080039#include <utils/Log.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -080040
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080041// ---------------------------------------------------------------------------
42
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080043namespace android {
44
Mathias Agopiand0566bc2011-11-17 17:49:17 -080045class IDisplayEventConnection;
46
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080047class BpSurfaceComposer : public BpInterface<ISurfaceComposer>
48{
49public:
50 BpSurfaceComposer(const sp<IBinder>& impl)
51 : BpInterface<ISurfaceComposer>(impl)
52 {
53 }
54
Dan Stozad723bd72014-11-18 10:24:03 -080055 virtual ~BpSurfaceComposer();
56
Mathias Agopian7e27f052010-05-28 14:22:23 -070057 virtual sp<ISurfaceComposerClient> createConnection()
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080058 {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080059 Parcel data, reply;
60 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
61 remote()->transact(BnSurfaceComposer::CREATE_CONNECTION, data, &reply);
Mathias Agopian7e27f052010-05-28 14:22:23 -070062 return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080063 }
64
Jamie Gennis9a78c902011-01-12 18:30:40 -080065 virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc()
66 {
Jamie Gennis9a78c902011-01-12 18:30:40 -080067 Parcel data, reply;
68 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
69 remote()->transact(BnSurfaceComposer::CREATE_GRAPHIC_BUFFER_ALLOC, data, &reply);
70 return interface_cast<IGraphicBufferAlloc>(reply.readStrongBinder());
71 }
72
Mathias Agopian8b33f032012-07-24 20:43:54 -070073 virtual void setTransactionState(
74 const Vector<ComposerState>& state,
75 const Vector<DisplayState>& displays,
76 uint32_t flags)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080077 {
78 Parcel data, reply;
79 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Dan Stozad723bd72014-11-18 10:24:03 -080080
81 data.writeUint32(static_cast<uint32_t>(state.size()));
82 for (const auto& s : state) {
83 s.write(data);
Mathias Agopian698c0872011-06-28 19:09:31 -070084 }
Dan Stozad723bd72014-11-18 10:24:03 -080085
86 data.writeUint32(static_cast<uint32_t>(displays.size()));
87 for (const auto& d : displays) {
88 d.write(data);
Mathias Agopian8b33f032012-07-24 20:43:54 -070089 }
Dan Stozad723bd72014-11-18 10:24:03 -080090
91 data.writeUint32(flags);
Jamie Gennisb8d69a52011-10-10 15:48:06 -070092 remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080093 }
94
95 virtual void bootFinished()
96 {
97 Parcel data, reply;
98 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
99 remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply);
100 }
101
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800102 virtual status_t captureScreen(const sp<IBinder>& display,
103 const sp<IGraphicBufferProducer>& producer,
Dan Stozac1879002014-05-22 15:59:05 -0700104 Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
Dan Stozac7014012014-02-14 15:03:43 -0800105 uint32_t minLayerZ, uint32_t maxLayerZ,
Riley Andrewsc3ebe662014-09-04 16:20:31 -0700106 bool useIdentityTransform,
107 ISurfaceComposer::Rotation rotation)
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800108 {
109 Parcel data, reply;
110 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
111 data.writeStrongBinder(display);
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800112 data.writeStrongBinder(IInterface::asBinder(producer));
Dan Stozac1879002014-05-22 15:59:05 -0700113 data.write(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800114 data.writeUint32(reqWidth);
115 data.writeUint32(reqHeight);
116 data.writeUint32(minLayerZ);
117 data.writeUint32(maxLayerZ);
Dan Stozac7014012014-02-14 15:03:43 -0800118 data.writeInt32(static_cast<int32_t>(useIdentityTransform));
Riley Andrewsc3ebe662014-09-04 16:20:31 -0700119 data.writeInt32(static_cast<int32_t>(rotation));
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800120 remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply);
121 return reply.readInt32();
122 }
123
Jamie Gennis582270d2011-08-17 18:19:00 -0700124 virtual bool authenticateSurfaceTexture(
Andy McFadden2adaf042012-12-18 09:49:45 -0800125 const sp<IGraphicBufferProducer>& bufferProducer) const
Jamie Gennis134f0422011-03-08 12:18:54 -0800126 {
127 Parcel data, reply;
128 int err = NO_ERROR;
129 err = data.writeInterfaceToken(
130 ISurfaceComposer::getInterfaceDescriptor());
131 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000132 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis134f0422011-03-08 12:18:54 -0800133 "interface descriptor: %s (%d)", strerror(-err), -err);
134 return false;
135 }
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800136 err = data.writeStrongBinder(IInterface::asBinder(bufferProducer));
Jamie Gennis134f0422011-03-08 12:18:54 -0800137 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000138 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis582270d2011-08-17 18:19:00 -0700139 "strong binder to parcel: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800140 return false;
141 }
142 err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
143 &reply);
144 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000145 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700146 "performing transaction: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800147 return false;
148 }
149 int32_t result = 0;
150 err = reply.readInt32(&result);
151 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000152 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700153 "retrieving result: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800154 return false;
155 }
156 return result != 0;
157 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800158
159 virtual sp<IDisplayEventConnection> createDisplayEventConnection()
160 {
161 Parcel data, reply;
162 sp<IDisplayEventConnection> result;
163 int err = data.writeInterfaceToken(
164 ISurfaceComposer::getInterfaceDescriptor());
165 if (err != NO_ERROR) {
166 return result;
167 }
168 err = remote()->transact(
169 BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION,
170 data, &reply);
171 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000172 ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing "
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800173 "transaction: %s (%d)", strerror(-err), -err);
174 return result;
175 }
176 result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder());
177 return result;
178 }
Colin Cross8e533062012-06-07 13:17:52 -0700179
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700180 virtual sp<IBinder> createDisplay(const String8& displayName, bool secure)
Mathias Agopiane57f2922012-08-09 16:29:12 -0700181 {
182 Parcel data, reply;
183 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700184 data.writeString8(displayName);
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700185 data.writeInt32(secure ? 1 : 0);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700186 remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply);
187 return reply.readStrongBinder();
188 }
189
Jesse Hall6c913be2013-08-08 12:15:49 -0700190 virtual void destroyDisplay(const sp<IBinder>& display)
191 {
192 Parcel data, reply;
193 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
194 data.writeStrongBinder(display);
195 remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply);
196 }
197
Mathias Agopiane57f2922012-08-09 16:29:12 -0700198 virtual sp<IBinder> getBuiltInDisplay(int32_t id)
199 {
200 Parcel data, reply;
201 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
202 data.writeInt32(id);
203 remote()->transact(BnSurfaceComposer::GET_BUILT_IN_DISPLAY, data, &reply);
204 return reply.readStrongBinder();
205 }
206
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700207 virtual void setPowerMode(const sp<IBinder>& display, int mode)
Colin Cross8e533062012-06-07 13:17:52 -0700208 {
209 Parcel data, reply;
210 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700211 data.writeStrongBinder(display);
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700212 data.writeInt32(mode);
213 remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply);
Colin Cross8e533062012-06-07 13:17:52 -0700214 }
Mathias Agopian3094df32012-06-18 18:06:45 -0700215
Dan Stoza7f7da322014-05-02 15:26:25 -0700216 virtual status_t getDisplayConfigs(const sp<IBinder>& display,
217 Vector<DisplayInfo>* configs)
Mathias Agopianc666cae2012-07-25 18:56:13 -0700218 {
219 Parcel data, reply;
220 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700221 data.writeStrongBinder(display);
Dan Stoza7f7da322014-05-02 15:26:25 -0700222 remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply);
223 status_t result = reply.readInt32();
224 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -0800225 size_t numConfigs = reply.readUint32();
Dan Stoza7f7da322014-05-02 15:26:25 -0700226 configs->clear();
227 configs->resize(numConfigs);
228 for (size_t c = 0; c < numConfigs; ++c) {
229 memcpy(&(configs->editItemAt(c)),
230 reply.readInplace(sizeof(DisplayInfo)),
231 sizeof(DisplayInfo));
232 }
233 }
234 return result;
235 }
236
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700237 virtual status_t getDisplayStats(const sp<IBinder>& display,
238 DisplayStatInfo* stats)
239 {
240 Parcel data, reply;
241 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
242 data.writeStrongBinder(display);
243 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply);
244 status_t result = reply.readInt32();
245 if (result == NO_ERROR) {
246 memcpy(stats,
247 reply.readInplace(sizeof(DisplayStatInfo)),
248 sizeof(DisplayStatInfo));
249 }
250 return result;
251 }
252
Dan Stoza7f7da322014-05-02 15:26:25 -0700253 virtual int getActiveConfig(const sp<IBinder>& display)
254 {
255 Parcel data, reply;
256 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
257 data.writeStrongBinder(display);
258 remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply);
259 return reply.readInt32();
260 }
261
262 virtual status_t setActiveConfig(const sp<IBinder>& display, int id)
263 {
264 Parcel data, reply;
265 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
266 data.writeStrongBinder(display);
267 data.writeInt32(id);
268 remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply);
Mathias Agopianc666cae2012-07-25 18:56:13 -0700269 return reply.readInt32();
270 }
Svetoslavd85084b2014-03-20 10:28:31 -0700271
272 virtual status_t clearAnimationFrameStats() {
273 Parcel data, reply;
274 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
275 remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply);
276 return reply.readInt32();
277 }
278
279 virtual status_t getAnimationFrameStats(FrameStats* outStats) const {
280 Parcel data, reply;
281 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
282 remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply);
283 reply.read(*outStats);
284 return reply.readInt32();
285 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700286
287 virtual status_t getHdrCapabilities(const sp<IBinder>& display,
288 HdrCapabilities* outCapabilities) const {
289 Parcel data, reply;
290 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
291 status_t result = data.writeStrongBinder(display);
292 if (result != NO_ERROR) {
293 ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result);
294 return result;
295 }
296 result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES,
297 data, &reply);
298 if (result != NO_ERROR) {
299 ALOGE("getHdrCapabilities failed to transact: %d", result);
300 return result;
301 }
302 result = reply.readInt32();
303 if (result == NO_ERROR) {
304 result = reply.readParcelable(outCapabilities);
305 }
306 return result;
307 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800308};
309
Dan Stozad723bd72014-11-18 10:24:03 -0800310// Out-of-line virtual method definition to trigger vtable emission in this
311// translation unit (see clang warning -Wweak-vtables)
312BpSurfaceComposer::~BpSurfaceComposer() {}
313
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800314IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
315
316// ----------------------------------------------------------------------
317
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800318status_t BnSurfaceComposer::onTransact(
319 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
320{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800321 switch(code) {
322 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700323 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800324 sp<IBinder> b = IInterface::asBinder(createConnection());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800325 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -0700326 return NO_ERROR;
327 }
Jamie Gennis9a78c902011-01-12 18:30:40 -0800328 case CREATE_GRAPHIC_BUFFER_ALLOC: {
329 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800330 sp<IBinder> b = IInterface::asBinder(createGraphicBufferAlloc());
Jamie Gennis9a78c902011-01-12 18:30:40 -0800331 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -0700332 return NO_ERROR;
333 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700334 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700335 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -0800336
337 size_t count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700338 if (count > data.dataSize()) {
339 return BAD_VALUE;
340 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700341 ComposerState s;
342 Vector<ComposerState> state;
343 state.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800344 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700345 if (s.read(data) == BAD_VALUE) {
346 return BAD_VALUE;
347 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700348 state.add(s);
349 }
Dan Stozad723bd72014-11-18 10:24:03 -0800350
351 count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700352 if (count > data.dataSize()) {
353 return BAD_VALUE;
354 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700355 DisplayState d;
356 Vector<DisplayState> displays;
357 displays.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800358 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700359 if (d.read(data) == BAD_VALUE) {
360 return BAD_VALUE;
361 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700362 displays.add(d);
363 }
Dan Stozad723bd72014-11-18 10:24:03 -0800364
365 uint32_t stateFlags = data.readUint32();
366 setTransactionState(state, displays, stateFlags);
Jesse Hall6c913be2013-08-08 12:15:49 -0700367 return NO_ERROR;
368 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800369 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700370 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800371 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -0700372 return NO_ERROR;
373 }
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800374 case CAPTURE_SCREEN: {
375 CHECK_INTERFACE(ISurfaceComposer, data, reply);
376 sp<IBinder> display = data.readStrongBinder();
377 sp<IGraphicBufferProducer> producer =
378 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
Pablo Ceballos60d69222015-08-07 14:47:20 -0700379 Rect sourceCrop(Rect::EMPTY_RECT);
Dan Stozac1879002014-05-22 15:59:05 -0700380 data.read(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800381 uint32_t reqWidth = data.readUint32();
382 uint32_t reqHeight = data.readUint32();
383 uint32_t minLayerZ = data.readUint32();
384 uint32_t maxLayerZ = data.readUint32();
Dan Stozac7014012014-02-14 15:03:43 -0800385 bool useIdentityTransform = static_cast<bool>(data.readInt32());
Dan Stozad723bd72014-11-18 10:24:03 -0800386 int32_t rotation = data.readInt32();
Dan Stozac7014012014-02-14 15:03:43 -0800387
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800388 status_t res = captureScreen(display, producer,
Dan Stozac1879002014-05-22 15:59:05 -0700389 sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ,
Riley Andrewsc3ebe662014-09-04 16:20:31 -0700390 useIdentityTransform,
391 static_cast<ISurfaceComposer::Rotation>(rotation));
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800392 reply->writeInt32(res);
Jesse Hall6c913be2013-08-08 12:15:49 -0700393 return NO_ERROR;
394 }
Jamie Gennis134f0422011-03-08 12:18:54 -0800395 case AUTHENTICATE_SURFACE: {
396 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -0800397 sp<IGraphicBufferProducer> bufferProducer =
398 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
399 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -0800400 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700401 return NO_ERROR;
402 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800403 case CREATE_DISPLAY_EVENT_CONNECTION: {
404 CHECK_INTERFACE(ISurfaceComposer, data, reply);
405 sp<IDisplayEventConnection> connection(createDisplayEventConnection());
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800406 reply->writeStrongBinder(IInterface::asBinder(connection));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800407 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700408 }
Mathias Agopiane57f2922012-08-09 16:29:12 -0700409 case CREATE_DISPLAY: {
410 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700411 String8 displayName = data.readString8();
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700412 bool secure = bool(data.readInt32());
413 sp<IBinder> display(createDisplay(displayName, secure));
Mathias Agopiane57f2922012-08-09 16:29:12 -0700414 reply->writeStrongBinder(display);
415 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700416 }
417 case DESTROY_DISPLAY: {
418 CHECK_INTERFACE(ISurfaceComposer, data, reply);
419 sp<IBinder> display = data.readStrongBinder();
420 destroyDisplay(display);
421 return NO_ERROR;
422 }
Mathias Agopiane57f2922012-08-09 16:29:12 -0700423 case GET_BUILT_IN_DISPLAY: {
424 CHECK_INTERFACE(ISurfaceComposer, data, reply);
425 int32_t id = data.readInt32();
426 sp<IBinder> display(getBuiltInDisplay(id));
427 reply->writeStrongBinder(display);
428 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700429 }
Dan Stoza7f7da322014-05-02 15:26:25 -0700430 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -0700431 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stoza7f7da322014-05-02 15:26:25 -0700432 Vector<DisplayInfo> configs;
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700433 sp<IBinder> display = data.readStrongBinder();
Dan Stoza7f7da322014-05-02 15:26:25 -0700434 status_t result = getDisplayConfigs(display, &configs);
435 reply->writeInt32(result);
436 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -0800437 reply->writeUint32(static_cast<uint32_t>(configs.size()));
Dan Stoza7f7da322014-05-02 15:26:25 -0700438 for (size_t c = 0; c < configs.size(); ++c) {
439 memcpy(reply->writeInplace(sizeof(DisplayInfo)),
440 &configs[c], sizeof(DisplayInfo));
441 }
442 }
443 return NO_ERROR;
444 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700445 case GET_DISPLAY_STATS: {
446 CHECK_INTERFACE(ISurfaceComposer, data, reply);
447 DisplayStatInfo stats;
448 sp<IBinder> display = data.readStrongBinder();
449 status_t result = getDisplayStats(display, &stats);
450 reply->writeInt32(result);
451 if (result == NO_ERROR) {
452 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
453 &stats, sizeof(DisplayStatInfo));
454 }
455 return NO_ERROR;
456 }
Dan Stoza7f7da322014-05-02 15:26:25 -0700457 case GET_ACTIVE_CONFIG: {
458 CHECK_INTERFACE(ISurfaceComposer, data, reply);
459 sp<IBinder> display = data.readStrongBinder();
460 int id = getActiveConfig(display);
461 reply->writeInt32(id);
462 return NO_ERROR;
463 }
464 case SET_ACTIVE_CONFIG: {
465 CHECK_INTERFACE(ISurfaceComposer, data, reply);
466 sp<IBinder> display = data.readStrongBinder();
467 int id = data.readInt32();
468 status_t result = setActiveConfig(display, id);
Mathias Agopianc666cae2012-07-25 18:56:13 -0700469 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700470 return NO_ERROR;
471 }
Svetoslavd85084b2014-03-20 10:28:31 -0700472 case CLEAR_ANIMATION_FRAME_STATS: {
473 CHECK_INTERFACE(ISurfaceComposer, data, reply);
474 status_t result = clearAnimationFrameStats();
475 reply->writeInt32(result);
476 return NO_ERROR;
477 }
478 case GET_ANIMATION_FRAME_STATS: {
479 CHECK_INTERFACE(ISurfaceComposer, data, reply);
480 FrameStats stats;
481 status_t result = getAnimationFrameStats(&stats);
482 reply->write(stats);
483 reply->writeInt32(result);
484 return NO_ERROR;
485 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700486 case SET_POWER_MODE: {
487 CHECK_INTERFACE(ISurfaceComposer, data, reply);
488 sp<IBinder> display = data.readStrongBinder();
489 int32_t mode = data.readInt32();
490 setPowerMode(display, mode);
491 return NO_ERROR;
492 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700493 case GET_HDR_CAPABILITIES: {
494 CHECK_INTERFACE(ISurfaceComposer, data, reply);
495 sp<IBinder> display = nullptr;
496 status_t result = data.readStrongBinder(&display);
497 if (result != NO_ERROR) {
498 ALOGE("getHdrCapabilities failed to readStrongBinder: %d",
499 result);
500 return result;
501 }
502 HdrCapabilities capabilities;
503 result = getHdrCapabilities(display, &capabilities);
504 reply->writeInt32(result);
505 if (result == NO_ERROR) {
506 reply->writeParcelable(capabilities);
507 }
508 return NO_ERROR;
509 }
Jesse Hall6c913be2013-08-08 12:15:49 -0700510 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700511 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -0700512 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800513 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800514}
515
516// ----------------------------------------------------------------------------
517
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800518};