blob: ebb687a28a77797f49c513a409d263171afb5d93 [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>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080037
Jamie Gennis134f0422011-03-08 12:18:54 -080038#include <utils/Log.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -080039
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080040// ---------------------------------------------------------------------------
41
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080042namespace android {
43
Mathias Agopiand0566bc2011-11-17 17:49:17 -080044class IDisplayEventConnection;
45
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080046class BpSurfaceComposer : public BpInterface<ISurfaceComposer>
47{
48public:
49 BpSurfaceComposer(const sp<IBinder>& impl)
50 : BpInterface<ISurfaceComposer>(impl)
51 {
52 }
53
Mathias Agopian7e27f052010-05-28 14:22:23 -070054 virtual sp<ISurfaceComposerClient> createConnection()
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080055 {
56 uint32_t n;
57 Parcel data, reply;
58 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
59 remote()->transact(BnSurfaceComposer::CREATE_CONNECTION, data, &reply);
Mathias Agopian7e27f052010-05-28 14:22:23 -070060 return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080061 }
62
Jamie Gennis9a78c902011-01-12 18:30:40 -080063 virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc()
64 {
65 uint32_t n;
66 Parcel data, reply;
67 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
68 remote()->transact(BnSurfaceComposer::CREATE_GRAPHIC_BUFFER_ALLOC, data, &reply);
69 return interface_cast<IGraphicBufferAlloc>(reply.readStrongBinder());
70 }
71
Mathias Agopian8b33f032012-07-24 20:43:54 -070072 virtual void setTransactionState(
73 const Vector<ComposerState>& state,
74 const Vector<DisplayState>& displays,
75 uint32_t flags)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080076 {
77 Parcel data, reply;
78 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Mathias Agopian8b33f032012-07-24 20:43:54 -070079 {
80 Vector<ComposerState>::const_iterator b(state.begin());
81 Vector<ComposerState>::const_iterator e(state.end());
82 data.writeInt32(state.size());
83 for ( ; b != e ; ++b ) {
84 b->write(data);
85 }
Mathias Agopian698c0872011-06-28 19:09:31 -070086 }
Mathias Agopian8b33f032012-07-24 20:43:54 -070087 {
88 Vector<DisplayState>::const_iterator b(displays.begin());
89 Vector<DisplayState>::const_iterator e(displays.end());
90 data.writeInt32(displays.size());
91 for ( ; b != e ; ++b ) {
92 b->write(data);
93 }
94 }
Jamie Gennis28378392011-10-12 17:39:00 -070095 data.writeInt32(flags);
Jamie Gennisb8d69a52011-10-10 15:48:06 -070096 remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080097 }
98
99 virtual void bootFinished()
100 {
101 Parcel data, reply;
102 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
103 remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply);
104 }
105
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800106 virtual status_t captureScreen(const sp<IBinder>& display,
107 const sp<IGraphicBufferProducer>& producer,
Dan Stozac1879002014-05-22 15:59:05 -0700108 Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
Dan Stozac7014012014-02-14 15:03:43 -0800109 uint32_t minLayerZ, uint32_t maxLayerZ,
Riley Andrewsc3ebe662014-09-04 16:20:31 -0700110 bool useIdentityTransform,
111 ISurfaceComposer::Rotation rotation)
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800112 {
113 Parcel data, reply;
114 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
115 data.writeStrongBinder(display);
116 data.writeStrongBinder(producer->asBinder());
Dan Stozac1879002014-05-22 15:59:05 -0700117 data.write(sourceCrop);
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800118 data.writeInt32(reqWidth);
119 data.writeInt32(reqHeight);
120 data.writeInt32(minLayerZ);
121 data.writeInt32(maxLayerZ);
Dan Stozac7014012014-02-14 15:03:43 -0800122 data.writeInt32(static_cast<int32_t>(useIdentityTransform));
Riley Andrewsc3ebe662014-09-04 16:20:31 -0700123 data.writeInt32(static_cast<int32_t>(rotation));
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800124 remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply);
125 return reply.readInt32();
126 }
127
Jamie Gennis582270d2011-08-17 18:19:00 -0700128 virtual bool authenticateSurfaceTexture(
Andy McFadden2adaf042012-12-18 09:49:45 -0800129 const sp<IGraphicBufferProducer>& bufferProducer) const
Jamie Gennis134f0422011-03-08 12:18:54 -0800130 {
131 Parcel data, reply;
132 int err = NO_ERROR;
133 err = data.writeInterfaceToken(
134 ISurfaceComposer::getInterfaceDescriptor());
135 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000136 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis134f0422011-03-08 12:18:54 -0800137 "interface descriptor: %s (%d)", strerror(-err), -err);
138 return false;
139 }
Andy McFadden2adaf042012-12-18 09:49:45 -0800140 err = data.writeStrongBinder(bufferProducer->asBinder());
Jamie Gennis134f0422011-03-08 12:18:54 -0800141 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000142 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis582270d2011-08-17 18:19:00 -0700143 "strong binder to parcel: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800144 return false;
145 }
146 err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
147 &reply);
148 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000149 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700150 "performing transaction: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800151 return false;
152 }
153 int32_t result = 0;
154 err = reply.readInt32(&result);
155 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000156 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700157 "retrieving result: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800158 return false;
159 }
160 return result != 0;
161 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800162
163 virtual sp<IDisplayEventConnection> createDisplayEventConnection()
164 {
165 Parcel data, reply;
166 sp<IDisplayEventConnection> result;
167 int err = data.writeInterfaceToken(
168 ISurfaceComposer::getInterfaceDescriptor());
169 if (err != NO_ERROR) {
170 return result;
171 }
172 err = remote()->transact(
173 BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION,
174 data, &reply);
175 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000176 ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing "
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800177 "transaction: %s (%d)", strerror(-err), -err);
178 return result;
179 }
180 result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder());
181 return result;
182 }
Colin Cross8e533062012-06-07 13:17:52 -0700183
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700184 virtual sp<IBinder> createDisplay(const String8& displayName, bool secure)
Mathias Agopiane57f2922012-08-09 16:29:12 -0700185 {
186 Parcel data, reply;
187 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700188 data.writeString8(displayName);
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700189 data.writeInt32(secure ? 1 : 0);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700190 remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply);
191 return reply.readStrongBinder();
192 }
193
Jesse Hall6c913be2013-08-08 12:15:49 -0700194 virtual void destroyDisplay(const sp<IBinder>& display)
195 {
196 Parcel data, reply;
197 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
198 data.writeStrongBinder(display);
199 remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply);
200 }
201
Mathias Agopiane57f2922012-08-09 16:29:12 -0700202 virtual sp<IBinder> getBuiltInDisplay(int32_t id)
203 {
204 Parcel data, reply;
205 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
206 data.writeInt32(id);
207 remote()->transact(BnSurfaceComposer::GET_BUILT_IN_DISPLAY, data, &reply);
208 return reply.readStrongBinder();
209 }
210
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700211 virtual void setPowerMode(const sp<IBinder>& display, int mode)
Colin Cross8e533062012-06-07 13:17:52 -0700212 {
213 Parcel data, reply;
214 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700215 data.writeStrongBinder(display);
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700216 data.writeInt32(mode);
217 remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply);
Colin Cross8e533062012-06-07 13:17:52 -0700218 }
Mathias Agopian3094df32012-06-18 18:06:45 -0700219
Dan Stoza7f7da322014-05-02 15:26:25 -0700220 virtual status_t getDisplayConfigs(const sp<IBinder>& display,
221 Vector<DisplayInfo>* configs)
Mathias Agopianc666cae2012-07-25 18:56:13 -0700222 {
223 Parcel data, reply;
224 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700225 data.writeStrongBinder(display);
Dan Stoza7f7da322014-05-02 15:26:25 -0700226 remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply);
227 status_t result = reply.readInt32();
228 if (result == NO_ERROR) {
229 size_t numConfigs = static_cast<size_t>(reply.readInt32());
230 configs->clear();
231 configs->resize(numConfigs);
232 for (size_t c = 0; c < numConfigs; ++c) {
233 memcpy(&(configs->editItemAt(c)),
234 reply.readInplace(sizeof(DisplayInfo)),
235 sizeof(DisplayInfo));
236 }
237 }
238 return result;
239 }
240
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700241 virtual status_t getDisplayStats(const sp<IBinder>& display,
242 DisplayStatInfo* stats)
243 {
244 Parcel data, reply;
245 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
246 data.writeStrongBinder(display);
247 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply);
248 status_t result = reply.readInt32();
249 if (result == NO_ERROR) {
250 memcpy(stats,
251 reply.readInplace(sizeof(DisplayStatInfo)),
252 sizeof(DisplayStatInfo));
253 }
254 return result;
255 }
256
Dan Stoza7f7da322014-05-02 15:26:25 -0700257 virtual int getActiveConfig(const sp<IBinder>& display)
258 {
259 Parcel data, reply;
260 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
261 data.writeStrongBinder(display);
262 remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply);
263 return reply.readInt32();
264 }
265
266 virtual status_t setActiveConfig(const sp<IBinder>& display, int id)
267 {
268 Parcel data, reply;
269 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
270 data.writeStrongBinder(display);
271 data.writeInt32(id);
272 remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply);
Mathias Agopianc666cae2012-07-25 18:56:13 -0700273 return reply.readInt32();
274 }
Svetoslavd85084b2014-03-20 10:28:31 -0700275
276 virtual status_t clearAnimationFrameStats() {
277 Parcel data, reply;
278 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
279 remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply);
280 return reply.readInt32();
281 }
282
283 virtual status_t getAnimationFrameStats(FrameStats* outStats) const {
284 Parcel data, reply;
285 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
286 remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply);
287 reply.read(*outStats);
288 return reply.readInt32();
289 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800290};
291
292IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
293
294// ----------------------------------------------------------------------
295
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800296status_t BnSurfaceComposer::onTransact(
297 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
298{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800299 switch(code) {
300 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700301 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800302 sp<IBinder> b = createConnection()->asBinder();
303 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -0700304 return NO_ERROR;
305 }
Jamie Gennis9a78c902011-01-12 18:30:40 -0800306 case CREATE_GRAPHIC_BUFFER_ALLOC: {
307 CHECK_INTERFACE(ISurfaceComposer, data, reply);
308 sp<IBinder> b = createGraphicBufferAlloc()->asBinder();
309 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -0700310 return NO_ERROR;
311 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700312 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700313 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Mathias Agopian698c0872011-06-28 19:09:31 -0700314 size_t count = data.readInt32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700315 if (count > data.dataSize()) {
316 return BAD_VALUE;
317 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700318 ComposerState s;
319 Vector<ComposerState> state;
320 state.setCapacity(count);
321 for (size_t i=0 ; i<count ; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700322 if (s.read(data) == BAD_VALUE) {
323 return BAD_VALUE;
324 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700325 state.add(s);
326 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700327 count = data.readInt32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700328 if (count > data.dataSize()) {
329 return BAD_VALUE;
330 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700331 DisplayState d;
332 Vector<DisplayState> displays;
333 displays.setCapacity(count);
334 for (size_t i=0 ; i<count ; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700335 if (d.read(data) == BAD_VALUE) {
336 return BAD_VALUE;
337 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700338 displays.add(d);
339 }
Jamie Gennis28378392011-10-12 17:39:00 -0700340 uint32_t flags = data.readInt32();
Mathias Agopian8b33f032012-07-24 20:43:54 -0700341 setTransactionState(state, displays, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -0700342 return NO_ERROR;
343 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800344 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700345 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800346 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -0700347 return NO_ERROR;
348 }
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800349 case CAPTURE_SCREEN: {
350 CHECK_INTERFACE(ISurfaceComposer, data, reply);
351 sp<IBinder> display = data.readStrongBinder();
352 sp<IGraphicBufferProducer> producer =
353 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
Dan Stozac1879002014-05-22 15:59:05 -0700354 Rect sourceCrop;
355 data.read(sourceCrop);
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800356 uint32_t reqWidth = data.readInt32();
357 uint32_t reqHeight = data.readInt32();
358 uint32_t minLayerZ = data.readInt32();
359 uint32_t maxLayerZ = data.readInt32();
Dan Stozac7014012014-02-14 15:03:43 -0800360 bool useIdentityTransform = static_cast<bool>(data.readInt32());
Riley Andrewsc3ebe662014-09-04 16:20:31 -0700361 uint32_t rotation = data.readInt32();
Dan Stozac7014012014-02-14 15:03:43 -0800362
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800363 status_t res = captureScreen(display, producer,
Dan Stozac1879002014-05-22 15:59:05 -0700364 sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ,
Riley Andrewsc3ebe662014-09-04 16:20:31 -0700365 useIdentityTransform,
366 static_cast<ISurfaceComposer::Rotation>(rotation));
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800367 reply->writeInt32(res);
Jesse Hall6c913be2013-08-08 12:15:49 -0700368 return NO_ERROR;
369 }
Jamie Gennis134f0422011-03-08 12:18:54 -0800370 case AUTHENTICATE_SURFACE: {
371 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -0800372 sp<IGraphicBufferProducer> bufferProducer =
373 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
374 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -0800375 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700376 return NO_ERROR;
377 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800378 case CREATE_DISPLAY_EVENT_CONNECTION: {
379 CHECK_INTERFACE(ISurfaceComposer, data, reply);
380 sp<IDisplayEventConnection> connection(createDisplayEventConnection());
381 reply->writeStrongBinder(connection->asBinder());
382 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700383 }
Mathias Agopiane57f2922012-08-09 16:29:12 -0700384 case CREATE_DISPLAY: {
385 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700386 String8 displayName = data.readString8();
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700387 bool secure = bool(data.readInt32());
388 sp<IBinder> display(createDisplay(displayName, secure));
Mathias Agopiane57f2922012-08-09 16:29:12 -0700389 reply->writeStrongBinder(display);
390 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700391 }
392 case DESTROY_DISPLAY: {
393 CHECK_INTERFACE(ISurfaceComposer, data, reply);
394 sp<IBinder> display = data.readStrongBinder();
395 destroyDisplay(display);
396 return NO_ERROR;
397 }
Mathias Agopiane57f2922012-08-09 16:29:12 -0700398 case GET_BUILT_IN_DISPLAY: {
399 CHECK_INTERFACE(ISurfaceComposer, data, reply);
400 int32_t id = data.readInt32();
401 sp<IBinder> display(getBuiltInDisplay(id));
402 reply->writeStrongBinder(display);
403 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700404 }
Dan Stoza7f7da322014-05-02 15:26:25 -0700405 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -0700406 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stoza7f7da322014-05-02 15:26:25 -0700407 Vector<DisplayInfo> configs;
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700408 sp<IBinder> display = data.readStrongBinder();
Dan Stoza7f7da322014-05-02 15:26:25 -0700409 status_t result = getDisplayConfigs(display, &configs);
410 reply->writeInt32(result);
411 if (result == NO_ERROR) {
412 reply->writeInt32(static_cast<int32_t>(configs.size()));
413 for (size_t c = 0; c < configs.size(); ++c) {
414 memcpy(reply->writeInplace(sizeof(DisplayInfo)),
415 &configs[c], sizeof(DisplayInfo));
416 }
417 }
418 return NO_ERROR;
419 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700420 case GET_DISPLAY_STATS: {
421 CHECK_INTERFACE(ISurfaceComposer, data, reply);
422 DisplayStatInfo stats;
423 sp<IBinder> display = data.readStrongBinder();
424 status_t result = getDisplayStats(display, &stats);
425 reply->writeInt32(result);
426 if (result == NO_ERROR) {
427 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
428 &stats, sizeof(DisplayStatInfo));
429 }
430 return NO_ERROR;
431 }
Dan Stoza7f7da322014-05-02 15:26:25 -0700432 case GET_ACTIVE_CONFIG: {
433 CHECK_INTERFACE(ISurfaceComposer, data, reply);
434 sp<IBinder> display = data.readStrongBinder();
435 int id = getActiveConfig(display);
436 reply->writeInt32(id);
437 return NO_ERROR;
438 }
439 case SET_ACTIVE_CONFIG: {
440 CHECK_INTERFACE(ISurfaceComposer, data, reply);
441 sp<IBinder> display = data.readStrongBinder();
442 int id = data.readInt32();
443 status_t result = setActiveConfig(display, id);
Mathias Agopianc666cae2012-07-25 18:56:13 -0700444 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700445 return NO_ERROR;
446 }
Svetoslavd85084b2014-03-20 10:28:31 -0700447 case CLEAR_ANIMATION_FRAME_STATS: {
448 CHECK_INTERFACE(ISurfaceComposer, data, reply);
449 status_t result = clearAnimationFrameStats();
450 reply->writeInt32(result);
451 return NO_ERROR;
452 }
453 case GET_ANIMATION_FRAME_STATS: {
454 CHECK_INTERFACE(ISurfaceComposer, data, reply);
455 FrameStats stats;
456 status_t result = getAnimationFrameStats(&stats);
457 reply->write(stats);
458 reply->writeInt32(result);
459 return NO_ERROR;
460 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700461 case SET_POWER_MODE: {
462 CHECK_INTERFACE(ISurfaceComposer, data, reply);
463 sp<IBinder> display = data.readStrongBinder();
464 int32_t mode = data.readInt32();
465 setPowerMode(display, mode);
466 return NO_ERROR;
467 }
Jesse Hall6c913be2013-08-08 12:15:49 -0700468 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700469 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -0700470 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800471 }
Jesse Hall6c913be2013-08-08 12:15:49 -0700472 // should be unreachable
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800473 return NO_ERROR;
474}
475
476// ----------------------------------------------------------------------------
477
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800478};