blob: a9fe5bf31941b04a06127f2f67ddc21de6a249a3 [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
Pablo Gamito6ee484d2020-07-30 14:26:28 +000023#include <android/gui/ITransactionTraceListener.h>
24
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070025#include <binder/Parcel.h>
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070026#include <binder/IPCThreadState.h>
27#include <binder/IServiceManager.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080028
Mathias Agopiand0566bc2011-11-17 17:49:17 -080029#include <gui/IDisplayEventConnection.h>
Andy McFadden2adaf042012-12-18 09:49:45 -080030#include <gui/IGraphicBufferProducer.h>
Dan Stoza84ab9372018-12-17 15:27:57 -080031#include <gui/IRegionSamplingListener.h>
Mathias Agopian2b5dd402017-02-07 17:36:19 -080032#include <gui/ISurfaceComposer.h>
33#include <gui/ISurfaceComposerClient.h>
Kalle Raitaa099a242017-01-11 11:17:29 -080034#include <gui/LayerDebugInfo.h>
Robert Carr4cdc58f2017-08-23 14:22:20 -070035#include <gui/LayerState.h>
Mathias Agopiand0566bc2011-11-17 17:49:17 -080036
Michael Wright28f24d02016-07-12 13:30:53 -070037#include <system/graphics.h>
38
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -080039#include <ui/DisplayConfig.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080040#include <ui/DisplayInfo.h>
Lajos Molnar67d8bd62014-09-11 14:58:45 -070041#include <ui/DisplayStatInfo.h>
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -080042#include <ui/DisplayState.h>
Dan Stozac4f471e2016-03-24 09:31:08 -070043#include <ui/HdrCapabilities.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080044
Jamie Gennis134f0422011-03-08 12:18:54 -080045#include <utils/Log.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -080046
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080047// ---------------------------------------------------------------------------
48
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080049namespace android {
50
Peiyong Lin9f034472018-03-28 15:29:00 -070051using ui::ColorMode;
52
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080053class BpSurfaceComposer : public BpInterface<ISurfaceComposer>
54{
55public:
Chih-Hung Hsiehe2347b72016-04-25 15:41:05 -070056 explicit BpSurfaceComposer(const sp<IBinder>& impl)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080057 : BpInterface<ISurfaceComposer>(impl)
58 {
59 }
60
Dan Stozad723bd72014-11-18 10:24:03 -080061 virtual ~BpSurfaceComposer();
62
Mathias Agopian7e27f052010-05-28 14:22:23 -070063 virtual sp<ISurfaceComposerClient> createConnection()
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080064 {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080065 Parcel data, reply;
66 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
67 remote()->transact(BnSurfaceComposer::CREATE_CONNECTION, data, &reply);
Mathias Agopian7e27f052010-05-28 14:22:23 -070068 return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080069 }
70
chaviw308ddba2020-08-11 16:23:51 -070071 virtual status_t setTransactionState(
Ady Abraham22c7b5c2020-09-22 19:33:40 -070072 int64_t frameTimelineVsyncId, const Vector<ComposerState>& state,
73 const Vector<DisplayState>& displays, uint32_t flags, const sp<IBinder>& applyToken,
74 const InputWindowCommands& commands, int64_t desiredPresentTime,
75 const client_cache_t& uncacheBuffer, bool hasListenerCallbacks,
76 const std::vector<ListenerCallbacks>& listenerCallbacks, uint64_t transactionId) {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080077 Parcel data, reply;
78 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Dan Stozad723bd72014-11-18 10:24:03 -080079
Ady Abraham22c7b5c2020-09-22 19:33:40 -070080 SAFE_PARCEL(data.writeInt64, frameTimelineVsyncId);
chaviw308ddba2020-08-11 16:23:51 -070081 SAFE_PARCEL(data.writeUint32, static_cast<uint32_t>(state.size()));
Dan Stozad723bd72014-11-18 10:24:03 -080082 for (const auto& s : state) {
chaviw308ddba2020-08-11 16:23:51 -070083 SAFE_PARCEL(s.write, data);
Mathias Agopian698c0872011-06-28 19:09:31 -070084 }
Dan Stozad723bd72014-11-18 10:24:03 -080085
chaviw308ddba2020-08-11 16:23:51 -070086 SAFE_PARCEL(data.writeUint32, static_cast<uint32_t>(displays.size()));
Dan Stozad723bd72014-11-18 10:24:03 -080087 for (const auto& d : displays) {
chaviw308ddba2020-08-11 16:23:51 -070088 SAFE_PARCEL(d.write, data);
Mathias Agopian8b33f032012-07-24 20:43:54 -070089 }
Dan Stozad723bd72014-11-18 10:24:03 -080090
chaviw308ddba2020-08-11 16:23:51 -070091 SAFE_PARCEL(data.writeUint32, flags);
92 SAFE_PARCEL(data.writeStrongBinder, applyToken);
93 SAFE_PARCEL(commands.write, data);
94 SAFE_PARCEL(data.writeInt64, desiredPresentTime);
95 SAFE_PARCEL(data.writeStrongBinder, uncacheBuffer.token.promote());
96 SAFE_PARCEL(data.writeUint64, uncacheBuffer.id);
97 SAFE_PARCEL(data.writeBool, hasListenerCallbacks);
Marissa Wall3dad52d2019-03-22 14:03:19 -070098
chaviw308ddba2020-08-11 16:23:51 -070099 SAFE_PARCEL(data.writeVectorSize, listenerCallbacks);
100 for (const auto& [listener, callbackIds] : listenerCallbacks) {
101 SAFE_PARCEL(data.writeStrongBinder, listener);
102 SAFE_PARCEL(data.writeInt64Vector, callbackIds);
Marissa Wall3dad52d2019-03-22 14:03:19 -0700103 }
104
Pablo Gamito7eb7ee72020-08-05 10:57:05 +0000105 SAFE_PARCEL(data.writeUint64, transactionId);
106
chaviw308ddba2020-08-11 16:23:51 -0700107 return remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800108 }
109
110 virtual void bootFinished()
111 {
112 Parcel data, reply;
113 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
114 remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply);
115 }
116
chaviwd2432892020-07-24 17:42:39 -0700117 virtual status_t captureDisplay(const DisplayCaptureArgs& args,
chaviw8ffc7b82020-08-18 11:25:37 -0700118 const sp<IScreenCaptureListener>& captureListener) {
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800119 Parcel data, reply;
120 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
chaviw308ddba2020-08-11 16:23:51 -0700121 SAFE_PARCEL(args.write, data);
chaviw8ffc7b82020-08-18 11:25:37 -0700122 SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(captureListener));
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000123
chaviw8ffc7b82020-08-18 11:25:37 -0700124 return remote()->transact(BnSurfaceComposer::CAPTURE_DISPLAY, data, &reply);
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800125 }
126
chaviwd2432892020-07-24 17:42:39 -0700127 virtual status_t captureDisplay(uint64_t displayOrLayerStack,
chaviw8ffc7b82020-08-18 11:25:37 -0700128 const sp<IScreenCaptureListener>& captureListener) {
chaviw93df2ea2019-04-30 16:45:12 -0700129 Parcel data, reply;
130 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
chaviw8ffc7b82020-08-18 11:25:37 -0700131 SAFE_PARCEL(data.writeUint64, displayOrLayerStack);
132 SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(captureListener));
chaviw93df2ea2019-04-30 16:45:12 -0700133
chaviw8ffc7b82020-08-18 11:25:37 -0700134 return remote()->transact(BnSurfaceComposer::CAPTURE_DISPLAY_BY_ID, data, &reply);
chaviw93df2ea2019-04-30 16:45:12 -0700135 }
136
chaviw3efadb12020-07-27 10:07:15 -0700137 virtual status_t captureLayers(const LayerCaptureArgs& args,
chaviw8ffc7b82020-08-18 11:25:37 -0700138 const sp<IScreenCaptureListener>& captureListener) {
chaviwa76b2712017-09-20 12:02:26 -0700139 Parcel data, reply;
140 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
chaviw308ddba2020-08-11 16:23:51 -0700141 SAFE_PARCEL(args.write, data);
chaviw8ffc7b82020-08-18 11:25:37 -0700142 SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(captureListener));
chaviw3efadb12020-07-27 10:07:15 -0700143
chaviw8ffc7b82020-08-18 11:25:37 -0700144 return remote()->transact(BnSurfaceComposer::CAPTURE_LAYERS, data, &reply);
chaviwa76b2712017-09-20 12:02:26 -0700145 }
146
Jamie Gennis582270d2011-08-17 18:19:00 -0700147 virtual bool authenticateSurfaceTexture(
Andy McFadden2adaf042012-12-18 09:49:45 -0800148 const sp<IGraphicBufferProducer>& bufferProducer) const
Jamie Gennis134f0422011-03-08 12:18:54 -0800149 {
150 Parcel data, reply;
151 int err = NO_ERROR;
152 err = data.writeInterfaceToken(
153 ISurfaceComposer::getInterfaceDescriptor());
154 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000155 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis134f0422011-03-08 12:18:54 -0800156 "interface descriptor: %s (%d)", strerror(-err), -err);
157 return false;
158 }
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800159 err = data.writeStrongBinder(IInterface::asBinder(bufferProducer));
Jamie Gennis134f0422011-03-08 12:18:54 -0800160 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000161 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis582270d2011-08-17 18:19:00 -0700162 "strong binder to parcel: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800163 return false;
164 }
165 err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
166 &reply);
167 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000168 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700169 "performing transaction: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800170 return false;
171 }
172 int32_t result = 0;
173 err = reply.readInt32(&result);
174 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000175 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700176 "retrieving result: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800177 return false;
178 }
179 return result != 0;
180 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800181
Brian Anderson6b376712017-04-04 10:51:39 -0700182 virtual status_t getSupportedFrameTimestamps(
183 std::vector<FrameEvent>* outSupported) const {
184 if (!outSupported) {
185 return UNEXPECTED_NULL;
186 }
187 outSupported->clear();
188
189 Parcel data, reply;
190
191 status_t err = data.writeInterfaceToken(
192 ISurfaceComposer::getInterfaceDescriptor());
193 if (err != NO_ERROR) {
194 return err;
195 }
196
197 err = remote()->transact(
198 BnSurfaceComposer::GET_SUPPORTED_FRAME_TIMESTAMPS,
199 data, &reply);
200 if (err != NO_ERROR) {
201 return err;
202 }
203
204 int32_t result = 0;
205 err = reply.readInt32(&result);
206 if (err != NO_ERROR) {
207 return err;
208 }
209 if (result != NO_ERROR) {
210 return result;
211 }
212
213 std::vector<int32_t> supported;
214 err = reply.readInt32Vector(&supported);
215 if (err != NO_ERROR) {
216 return err;
217 }
218
219 outSupported->reserve(supported.size());
220 for (int32_t s : supported) {
221 outSupported->push_back(static_cast<FrameEvent>(s));
222 }
223 return NO_ERROR;
224 }
225
Ady Abraham0f4a1b12019-06-04 16:04:04 -0700226 virtual sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource,
227 ConfigChanged configChanged) {
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800228 Parcel data, reply;
229 sp<IDisplayEventConnection> result;
230 int err = data.writeInterfaceToken(
231 ISurfaceComposer::getInterfaceDescriptor());
232 if (err != NO_ERROR) {
233 return result;
234 }
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700235 data.writeInt32(static_cast<int32_t>(vsyncSource));
Ady Abraham0f4a1b12019-06-04 16:04:04 -0700236 data.writeInt32(static_cast<int32_t>(configChanged));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800237 err = remote()->transact(
238 BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION,
239 data, &reply);
240 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000241 ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing "
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800242 "transaction: %s (%d)", strerror(-err), -err);
243 return result;
244 }
245 result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder());
246 return result;
247 }
Colin Cross8e533062012-06-07 13:17:52 -0700248
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700249 virtual sp<IBinder> createDisplay(const String8& displayName, bool secure)
Mathias Agopiane57f2922012-08-09 16:29:12 -0700250 {
251 Parcel data, reply;
252 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
chaviwd4a61642020-09-01 14:53:46 -0700253 status_t status = data.writeString8(displayName);
254 if (status) {
255 return nullptr;
256 }
257 status = data.writeBool(secure);
258 if (status) {
259 return nullptr;
260 }
261
262 status = remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply);
263 if (status) {
264 return nullptr;
265 }
266 sp<IBinder> display;
267 status = reply.readNullableStrongBinder(&display);
268 if (status) {
269 return nullptr;
270 }
271 return display;
Mathias Agopiane57f2922012-08-09 16:29:12 -0700272 }
273
Jesse Hall6c913be2013-08-08 12:15:49 -0700274 virtual void destroyDisplay(const sp<IBinder>& display)
275 {
276 Parcel data, reply;
277 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
278 data.writeStrongBinder(display);
279 remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply);
280 }
281
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800282 virtual std::vector<PhysicalDisplayId> getPhysicalDisplayIds() const {
Mathias Agopiane57f2922012-08-09 16:29:12 -0700283 Parcel data, reply;
284 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800285 if (remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_IDS, data, &reply) ==
286 NO_ERROR) {
Marin Shalamanova524a092020-07-27 21:39:55 +0200287 std::vector<uint64_t> rawIds;
288 if (reply.readUint64Vector(&rawIds) == NO_ERROR) {
289 std::vector<PhysicalDisplayId> displayIds(rawIds.size());
290 std::transform(rawIds.begin(), rawIds.end(), displayIds.begin(),
291 [](uint64_t rawId) { return PhysicalDisplayId(rawId); });
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800292 return displayIds;
293 }
294 }
295
296 return {};
297 }
298
299 virtual sp<IBinder> getPhysicalDisplayToken(PhysicalDisplayId displayId) const {
300 Parcel data, reply;
301 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Marin Shalamanova524a092020-07-27 21:39:55 +0200302 data.writeUint64(displayId.value);
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800303 remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_TOKEN, data, &reply);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700304 return reply.readStrongBinder();
305 }
306
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700307 virtual void setPowerMode(const sp<IBinder>& display, int mode)
Colin Cross8e533062012-06-07 13:17:52 -0700308 {
309 Parcel data, reply;
310 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700311 data.writeStrongBinder(display);
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700312 data.writeInt32(mode);
313 remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply);
Colin Cross8e533062012-06-07 13:17:52 -0700314 }
Mathias Agopian3094df32012-06-18 18:06:45 -0700315
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800316 virtual status_t getDisplayState(const sp<IBinder>& display, ui::DisplayState* state) {
317 Parcel data, reply;
318 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
319 data.writeStrongBinder(display);
320 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATE, data, &reply);
321 const status_t result = reply.readInt32();
322 if (result == NO_ERROR) {
323 memcpy(state, reply.readInplace(sizeof(ui::DisplayState)), sizeof(ui::DisplayState));
324 }
325 return result;
326 }
327
328 virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) {
329 Parcel data, reply;
330 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
331 data.writeStrongBinder(display);
332 remote()->transact(BnSurfaceComposer::GET_DISPLAY_INFO, data, &reply);
333 const status_t result = reply.readInt32();
Marin Shalamanov359a7e72020-02-17 17:03:07 +0100334 if (result != NO_ERROR) return result;
335 return reply.read(*info);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800336 }
337
338 virtual status_t getDisplayConfigs(const sp<IBinder>& display, Vector<DisplayConfig>* configs) {
Mathias Agopianc666cae2012-07-25 18:56:13 -0700339 Parcel data, reply;
340 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700341 data.writeStrongBinder(display);
Dan Stoza7f7da322014-05-02 15:26:25 -0700342 remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800343 const status_t result = reply.readInt32();
Dan Stoza7f7da322014-05-02 15:26:25 -0700344 if (result == NO_ERROR) {
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800345 const size_t numConfigs = reply.readUint32();
Dan Stoza7f7da322014-05-02 15:26:25 -0700346 configs->clear();
347 configs->resize(numConfigs);
348 for (size_t c = 0; c < numConfigs; ++c) {
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800349 memcpy(&(configs->editItemAt(c)), reply.readInplace(sizeof(DisplayConfig)),
350 sizeof(DisplayConfig));
Dan Stoza7f7da322014-05-02 15:26:25 -0700351 }
352 }
353 return result;
354 }
355
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700356 virtual status_t getDisplayStats(const sp<IBinder>& display,
357 DisplayStatInfo* stats)
358 {
359 Parcel data, reply;
360 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
361 data.writeStrongBinder(display);
362 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply);
363 status_t result = reply.readInt32();
364 if (result == NO_ERROR) {
365 memcpy(stats,
366 reply.readInplace(sizeof(DisplayStatInfo)),
367 sizeof(DisplayStatInfo));
368 }
369 return result;
370 }
371
Dan Stoza7f7da322014-05-02 15:26:25 -0700372 virtual int getActiveConfig(const sp<IBinder>& display)
373 {
374 Parcel data, reply;
375 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
376 data.writeStrongBinder(display);
377 remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply);
378 return reply.readInt32();
379 }
380
Michael Wright28f24d02016-07-12 13:30:53 -0700381 virtual status_t getDisplayColorModes(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700382 Vector<ColorMode>* outColorModes) {
Michael Wright28f24d02016-07-12 13:30:53 -0700383 Parcel data, reply;
384 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
385 if (result != NO_ERROR) {
386 ALOGE("getDisplayColorModes failed to writeInterfaceToken: %d", result);
387 return result;
388 }
389 result = data.writeStrongBinder(display);
390 if (result != NO_ERROR) {
391 ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result);
392 return result;
393 }
394 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply);
395 if (result != NO_ERROR) {
396 ALOGE("getDisplayColorModes failed to transact: %d", result);
397 return result;
398 }
399 result = static_cast<status_t>(reply.readInt32());
400 if (result == NO_ERROR) {
401 size_t numModes = reply.readUint32();
402 outColorModes->clear();
403 outColorModes->resize(numModes);
404 for (size_t i = 0; i < numModes; ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -0700405 outColorModes->replaceAt(static_cast<ColorMode>(reply.readInt32()), i);
Michael Wright28f24d02016-07-12 13:30:53 -0700406 }
407 }
408 return result;
409 }
410
Daniel Solomon42d04562019-01-20 21:03:19 -0800411 virtual status_t getDisplayNativePrimaries(const sp<IBinder>& display,
412 ui::DisplayPrimaries& primaries) {
413 Parcel data, reply;
414 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
415 if (result != NO_ERROR) {
416 ALOGE("getDisplayNativePrimaries failed to writeInterfaceToken: %d", result);
417 return result;
418 }
419 result = data.writeStrongBinder(display);
420 if (result != NO_ERROR) {
421 ALOGE("getDisplayNativePrimaries failed to writeStrongBinder: %d", result);
422 return result;
423 }
424 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_NATIVE_PRIMARIES, data, &reply);
425 if (result != NO_ERROR) {
426 ALOGE("getDisplayNativePrimaries failed to transact: %d", result);
427 return result;
428 }
429 result = reply.readInt32();
430 if (result == NO_ERROR) {
431 memcpy(&primaries, reply.readInplace(sizeof(ui::DisplayPrimaries)),
432 sizeof(ui::DisplayPrimaries));
433 }
434 return result;
435 }
436
Peiyong Lina52f0292018-03-14 17:26:31 -0700437 virtual ColorMode getActiveColorMode(const sp<IBinder>& display) {
Michael Wright28f24d02016-07-12 13:30:53 -0700438 Parcel data, reply;
439 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
440 if (result != NO_ERROR) {
441 ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700442 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700443 }
444 result = data.writeStrongBinder(display);
445 if (result != NO_ERROR) {
446 ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700447 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700448 }
449 result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply);
450 if (result != NO_ERROR) {
451 ALOGE("getActiveColorMode failed to transact: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700452 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700453 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700454 return static_cast<ColorMode>(reply.readInt32());
Michael Wright28f24d02016-07-12 13:30:53 -0700455 }
456
457 virtual status_t setActiveColorMode(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700458 ColorMode colorMode) {
Michael Wright28f24d02016-07-12 13:30:53 -0700459 Parcel data, reply;
460 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
461 if (result != NO_ERROR) {
462 ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result);
463 return result;
464 }
465 result = data.writeStrongBinder(display);
466 if (result != NO_ERROR) {
467 ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result);
468 return result;
469 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700470 result = data.writeInt32(static_cast<int32_t>(colorMode));
Michael Wright28f24d02016-07-12 13:30:53 -0700471 if (result != NO_ERROR) {
472 ALOGE("setActiveColorMode failed to writeInt32: %d", result);
473 return result;
474 }
475 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply);
476 if (result != NO_ERROR) {
477 ALOGE("setActiveColorMode failed to transact: %d", result);
478 return result;
479 }
480 return static_cast<status_t>(reply.readInt32());
481 }
482
Galia Peycheva5492cb52019-10-30 14:13:16 +0100483 virtual status_t getAutoLowLatencyModeSupport(const sp<IBinder>& display,
484 bool* outSupport) const {
485 Parcel data, reply;
486 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
487 status_t result = data.writeStrongBinder(display);
488 if (result != NO_ERROR) {
489 ALOGE("getAutoLowLatencyModeSupport failed to writeStrongBinder: %d", result);
490 return result;
491 }
492 result = remote()->transact(BnSurfaceComposer::GET_AUTO_LOW_LATENCY_MODE_SUPPORT, data,
493 &reply);
494 if (result != NO_ERROR) {
495 ALOGE("getAutoLowLatencyModeSupport failed to transact: %d", result);
496 return result;
497 }
498 return reply.readBool(outSupport);
499 }
500
501 virtual void setAutoLowLatencyMode(const sp<IBinder>& display, bool on) {
502 Parcel data, reply;
503 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
504 if (result != NO_ERROR) {
505 ALOGE("setAutoLowLatencyMode failed to writeInterfaceToken: %d", result);
506 return;
507 }
508
509 result = data.writeStrongBinder(display);
510 if (result != NO_ERROR) {
511 ALOGE("setAutoLowLatencyMode failed to writeStrongBinder: %d", result);
512 return;
513 }
514 result = data.writeBool(on);
515 if (result != NO_ERROR) {
516 ALOGE("setAutoLowLatencyMode failed to writeBool: %d", result);
517 return;
518 }
519 result = remote()->transact(BnSurfaceComposer::SET_AUTO_LOW_LATENCY_MODE, data, &reply);
520 if (result != NO_ERROR) {
521 ALOGE("setAutoLowLatencyMode failed to transact: %d", result);
522 return;
523 }
524 }
525
526 virtual status_t getGameContentTypeSupport(const sp<IBinder>& display, bool* outSupport) const {
527 Parcel data, reply;
528 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
529 status_t result = data.writeStrongBinder(display);
530 if (result != NO_ERROR) {
531 ALOGE("getGameContentTypeSupport failed to writeStrongBinder: %d", result);
532 return result;
533 }
534 result = remote()->transact(BnSurfaceComposer::GET_GAME_CONTENT_TYPE_SUPPORT, data, &reply);
535 if (result != NO_ERROR) {
536 ALOGE("getGameContentTypeSupport failed to transact: %d", result);
537 return result;
538 }
539 return reply.readBool(outSupport);
540 }
541
542 virtual void setGameContentType(const sp<IBinder>& display, bool on) {
543 Parcel data, reply;
544 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
545 if (result != NO_ERROR) {
546 ALOGE("setGameContentType failed to writeInterfaceToken: %d", result);
547 return;
548 }
549 result = data.writeStrongBinder(display);
550 if (result != NO_ERROR) {
551 ALOGE("setGameContentType failed to writeStrongBinder: %d", result);
552 return;
553 }
554 result = data.writeBool(on);
555 if (result != NO_ERROR) {
556 ALOGE("setGameContentType failed to writeBool: %d", result);
557 return;
558 }
559 result = remote()->transact(BnSurfaceComposer::SET_GAME_CONTENT_TYPE, data, &reply);
560 if (result != NO_ERROR) {
561 ALOGE("setGameContentType failed to transact: %d", result);
562 }
563 }
564
Svetoslavd85084b2014-03-20 10:28:31 -0700565 virtual status_t clearAnimationFrameStats() {
566 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700567 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
568 if (result != NO_ERROR) {
569 ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result);
570 return result;
571 }
572 result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply);
573 if (result != NO_ERROR) {
574 ALOGE("clearAnimationFrameStats failed to transact: %d", result);
575 return result;
576 }
Svetoslavd85084b2014-03-20 10:28:31 -0700577 return reply.readInt32();
578 }
579
580 virtual status_t getAnimationFrameStats(FrameStats* outStats) const {
581 Parcel data, reply;
582 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
583 remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply);
584 reply.read(*outStats);
585 return reply.readInt32();
586 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700587
588 virtual status_t getHdrCapabilities(const sp<IBinder>& display,
589 HdrCapabilities* outCapabilities) const {
590 Parcel data, reply;
591 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
592 status_t result = data.writeStrongBinder(display);
593 if (result != NO_ERROR) {
594 ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result);
595 return result;
596 }
597 result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES,
598 data, &reply);
599 if (result != NO_ERROR) {
600 ALOGE("getHdrCapabilities failed to transact: %d", result);
601 return result;
602 }
603 result = reply.readInt32();
604 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800605 result = reply.read(*outCapabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700606 }
607 return result;
608 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700609
610 virtual status_t enableVSyncInjections(bool enable) {
611 Parcel data, reply;
612 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
613 if (result != NO_ERROR) {
614 ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result);
615 return result;
616 }
617 result = data.writeBool(enable);
618 if (result != NO_ERROR) {
619 ALOGE("enableVSyncInjections failed to writeBool: %d", result);
620 return result;
621 }
Steven Moreland366eb422019-04-01 19:22:32 -0700622 result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS, data, &reply,
623 IBinder::FLAG_ONEWAY);
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700624 if (result != NO_ERROR) {
625 ALOGE("enableVSyncInjections failed to transact: %d", result);
626 return result;
627 }
628 return result;
629 }
630
631 virtual status_t injectVSync(nsecs_t when) {
632 Parcel data, reply;
633 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
634 if (result != NO_ERROR) {
635 ALOGE("injectVSync failed to writeInterfaceToken: %d", result);
636 return result;
637 }
638 result = data.writeInt64(when);
639 if (result != NO_ERROR) {
640 ALOGE("injectVSync failed to writeInt64: %d", result);
641 return result;
642 }
Steven Moreland366eb422019-04-01 19:22:32 -0700643 result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply,
644 IBinder::FLAG_ONEWAY);
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700645 if (result != NO_ERROR) {
646 ALOGE("injectVSync failed to transact: %d", result);
647 return result;
648 }
649 return result;
650 }
651
Vishnu Nair43bccf82020-06-05 10:53:37 -0700652 virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) {
Kalle Raitaa099a242017-01-11 11:17:29 -0800653 if (!outLayers) {
654 return UNEXPECTED_NULL;
655 }
656
657 Parcel data, reply;
658
659 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
660 if (err != NO_ERROR) {
661 return err;
662 }
663
664 err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply);
665 if (err != NO_ERROR) {
666 return err;
667 }
668
669 int32_t result = 0;
670 err = reply.readInt32(&result);
671 if (err != NO_ERROR) {
672 return err;
673 }
674 if (result != NO_ERROR) {
675 return result;
676 }
677
678 outLayers->clear();
679 return reply.readParcelableVector(outLayers);
680 }
Peiyong Lin0256f722018-08-31 15:45:10 -0700681
Peiyong Linc6780972018-10-28 15:24:08 -0700682 virtual status_t getCompositionPreference(ui::Dataspace* defaultDataspace,
683 ui::PixelFormat* defaultPixelFormat,
684 ui::Dataspace* wideColorGamutDataspace,
685 ui::PixelFormat* wideColorGamutPixelFormat) const {
Peiyong Lin0256f722018-08-31 15:45:10 -0700686 Parcel data, reply;
687 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
688 if (error != NO_ERROR) {
689 return error;
690 }
691 error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply);
692 if (error != NO_ERROR) {
693 return error;
694 }
695 error = static_cast<status_t>(reply.readInt32());
696 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -0700697 *defaultDataspace = static_cast<ui::Dataspace>(reply.readInt32());
698 *defaultPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
699 *wideColorGamutDataspace = static_cast<ui::Dataspace>(reply.readInt32());
700 *wideColorGamutPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
Peiyong Lin0256f722018-08-31 15:45:10 -0700701 }
702 return error;
703 }
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700704
Ady Abraham37965d42018-11-01 13:43:32 -0700705 virtual status_t getColorManagement(bool* outGetColorManagement) const {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700706 Parcel data, reply;
707 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Ady Abraham37965d42018-11-01 13:43:32 -0700708 remote()->transact(BnSurfaceComposer::GET_COLOR_MANAGEMENT, data, &reply);
709 bool result;
710 status_t err = reply.readBool(&result);
711 if (err == NO_ERROR) {
712 *outGetColorManagement = result;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700713 }
Ady Abraham37965d42018-11-01 13:43:32 -0700714 return err;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700715 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -0700716
717 virtual status_t getDisplayedContentSamplingAttributes(const sp<IBinder>& display,
718 ui::PixelFormat* outFormat,
719 ui::Dataspace* outDataspace,
720 uint8_t* outComponentMask) const {
721 if (!outFormat || !outDataspace || !outComponentMask) return BAD_VALUE;
722 Parcel data, reply;
723 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
724 data.writeStrongBinder(display);
725
726 status_t error =
727 remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES,
728 data, &reply);
729 if (error != NO_ERROR) {
730 return error;
731 }
732
733 uint32_t value = 0;
734 error = reply.readUint32(&value);
735 if (error != NO_ERROR) {
736 return error;
737 }
738 *outFormat = static_cast<ui::PixelFormat>(value);
739
740 error = reply.readUint32(&value);
741 if (error != NO_ERROR) {
742 return error;
743 }
744 *outDataspace = static_cast<ui::Dataspace>(value);
745
746 error = reply.readUint32(&value);
747 if (error != NO_ERROR) {
748 return error;
749 }
750 *outComponentMask = static_cast<uint8_t>(value);
751 return error;
752 }
Kevin DuBois74e53772018-11-19 10:52:38 -0800753
754 virtual status_t setDisplayContentSamplingEnabled(const sp<IBinder>& display, bool enable,
Dominik Laskowski470df5f2020-04-02 22:27:42 -0700755 uint8_t componentMask, uint64_t maxFrames) {
Kevin DuBois74e53772018-11-19 10:52:38 -0800756 Parcel data, reply;
757 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
758 data.writeStrongBinder(display);
759 data.writeBool(enable);
760 data.writeByte(static_cast<int8_t>(componentMask));
761 data.writeUint64(maxFrames);
762 status_t result =
763 remote()->transact(BnSurfaceComposer::SET_DISPLAY_CONTENT_SAMPLING_ENABLED, data,
764 &reply);
765 return result;
766 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700767
768 virtual status_t getDisplayedContentSample(const sp<IBinder>& display, uint64_t maxFrames,
769 uint64_t timestamp,
770 DisplayedFrameStats* outStats) const {
771 if (!outStats) return BAD_VALUE;
772
773 Parcel data, reply;
774 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
775 data.writeStrongBinder(display);
776 data.writeUint64(maxFrames);
777 data.writeUint64(timestamp);
778
779 status_t result =
780 remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLE, data, &reply);
781
782 if (result != NO_ERROR) {
783 return result;
784 }
785
786 result = reply.readUint64(&outStats->numFrames);
787 if (result != NO_ERROR) {
788 return result;
789 }
790
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800791 result = reply.readUint64Vector(&outStats->component_0_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700792 if (result != NO_ERROR) {
793 return result;
794 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800795 result = reply.readUint64Vector(&outStats->component_1_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700796 if (result != NO_ERROR) {
797 return result;
798 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800799 result = reply.readUint64Vector(&outStats->component_2_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700800 if (result != NO_ERROR) {
801 return result;
802 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800803 result = reply.readUint64Vector(&outStats->component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700804 return result;
805 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800806
807 virtual status_t getProtectedContentSupport(bool* outSupported) const {
808 Parcel data, reply;
809 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Peiyong Linb6888fa2019-01-28 13:20:58 -0800810 status_t error =
811 remote()->transact(BnSurfaceComposer::GET_PROTECTED_CONTENT_SUPPORT, data, &reply);
812 if (error != NO_ERROR) {
813 return error;
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800814 }
Peiyong Linb6888fa2019-01-28 13:20:58 -0800815 error = reply.readBool(outSupported);
816 return error;
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800817 }
Marissa Wallebc2c052019-01-16 19:16:55 -0800818
Peiyong Lin4f3fddf2019-01-24 17:21:24 -0800819 virtual status_t isWideColorDisplay(const sp<IBinder>& token,
820 bool* outIsWideColorDisplay) const {
821 Parcel data, reply;
822 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
823 if (error != NO_ERROR) {
824 return error;
825 }
826 error = data.writeStrongBinder(token);
827 if (error != NO_ERROR) {
828 return error;
829 }
830
831 error = remote()->transact(BnSurfaceComposer::IS_WIDE_COLOR_DISPLAY, data, &reply);
832 if (error != NO_ERROR) {
833 return error;
834 }
835 error = reply.readBool(outIsWideColorDisplay);
836 return error;
837 }
Dan Stoza84ab9372018-12-17 15:27:57 -0800838
839 virtual status_t addRegionSamplingListener(const Rect& samplingArea,
840 const sp<IBinder>& stopLayerHandle,
841 const sp<IRegionSamplingListener>& listener) {
842 Parcel data, reply;
843 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
844 if (error != NO_ERROR) {
845 ALOGE("addRegionSamplingListener: Failed to write interface token");
846 return error;
847 }
848 error = data.write(samplingArea);
849 if (error != NO_ERROR) {
850 ALOGE("addRegionSamplingListener: Failed to write sampling area");
851 return error;
852 }
853 error = data.writeStrongBinder(stopLayerHandle);
854 if (error != NO_ERROR) {
855 ALOGE("addRegionSamplingListener: Failed to write stop layer handle");
856 return error;
857 }
858 error = data.writeStrongBinder(IInterface::asBinder(listener));
859 if (error != NO_ERROR) {
860 ALOGE("addRegionSamplingListener: Failed to write listener");
861 return error;
862 }
863 error = remote()->transact(BnSurfaceComposer::ADD_REGION_SAMPLING_LISTENER, data, &reply);
864 if (error != NO_ERROR) {
865 ALOGE("addRegionSamplingListener: Failed to transact");
866 }
867 return error;
868 }
869
870 virtual status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) {
871 Parcel data, reply;
872 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
873 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800874 ALOGE("removeRegionSamplingListener: Failed to write interface token");
Dan Stoza84ab9372018-12-17 15:27:57 -0800875 return error;
876 }
877 error = data.writeStrongBinder(IInterface::asBinder(listener));
878 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800879 ALOGE("removeRegionSamplingListener: Failed to write listener");
Dan Stoza84ab9372018-12-17 15:27:57 -0800880 return error;
881 }
882 error = remote()->transact(BnSurfaceComposer::REMOVE_REGION_SAMPLING_LISTENER, data,
883 &reply);
884 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800885 ALOGE("removeRegionSamplingListener: Failed to transact");
Dan Stoza84ab9372018-12-17 15:27:57 -0800886 }
887 return error;
888 }
Ady Abraham838de062019-02-04 10:24:03 -0800889
Ana Krulec0782b882019-10-15 17:34:54 -0700890 virtual status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
Marin Shalamanov30b0b3c2020-10-13 19:15:06 +0200891 int32_t defaultConfig, bool allowGroupSwitching,
Steven Thomasf734df42020-04-13 21:09:28 -0700892 float primaryRefreshRateMin,
893 float primaryRefreshRateMax,
894 float appRequestRefreshRateMin,
895 float appRequestRefreshRateMax) {
Ana Krulec0782b882019-10-15 17:34:54 -0700896 Parcel data, reply;
897 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
898 if (result != NO_ERROR) {
899 ALOGE("setDesiredDisplayConfigSpecs: failed to writeInterfaceToken: %d", result);
900 return result;
901 }
902 result = data.writeStrongBinder(displayToken);
903 if (result != NO_ERROR) {
904 ALOGE("setDesiredDisplayConfigSpecs: failed to write display token: %d", result);
905 return result;
906 }
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100907 result = data.writeInt32(defaultConfig);
Ana Krulec0782b882019-10-15 17:34:54 -0700908 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100909 ALOGE("setDesiredDisplayConfigSpecs failed to write defaultConfig: %d", result);
Ana Krulec0782b882019-10-15 17:34:54 -0700910 return result;
911 }
Marin Shalamanov30b0b3c2020-10-13 19:15:06 +0200912 result = data.writeBool(allowGroupSwitching);
913 if (result != NO_ERROR) {
914 ALOGE("setDesiredDisplayConfigSpecs failed to write allowGroupSwitching: %d", result);
915 return result;
916 }
Steven Thomasf734df42020-04-13 21:09:28 -0700917 result = data.writeFloat(primaryRefreshRateMin);
Ana Krulec0782b882019-10-15 17:34:54 -0700918 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -0700919 ALOGE("setDesiredDisplayConfigSpecs failed to write primaryRefreshRateMin: %d", result);
Ana Krulec0782b882019-10-15 17:34:54 -0700920 return result;
921 }
Steven Thomasf734df42020-04-13 21:09:28 -0700922 result = data.writeFloat(primaryRefreshRateMax);
Ana Krulec0782b882019-10-15 17:34:54 -0700923 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -0700924 ALOGE("setDesiredDisplayConfigSpecs failed to write primaryRefreshRateMax: %d", result);
925 return result;
926 }
927 result = data.writeFloat(appRequestRefreshRateMin);
928 if (result != NO_ERROR) {
929 ALOGE("setDesiredDisplayConfigSpecs failed to write appRequestRefreshRateMin: %d",
930 result);
931 return result;
932 }
933 result = data.writeFloat(appRequestRefreshRateMax);
934 if (result != NO_ERROR) {
935 ALOGE("setDesiredDisplayConfigSpecs failed to write appRequestRefreshRateMax: %d",
936 result);
Ana Krulec0782b882019-10-15 17:34:54 -0700937 return result;
938 }
939
940 result = remote()->transact(BnSurfaceComposer::SET_DESIRED_DISPLAY_CONFIG_SPECS, data,
941 &reply);
942 if (result != NO_ERROR) {
943 ALOGE("setDesiredDisplayConfigSpecs failed to transact: %d", result);
944 return result;
945 }
946 return reply.readInt32();
947 }
948
Ana Krulec234bb162019-11-10 22:55:55 +0100949 virtual status_t getDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100950 int32_t* outDefaultConfig,
Marin Shalamanov30b0b3c2020-10-13 19:15:06 +0200951 bool* outAllowGroupSwitching,
Steven Thomasf734df42020-04-13 21:09:28 -0700952 float* outPrimaryRefreshRateMin,
953 float* outPrimaryRefreshRateMax,
954 float* outAppRequestRefreshRateMin,
955 float* outAppRequestRefreshRateMax) {
Marin Shalamanov30b0b3c2020-10-13 19:15:06 +0200956 if (!outDefaultConfig || !outAllowGroupSwitching || !outPrimaryRefreshRateMin ||
957 !outPrimaryRefreshRateMax || !outAppRequestRefreshRateMin ||
958 !outAppRequestRefreshRateMax) {
Steven Thomasf734df42020-04-13 21:09:28 -0700959 return BAD_VALUE;
960 }
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800961 Parcel data, reply;
962 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
963 if (result != NO_ERROR) {
Ana Krulec234bb162019-11-10 22:55:55 +0100964 ALOGE("getDesiredDisplayConfigSpecs failed to writeInterfaceToken: %d", result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800965 return result;
966 }
967 result = data.writeStrongBinder(displayToken);
968 if (result != NO_ERROR) {
Ana Krulec234bb162019-11-10 22:55:55 +0100969 ALOGE("getDesiredDisplayConfigSpecs failed to writeStrongBinder: %d", result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800970 return result;
971 }
Ana Krulec234bb162019-11-10 22:55:55 +0100972 result = remote()->transact(BnSurfaceComposer::GET_DESIRED_DISPLAY_CONFIG_SPECS, data,
973 &reply);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800974 if (result != NO_ERROR) {
Ana Krulec234bb162019-11-10 22:55:55 +0100975 ALOGE("getDesiredDisplayConfigSpecs failed to transact: %d", result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800976 return result;
977 }
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100978 result = reply.readInt32(outDefaultConfig);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800979 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100980 ALOGE("getDesiredDisplayConfigSpecs failed to read defaultConfig: %d", result);
Ana Krulec234bb162019-11-10 22:55:55 +0100981 return result;
982 }
Marin Shalamanov30b0b3c2020-10-13 19:15:06 +0200983 result = reply.readBool(outAllowGroupSwitching);
984 if (result != NO_ERROR) {
985 ALOGE("getDesiredDisplayConfigSpecs failed to read allowGroupSwitching: %d", result);
986 return result;
987 }
Steven Thomasf734df42020-04-13 21:09:28 -0700988 result = reply.readFloat(outPrimaryRefreshRateMin);
Ana Krulec234bb162019-11-10 22:55:55 +0100989 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -0700990 ALOGE("getDesiredDisplayConfigSpecs failed to read primaryRefreshRateMin: %d", result);
Ana Krulec234bb162019-11-10 22:55:55 +0100991 return result;
992 }
Steven Thomasf734df42020-04-13 21:09:28 -0700993 result = reply.readFloat(outPrimaryRefreshRateMax);
Ana Krulec234bb162019-11-10 22:55:55 +0100994 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -0700995 ALOGE("getDesiredDisplayConfigSpecs failed to read primaryRefreshRateMax: %d", result);
996 return result;
997 }
998 result = reply.readFloat(outAppRequestRefreshRateMin);
999 if (result != NO_ERROR) {
1000 ALOGE("getDesiredDisplayConfigSpecs failed to read appRequestRefreshRateMin: %d",
1001 result);
1002 return result;
1003 }
1004 result = reply.readFloat(outAppRequestRefreshRateMax);
1005 if (result != NO_ERROR) {
1006 ALOGE("getDesiredDisplayConfigSpecs failed to read appRequestRefreshRateMax: %d",
1007 result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -08001008 return result;
1009 }
1010 return reply.readInt32();
1011 }
Dan Gittik57e63c52019-01-18 16:37:54 +00001012
1013 virtual status_t getDisplayBrightnessSupport(const sp<IBinder>& displayToken,
1014 bool* outSupport) const {
1015 Parcel data, reply;
1016 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1017 if (error != NO_ERROR) {
1018 ALOGE("getDisplayBrightnessSupport: failed to write interface token: %d", error);
1019 return error;
1020 }
1021 error = data.writeStrongBinder(displayToken);
1022 if (error != NO_ERROR) {
1023 ALOGE("getDisplayBrightnessSupport: failed to write display token: %d", error);
1024 return error;
1025 }
1026 error = remote()->transact(BnSurfaceComposer::GET_DISPLAY_BRIGHTNESS_SUPPORT, data, &reply);
1027 if (error != NO_ERROR) {
1028 ALOGE("getDisplayBrightnessSupport: failed to transact: %d", error);
1029 return error;
1030 }
1031 bool support;
1032 error = reply.readBool(&support);
1033 if (error != NO_ERROR) {
1034 ALOGE("getDisplayBrightnessSupport: failed to read support: %d", error);
1035 return error;
1036 }
1037 *outSupport = support;
1038 return NO_ERROR;
1039 }
1040
Dominik Laskowski470df5f2020-04-02 22:27:42 -07001041 virtual status_t setDisplayBrightness(const sp<IBinder>& displayToken, float brightness) {
Dan Gittik57e63c52019-01-18 16:37:54 +00001042 Parcel data, reply;
1043 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1044 if (error != NO_ERROR) {
1045 ALOGE("setDisplayBrightness: failed to write interface token: %d", error);
1046 return error;
1047 }
1048 error = data.writeStrongBinder(displayToken);
1049 if (error != NO_ERROR) {
1050 ALOGE("setDisplayBrightness: failed to write display token: %d", error);
1051 return error;
1052 }
1053 error = data.writeFloat(brightness);
1054 if (error != NO_ERROR) {
1055 ALOGE("setDisplayBrightness: failed to write brightness: %d", error);
1056 return error;
1057 }
1058 error = remote()->transact(BnSurfaceComposer::SET_DISPLAY_BRIGHTNESS, data, &reply);
1059 if (error != NO_ERROR) {
1060 ALOGE("setDisplayBrightness: failed to transact: %d", error);
1061 return error;
1062 }
1063 return NO_ERROR;
1064 }
Ady Abraham8532d012019-05-08 14:50:56 -07001065
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001066 virtual status_t notifyPowerBoost(int32_t boostId) {
Ady Abraham8532d012019-05-08 14:50:56 -07001067 Parcel data, reply;
1068 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1069 if (error != NO_ERROR) {
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001070 ALOGE("notifyPowerBoost: failed to write interface token: %d", error);
Ady Abraham8532d012019-05-08 14:50:56 -07001071 return error;
1072 }
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001073 error = data.writeInt32(boostId);
Ady Abraham8532d012019-05-08 14:50:56 -07001074 if (error != NO_ERROR) {
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001075 ALOGE("notifyPowerBoost: failed to write boostId: %d", error);
Ady Abraham8532d012019-05-08 14:50:56 -07001076 return error;
1077 }
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001078 error = remote()->transact(BnSurfaceComposer::NOTIFY_POWER_BOOST, data, &reply,
Ady Abraham8532d012019-05-08 14:50:56 -07001079 IBinder::FLAG_ONEWAY);
1080 if (error != NO_ERROR) {
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001081 ALOGE("notifyPowerBoost: failed to transact: %d", error);
Ady Abraham8532d012019-05-08 14:50:56 -07001082 return error;
1083 }
1084 return NO_ERROR;
1085 }
Vishnu Nairb13bb952019-11-15 10:24:08 -08001086
1087 virtual status_t setGlobalShadowSettings(const half4& ambientColor, const half4& spotColor,
1088 float lightPosY, float lightPosZ, float lightRadius) {
1089 Parcel data, reply;
1090 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1091 if (error != NO_ERROR) {
1092 ALOGE("setGlobalShadowSettings: failed to write interface token: %d", error);
1093 return error;
1094 }
1095
1096 std::vector<float> shadowConfig = {ambientColor.r, ambientColor.g, ambientColor.b,
1097 ambientColor.a, spotColor.r, spotColor.g,
1098 spotColor.b, spotColor.a, lightPosY,
1099 lightPosZ, lightRadius};
1100
1101 error = data.writeFloatVector(shadowConfig);
1102 if (error != NO_ERROR) {
1103 ALOGE("setGlobalShadowSettings: failed to write shadowConfig: %d", error);
1104 return error;
1105 }
1106
1107 error = remote()->transact(BnSurfaceComposer::SET_GLOBAL_SHADOW_SETTINGS, data, &reply,
1108 IBinder::FLAG_ONEWAY);
1109 if (error != NO_ERROR) {
1110 ALOGE("setGlobalShadowSettings: failed to transact: %d", error);
1111 return error;
1112 }
1113 return NO_ERROR;
1114 }
Steven Thomas62a4cf82020-01-31 12:04:03 -08001115
1116 virtual status_t setFrameRate(const sp<IGraphicBufferProducer>& surface, float frameRate,
Marin Shalamanov46084422020-10-13 12:33:42 +02001117 int8_t compatibility, bool shouldBeSeamless) {
Steven Thomas62a4cf82020-01-31 12:04:03 -08001118 Parcel data, reply;
1119 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1120 if (err != NO_ERROR) {
1121 ALOGE("setFrameRate: failed writing interface token: %s (%d)", strerror(-err), -err);
1122 return err;
1123 }
1124
1125 err = data.writeStrongBinder(IInterface::asBinder(surface));
1126 if (err != NO_ERROR) {
1127 ALOGE("setFrameRate: failed writing strong binder: %s (%d)", strerror(-err), -err);
1128 return err;
1129 }
1130
1131 err = data.writeFloat(frameRate);
1132 if (err != NO_ERROR) {
1133 ALOGE("setFrameRate: failed writing float: %s (%d)", strerror(-err), -err);
1134 return err;
1135 }
1136
1137 err = data.writeByte(compatibility);
1138 if (err != NO_ERROR) {
1139 ALOGE("setFrameRate: failed writing byte: %s (%d)", strerror(-err), -err);
1140 return err;
1141 }
1142
Marin Shalamanov46084422020-10-13 12:33:42 +02001143 err = data.writeBool(shouldBeSeamless);
1144 if (err != NO_ERROR) {
1145 ALOGE("setFrameRate: failed writing bool: %s (%d)", strerror(-err), -err);
1146 return err;
1147 }
1148
Ady Abraham60e42ea2020-03-09 19:17:31 -07001149 err = remote()->transact(BnSurfaceComposer::SET_FRAME_RATE, data, &reply);
Steven Thomas62a4cf82020-01-31 12:04:03 -08001150 if (err != NO_ERROR) {
1151 ALOGE("setFrameRate: failed to transact: %s (%d)", strerror(-err), err);
1152 return err;
1153 }
Steven Thomasd4071902020-03-24 16:02:53 -07001154
1155 return reply.readInt32();
1156 }
1157
1158 virtual status_t acquireFrameRateFlexibilityToken(sp<IBinder>* outToken) {
1159 if (!outToken) return BAD_VALUE;
1160
1161 Parcel data, reply;
1162 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1163 if (err != NO_ERROR) {
1164 ALOGE("acquireFrameRateFlexibilityToken: failed writing interface token: %s (%d)",
1165 strerror(-err), -err);
1166 return err;
1167 }
1168
1169 err = remote()->transact(BnSurfaceComposer::ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN, data,
1170 &reply);
1171 if (err != NO_ERROR) {
1172 ALOGE("acquireFrameRateFlexibilityToken: failed to transact: %s (%d)", strerror(-err),
1173 err);
1174 return err;
1175 }
1176
1177 err = reply.readInt32();
1178 if (err != NO_ERROR) {
1179 ALOGE("acquireFrameRateFlexibilityToken: call failed: %s (%d)", strerror(-err), err);
1180 return err;
1181 }
1182
1183 err = reply.readStrongBinder(outToken);
1184 if (err != NO_ERROR) {
1185 ALOGE("acquireFrameRateFlexibilityToken: failed reading binder token: %s (%d)",
1186 strerror(-err), err);
1187 return err;
1188 }
1189
Steven Thomas62a4cf82020-01-31 12:04:03 -08001190 return NO_ERROR;
1191 }
Ady Abraham74e17562020-08-24 18:18:19 -07001192
1193 virtual status_t setFrameTimelineVsync(const sp<IGraphicBufferProducer>& surface,
1194 int64_t frameTimelineVsyncId) {
1195 Parcel data, reply;
1196 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1197 if (err != NO_ERROR) {
1198 ALOGE("setFrameTimelineVsync: failed writing interface token: %s (%d)", strerror(-err),
1199 -err);
1200 return err;
1201 }
1202
1203 err = data.writeStrongBinder(IInterface::asBinder(surface));
1204 if (err != NO_ERROR) {
1205 ALOGE("setFrameTimelineVsync: failed writing strong binder: %s (%d)", strerror(-err),
1206 -err);
1207 return err;
1208 }
1209
1210 err = data.writeInt64(frameTimelineVsyncId);
1211 if (err != NO_ERROR) {
1212 ALOGE("setFrameTimelineVsync: failed writing int64_t: %s (%d)", strerror(-err), -err);
1213 return err;
1214 }
1215
1216 err = remote()->transact(BnSurfaceComposer::SET_FRAME_TIMELINE_VSYNC, data, &reply);
1217 if (err != NO_ERROR) {
1218 ALOGE("setFrameTimelineVsync: failed to transact: %s (%d)", strerror(-err), err);
1219 return err;
1220 }
1221
1222 return reply.readInt32();
1223 }
Pablo Gamito6ee484d2020-07-30 14:26:28 +00001224
1225 virtual status_t addTransactionTraceListener(
1226 const sp<gui::ITransactionTraceListener>& listener) {
1227 Parcel data, reply;
1228 SAFE_PARCEL(data.writeInterfaceToken, ISurfaceComposer::getInterfaceDescriptor());
1229 SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(listener));
1230
1231 return remote()->transact(BnSurfaceComposer::ADD_TRANSACTION_TRACE_LISTENER, data, &reply);
1232 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001233};
1234
Dan Stozad723bd72014-11-18 10:24:03 -08001235// Out-of-line virtual method definition to trigger vtable emission in this
1236// translation unit (see clang warning -Wweak-vtables)
1237BpSurfaceComposer::~BpSurfaceComposer() {}
1238
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001239IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
1240
1241// ----------------------------------------------------------------------
1242
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001243status_t BnSurfaceComposer::onTransact(
1244 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
1245{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001246 switch(code) {
1247 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001248 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -08001249 sp<IBinder> b = IInterface::asBinder(createConnection());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001250 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -07001251 return NO_ERROR;
1252 }
Mathias Agopian698c0872011-06-28 19:09:31 -07001253 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001254 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -08001255
Ady Abraham22c7b5c2020-09-22 19:33:40 -07001256 int64_t frameTimelineVsyncId;
1257 SAFE_PARCEL(data.readInt64, &frameTimelineVsyncId);
chaviw308ddba2020-08-11 16:23:51 -07001258 uint32_t count = 0;
1259 SAFE_PARCEL_READ_SIZE(data.readUint32, &count, data.dataSize());
Mathias Agopian698c0872011-06-28 19:09:31 -07001260 Vector<ComposerState> state;
1261 state.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -08001262 for (size_t i = 0; i < count; i++) {
Marissa Wallc837b5e2018-10-12 10:04:44 -07001263 ComposerState s;
chaviw308ddba2020-08-11 16:23:51 -07001264 SAFE_PARCEL(s.read, data);
Mathias Agopian698c0872011-06-28 19:09:31 -07001265 state.add(s);
1266 }
Dan Stozad723bd72014-11-18 10:24:03 -08001267
chaviw308ddba2020-08-11 16:23:51 -07001268 SAFE_PARCEL_READ_SIZE(data.readUint32, &count, data.dataSize());
Mathias Agopian8b33f032012-07-24 20:43:54 -07001269 DisplayState d;
1270 Vector<DisplayState> displays;
1271 displays.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -08001272 for (size_t i = 0; i < count; i++) {
chaviw308ddba2020-08-11 16:23:51 -07001273 SAFE_PARCEL(d.read, data);
Mathias Agopian8b33f032012-07-24 20:43:54 -07001274 displays.add(d);
1275 }
Dan Stozad723bd72014-11-18 10:24:03 -08001276
chaviw308ddba2020-08-11 16:23:51 -07001277 uint32_t stateFlags = 0;
1278 SAFE_PARCEL(data.readUint32, &stateFlags);
1279 sp<IBinder> applyToken;
1280 SAFE_PARCEL(data.readStrongBinder, &applyToken);
chaviw273171b2018-12-26 11:46:30 -08001281 InputWindowCommands inputWindowCommands;
chaviw308ddba2020-08-11 16:23:51 -07001282 SAFE_PARCEL(inputWindowCommands.read, data);
Marissa Wall17b4e452018-12-26 16:32:34 -08001283
chaviw308ddba2020-08-11 16:23:51 -07001284 int64_t desiredPresentTime = 0;
1285 SAFE_PARCEL(data.readInt64, &desiredPresentTime);
Marissa Wall78b72202019-03-15 14:58:34 -07001286
Marissa Wall947d34e2019-03-29 14:03:53 -07001287 client_cache_t uncachedBuffer;
chaviw308ddba2020-08-11 16:23:51 -07001288 sp<IBinder> tmpBinder;
1289 SAFE_PARCEL(data.readNullableStrongBinder, &tmpBinder);
1290 uncachedBuffer.token = tmpBinder;
1291 SAFE_PARCEL(data.readUint64, &uncachedBuffer.id);
Marissa Wall78b72202019-03-15 14:58:34 -07001292
chaviw308ddba2020-08-11 16:23:51 -07001293 bool hasListenerCallbacks = false;
1294 SAFE_PARCEL(data.readBool, &hasListenerCallbacks);
Valerie Hau9dab9732019-08-20 09:29:25 -07001295
Marissa Wall3dad52d2019-03-22 14:03:19 -07001296 std::vector<ListenerCallbacks> listenerCallbacks;
chaviw308ddba2020-08-11 16:23:51 -07001297 int32_t listenersSize = 0;
1298 SAFE_PARCEL_READ_SIZE(data.readInt32, &listenersSize, data.dataSize());
Marissa Wall3dad52d2019-03-22 14:03:19 -07001299 for (int32_t i = 0; i < listenersSize; i++) {
chaviw308ddba2020-08-11 16:23:51 -07001300 SAFE_PARCEL(data.readStrongBinder, &tmpBinder);
Marissa Wall3dad52d2019-03-22 14:03:19 -07001301 std::vector<CallbackId> callbackIds;
chaviw308ddba2020-08-11 16:23:51 -07001302 SAFE_PARCEL(data.readInt64Vector, &callbackIds);
1303 listenerCallbacks.emplace_back(tmpBinder, callbackIds);
Marissa Wall3dad52d2019-03-22 14:03:19 -07001304 }
Pablo Gamito7eb7ee72020-08-05 10:57:05 +00001305
1306 uint64_t transactionId = -1;
1307 SAFE_PARCEL(data.readUint64, &transactionId);
1308
Ady Abraham22c7b5c2020-09-22 19:33:40 -07001309 return setTransactionState(frameTimelineVsyncId, state, displays, stateFlags,
1310 applyToken, inputWindowCommands, desiredPresentTime,
1311 uncachedBuffer, hasListenerCallbacks, listenerCallbacks,
1312 transactionId);
Jesse Hall6c913be2013-08-08 12:15:49 -07001313 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001314 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001315 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001316 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -07001317 return NO_ERROR;
1318 }
chaviwd2432892020-07-24 17:42:39 -07001319 case CAPTURE_DISPLAY: {
Mathias Agopian2a9fc492013-03-01 13:42:57 -08001320 CHECK_INTERFACE(ISurfaceComposer, data, reply);
chaviwd2432892020-07-24 17:42:39 -07001321 DisplayCaptureArgs args;
chaviw8ffc7b82020-08-18 11:25:37 -07001322 sp<IScreenCaptureListener> captureListener;
chaviw308ddba2020-08-11 16:23:51 -07001323 SAFE_PARCEL(args.read, data);
chaviw8ffc7b82020-08-18 11:25:37 -07001324 SAFE_PARCEL(data.readStrongBinder, &captureListener);
1325
1326 return captureDisplay(args, captureListener);
Jesse Hall6c913be2013-08-08 12:15:49 -07001327 }
chaviwd2432892020-07-24 17:42:39 -07001328 case CAPTURE_DISPLAY_BY_ID: {
chaviw93df2ea2019-04-30 16:45:12 -07001329 CHECK_INTERFACE(ISurfaceComposer, data, reply);
chaviw308ddba2020-08-11 16:23:51 -07001330 uint64_t displayOrLayerStack = 0;
chaviw8ffc7b82020-08-18 11:25:37 -07001331 sp<IScreenCaptureListener> captureListener;
chaviw308ddba2020-08-11 16:23:51 -07001332 SAFE_PARCEL(data.readUint64, &displayOrLayerStack);
chaviw8ffc7b82020-08-18 11:25:37 -07001333 SAFE_PARCEL(data.readStrongBinder, &captureListener);
1334
1335 return captureDisplay(displayOrLayerStack, captureListener);
chaviw93df2ea2019-04-30 16:45:12 -07001336 }
chaviwa76b2712017-09-20 12:02:26 -07001337 case CAPTURE_LAYERS: {
1338 CHECK_INTERFACE(ISurfaceComposer, data, reply);
chaviw3efadb12020-07-27 10:07:15 -07001339 LayerCaptureArgs args;
chaviw8ffc7b82020-08-18 11:25:37 -07001340 sp<IScreenCaptureListener> captureListener;
chaviw308ddba2020-08-11 16:23:51 -07001341 SAFE_PARCEL(args.read, data);
chaviw8ffc7b82020-08-18 11:25:37 -07001342 SAFE_PARCEL(data.readStrongBinder, &captureListener);
1343
1344 return captureLayers(args, captureListener);
chaviwa76b2712017-09-20 12:02:26 -07001345 }
Jamie Gennis134f0422011-03-08 12:18:54 -08001346 case AUTHENTICATE_SURFACE: {
1347 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -08001348 sp<IGraphicBufferProducer> bufferProducer =
1349 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
1350 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -08001351 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -07001352 return NO_ERROR;
1353 }
Brian Anderson6b376712017-04-04 10:51:39 -07001354 case GET_SUPPORTED_FRAME_TIMESTAMPS: {
1355 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1356 std::vector<FrameEvent> supportedTimestamps;
1357 status_t result = getSupportedFrameTimestamps(&supportedTimestamps);
1358 status_t err = reply->writeInt32(result);
1359 if (err != NO_ERROR) {
1360 return err;
1361 }
1362 if (result != NO_ERROR) {
1363 return result;
1364 }
1365
1366 std::vector<int32_t> supported;
1367 supported.reserve(supportedTimestamps.size());
1368 for (FrameEvent s : supportedTimestamps) {
1369 supported.push_back(static_cast<int32_t>(s));
1370 }
1371 return reply->writeInt32Vector(supported);
1372 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001373 case CREATE_DISPLAY_EVENT_CONNECTION: {
1374 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Ady Abraham0f4a1b12019-06-04 16:04:04 -07001375 auto vsyncSource = static_cast<ISurfaceComposer::VsyncSource>(data.readInt32());
1376 auto configChanged = static_cast<ISurfaceComposer::ConfigChanged>(data.readInt32());
1377
1378 sp<IDisplayEventConnection> connection(
1379 createDisplayEventConnection(vsyncSource, configChanged));
Marco Nelissen2ea926b2014-11-14 08:01:01 -08001380 reply->writeStrongBinder(IInterface::asBinder(connection));
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001381 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001382 }
Mathias Agopiane57f2922012-08-09 16:29:12 -07001383 case CREATE_DISPLAY: {
1384 CHECK_INTERFACE(ISurfaceComposer, data, reply);
chaviwd4a61642020-09-01 14:53:46 -07001385 String8 displayName;
1386 SAFE_PARCEL(data.readString8, &displayName);
1387 bool secure = false;
1388 SAFE_PARCEL(data.readBool, &secure);
1389 sp<IBinder> display = createDisplay(displayName, secure);
1390 SAFE_PARCEL(reply->writeStrongBinder, display);
Mathias Agopiane57f2922012-08-09 16:29:12 -07001391 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001392 }
1393 case DESTROY_DISPLAY: {
1394 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1395 sp<IBinder> display = data.readStrongBinder();
1396 destroyDisplay(display);
1397 return NO_ERROR;
1398 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001399 case GET_PHYSICAL_DISPLAY_TOKEN: {
Mathias Agopiane57f2922012-08-09 16:29:12 -07001400 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marin Shalamanova524a092020-07-27 21:39:55 +02001401 PhysicalDisplayId displayId(data.readUint64());
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001402 sp<IBinder> display = getPhysicalDisplayToken(displayId);
Mathias Agopiane57f2922012-08-09 16:29:12 -07001403 reply->writeStrongBinder(display);
1404 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001405 }
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001406 case GET_DISPLAY_STATE: {
1407 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1408 ui::DisplayState state;
1409 const sp<IBinder> display = data.readStrongBinder();
1410 const status_t result = getDisplayState(display, &state);
1411 reply->writeInt32(result);
1412 if (result == NO_ERROR) {
1413 memcpy(reply->writeInplace(sizeof(ui::DisplayState)), &state,
1414 sizeof(ui::DisplayState));
1415 }
1416 return NO_ERROR;
1417 }
1418 case GET_DISPLAY_INFO: {
1419 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1420 DisplayInfo info;
1421 const sp<IBinder> display = data.readStrongBinder();
1422 const status_t result = getDisplayInfo(display, &info);
1423 reply->writeInt32(result);
Marin Shalamanov359a7e72020-02-17 17:03:07 +01001424 if (result != NO_ERROR) return result;
1425 return reply->write(info);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001426 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001427 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -07001428 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001429 Vector<DisplayConfig> configs;
1430 const sp<IBinder> display = data.readStrongBinder();
1431 const status_t result = getDisplayConfigs(display, &configs);
Dan Stoza7f7da322014-05-02 15:26:25 -07001432 reply->writeInt32(result);
1433 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -08001434 reply->writeUint32(static_cast<uint32_t>(configs.size()));
Dan Stoza7f7da322014-05-02 15:26:25 -07001435 for (size_t c = 0; c < configs.size(); ++c) {
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001436 memcpy(reply->writeInplace(sizeof(DisplayConfig)), &configs[c],
1437 sizeof(DisplayConfig));
Dan Stoza7f7da322014-05-02 15:26:25 -07001438 }
1439 }
1440 return NO_ERROR;
1441 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -07001442 case GET_DISPLAY_STATS: {
1443 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1444 DisplayStatInfo stats;
1445 sp<IBinder> display = data.readStrongBinder();
1446 status_t result = getDisplayStats(display, &stats);
1447 reply->writeInt32(result);
1448 if (result == NO_ERROR) {
1449 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
1450 &stats, sizeof(DisplayStatInfo));
1451 }
1452 return NO_ERROR;
1453 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001454 case GET_ACTIVE_CONFIG: {
1455 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1456 sp<IBinder> display = data.readStrongBinder();
1457 int id = getActiveConfig(display);
1458 reply->writeInt32(id);
1459 return NO_ERROR;
1460 }
Michael Wright28f24d02016-07-12 13:30:53 -07001461 case GET_DISPLAY_COLOR_MODES: {
1462 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Lina52f0292018-03-14 17:26:31 -07001463 Vector<ColorMode> colorModes;
Michael Wright28f24d02016-07-12 13:30:53 -07001464 sp<IBinder> display = nullptr;
1465 status_t result = data.readStrongBinder(&display);
1466 if (result != NO_ERROR) {
1467 ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result);
1468 return result;
1469 }
1470 result = getDisplayColorModes(display, &colorModes);
1471 reply->writeInt32(result);
1472 if (result == NO_ERROR) {
1473 reply->writeUint32(static_cast<uint32_t>(colorModes.size()));
1474 for (size_t i = 0; i < colorModes.size(); ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -07001475 reply->writeInt32(static_cast<int32_t>(colorModes[i]));
Michael Wright28f24d02016-07-12 13:30:53 -07001476 }
1477 }
1478 return NO_ERROR;
1479 }
Daniel Solomon42d04562019-01-20 21:03:19 -08001480 case GET_DISPLAY_NATIVE_PRIMARIES: {
1481 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1482 ui::DisplayPrimaries primaries;
1483 sp<IBinder> display = nullptr;
1484
1485 status_t result = data.readStrongBinder(&display);
1486 if (result != NO_ERROR) {
1487 ALOGE("getDisplayNativePrimaries failed to readStrongBinder: %d", result);
1488 return result;
1489 }
1490
1491 result = getDisplayNativePrimaries(display, primaries);
1492 reply->writeInt32(result);
1493 if (result == NO_ERROR) {
1494 memcpy(reply->writeInplace(sizeof(ui::DisplayPrimaries)), &primaries,
1495 sizeof(ui::DisplayPrimaries));
1496 }
1497
1498 return NO_ERROR;
1499 }
Michael Wright28f24d02016-07-12 13:30:53 -07001500 case GET_ACTIVE_COLOR_MODE: {
1501 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1502 sp<IBinder> display = nullptr;
1503 status_t result = data.readStrongBinder(&display);
1504 if (result != NO_ERROR) {
1505 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1506 return result;
1507 }
Peiyong Lina52f0292018-03-14 17:26:31 -07001508 ColorMode colorMode = getActiveColorMode(display);
Michael Wright28f24d02016-07-12 13:30:53 -07001509 result = reply->writeInt32(static_cast<int32_t>(colorMode));
1510 return result;
1511 }
1512 case SET_ACTIVE_COLOR_MODE: {
1513 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1514 sp<IBinder> display = nullptr;
1515 status_t result = data.readStrongBinder(&display);
1516 if (result != NO_ERROR) {
1517 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1518 return result;
1519 }
1520 int32_t colorModeInt = 0;
1521 result = data.readInt32(&colorModeInt);
1522 if (result != NO_ERROR) {
1523 ALOGE("setActiveColorMode failed to readInt32: %d", result);
1524 return result;
1525 }
1526 result = setActiveColorMode(display,
Peiyong Lina52f0292018-03-14 17:26:31 -07001527 static_cast<ColorMode>(colorModeInt));
Michael Wright28f24d02016-07-12 13:30:53 -07001528 result = reply->writeInt32(result);
1529 return result;
1530 }
Galia Peycheva5492cb52019-10-30 14:13:16 +01001531
1532 case GET_AUTO_LOW_LATENCY_MODE_SUPPORT: {
1533 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1534 sp<IBinder> display = nullptr;
1535 status_t result = data.readStrongBinder(&display);
1536 if (result != NO_ERROR) {
1537 ALOGE("getAutoLowLatencyModeSupport failed to readStrongBinder: %d", result);
1538 return result;
1539 }
1540 bool supported = false;
1541 result = getAutoLowLatencyModeSupport(display, &supported);
1542 if (result == NO_ERROR) {
1543 result = reply->writeBool(supported);
1544 }
1545 return result;
1546 }
1547
1548 case SET_AUTO_LOW_LATENCY_MODE: {
1549 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1550 sp<IBinder> display = nullptr;
1551 status_t result = data.readStrongBinder(&display);
1552 if (result != NO_ERROR) {
1553 ALOGE("setAutoLowLatencyMode failed to readStrongBinder: %d", result);
1554 return result;
1555 }
1556 bool setAllm = false;
1557 result = data.readBool(&setAllm);
1558 if (result != NO_ERROR) {
1559 ALOGE("setAutoLowLatencyMode failed to readBool: %d", result);
1560 return result;
1561 }
1562 setAutoLowLatencyMode(display, setAllm);
1563 return result;
1564 }
1565
1566 case GET_GAME_CONTENT_TYPE_SUPPORT: {
1567 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1568 sp<IBinder> display = nullptr;
1569 status_t result = data.readStrongBinder(&display);
1570 if (result != NO_ERROR) {
1571 ALOGE("getGameContentTypeSupport failed to readStrongBinder: %d", result);
1572 return result;
1573 }
1574 bool supported = false;
1575 result = getGameContentTypeSupport(display, &supported);
1576 if (result == NO_ERROR) {
1577 result = reply->writeBool(supported);
1578 }
1579 return result;
1580 }
1581
1582 case SET_GAME_CONTENT_TYPE: {
1583 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1584 sp<IBinder> display = nullptr;
1585 status_t result = data.readStrongBinder(&display);
1586 if (result != NO_ERROR) {
1587 ALOGE("setGameContentType failed to readStrongBinder: %d", result);
1588 return result;
1589 }
1590 bool setGameContentTypeOn = false;
1591 result = data.readBool(&setGameContentTypeOn);
1592 if (result != NO_ERROR) {
1593 ALOGE("setGameContentType failed to readBool: %d", result);
1594 return result;
1595 }
1596 setGameContentType(display, setGameContentTypeOn);
1597 return result;
1598 }
1599
Svetoslavd85084b2014-03-20 10:28:31 -07001600 case CLEAR_ANIMATION_FRAME_STATS: {
1601 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1602 status_t result = clearAnimationFrameStats();
1603 reply->writeInt32(result);
1604 return NO_ERROR;
1605 }
1606 case GET_ANIMATION_FRAME_STATS: {
1607 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1608 FrameStats stats;
1609 status_t result = getAnimationFrameStats(&stats);
1610 reply->write(stats);
1611 reply->writeInt32(result);
1612 return NO_ERROR;
1613 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -07001614 case SET_POWER_MODE: {
1615 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1616 sp<IBinder> display = data.readStrongBinder();
1617 int32_t mode = data.readInt32();
1618 setPowerMode(display, mode);
1619 return NO_ERROR;
1620 }
Dan Stozac4f471e2016-03-24 09:31:08 -07001621 case GET_HDR_CAPABILITIES: {
1622 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1623 sp<IBinder> display = nullptr;
1624 status_t result = data.readStrongBinder(&display);
1625 if (result != NO_ERROR) {
1626 ALOGE("getHdrCapabilities failed to readStrongBinder: %d",
1627 result);
1628 return result;
1629 }
1630 HdrCapabilities capabilities;
1631 result = getHdrCapabilities(display, &capabilities);
1632 reply->writeInt32(result);
1633 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -08001634 reply->write(capabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -07001635 }
1636 return NO_ERROR;
1637 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -07001638 case ENABLE_VSYNC_INJECTIONS: {
1639 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1640 bool enable = false;
1641 status_t result = data.readBool(&enable);
1642 if (result != NO_ERROR) {
1643 ALOGE("enableVSyncInjections failed to readBool: %d", result);
1644 return result;
1645 }
1646 return enableVSyncInjections(enable);
1647 }
1648 case INJECT_VSYNC: {
1649 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1650 int64_t when = 0;
1651 status_t result = data.readInt64(&when);
1652 if (result != NO_ERROR) {
1653 ALOGE("enableVSyncInjections failed to readInt64: %d", result);
1654 return result;
1655 }
1656 return injectVSync(when);
1657 }
Kalle Raitaa099a242017-01-11 11:17:29 -08001658 case GET_LAYER_DEBUG_INFO: {
1659 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1660 std::vector<LayerDebugInfo> outLayers;
1661 status_t result = getLayerDebugInfo(&outLayers);
1662 reply->writeInt32(result);
1663 if (result == NO_ERROR)
1664 {
1665 result = reply->writeParcelableVector(outLayers);
1666 }
1667 return result;
1668 }
Peiyong Lin0256f722018-08-31 15:45:10 -07001669 case GET_COMPOSITION_PREFERENCE: {
1670 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Linc6780972018-10-28 15:24:08 -07001671 ui::Dataspace defaultDataspace;
1672 ui::PixelFormat defaultPixelFormat;
1673 ui::Dataspace wideColorGamutDataspace;
1674 ui::PixelFormat wideColorGamutPixelFormat;
1675 status_t error =
1676 getCompositionPreference(&defaultDataspace, &defaultPixelFormat,
1677 &wideColorGamutDataspace, &wideColorGamutPixelFormat);
Peiyong Lin0256f722018-08-31 15:45:10 -07001678 reply->writeInt32(error);
1679 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -07001680 reply->writeInt32(static_cast<int32_t>(defaultDataspace));
1681 reply->writeInt32(static_cast<int32_t>(defaultPixelFormat));
1682 reply->writeInt32(static_cast<int32_t>(wideColorGamutDataspace));
Peiyong Linaa3da6a2018-12-12 02:48:43 -08001683 reply->writeInt32(static_cast<int32_t>(wideColorGamutPixelFormat));
Peiyong Lin0256f722018-08-31 15:45:10 -07001684 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001685 return error;
Peiyong Lin0256f722018-08-31 15:45:10 -07001686 }
Ady Abraham37965d42018-11-01 13:43:32 -07001687 case GET_COLOR_MANAGEMENT: {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001688 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Ady Abraham37965d42018-11-01 13:43:32 -07001689 bool result;
1690 status_t error = getColorManagement(&result);
1691 if (error == NO_ERROR) {
1692 reply->writeBool(result);
1693 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001694 return error;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001695 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -07001696 case GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: {
1697 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1698
1699 sp<IBinder> display = data.readStrongBinder();
1700 ui::PixelFormat format;
1701 ui::Dataspace dataspace;
1702 uint8_t component = 0;
1703 auto result =
1704 getDisplayedContentSamplingAttributes(display, &format, &dataspace, &component);
1705 if (result == NO_ERROR) {
1706 reply->writeUint32(static_cast<uint32_t>(format));
1707 reply->writeUint32(static_cast<uint32_t>(dataspace));
1708 reply->writeUint32(static_cast<uint32_t>(component));
1709 }
1710 return result;
1711 }
Kevin DuBois74e53772018-11-19 10:52:38 -08001712 case SET_DISPLAY_CONTENT_SAMPLING_ENABLED: {
1713 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1714
1715 sp<IBinder> display = nullptr;
1716 bool enable = false;
1717 int8_t componentMask = 0;
1718 uint64_t maxFrames = 0;
1719 status_t result = data.readStrongBinder(&display);
1720 if (result != NO_ERROR) {
1721 ALOGE("setDisplayContentSamplingEnabled failure in reading Display token: %d",
1722 result);
1723 return result;
1724 }
1725
1726 result = data.readBool(&enable);
1727 if (result != NO_ERROR) {
1728 ALOGE("setDisplayContentSamplingEnabled failure in reading enable: %d", result);
1729 return result;
1730 }
1731
1732 result = data.readByte(static_cast<int8_t*>(&componentMask));
1733 if (result != NO_ERROR) {
1734 ALOGE("setDisplayContentSamplingEnabled failure in reading component mask: %d",
1735 result);
1736 return result;
1737 }
1738
1739 result = data.readUint64(&maxFrames);
1740 if (result != NO_ERROR) {
1741 ALOGE("setDisplayContentSamplingEnabled failure in reading max frames: %d", result);
1742 return result;
1743 }
1744
1745 return setDisplayContentSamplingEnabled(display, enable,
1746 static_cast<uint8_t>(componentMask), maxFrames);
1747 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001748 case GET_DISPLAYED_CONTENT_SAMPLE: {
1749 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1750
1751 sp<IBinder> display = data.readStrongBinder();
1752 uint64_t maxFrames = 0;
1753 uint64_t timestamp = 0;
1754
1755 status_t result = data.readUint64(&maxFrames);
1756 if (result != NO_ERROR) {
1757 ALOGE("getDisplayedContentSample failure in reading max frames: %d", result);
1758 return result;
1759 }
1760
1761 result = data.readUint64(&timestamp);
1762 if (result != NO_ERROR) {
1763 ALOGE("getDisplayedContentSample failure in reading timestamp: %d", result);
1764 return result;
1765 }
1766
1767 DisplayedFrameStats stats;
1768 result = getDisplayedContentSample(display, maxFrames, timestamp, &stats);
1769 if (result == NO_ERROR) {
1770 reply->writeUint64(stats.numFrames);
Kevin DuBois1d4c6a62018-12-12 13:59:46 -08001771 reply->writeUint64Vector(stats.component_0_sample);
1772 reply->writeUint64Vector(stats.component_1_sample);
1773 reply->writeUint64Vector(stats.component_2_sample);
1774 reply->writeUint64Vector(stats.component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001775 }
1776 return result;
1777 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001778 case GET_PROTECTED_CONTENT_SUPPORT: {
1779 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1780 bool result;
1781 status_t error = getProtectedContentSupport(&result);
1782 if (error == NO_ERROR) {
1783 reply->writeBool(result);
1784 }
1785 return error;
1786 }
Peiyong Lin4f3fddf2019-01-24 17:21:24 -08001787 case IS_WIDE_COLOR_DISPLAY: {
1788 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1789 sp<IBinder> display = nullptr;
1790 status_t error = data.readStrongBinder(&display);
1791 if (error != NO_ERROR) {
1792 return error;
1793 }
1794 bool result;
1795 error = isWideColorDisplay(display, &result);
1796 if (error == NO_ERROR) {
1797 reply->writeBool(result);
1798 }
1799 return error;
1800 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001801 case GET_PHYSICAL_DISPLAY_IDS: {
1802 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marin Shalamanova524a092020-07-27 21:39:55 +02001803 std::vector<PhysicalDisplayId> ids = getPhysicalDisplayIds();
1804 std::vector<uint64_t> rawIds(ids.size());
1805 std::transform(ids.begin(), ids.end(), rawIds.begin(),
1806 [](PhysicalDisplayId id) { return id.value; });
1807 return reply->writeUint64Vector(rawIds);
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001808 }
Dan Stoza84ab9372018-12-17 15:27:57 -08001809 case ADD_REGION_SAMPLING_LISTENER: {
1810 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1811 Rect samplingArea;
1812 status_t result = data.read(samplingArea);
1813 if (result != NO_ERROR) {
1814 ALOGE("addRegionSamplingListener: Failed to read sampling area");
1815 return result;
1816 }
1817 sp<IBinder> stopLayerHandle;
1818 result = data.readNullableStrongBinder(&stopLayerHandle);
1819 if (result != NO_ERROR) {
1820 ALOGE("addRegionSamplingListener: Failed to read stop layer handle");
1821 return result;
1822 }
1823 sp<IRegionSamplingListener> listener;
1824 result = data.readNullableStrongBinder(&listener);
1825 if (result != NO_ERROR) {
1826 ALOGE("addRegionSamplingListener: Failed to read listener");
1827 return result;
1828 }
1829 return addRegionSamplingListener(samplingArea, stopLayerHandle, listener);
1830 }
1831 case REMOVE_REGION_SAMPLING_LISTENER: {
1832 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1833 sp<IRegionSamplingListener> listener;
1834 status_t result = data.readNullableStrongBinder(&listener);
1835 if (result != NO_ERROR) {
1836 ALOGE("removeRegionSamplingListener: Failed to read listener");
1837 return result;
1838 }
1839 return removeRegionSamplingListener(listener);
1840 }
Ana Krulec0782b882019-10-15 17:34:54 -07001841 case SET_DESIRED_DISPLAY_CONFIG_SPECS: {
1842 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1843 sp<IBinder> displayToken = data.readStrongBinder();
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001844 int32_t defaultConfig;
1845 status_t result = data.readInt32(&defaultConfig);
Ana Krulec0782b882019-10-15 17:34:54 -07001846 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001847 ALOGE("setDesiredDisplayConfigSpecs: failed to read defaultConfig: %d", result);
Ana Krulec0782b882019-10-15 17:34:54 -07001848 return result;
1849 }
Marin Shalamanov30b0b3c2020-10-13 19:15:06 +02001850 bool allowGroupSwitching;
1851 result = data.readBool(&allowGroupSwitching);
1852 if (result != NO_ERROR) {
1853 ALOGE("setDesiredDisplayConfigSpecs: failed to read allowGroupSwitching: %d",
1854 result);
1855 return result;
1856 }
Steven Thomasf734df42020-04-13 21:09:28 -07001857 float primaryRefreshRateMin;
1858 result = data.readFloat(&primaryRefreshRateMin);
Ana Krulec0782b882019-10-15 17:34:54 -07001859 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001860 ALOGE("setDesiredDisplayConfigSpecs: failed to read primaryRefreshRateMin: %d",
1861 result);
Ana Krulec0782b882019-10-15 17:34:54 -07001862 return result;
1863 }
Steven Thomasf734df42020-04-13 21:09:28 -07001864 float primaryRefreshRateMax;
1865 result = data.readFloat(&primaryRefreshRateMax);
Ana Krulec0782b882019-10-15 17:34:54 -07001866 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001867 ALOGE("setDesiredDisplayConfigSpecs: failed to read primaryRefreshRateMax: %d",
1868 result);
Ana Krulec0782b882019-10-15 17:34:54 -07001869 return result;
1870 }
Steven Thomasf734df42020-04-13 21:09:28 -07001871 float appRequestRefreshRateMin;
1872 result = data.readFloat(&appRequestRefreshRateMin);
1873 if (result != NO_ERROR) {
1874 ALOGE("setDesiredDisplayConfigSpecs: failed to read appRequestRefreshRateMin: %d",
1875 result);
1876 return result;
1877 }
1878 float appRequestRefreshRateMax;
1879 result = data.readFloat(&appRequestRefreshRateMax);
1880 if (result != NO_ERROR) {
1881 ALOGE("setDesiredDisplayConfigSpecs: failed to read appRequestRefreshRateMax: %d",
1882 result);
1883 return result;
1884 }
Marin Shalamanov30b0b3c2020-10-13 19:15:06 +02001885 result = setDesiredDisplayConfigSpecs(displayToken, defaultConfig, allowGroupSwitching,
1886 primaryRefreshRateMin, primaryRefreshRateMax,
1887 appRequestRefreshRateMin,
1888 appRequestRefreshRateMax);
Ana Krulec0782b882019-10-15 17:34:54 -07001889 if (result != NO_ERROR) {
1890 ALOGE("setDesiredDisplayConfigSpecs: failed to call setDesiredDisplayConfigSpecs: "
1891 "%d",
1892 result);
1893 return result;
1894 }
1895 reply->writeInt32(result);
1896 return result;
1897 }
Ana Krulec234bb162019-11-10 22:55:55 +01001898 case GET_DESIRED_DISPLAY_CONFIG_SPECS: {
1899 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1900 sp<IBinder> displayToken = data.readStrongBinder();
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001901 int32_t defaultConfig;
Marin Shalamanov30b0b3c2020-10-13 19:15:06 +02001902 bool allowGroupSwitching;
Steven Thomasf734df42020-04-13 21:09:28 -07001903 float primaryRefreshRateMin;
1904 float primaryRefreshRateMax;
1905 float appRequestRefreshRateMin;
1906 float appRequestRefreshRateMax;
Ana Krulec234bb162019-11-10 22:55:55 +01001907
Steven Thomasf734df42020-04-13 21:09:28 -07001908 status_t result =
Marin Shalamanov30b0b3c2020-10-13 19:15:06 +02001909 getDesiredDisplayConfigSpecs(displayToken, &defaultConfig, &allowGroupSwitching,
Steven Thomasf734df42020-04-13 21:09:28 -07001910 &primaryRefreshRateMin, &primaryRefreshRateMax,
1911 &appRequestRefreshRateMin,
1912 &appRequestRefreshRateMax);
Ana Krulec234bb162019-11-10 22:55:55 +01001913 if (result != NO_ERROR) {
1914 ALOGE("getDesiredDisplayConfigSpecs: failed to get getDesiredDisplayConfigSpecs: "
1915 "%d",
1916 result);
1917 return result;
1918 }
1919
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001920 result = reply->writeInt32(defaultConfig);
Ana Krulec234bb162019-11-10 22:55:55 +01001921 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001922 ALOGE("getDesiredDisplayConfigSpecs: failed to write defaultConfig: %d", result);
Ana Krulec234bb162019-11-10 22:55:55 +01001923 return result;
1924 }
Marin Shalamanov30b0b3c2020-10-13 19:15:06 +02001925 result = reply->writeBool(allowGroupSwitching);
1926 if (result != NO_ERROR) {
1927 ALOGE("getDesiredDisplayConfigSpecs: failed to write allowGroupSwitching: %d",
1928 result);
1929 return result;
1930 }
Steven Thomasf734df42020-04-13 21:09:28 -07001931 result = reply->writeFloat(primaryRefreshRateMin);
Ana Krulec234bb162019-11-10 22:55:55 +01001932 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001933 ALOGE("getDesiredDisplayConfigSpecs: failed to write primaryRefreshRateMin: %d",
1934 result);
Ana Krulec234bb162019-11-10 22:55:55 +01001935 return result;
1936 }
Steven Thomasf734df42020-04-13 21:09:28 -07001937 result = reply->writeFloat(primaryRefreshRateMax);
Ana Krulec234bb162019-11-10 22:55:55 +01001938 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001939 ALOGE("getDesiredDisplayConfigSpecs: failed to write primaryRefreshRateMax: %d",
1940 result);
1941 return result;
1942 }
1943 result = reply->writeFloat(appRequestRefreshRateMin);
1944 if (result != NO_ERROR) {
1945 ALOGE("getDesiredDisplayConfigSpecs: failed to write appRequestRefreshRateMin: %d",
1946 result);
1947 return result;
1948 }
1949 result = reply->writeFloat(appRequestRefreshRateMax);
1950 if (result != NO_ERROR) {
1951 ALOGE("getDesiredDisplayConfigSpecs: failed to write appRequestRefreshRateMax: %d",
1952 result);
Ana Krulec234bb162019-11-10 22:55:55 +01001953 return result;
1954 }
1955 reply->writeInt32(result);
1956 return result;
1957 }
Dan Gittik57e63c52019-01-18 16:37:54 +00001958 case GET_DISPLAY_BRIGHTNESS_SUPPORT: {
1959 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1960 sp<IBinder> displayToken;
1961 status_t error = data.readNullableStrongBinder(&displayToken);
1962 if (error != NO_ERROR) {
1963 ALOGE("getDisplayBrightnessSupport: failed to read display token: %d", error);
1964 return error;
1965 }
1966 bool support = false;
1967 error = getDisplayBrightnessSupport(displayToken, &support);
1968 reply->writeBool(support);
1969 return error;
1970 }
1971 case SET_DISPLAY_BRIGHTNESS: {
1972 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1973 sp<IBinder> displayToken;
1974 status_t error = data.readNullableStrongBinder(&displayToken);
1975 if (error != NO_ERROR) {
1976 ALOGE("setDisplayBrightness: failed to read display token: %d", error);
1977 return error;
1978 }
1979 float brightness = -1.0f;
1980 error = data.readFloat(&brightness);
1981 if (error != NO_ERROR) {
1982 ALOGE("setDisplayBrightness: failed to read brightness: %d", error);
1983 return error;
1984 }
1985 return setDisplayBrightness(displayToken, brightness);
1986 }
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001987 case NOTIFY_POWER_BOOST: {
Ady Abraham8532d012019-05-08 14:50:56 -07001988 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001989 int32_t boostId;
1990 status_t error = data.readInt32(&boostId);
Ady Abraham8532d012019-05-08 14:50:56 -07001991 if (error != NO_ERROR) {
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001992 ALOGE("notifyPowerBoost: failed to read boostId: %d", error);
Ady Abraham8532d012019-05-08 14:50:56 -07001993 return error;
1994 }
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001995 return notifyPowerBoost(boostId);
Ady Abraham8532d012019-05-08 14:50:56 -07001996 }
Vishnu Nairb13bb952019-11-15 10:24:08 -08001997 case SET_GLOBAL_SHADOW_SETTINGS: {
1998 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1999
2000 std::vector<float> shadowConfig;
2001 status_t error = data.readFloatVector(&shadowConfig);
2002 if (error != NO_ERROR || shadowConfig.size() != 11) {
2003 ALOGE("setGlobalShadowSettings: failed to read shadowConfig: %d", error);
2004 return error;
2005 }
2006
2007 half4 ambientColor = {shadowConfig[0], shadowConfig[1], shadowConfig[2],
2008 shadowConfig[3]};
2009 half4 spotColor = {shadowConfig[4], shadowConfig[5], shadowConfig[6], shadowConfig[7]};
2010 float lightPosY = shadowConfig[8];
2011 float lightPosZ = shadowConfig[9];
2012 float lightRadius = shadowConfig[10];
2013 return setGlobalShadowSettings(ambientColor, spotColor, lightPosY, lightPosZ,
2014 lightRadius);
2015 }
Steven Thomas62a4cf82020-01-31 12:04:03 -08002016 case SET_FRAME_RATE: {
2017 CHECK_INTERFACE(ISurfaceComposer, data, reply);
2018 sp<IBinder> binder;
2019 status_t err = data.readStrongBinder(&binder);
2020 if (err != NO_ERROR) {
2021 ALOGE("setFrameRate: failed to read strong binder: %s (%d)", strerror(-err), -err);
2022 return err;
2023 }
2024 sp<IGraphicBufferProducer> surface = interface_cast<IGraphicBufferProducer>(binder);
2025 if (!surface) {
2026 ALOGE("setFrameRate: failed to cast to IGraphicBufferProducer: %s (%d)",
2027 strerror(-err), -err);
2028 return err;
2029 }
2030 float frameRate;
2031 err = data.readFloat(&frameRate);
2032 if (err != NO_ERROR) {
2033 ALOGE("setFrameRate: failed to read float: %s (%d)", strerror(-err), -err);
2034 return err;
2035 }
2036 int8_t compatibility;
2037 err = data.readByte(&compatibility);
2038 if (err != NO_ERROR) {
2039 ALOGE("setFrameRate: failed to read byte: %s (%d)", strerror(-err), -err);
2040 return err;
2041 }
Marin Shalamanov46084422020-10-13 12:33:42 +02002042 bool shouldBeSeamless;
2043 err = data.readBool(&shouldBeSeamless);
2044 if (err != NO_ERROR) {
2045 ALOGE("setFrameRate: failed to read bool: %s (%d)", strerror(-err), -err);
2046 return err;
2047 }
2048 status_t result = setFrameRate(surface, frameRate, compatibility, shouldBeSeamless);
Steven Thomas62a4cf82020-01-31 12:04:03 -08002049 reply->writeInt32(result);
2050 return NO_ERROR;
2051 }
Steven Thomasd4071902020-03-24 16:02:53 -07002052 case ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN: {
2053 CHECK_INTERFACE(ISurfaceComposer, data, reply);
2054 sp<IBinder> token;
2055 status_t result = acquireFrameRateFlexibilityToken(&token);
2056 reply->writeInt32(result);
2057 if (result == NO_ERROR) {
2058 reply->writeStrongBinder(token);
2059 }
2060 return NO_ERROR;
2061 }
Ady Abraham74e17562020-08-24 18:18:19 -07002062 case SET_FRAME_TIMELINE_VSYNC: {
2063 CHECK_INTERFACE(ISurfaceComposer, data, reply);
2064 sp<IBinder> binder;
2065 status_t err = data.readStrongBinder(&binder);
2066 if (err != NO_ERROR) {
2067 ALOGE("setFrameTimelineVsync: failed to read strong binder: %s (%d)",
2068 strerror(-err), -err);
2069 return err;
2070 }
2071 sp<IGraphicBufferProducer> surface = interface_cast<IGraphicBufferProducer>(binder);
2072 if (!surface) {
2073 ALOGE("setFrameTimelineVsync: failed to cast to IGraphicBufferProducer: %s (%d)",
2074 strerror(-err), -err);
2075 return err;
2076 }
2077 int64_t frameTimelineVsyncId;
2078 err = data.readInt64(&frameTimelineVsyncId);
2079 if (err != NO_ERROR) {
2080 ALOGE("setFrameTimelineVsync: failed to read int64_t: %s (%d)", strerror(-err),
2081 -err);
2082 return err;
2083 }
2084
2085 status_t result = setFrameTimelineVsync(surface, frameTimelineVsyncId);
2086 reply->writeInt32(result);
2087 return NO_ERROR;
2088 }
Pablo Gamito6ee484d2020-07-30 14:26:28 +00002089 case ADD_TRANSACTION_TRACE_LISTENER: {
2090 CHECK_INTERFACE(ISurfaceComposer, data, reply);
2091 sp<gui::ITransactionTraceListener> listener;
2092 SAFE_PARCEL(data.readStrongBinder, &listener);
2093
2094 return addTransactionTraceListener(listener);
2095 }
Jesse Hall6c913be2013-08-08 12:15:49 -07002096 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -07002097 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -07002098 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08002099 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08002100}
2101
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08002102} // namespace android