blob: 0ac493dab194b23451d8ddb93c5defda4e82034d [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// tag as surfaceflinger
18#define LOG_TAG "SurfaceFlinger"
19
20#include <stdint.h>
21#include <sys/types.h>
22
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070023#include <binder/Parcel.h>
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070024#include <binder/IPCThreadState.h>
25#include <binder/IServiceManager.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080026
Mathias Agopiand0566bc2011-11-17 17:49:17 -080027#include <gui/IDisplayEventConnection.h>
Andy McFadden2adaf042012-12-18 09:49:45 -080028#include <gui/IGraphicBufferProducer.h>
Dan Stoza84ab9372018-12-17 15:27:57 -080029#include <gui/IRegionSamplingListener.h>
Mathias Agopian2b5dd402017-02-07 17:36:19 -080030#include <gui/ISurfaceComposer.h>
31#include <gui/ISurfaceComposerClient.h>
Kalle Raitaa099a242017-01-11 11:17:29 -080032#include <gui/LayerDebugInfo.h>
Robert Carr4cdc58f2017-08-23 14:22:20 -070033#include <gui/LayerState.h>
Mathias Agopiand0566bc2011-11-17 17:49:17 -080034
Michael Wright28f24d02016-07-12 13:30:53 -070035#include <system/graphics.h>
36
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -080037#include <ui/DisplayConfig.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080038#include <ui/DisplayInfo.h>
Lajos Molnar67d8bd62014-09-11 14:58:45 -070039#include <ui/DisplayStatInfo.h>
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -080040#include <ui/DisplayState.h>
Dan Stozac4f471e2016-03-24 09:31:08 -070041#include <ui/HdrCapabilities.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080042
Jamie Gennis134f0422011-03-08 12:18:54 -080043#include <utils/Log.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -080044
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080045// ---------------------------------------------------------------------------
46
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080047namespace android {
48
Peiyong Lin9f034472018-03-28 15:29:00 -070049using ui::ColorMode;
50
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080051class BpSurfaceComposer : public BpInterface<ISurfaceComposer>
52{
53public:
Chih-Hung Hsiehe2347b72016-04-25 15:41:05 -070054 explicit BpSurfaceComposer(const sp<IBinder>& impl)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080055 : BpInterface<ISurfaceComposer>(impl)
56 {
57 }
58
Dan Stozad723bd72014-11-18 10:24:03 -080059 virtual ~BpSurfaceComposer();
60
Mathias Agopian7e27f052010-05-28 14:22:23 -070061 virtual sp<ISurfaceComposerClient> createConnection()
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080062 {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080063 Parcel data, reply;
64 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
65 remote()->transact(BnSurfaceComposer::CREATE_CONNECTION, data, &reply);
Mathias Agopian7e27f052010-05-28 14:22:23 -070066 return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080067 }
68
chaviw308ddba2020-08-11 16:23:51 -070069 virtual status_t setTransactionState(
70 const Vector<ComposerState>& state, const Vector<DisplayState>& displays,
71 uint32_t flags, const sp<IBinder>& applyToken, const InputWindowCommands& commands,
72 int64_t desiredPresentTime, const client_cache_t& uncacheBuffer,
73 bool hasListenerCallbacks, const std::vector<ListenerCallbacks>& listenerCallbacks) {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080074 Parcel data, reply;
75 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Dan Stozad723bd72014-11-18 10:24:03 -080076
chaviw308ddba2020-08-11 16:23:51 -070077 SAFE_PARCEL(data.writeUint32, static_cast<uint32_t>(state.size()));
Dan Stozad723bd72014-11-18 10:24:03 -080078 for (const auto& s : state) {
chaviw308ddba2020-08-11 16:23:51 -070079 SAFE_PARCEL(s.write, data);
Mathias Agopian698c0872011-06-28 19:09:31 -070080 }
Dan Stozad723bd72014-11-18 10:24:03 -080081
chaviw308ddba2020-08-11 16:23:51 -070082 SAFE_PARCEL(data.writeUint32, static_cast<uint32_t>(displays.size()));
Dan Stozad723bd72014-11-18 10:24:03 -080083 for (const auto& d : displays) {
chaviw308ddba2020-08-11 16:23:51 -070084 SAFE_PARCEL(d.write, data);
Mathias Agopian8b33f032012-07-24 20:43:54 -070085 }
Dan Stozad723bd72014-11-18 10:24:03 -080086
chaviw308ddba2020-08-11 16:23:51 -070087 SAFE_PARCEL(data.writeUint32, flags);
88 SAFE_PARCEL(data.writeStrongBinder, applyToken);
89 SAFE_PARCEL(commands.write, data);
90 SAFE_PARCEL(data.writeInt64, desiredPresentTime);
91 SAFE_PARCEL(data.writeStrongBinder, uncacheBuffer.token.promote());
92 SAFE_PARCEL(data.writeUint64, uncacheBuffer.id);
93 SAFE_PARCEL(data.writeBool, hasListenerCallbacks);
Marissa Wall3dad52d2019-03-22 14:03:19 -070094
chaviw308ddba2020-08-11 16:23:51 -070095 SAFE_PARCEL(data.writeVectorSize, listenerCallbacks);
96 for (const auto& [listener, callbackIds] : listenerCallbacks) {
97 SAFE_PARCEL(data.writeStrongBinder, listener);
98 SAFE_PARCEL(data.writeInt64Vector, callbackIds);
Marissa Wall3dad52d2019-03-22 14:03:19 -070099 }
100
chaviw308ddba2020-08-11 16:23:51 -0700101 return remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800102 }
103
104 virtual void bootFinished()
105 {
106 Parcel data, reply;
107 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
108 remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply);
109 }
110
chaviwd2432892020-07-24 17:42:39 -0700111 virtual status_t captureDisplay(const DisplayCaptureArgs& args,
chaviw8ffc7b82020-08-18 11:25:37 -0700112 const sp<IScreenCaptureListener>& captureListener) {
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800113 Parcel data, reply;
114 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
chaviw308ddba2020-08-11 16:23:51 -0700115 SAFE_PARCEL(args.write, data);
chaviw8ffc7b82020-08-18 11:25:37 -0700116 SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(captureListener));
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000117
chaviw8ffc7b82020-08-18 11:25:37 -0700118 return remote()->transact(BnSurfaceComposer::CAPTURE_DISPLAY, data, &reply);
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800119 }
120
chaviwd2432892020-07-24 17:42:39 -0700121 virtual status_t captureDisplay(uint64_t displayOrLayerStack,
chaviw8ffc7b82020-08-18 11:25:37 -0700122 const sp<IScreenCaptureListener>& captureListener) {
chaviw93df2ea2019-04-30 16:45:12 -0700123 Parcel data, reply;
124 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
chaviw8ffc7b82020-08-18 11:25:37 -0700125 SAFE_PARCEL(data.writeUint64, displayOrLayerStack);
126 SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(captureListener));
chaviw93df2ea2019-04-30 16:45:12 -0700127
chaviw8ffc7b82020-08-18 11:25:37 -0700128 return remote()->transact(BnSurfaceComposer::CAPTURE_DISPLAY_BY_ID, data, &reply);
chaviw93df2ea2019-04-30 16:45:12 -0700129 }
130
chaviw3efadb12020-07-27 10:07:15 -0700131 virtual status_t captureLayers(const LayerCaptureArgs& args,
chaviw8ffc7b82020-08-18 11:25:37 -0700132 const sp<IScreenCaptureListener>& captureListener) {
chaviwa76b2712017-09-20 12:02:26 -0700133 Parcel data, reply;
134 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
chaviw308ddba2020-08-11 16:23:51 -0700135 SAFE_PARCEL(args.write, data);
chaviw8ffc7b82020-08-18 11:25:37 -0700136 SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(captureListener));
chaviw3efadb12020-07-27 10:07:15 -0700137
chaviw8ffc7b82020-08-18 11:25:37 -0700138 return remote()->transact(BnSurfaceComposer::CAPTURE_LAYERS, data, &reply);
chaviwa76b2712017-09-20 12:02:26 -0700139 }
140
Jamie Gennis582270d2011-08-17 18:19:00 -0700141 virtual bool authenticateSurfaceTexture(
Andy McFadden2adaf042012-12-18 09:49:45 -0800142 const sp<IGraphicBufferProducer>& bufferProducer) const
Jamie Gennis134f0422011-03-08 12:18:54 -0800143 {
144 Parcel data, reply;
145 int err = NO_ERROR;
146 err = data.writeInterfaceToken(
147 ISurfaceComposer::getInterfaceDescriptor());
148 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000149 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis134f0422011-03-08 12:18:54 -0800150 "interface descriptor: %s (%d)", strerror(-err), -err);
151 return false;
152 }
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800153 err = data.writeStrongBinder(IInterface::asBinder(bufferProducer));
Jamie Gennis134f0422011-03-08 12:18:54 -0800154 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000155 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis582270d2011-08-17 18:19:00 -0700156 "strong binder to parcel: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800157 return false;
158 }
159 err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
160 &reply);
161 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000162 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700163 "performing transaction: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800164 return false;
165 }
166 int32_t result = 0;
167 err = reply.readInt32(&result);
168 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000169 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700170 "retrieving result: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800171 return false;
172 }
173 return result != 0;
174 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800175
Brian Anderson6b376712017-04-04 10:51:39 -0700176 virtual status_t getSupportedFrameTimestamps(
177 std::vector<FrameEvent>* outSupported) const {
178 if (!outSupported) {
179 return UNEXPECTED_NULL;
180 }
181 outSupported->clear();
182
183 Parcel data, reply;
184
185 status_t err = data.writeInterfaceToken(
186 ISurfaceComposer::getInterfaceDescriptor());
187 if (err != NO_ERROR) {
188 return err;
189 }
190
191 err = remote()->transact(
192 BnSurfaceComposer::GET_SUPPORTED_FRAME_TIMESTAMPS,
193 data, &reply);
194 if (err != NO_ERROR) {
195 return err;
196 }
197
198 int32_t result = 0;
199 err = reply.readInt32(&result);
200 if (err != NO_ERROR) {
201 return err;
202 }
203 if (result != NO_ERROR) {
204 return result;
205 }
206
207 std::vector<int32_t> supported;
208 err = reply.readInt32Vector(&supported);
209 if (err != NO_ERROR) {
210 return err;
211 }
212
213 outSupported->reserve(supported.size());
214 for (int32_t s : supported) {
215 outSupported->push_back(static_cast<FrameEvent>(s));
216 }
217 return NO_ERROR;
218 }
219
Ady Abraham0f4a1b12019-06-04 16:04:04 -0700220 virtual sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource,
221 ConfigChanged configChanged) {
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800222 Parcel data, reply;
223 sp<IDisplayEventConnection> result;
224 int err = data.writeInterfaceToken(
225 ISurfaceComposer::getInterfaceDescriptor());
226 if (err != NO_ERROR) {
227 return result;
228 }
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700229 data.writeInt32(static_cast<int32_t>(vsyncSource));
Ady Abraham0f4a1b12019-06-04 16:04:04 -0700230 data.writeInt32(static_cast<int32_t>(configChanged));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800231 err = remote()->transact(
232 BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION,
233 data, &reply);
234 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000235 ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing "
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800236 "transaction: %s (%d)", strerror(-err), -err);
237 return result;
238 }
239 result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder());
240 return result;
241 }
Colin Cross8e533062012-06-07 13:17:52 -0700242
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700243 virtual sp<IBinder> createDisplay(const String8& displayName, bool secure)
Mathias Agopiane57f2922012-08-09 16:29:12 -0700244 {
245 Parcel data, reply;
246 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700247 data.writeString8(displayName);
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700248 data.writeInt32(secure ? 1 : 0);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700249 remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply);
250 return reply.readStrongBinder();
251 }
252
Jesse Hall6c913be2013-08-08 12:15:49 -0700253 virtual void destroyDisplay(const sp<IBinder>& display)
254 {
255 Parcel data, reply;
256 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
257 data.writeStrongBinder(display);
258 remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply);
259 }
260
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800261 virtual std::vector<PhysicalDisplayId> getPhysicalDisplayIds() const {
Mathias Agopiane57f2922012-08-09 16:29:12 -0700262 Parcel data, reply;
263 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800264 if (remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_IDS, data, &reply) ==
265 NO_ERROR) {
Marin Shalamanova524a092020-07-27 21:39:55 +0200266 std::vector<uint64_t> rawIds;
267 if (reply.readUint64Vector(&rawIds) == NO_ERROR) {
268 std::vector<PhysicalDisplayId> displayIds(rawIds.size());
269 std::transform(rawIds.begin(), rawIds.end(), displayIds.begin(),
270 [](uint64_t rawId) { return PhysicalDisplayId(rawId); });
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800271 return displayIds;
272 }
273 }
274
275 return {};
276 }
277
278 virtual sp<IBinder> getPhysicalDisplayToken(PhysicalDisplayId displayId) const {
279 Parcel data, reply;
280 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Marin Shalamanova524a092020-07-27 21:39:55 +0200281 data.writeUint64(displayId.value);
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800282 remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_TOKEN, data, &reply);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700283 return reply.readStrongBinder();
284 }
285
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700286 virtual void setPowerMode(const sp<IBinder>& display, int mode)
Colin Cross8e533062012-06-07 13:17:52 -0700287 {
288 Parcel data, reply;
289 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700290 data.writeStrongBinder(display);
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700291 data.writeInt32(mode);
292 remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply);
Colin Cross8e533062012-06-07 13:17:52 -0700293 }
Mathias Agopian3094df32012-06-18 18:06:45 -0700294
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800295 virtual status_t getDisplayState(const sp<IBinder>& display, ui::DisplayState* state) {
296 Parcel data, reply;
297 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
298 data.writeStrongBinder(display);
299 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATE, data, &reply);
300 const status_t result = reply.readInt32();
301 if (result == NO_ERROR) {
302 memcpy(state, reply.readInplace(sizeof(ui::DisplayState)), sizeof(ui::DisplayState));
303 }
304 return result;
305 }
306
307 virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) {
308 Parcel data, reply;
309 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
310 data.writeStrongBinder(display);
311 remote()->transact(BnSurfaceComposer::GET_DISPLAY_INFO, data, &reply);
312 const status_t result = reply.readInt32();
Marin Shalamanov359a7e72020-02-17 17:03:07 +0100313 if (result != NO_ERROR) return result;
314 return reply.read(*info);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800315 }
316
317 virtual status_t getDisplayConfigs(const sp<IBinder>& display, Vector<DisplayConfig>* configs) {
Mathias Agopianc666cae2012-07-25 18:56:13 -0700318 Parcel data, reply;
319 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700320 data.writeStrongBinder(display);
Dan Stoza7f7da322014-05-02 15:26:25 -0700321 remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800322 const status_t result = reply.readInt32();
Dan Stoza7f7da322014-05-02 15:26:25 -0700323 if (result == NO_ERROR) {
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800324 const size_t numConfigs = reply.readUint32();
Dan Stoza7f7da322014-05-02 15:26:25 -0700325 configs->clear();
326 configs->resize(numConfigs);
327 for (size_t c = 0; c < numConfigs; ++c) {
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800328 memcpy(&(configs->editItemAt(c)), reply.readInplace(sizeof(DisplayConfig)),
329 sizeof(DisplayConfig));
Dan Stoza7f7da322014-05-02 15:26:25 -0700330 }
331 }
332 return result;
333 }
334
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700335 virtual status_t getDisplayStats(const sp<IBinder>& display,
336 DisplayStatInfo* stats)
337 {
338 Parcel data, reply;
339 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
340 data.writeStrongBinder(display);
341 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply);
342 status_t result = reply.readInt32();
343 if (result == NO_ERROR) {
344 memcpy(stats,
345 reply.readInplace(sizeof(DisplayStatInfo)),
346 sizeof(DisplayStatInfo));
347 }
348 return result;
349 }
350
Dan Stoza7f7da322014-05-02 15:26:25 -0700351 virtual int getActiveConfig(const sp<IBinder>& display)
352 {
353 Parcel data, reply;
354 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
355 data.writeStrongBinder(display);
356 remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply);
357 return reply.readInt32();
358 }
359
Michael Wright28f24d02016-07-12 13:30:53 -0700360 virtual status_t getDisplayColorModes(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700361 Vector<ColorMode>* outColorModes) {
Michael Wright28f24d02016-07-12 13:30:53 -0700362 Parcel data, reply;
363 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
364 if (result != NO_ERROR) {
365 ALOGE("getDisplayColorModes failed to writeInterfaceToken: %d", result);
366 return result;
367 }
368 result = data.writeStrongBinder(display);
369 if (result != NO_ERROR) {
370 ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result);
371 return result;
372 }
373 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply);
374 if (result != NO_ERROR) {
375 ALOGE("getDisplayColorModes failed to transact: %d", result);
376 return result;
377 }
378 result = static_cast<status_t>(reply.readInt32());
379 if (result == NO_ERROR) {
380 size_t numModes = reply.readUint32();
381 outColorModes->clear();
382 outColorModes->resize(numModes);
383 for (size_t i = 0; i < numModes; ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -0700384 outColorModes->replaceAt(static_cast<ColorMode>(reply.readInt32()), i);
Michael Wright28f24d02016-07-12 13:30:53 -0700385 }
386 }
387 return result;
388 }
389
Daniel Solomon42d04562019-01-20 21:03:19 -0800390 virtual status_t getDisplayNativePrimaries(const sp<IBinder>& display,
391 ui::DisplayPrimaries& primaries) {
392 Parcel data, reply;
393 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
394 if (result != NO_ERROR) {
395 ALOGE("getDisplayNativePrimaries failed to writeInterfaceToken: %d", result);
396 return result;
397 }
398 result = data.writeStrongBinder(display);
399 if (result != NO_ERROR) {
400 ALOGE("getDisplayNativePrimaries failed to writeStrongBinder: %d", result);
401 return result;
402 }
403 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_NATIVE_PRIMARIES, data, &reply);
404 if (result != NO_ERROR) {
405 ALOGE("getDisplayNativePrimaries failed to transact: %d", result);
406 return result;
407 }
408 result = reply.readInt32();
409 if (result == NO_ERROR) {
410 memcpy(&primaries, reply.readInplace(sizeof(ui::DisplayPrimaries)),
411 sizeof(ui::DisplayPrimaries));
412 }
413 return result;
414 }
415
Peiyong Lina52f0292018-03-14 17:26:31 -0700416 virtual ColorMode getActiveColorMode(const sp<IBinder>& display) {
Michael Wright28f24d02016-07-12 13:30:53 -0700417 Parcel data, reply;
418 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
419 if (result != NO_ERROR) {
420 ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700421 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700422 }
423 result = data.writeStrongBinder(display);
424 if (result != NO_ERROR) {
425 ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700426 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700427 }
428 result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply);
429 if (result != NO_ERROR) {
430 ALOGE("getActiveColorMode failed to transact: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700431 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700432 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700433 return static_cast<ColorMode>(reply.readInt32());
Michael Wright28f24d02016-07-12 13:30:53 -0700434 }
435
436 virtual status_t setActiveColorMode(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700437 ColorMode colorMode) {
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("setActiveColorMode failed to writeInterfaceToken: %d", result);
442 return result;
443 }
444 result = data.writeStrongBinder(display);
445 if (result != NO_ERROR) {
446 ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result);
447 return result;
448 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700449 result = data.writeInt32(static_cast<int32_t>(colorMode));
Michael Wright28f24d02016-07-12 13:30:53 -0700450 if (result != NO_ERROR) {
451 ALOGE("setActiveColorMode failed to writeInt32: %d", result);
452 return result;
453 }
454 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply);
455 if (result != NO_ERROR) {
456 ALOGE("setActiveColorMode failed to transact: %d", result);
457 return result;
458 }
459 return static_cast<status_t>(reply.readInt32());
460 }
461
Galia Peycheva5492cb52019-10-30 14:13:16 +0100462 virtual status_t getAutoLowLatencyModeSupport(const sp<IBinder>& display,
463 bool* outSupport) const {
464 Parcel data, reply;
465 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
466 status_t result = data.writeStrongBinder(display);
467 if (result != NO_ERROR) {
468 ALOGE("getAutoLowLatencyModeSupport failed to writeStrongBinder: %d", result);
469 return result;
470 }
471 result = remote()->transact(BnSurfaceComposer::GET_AUTO_LOW_LATENCY_MODE_SUPPORT, data,
472 &reply);
473 if (result != NO_ERROR) {
474 ALOGE("getAutoLowLatencyModeSupport failed to transact: %d", result);
475 return result;
476 }
477 return reply.readBool(outSupport);
478 }
479
480 virtual void setAutoLowLatencyMode(const sp<IBinder>& display, bool on) {
481 Parcel data, reply;
482 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
483 if (result != NO_ERROR) {
484 ALOGE("setAutoLowLatencyMode failed to writeInterfaceToken: %d", result);
485 return;
486 }
487
488 result = data.writeStrongBinder(display);
489 if (result != NO_ERROR) {
490 ALOGE("setAutoLowLatencyMode failed to writeStrongBinder: %d", result);
491 return;
492 }
493 result = data.writeBool(on);
494 if (result != NO_ERROR) {
495 ALOGE("setAutoLowLatencyMode failed to writeBool: %d", result);
496 return;
497 }
498 result = remote()->transact(BnSurfaceComposer::SET_AUTO_LOW_LATENCY_MODE, data, &reply);
499 if (result != NO_ERROR) {
500 ALOGE("setAutoLowLatencyMode failed to transact: %d", result);
501 return;
502 }
503 }
504
505 virtual status_t getGameContentTypeSupport(const sp<IBinder>& display, bool* outSupport) const {
506 Parcel data, reply;
507 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
508 status_t result = data.writeStrongBinder(display);
509 if (result != NO_ERROR) {
510 ALOGE("getGameContentTypeSupport failed to writeStrongBinder: %d", result);
511 return result;
512 }
513 result = remote()->transact(BnSurfaceComposer::GET_GAME_CONTENT_TYPE_SUPPORT, data, &reply);
514 if (result != NO_ERROR) {
515 ALOGE("getGameContentTypeSupport failed to transact: %d", result);
516 return result;
517 }
518 return reply.readBool(outSupport);
519 }
520
521 virtual void setGameContentType(const sp<IBinder>& display, bool on) {
522 Parcel data, reply;
523 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
524 if (result != NO_ERROR) {
525 ALOGE("setGameContentType failed to writeInterfaceToken: %d", result);
526 return;
527 }
528 result = data.writeStrongBinder(display);
529 if (result != NO_ERROR) {
530 ALOGE("setGameContentType failed to writeStrongBinder: %d", result);
531 return;
532 }
533 result = data.writeBool(on);
534 if (result != NO_ERROR) {
535 ALOGE("setGameContentType failed to writeBool: %d", result);
536 return;
537 }
538 result = remote()->transact(BnSurfaceComposer::SET_GAME_CONTENT_TYPE, data, &reply);
539 if (result != NO_ERROR) {
540 ALOGE("setGameContentType failed to transact: %d", result);
541 }
542 }
543
Svetoslavd85084b2014-03-20 10:28:31 -0700544 virtual status_t clearAnimationFrameStats() {
545 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700546 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
547 if (result != NO_ERROR) {
548 ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result);
549 return result;
550 }
551 result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply);
552 if (result != NO_ERROR) {
553 ALOGE("clearAnimationFrameStats failed to transact: %d", result);
554 return result;
555 }
Svetoslavd85084b2014-03-20 10:28:31 -0700556 return reply.readInt32();
557 }
558
559 virtual status_t getAnimationFrameStats(FrameStats* outStats) const {
560 Parcel data, reply;
561 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
562 remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply);
563 reply.read(*outStats);
564 return reply.readInt32();
565 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700566
567 virtual status_t getHdrCapabilities(const sp<IBinder>& display,
568 HdrCapabilities* outCapabilities) const {
569 Parcel data, reply;
570 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
571 status_t result = data.writeStrongBinder(display);
572 if (result != NO_ERROR) {
573 ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result);
574 return result;
575 }
576 result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES,
577 data, &reply);
578 if (result != NO_ERROR) {
579 ALOGE("getHdrCapabilities failed to transact: %d", result);
580 return result;
581 }
582 result = reply.readInt32();
583 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800584 result = reply.read(*outCapabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700585 }
586 return result;
587 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700588
589 virtual status_t enableVSyncInjections(bool enable) {
590 Parcel data, reply;
591 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
592 if (result != NO_ERROR) {
593 ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result);
594 return result;
595 }
596 result = data.writeBool(enable);
597 if (result != NO_ERROR) {
598 ALOGE("enableVSyncInjections failed to writeBool: %d", result);
599 return result;
600 }
Steven Moreland366eb422019-04-01 19:22:32 -0700601 result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS, data, &reply,
602 IBinder::FLAG_ONEWAY);
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700603 if (result != NO_ERROR) {
604 ALOGE("enableVSyncInjections failed to transact: %d", result);
605 return result;
606 }
607 return result;
608 }
609
610 virtual status_t injectVSync(nsecs_t when) {
611 Parcel data, reply;
612 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
613 if (result != NO_ERROR) {
614 ALOGE("injectVSync failed to writeInterfaceToken: %d", result);
615 return result;
616 }
617 result = data.writeInt64(when);
618 if (result != NO_ERROR) {
619 ALOGE("injectVSync failed to writeInt64: %d", result);
620 return result;
621 }
Steven Moreland366eb422019-04-01 19:22:32 -0700622 result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply,
623 IBinder::FLAG_ONEWAY);
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700624 if (result != NO_ERROR) {
625 ALOGE("injectVSync failed to transact: %d", result);
626 return result;
627 }
628 return result;
629 }
630
Vishnu Nair43bccf82020-06-05 10:53:37 -0700631 virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) {
Kalle Raitaa099a242017-01-11 11:17:29 -0800632 if (!outLayers) {
633 return UNEXPECTED_NULL;
634 }
635
636 Parcel data, reply;
637
638 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
639 if (err != NO_ERROR) {
640 return err;
641 }
642
643 err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply);
644 if (err != NO_ERROR) {
645 return err;
646 }
647
648 int32_t result = 0;
649 err = reply.readInt32(&result);
650 if (err != NO_ERROR) {
651 return err;
652 }
653 if (result != NO_ERROR) {
654 return result;
655 }
656
657 outLayers->clear();
658 return reply.readParcelableVector(outLayers);
659 }
Peiyong Lin0256f722018-08-31 15:45:10 -0700660
Peiyong Linc6780972018-10-28 15:24:08 -0700661 virtual status_t getCompositionPreference(ui::Dataspace* defaultDataspace,
662 ui::PixelFormat* defaultPixelFormat,
663 ui::Dataspace* wideColorGamutDataspace,
664 ui::PixelFormat* wideColorGamutPixelFormat) const {
Peiyong Lin0256f722018-08-31 15:45:10 -0700665 Parcel data, reply;
666 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
667 if (error != NO_ERROR) {
668 return error;
669 }
670 error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply);
671 if (error != NO_ERROR) {
672 return error;
673 }
674 error = static_cast<status_t>(reply.readInt32());
675 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -0700676 *defaultDataspace = static_cast<ui::Dataspace>(reply.readInt32());
677 *defaultPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
678 *wideColorGamutDataspace = static_cast<ui::Dataspace>(reply.readInt32());
679 *wideColorGamutPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
Peiyong Lin0256f722018-08-31 15:45:10 -0700680 }
681 return error;
682 }
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700683
Ady Abraham37965d42018-11-01 13:43:32 -0700684 virtual status_t getColorManagement(bool* outGetColorManagement) const {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700685 Parcel data, reply;
686 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Ady Abraham37965d42018-11-01 13:43:32 -0700687 remote()->transact(BnSurfaceComposer::GET_COLOR_MANAGEMENT, data, &reply);
688 bool result;
689 status_t err = reply.readBool(&result);
690 if (err == NO_ERROR) {
691 *outGetColorManagement = result;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700692 }
Ady Abraham37965d42018-11-01 13:43:32 -0700693 return err;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700694 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -0700695
696 virtual status_t getDisplayedContentSamplingAttributes(const sp<IBinder>& display,
697 ui::PixelFormat* outFormat,
698 ui::Dataspace* outDataspace,
699 uint8_t* outComponentMask) const {
700 if (!outFormat || !outDataspace || !outComponentMask) return BAD_VALUE;
701 Parcel data, reply;
702 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
703 data.writeStrongBinder(display);
704
705 status_t error =
706 remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES,
707 data, &reply);
708 if (error != NO_ERROR) {
709 return error;
710 }
711
712 uint32_t value = 0;
713 error = reply.readUint32(&value);
714 if (error != NO_ERROR) {
715 return error;
716 }
717 *outFormat = static_cast<ui::PixelFormat>(value);
718
719 error = reply.readUint32(&value);
720 if (error != NO_ERROR) {
721 return error;
722 }
723 *outDataspace = static_cast<ui::Dataspace>(value);
724
725 error = reply.readUint32(&value);
726 if (error != NO_ERROR) {
727 return error;
728 }
729 *outComponentMask = static_cast<uint8_t>(value);
730 return error;
731 }
Kevin DuBois74e53772018-11-19 10:52:38 -0800732
733 virtual status_t setDisplayContentSamplingEnabled(const sp<IBinder>& display, bool enable,
Dominik Laskowski470df5f2020-04-02 22:27:42 -0700734 uint8_t componentMask, uint64_t maxFrames) {
Kevin DuBois74e53772018-11-19 10:52:38 -0800735 Parcel data, reply;
736 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
737 data.writeStrongBinder(display);
738 data.writeBool(enable);
739 data.writeByte(static_cast<int8_t>(componentMask));
740 data.writeUint64(maxFrames);
741 status_t result =
742 remote()->transact(BnSurfaceComposer::SET_DISPLAY_CONTENT_SAMPLING_ENABLED, data,
743 &reply);
744 return result;
745 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700746
747 virtual status_t getDisplayedContentSample(const sp<IBinder>& display, uint64_t maxFrames,
748 uint64_t timestamp,
749 DisplayedFrameStats* outStats) const {
750 if (!outStats) return BAD_VALUE;
751
752 Parcel data, reply;
753 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
754 data.writeStrongBinder(display);
755 data.writeUint64(maxFrames);
756 data.writeUint64(timestamp);
757
758 status_t result =
759 remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLE, data, &reply);
760
761 if (result != NO_ERROR) {
762 return result;
763 }
764
765 result = reply.readUint64(&outStats->numFrames);
766 if (result != NO_ERROR) {
767 return result;
768 }
769
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800770 result = reply.readUint64Vector(&outStats->component_0_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700771 if (result != NO_ERROR) {
772 return result;
773 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800774 result = reply.readUint64Vector(&outStats->component_1_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700775 if (result != NO_ERROR) {
776 return result;
777 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800778 result = reply.readUint64Vector(&outStats->component_2_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700779 if (result != NO_ERROR) {
780 return result;
781 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800782 result = reply.readUint64Vector(&outStats->component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700783 return result;
784 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800785
786 virtual status_t getProtectedContentSupport(bool* outSupported) const {
787 Parcel data, reply;
788 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Peiyong Linb6888fa2019-01-28 13:20:58 -0800789 status_t error =
790 remote()->transact(BnSurfaceComposer::GET_PROTECTED_CONTENT_SUPPORT, data, &reply);
791 if (error != NO_ERROR) {
792 return error;
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800793 }
Peiyong Linb6888fa2019-01-28 13:20:58 -0800794 error = reply.readBool(outSupported);
795 return error;
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800796 }
Marissa Wallebc2c052019-01-16 19:16:55 -0800797
Peiyong Lin4f3fddf2019-01-24 17:21:24 -0800798 virtual status_t isWideColorDisplay(const sp<IBinder>& token,
799 bool* outIsWideColorDisplay) const {
800 Parcel data, reply;
801 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
802 if (error != NO_ERROR) {
803 return error;
804 }
805 error = data.writeStrongBinder(token);
806 if (error != NO_ERROR) {
807 return error;
808 }
809
810 error = remote()->transact(BnSurfaceComposer::IS_WIDE_COLOR_DISPLAY, data, &reply);
811 if (error != NO_ERROR) {
812 return error;
813 }
814 error = reply.readBool(outIsWideColorDisplay);
815 return error;
816 }
Dan Stoza84ab9372018-12-17 15:27:57 -0800817
818 virtual status_t addRegionSamplingListener(const Rect& samplingArea,
819 const sp<IBinder>& stopLayerHandle,
820 const sp<IRegionSamplingListener>& listener) {
821 Parcel data, reply;
822 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
823 if (error != NO_ERROR) {
824 ALOGE("addRegionSamplingListener: Failed to write interface token");
825 return error;
826 }
827 error = data.write(samplingArea);
828 if (error != NO_ERROR) {
829 ALOGE("addRegionSamplingListener: Failed to write sampling area");
830 return error;
831 }
832 error = data.writeStrongBinder(stopLayerHandle);
833 if (error != NO_ERROR) {
834 ALOGE("addRegionSamplingListener: Failed to write stop layer handle");
835 return error;
836 }
837 error = data.writeStrongBinder(IInterface::asBinder(listener));
838 if (error != NO_ERROR) {
839 ALOGE("addRegionSamplingListener: Failed to write listener");
840 return error;
841 }
842 error = remote()->transact(BnSurfaceComposer::ADD_REGION_SAMPLING_LISTENER, data, &reply);
843 if (error != NO_ERROR) {
844 ALOGE("addRegionSamplingListener: Failed to transact");
845 }
846 return error;
847 }
848
849 virtual status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) {
850 Parcel data, reply;
851 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
852 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800853 ALOGE("removeRegionSamplingListener: Failed to write interface token");
Dan Stoza84ab9372018-12-17 15:27:57 -0800854 return error;
855 }
856 error = data.writeStrongBinder(IInterface::asBinder(listener));
857 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800858 ALOGE("removeRegionSamplingListener: Failed to write listener");
Dan Stoza84ab9372018-12-17 15:27:57 -0800859 return error;
860 }
861 error = remote()->transact(BnSurfaceComposer::REMOVE_REGION_SAMPLING_LISTENER, data,
862 &reply);
863 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800864 ALOGE("removeRegionSamplingListener: Failed to transact");
Dan Stoza84ab9372018-12-17 15:27:57 -0800865 }
866 return error;
867 }
Ady Abraham838de062019-02-04 10:24:03 -0800868
Ana Krulec0782b882019-10-15 17:34:54 -0700869 virtual status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
Steven Thomasf734df42020-04-13 21:09:28 -0700870 int32_t defaultConfig,
871 float primaryRefreshRateMin,
872 float primaryRefreshRateMax,
873 float appRequestRefreshRateMin,
874 float appRequestRefreshRateMax) {
Ana Krulec0782b882019-10-15 17:34:54 -0700875 Parcel data, reply;
876 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
877 if (result != NO_ERROR) {
878 ALOGE("setDesiredDisplayConfigSpecs: failed to writeInterfaceToken: %d", result);
879 return result;
880 }
881 result = data.writeStrongBinder(displayToken);
882 if (result != NO_ERROR) {
883 ALOGE("setDesiredDisplayConfigSpecs: failed to write display token: %d", result);
884 return result;
885 }
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100886 result = data.writeInt32(defaultConfig);
Ana Krulec0782b882019-10-15 17:34:54 -0700887 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100888 ALOGE("setDesiredDisplayConfigSpecs failed to write defaultConfig: %d", result);
Ana Krulec0782b882019-10-15 17:34:54 -0700889 return result;
890 }
Steven Thomasf734df42020-04-13 21:09:28 -0700891 result = data.writeFloat(primaryRefreshRateMin);
Ana Krulec0782b882019-10-15 17:34:54 -0700892 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -0700893 ALOGE("setDesiredDisplayConfigSpecs failed to write primaryRefreshRateMin: %d", result);
Ana Krulec0782b882019-10-15 17:34:54 -0700894 return result;
895 }
Steven Thomasf734df42020-04-13 21:09:28 -0700896 result = data.writeFloat(primaryRefreshRateMax);
Ana Krulec0782b882019-10-15 17:34:54 -0700897 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -0700898 ALOGE("setDesiredDisplayConfigSpecs failed to write primaryRefreshRateMax: %d", result);
899 return result;
900 }
901 result = data.writeFloat(appRequestRefreshRateMin);
902 if (result != NO_ERROR) {
903 ALOGE("setDesiredDisplayConfigSpecs failed to write appRequestRefreshRateMin: %d",
904 result);
905 return result;
906 }
907 result = data.writeFloat(appRequestRefreshRateMax);
908 if (result != NO_ERROR) {
909 ALOGE("setDesiredDisplayConfigSpecs failed to write appRequestRefreshRateMax: %d",
910 result);
Ana Krulec0782b882019-10-15 17:34:54 -0700911 return result;
912 }
913
914 result = remote()->transact(BnSurfaceComposer::SET_DESIRED_DISPLAY_CONFIG_SPECS, data,
915 &reply);
916 if (result != NO_ERROR) {
917 ALOGE("setDesiredDisplayConfigSpecs failed to transact: %d", result);
918 return result;
919 }
920 return reply.readInt32();
921 }
922
Ana Krulec234bb162019-11-10 22:55:55 +0100923 virtual status_t getDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100924 int32_t* outDefaultConfig,
Steven Thomasf734df42020-04-13 21:09:28 -0700925 float* outPrimaryRefreshRateMin,
926 float* outPrimaryRefreshRateMax,
927 float* outAppRequestRefreshRateMin,
928 float* outAppRequestRefreshRateMax) {
929 if (!outDefaultConfig || !outPrimaryRefreshRateMin || !outPrimaryRefreshRateMax ||
930 !outAppRequestRefreshRateMin || !outAppRequestRefreshRateMax) {
931 return BAD_VALUE;
932 }
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800933 Parcel data, reply;
934 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
935 if (result != NO_ERROR) {
Ana Krulec234bb162019-11-10 22:55:55 +0100936 ALOGE("getDesiredDisplayConfigSpecs failed to writeInterfaceToken: %d", result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800937 return result;
938 }
939 result = data.writeStrongBinder(displayToken);
940 if (result != NO_ERROR) {
Ana Krulec234bb162019-11-10 22:55:55 +0100941 ALOGE("getDesiredDisplayConfigSpecs failed to writeStrongBinder: %d", result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800942 return result;
943 }
Ana Krulec234bb162019-11-10 22:55:55 +0100944 result = remote()->transact(BnSurfaceComposer::GET_DESIRED_DISPLAY_CONFIG_SPECS, data,
945 &reply);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800946 if (result != NO_ERROR) {
Ana Krulec234bb162019-11-10 22:55:55 +0100947 ALOGE("getDesiredDisplayConfigSpecs failed to transact: %d", result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800948 return result;
949 }
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100950 result = reply.readInt32(outDefaultConfig);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800951 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100952 ALOGE("getDesiredDisplayConfigSpecs failed to read defaultConfig: %d", result);
Ana Krulec234bb162019-11-10 22:55:55 +0100953 return result;
954 }
Steven Thomasf734df42020-04-13 21:09:28 -0700955 result = reply.readFloat(outPrimaryRefreshRateMin);
Ana Krulec234bb162019-11-10 22:55:55 +0100956 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -0700957 ALOGE("getDesiredDisplayConfigSpecs failed to read primaryRefreshRateMin: %d", result);
Ana Krulec234bb162019-11-10 22:55:55 +0100958 return result;
959 }
Steven Thomasf734df42020-04-13 21:09:28 -0700960 result = reply.readFloat(outPrimaryRefreshRateMax);
Ana Krulec234bb162019-11-10 22:55:55 +0100961 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -0700962 ALOGE("getDesiredDisplayConfigSpecs failed to read primaryRefreshRateMax: %d", result);
963 return result;
964 }
965 result = reply.readFloat(outAppRequestRefreshRateMin);
966 if (result != NO_ERROR) {
967 ALOGE("getDesiredDisplayConfigSpecs failed to read appRequestRefreshRateMin: %d",
968 result);
969 return result;
970 }
971 result = reply.readFloat(outAppRequestRefreshRateMax);
972 if (result != NO_ERROR) {
973 ALOGE("getDesiredDisplayConfigSpecs failed to read appRequestRefreshRateMax: %d",
974 result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800975 return result;
976 }
977 return reply.readInt32();
978 }
Dan Gittik57e63c52019-01-18 16:37:54 +0000979
980 virtual status_t getDisplayBrightnessSupport(const sp<IBinder>& displayToken,
981 bool* outSupport) const {
982 Parcel data, reply;
983 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
984 if (error != NO_ERROR) {
985 ALOGE("getDisplayBrightnessSupport: failed to write interface token: %d", error);
986 return error;
987 }
988 error = data.writeStrongBinder(displayToken);
989 if (error != NO_ERROR) {
990 ALOGE("getDisplayBrightnessSupport: failed to write display token: %d", error);
991 return error;
992 }
993 error = remote()->transact(BnSurfaceComposer::GET_DISPLAY_BRIGHTNESS_SUPPORT, data, &reply);
994 if (error != NO_ERROR) {
995 ALOGE("getDisplayBrightnessSupport: failed to transact: %d", error);
996 return error;
997 }
998 bool support;
999 error = reply.readBool(&support);
1000 if (error != NO_ERROR) {
1001 ALOGE("getDisplayBrightnessSupport: failed to read support: %d", error);
1002 return error;
1003 }
1004 *outSupport = support;
1005 return NO_ERROR;
1006 }
1007
Dominik Laskowski470df5f2020-04-02 22:27:42 -07001008 virtual status_t setDisplayBrightness(const sp<IBinder>& displayToken, float brightness) {
Dan Gittik57e63c52019-01-18 16:37:54 +00001009 Parcel data, reply;
1010 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1011 if (error != NO_ERROR) {
1012 ALOGE("setDisplayBrightness: failed to write interface token: %d", error);
1013 return error;
1014 }
1015 error = data.writeStrongBinder(displayToken);
1016 if (error != NO_ERROR) {
1017 ALOGE("setDisplayBrightness: failed to write display token: %d", error);
1018 return error;
1019 }
1020 error = data.writeFloat(brightness);
1021 if (error != NO_ERROR) {
1022 ALOGE("setDisplayBrightness: failed to write brightness: %d", error);
1023 return error;
1024 }
1025 error = remote()->transact(BnSurfaceComposer::SET_DISPLAY_BRIGHTNESS, data, &reply);
1026 if (error != NO_ERROR) {
1027 ALOGE("setDisplayBrightness: failed to transact: %d", error);
1028 return error;
1029 }
1030 return NO_ERROR;
1031 }
Ady Abraham8532d012019-05-08 14:50:56 -07001032
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001033 virtual status_t notifyPowerBoost(int32_t boostId) {
Ady Abraham8532d012019-05-08 14:50:56 -07001034 Parcel data, reply;
1035 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1036 if (error != NO_ERROR) {
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001037 ALOGE("notifyPowerBoost: failed to write interface token: %d", error);
Ady Abraham8532d012019-05-08 14:50:56 -07001038 return error;
1039 }
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001040 error = data.writeInt32(boostId);
Ady Abraham8532d012019-05-08 14:50:56 -07001041 if (error != NO_ERROR) {
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001042 ALOGE("notifyPowerBoost: failed to write boostId: %d", error);
Ady Abraham8532d012019-05-08 14:50:56 -07001043 return error;
1044 }
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001045 error = remote()->transact(BnSurfaceComposer::NOTIFY_POWER_BOOST, data, &reply,
Ady Abraham8532d012019-05-08 14:50:56 -07001046 IBinder::FLAG_ONEWAY);
1047 if (error != NO_ERROR) {
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001048 ALOGE("notifyPowerBoost: failed to transact: %d", error);
Ady Abraham8532d012019-05-08 14:50:56 -07001049 return error;
1050 }
1051 return NO_ERROR;
1052 }
Vishnu Nairb13bb952019-11-15 10:24:08 -08001053
1054 virtual status_t setGlobalShadowSettings(const half4& ambientColor, const half4& spotColor,
1055 float lightPosY, float lightPosZ, float lightRadius) {
1056 Parcel data, reply;
1057 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1058 if (error != NO_ERROR) {
1059 ALOGE("setGlobalShadowSettings: failed to write interface token: %d", error);
1060 return error;
1061 }
1062
1063 std::vector<float> shadowConfig = {ambientColor.r, ambientColor.g, ambientColor.b,
1064 ambientColor.a, spotColor.r, spotColor.g,
1065 spotColor.b, spotColor.a, lightPosY,
1066 lightPosZ, lightRadius};
1067
1068 error = data.writeFloatVector(shadowConfig);
1069 if (error != NO_ERROR) {
1070 ALOGE("setGlobalShadowSettings: failed to write shadowConfig: %d", error);
1071 return error;
1072 }
1073
1074 error = remote()->transact(BnSurfaceComposer::SET_GLOBAL_SHADOW_SETTINGS, data, &reply,
1075 IBinder::FLAG_ONEWAY);
1076 if (error != NO_ERROR) {
1077 ALOGE("setGlobalShadowSettings: failed to transact: %d", error);
1078 return error;
1079 }
1080 return NO_ERROR;
1081 }
Steven Thomas62a4cf82020-01-31 12:04:03 -08001082
1083 virtual status_t setFrameRate(const sp<IGraphicBufferProducer>& surface, float frameRate,
1084 int8_t compatibility) {
1085 Parcel data, reply;
1086 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1087 if (err != NO_ERROR) {
1088 ALOGE("setFrameRate: failed writing interface token: %s (%d)", strerror(-err), -err);
1089 return err;
1090 }
1091
1092 err = data.writeStrongBinder(IInterface::asBinder(surface));
1093 if (err != NO_ERROR) {
1094 ALOGE("setFrameRate: failed writing strong binder: %s (%d)", strerror(-err), -err);
1095 return err;
1096 }
1097
1098 err = data.writeFloat(frameRate);
1099 if (err != NO_ERROR) {
1100 ALOGE("setFrameRate: failed writing float: %s (%d)", strerror(-err), -err);
1101 return err;
1102 }
1103
1104 err = data.writeByte(compatibility);
1105 if (err != NO_ERROR) {
1106 ALOGE("setFrameRate: failed writing byte: %s (%d)", strerror(-err), -err);
1107 return err;
1108 }
1109
Ady Abraham60e42ea2020-03-09 19:17:31 -07001110 err = remote()->transact(BnSurfaceComposer::SET_FRAME_RATE, data, &reply);
Steven Thomas62a4cf82020-01-31 12:04:03 -08001111 if (err != NO_ERROR) {
1112 ALOGE("setFrameRate: failed to transact: %s (%d)", strerror(-err), err);
1113 return err;
1114 }
Steven Thomasd4071902020-03-24 16:02:53 -07001115
1116 return reply.readInt32();
1117 }
1118
1119 virtual status_t acquireFrameRateFlexibilityToken(sp<IBinder>* outToken) {
1120 if (!outToken) return BAD_VALUE;
1121
1122 Parcel data, reply;
1123 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1124 if (err != NO_ERROR) {
1125 ALOGE("acquireFrameRateFlexibilityToken: failed writing interface token: %s (%d)",
1126 strerror(-err), -err);
1127 return err;
1128 }
1129
1130 err = remote()->transact(BnSurfaceComposer::ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN, data,
1131 &reply);
1132 if (err != NO_ERROR) {
1133 ALOGE("acquireFrameRateFlexibilityToken: failed to transact: %s (%d)", strerror(-err),
1134 err);
1135 return err;
1136 }
1137
1138 err = reply.readInt32();
1139 if (err != NO_ERROR) {
1140 ALOGE("acquireFrameRateFlexibilityToken: call failed: %s (%d)", strerror(-err), err);
1141 return err;
1142 }
1143
1144 err = reply.readStrongBinder(outToken);
1145 if (err != NO_ERROR) {
1146 ALOGE("acquireFrameRateFlexibilityToken: failed reading binder token: %s (%d)",
1147 strerror(-err), err);
1148 return err;
1149 }
1150
Steven Thomas62a4cf82020-01-31 12:04:03 -08001151 return NO_ERROR;
1152 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001153};
1154
Dan Stozad723bd72014-11-18 10:24:03 -08001155// Out-of-line virtual method definition to trigger vtable emission in this
1156// translation unit (see clang warning -Wweak-vtables)
1157BpSurfaceComposer::~BpSurfaceComposer() {}
1158
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001159IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
1160
1161// ----------------------------------------------------------------------
1162
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001163status_t BnSurfaceComposer::onTransact(
1164 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
1165{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001166 switch(code) {
1167 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001168 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -08001169 sp<IBinder> b = IInterface::asBinder(createConnection());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001170 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -07001171 return NO_ERROR;
1172 }
Mathias Agopian698c0872011-06-28 19:09:31 -07001173 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001174 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -08001175
chaviw308ddba2020-08-11 16:23:51 -07001176 uint32_t count = 0;
1177 SAFE_PARCEL_READ_SIZE(data.readUint32, &count, data.dataSize());
Mathias Agopian698c0872011-06-28 19:09:31 -07001178 Vector<ComposerState> state;
1179 state.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -08001180 for (size_t i = 0; i < count; i++) {
Marissa Wallc837b5e2018-10-12 10:04:44 -07001181 ComposerState s;
chaviw308ddba2020-08-11 16:23:51 -07001182 SAFE_PARCEL(s.read, data);
Mathias Agopian698c0872011-06-28 19:09:31 -07001183 state.add(s);
1184 }
Dan Stozad723bd72014-11-18 10:24:03 -08001185
chaviw308ddba2020-08-11 16:23:51 -07001186 SAFE_PARCEL_READ_SIZE(data.readUint32, &count, data.dataSize());
Mathias Agopian8b33f032012-07-24 20:43:54 -07001187 DisplayState d;
1188 Vector<DisplayState> displays;
1189 displays.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -08001190 for (size_t i = 0; i < count; i++) {
chaviw308ddba2020-08-11 16:23:51 -07001191 SAFE_PARCEL(d.read, data);
Mathias Agopian8b33f032012-07-24 20:43:54 -07001192 displays.add(d);
1193 }
Dan Stozad723bd72014-11-18 10:24:03 -08001194
chaviw308ddba2020-08-11 16:23:51 -07001195 uint32_t stateFlags = 0;
1196 SAFE_PARCEL(data.readUint32, &stateFlags);
1197 sp<IBinder> applyToken;
1198 SAFE_PARCEL(data.readStrongBinder, &applyToken);
chaviw273171b2018-12-26 11:46:30 -08001199 InputWindowCommands inputWindowCommands;
chaviw308ddba2020-08-11 16:23:51 -07001200 SAFE_PARCEL(inputWindowCommands.read, data);
Marissa Wall17b4e452018-12-26 16:32:34 -08001201
chaviw308ddba2020-08-11 16:23:51 -07001202 int64_t desiredPresentTime = 0;
1203 SAFE_PARCEL(data.readInt64, &desiredPresentTime);
Marissa Wall78b72202019-03-15 14:58:34 -07001204
Marissa Wall947d34e2019-03-29 14:03:53 -07001205 client_cache_t uncachedBuffer;
chaviw308ddba2020-08-11 16:23:51 -07001206 sp<IBinder> tmpBinder;
1207 SAFE_PARCEL(data.readNullableStrongBinder, &tmpBinder);
1208 uncachedBuffer.token = tmpBinder;
1209 SAFE_PARCEL(data.readUint64, &uncachedBuffer.id);
Marissa Wall78b72202019-03-15 14:58:34 -07001210
chaviw308ddba2020-08-11 16:23:51 -07001211 bool hasListenerCallbacks = false;
1212 SAFE_PARCEL(data.readBool, &hasListenerCallbacks);
Valerie Hau9dab9732019-08-20 09:29:25 -07001213
Marissa Wall3dad52d2019-03-22 14:03:19 -07001214 std::vector<ListenerCallbacks> listenerCallbacks;
chaviw308ddba2020-08-11 16:23:51 -07001215 int32_t listenersSize = 0;
1216 SAFE_PARCEL_READ_SIZE(data.readInt32, &listenersSize, data.dataSize());
Marissa Wall3dad52d2019-03-22 14:03:19 -07001217 for (int32_t i = 0; i < listenersSize; i++) {
chaviw308ddba2020-08-11 16:23:51 -07001218 SAFE_PARCEL(data.readStrongBinder, &tmpBinder);
Marissa Wall3dad52d2019-03-22 14:03:19 -07001219 std::vector<CallbackId> callbackIds;
chaviw308ddba2020-08-11 16:23:51 -07001220 SAFE_PARCEL(data.readInt64Vector, &callbackIds);
1221 listenerCallbacks.emplace_back(tmpBinder, callbackIds);
Marissa Wall3dad52d2019-03-22 14:03:19 -07001222 }
chaviw308ddba2020-08-11 16:23:51 -07001223 return setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands,
1224 desiredPresentTime, uncachedBuffer, hasListenerCallbacks,
1225 listenerCallbacks);
Jesse Hall6c913be2013-08-08 12:15:49 -07001226 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001227 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001228 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001229 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -07001230 return NO_ERROR;
1231 }
chaviwd2432892020-07-24 17:42:39 -07001232 case CAPTURE_DISPLAY: {
Mathias Agopian2a9fc492013-03-01 13:42:57 -08001233 CHECK_INTERFACE(ISurfaceComposer, data, reply);
chaviwd2432892020-07-24 17:42:39 -07001234 DisplayCaptureArgs args;
chaviw8ffc7b82020-08-18 11:25:37 -07001235 sp<IScreenCaptureListener> captureListener;
chaviw308ddba2020-08-11 16:23:51 -07001236 SAFE_PARCEL(args.read, data);
chaviw8ffc7b82020-08-18 11:25:37 -07001237 SAFE_PARCEL(data.readStrongBinder, &captureListener);
1238
1239 return captureDisplay(args, captureListener);
Jesse Hall6c913be2013-08-08 12:15:49 -07001240 }
chaviwd2432892020-07-24 17:42:39 -07001241 case CAPTURE_DISPLAY_BY_ID: {
chaviw93df2ea2019-04-30 16:45:12 -07001242 CHECK_INTERFACE(ISurfaceComposer, data, reply);
chaviw308ddba2020-08-11 16:23:51 -07001243 uint64_t displayOrLayerStack = 0;
chaviw8ffc7b82020-08-18 11:25:37 -07001244 sp<IScreenCaptureListener> captureListener;
chaviw308ddba2020-08-11 16:23:51 -07001245 SAFE_PARCEL(data.readUint64, &displayOrLayerStack);
chaviw8ffc7b82020-08-18 11:25:37 -07001246 SAFE_PARCEL(data.readStrongBinder, &captureListener);
1247
1248 return captureDisplay(displayOrLayerStack, captureListener);
chaviw93df2ea2019-04-30 16:45:12 -07001249 }
chaviwa76b2712017-09-20 12:02:26 -07001250 case CAPTURE_LAYERS: {
1251 CHECK_INTERFACE(ISurfaceComposer, data, reply);
chaviw3efadb12020-07-27 10:07:15 -07001252 LayerCaptureArgs args;
chaviw8ffc7b82020-08-18 11:25:37 -07001253 sp<IScreenCaptureListener> captureListener;
chaviw308ddba2020-08-11 16:23:51 -07001254 SAFE_PARCEL(args.read, data);
chaviw8ffc7b82020-08-18 11:25:37 -07001255 SAFE_PARCEL(data.readStrongBinder, &captureListener);
1256
1257 return captureLayers(args, captureListener);
chaviwa76b2712017-09-20 12:02:26 -07001258 }
Jamie Gennis134f0422011-03-08 12:18:54 -08001259 case AUTHENTICATE_SURFACE: {
1260 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -08001261 sp<IGraphicBufferProducer> bufferProducer =
1262 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
1263 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -08001264 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -07001265 return NO_ERROR;
1266 }
Brian Anderson6b376712017-04-04 10:51:39 -07001267 case GET_SUPPORTED_FRAME_TIMESTAMPS: {
1268 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1269 std::vector<FrameEvent> supportedTimestamps;
1270 status_t result = getSupportedFrameTimestamps(&supportedTimestamps);
1271 status_t err = reply->writeInt32(result);
1272 if (err != NO_ERROR) {
1273 return err;
1274 }
1275 if (result != NO_ERROR) {
1276 return result;
1277 }
1278
1279 std::vector<int32_t> supported;
1280 supported.reserve(supportedTimestamps.size());
1281 for (FrameEvent s : supportedTimestamps) {
1282 supported.push_back(static_cast<int32_t>(s));
1283 }
1284 return reply->writeInt32Vector(supported);
1285 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001286 case CREATE_DISPLAY_EVENT_CONNECTION: {
1287 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Ady Abraham0f4a1b12019-06-04 16:04:04 -07001288 auto vsyncSource = static_cast<ISurfaceComposer::VsyncSource>(data.readInt32());
1289 auto configChanged = static_cast<ISurfaceComposer::ConfigChanged>(data.readInt32());
1290
1291 sp<IDisplayEventConnection> connection(
1292 createDisplayEventConnection(vsyncSource, configChanged));
Marco Nelissen2ea926b2014-11-14 08:01:01 -08001293 reply->writeStrongBinder(IInterface::asBinder(connection));
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001294 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001295 }
Mathias Agopiane57f2922012-08-09 16:29:12 -07001296 case CREATE_DISPLAY: {
1297 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden8dfa92f2012-09-17 18:27:17 -07001298 String8 displayName = data.readString8();
Jamie Gennisdd3cb842012-10-19 18:19:11 -07001299 bool secure = bool(data.readInt32());
1300 sp<IBinder> display(createDisplay(displayName, secure));
Mathias Agopiane57f2922012-08-09 16:29:12 -07001301 reply->writeStrongBinder(display);
1302 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001303 }
1304 case DESTROY_DISPLAY: {
1305 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1306 sp<IBinder> display = data.readStrongBinder();
1307 destroyDisplay(display);
1308 return NO_ERROR;
1309 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001310 case GET_PHYSICAL_DISPLAY_TOKEN: {
Mathias Agopiane57f2922012-08-09 16:29:12 -07001311 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marin Shalamanova524a092020-07-27 21:39:55 +02001312 PhysicalDisplayId displayId(data.readUint64());
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001313 sp<IBinder> display = getPhysicalDisplayToken(displayId);
Mathias Agopiane57f2922012-08-09 16:29:12 -07001314 reply->writeStrongBinder(display);
1315 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001316 }
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001317 case GET_DISPLAY_STATE: {
1318 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1319 ui::DisplayState state;
1320 const sp<IBinder> display = data.readStrongBinder();
1321 const status_t result = getDisplayState(display, &state);
1322 reply->writeInt32(result);
1323 if (result == NO_ERROR) {
1324 memcpy(reply->writeInplace(sizeof(ui::DisplayState)), &state,
1325 sizeof(ui::DisplayState));
1326 }
1327 return NO_ERROR;
1328 }
1329 case GET_DISPLAY_INFO: {
1330 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1331 DisplayInfo info;
1332 const sp<IBinder> display = data.readStrongBinder();
1333 const status_t result = getDisplayInfo(display, &info);
1334 reply->writeInt32(result);
Marin Shalamanov359a7e72020-02-17 17:03:07 +01001335 if (result != NO_ERROR) return result;
1336 return reply->write(info);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001337 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001338 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -07001339 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001340 Vector<DisplayConfig> configs;
1341 const sp<IBinder> display = data.readStrongBinder();
1342 const status_t result = getDisplayConfigs(display, &configs);
Dan Stoza7f7da322014-05-02 15:26:25 -07001343 reply->writeInt32(result);
1344 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -08001345 reply->writeUint32(static_cast<uint32_t>(configs.size()));
Dan Stoza7f7da322014-05-02 15:26:25 -07001346 for (size_t c = 0; c < configs.size(); ++c) {
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001347 memcpy(reply->writeInplace(sizeof(DisplayConfig)), &configs[c],
1348 sizeof(DisplayConfig));
Dan Stoza7f7da322014-05-02 15:26:25 -07001349 }
1350 }
1351 return NO_ERROR;
1352 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -07001353 case GET_DISPLAY_STATS: {
1354 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1355 DisplayStatInfo stats;
1356 sp<IBinder> display = data.readStrongBinder();
1357 status_t result = getDisplayStats(display, &stats);
1358 reply->writeInt32(result);
1359 if (result == NO_ERROR) {
1360 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
1361 &stats, sizeof(DisplayStatInfo));
1362 }
1363 return NO_ERROR;
1364 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001365 case GET_ACTIVE_CONFIG: {
1366 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1367 sp<IBinder> display = data.readStrongBinder();
1368 int id = getActiveConfig(display);
1369 reply->writeInt32(id);
1370 return NO_ERROR;
1371 }
Michael Wright28f24d02016-07-12 13:30:53 -07001372 case GET_DISPLAY_COLOR_MODES: {
1373 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Lina52f0292018-03-14 17:26:31 -07001374 Vector<ColorMode> colorModes;
Michael Wright28f24d02016-07-12 13:30:53 -07001375 sp<IBinder> display = nullptr;
1376 status_t result = data.readStrongBinder(&display);
1377 if (result != NO_ERROR) {
1378 ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result);
1379 return result;
1380 }
1381 result = getDisplayColorModes(display, &colorModes);
1382 reply->writeInt32(result);
1383 if (result == NO_ERROR) {
1384 reply->writeUint32(static_cast<uint32_t>(colorModes.size()));
1385 for (size_t i = 0; i < colorModes.size(); ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -07001386 reply->writeInt32(static_cast<int32_t>(colorModes[i]));
Michael Wright28f24d02016-07-12 13:30:53 -07001387 }
1388 }
1389 return NO_ERROR;
1390 }
Daniel Solomon42d04562019-01-20 21:03:19 -08001391 case GET_DISPLAY_NATIVE_PRIMARIES: {
1392 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1393 ui::DisplayPrimaries primaries;
1394 sp<IBinder> display = nullptr;
1395
1396 status_t result = data.readStrongBinder(&display);
1397 if (result != NO_ERROR) {
1398 ALOGE("getDisplayNativePrimaries failed to readStrongBinder: %d", result);
1399 return result;
1400 }
1401
1402 result = getDisplayNativePrimaries(display, primaries);
1403 reply->writeInt32(result);
1404 if (result == NO_ERROR) {
1405 memcpy(reply->writeInplace(sizeof(ui::DisplayPrimaries)), &primaries,
1406 sizeof(ui::DisplayPrimaries));
1407 }
1408
1409 return NO_ERROR;
1410 }
Michael Wright28f24d02016-07-12 13:30:53 -07001411 case GET_ACTIVE_COLOR_MODE: {
1412 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1413 sp<IBinder> display = nullptr;
1414 status_t result = data.readStrongBinder(&display);
1415 if (result != NO_ERROR) {
1416 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1417 return result;
1418 }
Peiyong Lina52f0292018-03-14 17:26:31 -07001419 ColorMode colorMode = getActiveColorMode(display);
Michael Wright28f24d02016-07-12 13:30:53 -07001420 result = reply->writeInt32(static_cast<int32_t>(colorMode));
1421 return result;
1422 }
1423 case SET_ACTIVE_COLOR_MODE: {
1424 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1425 sp<IBinder> display = nullptr;
1426 status_t result = data.readStrongBinder(&display);
1427 if (result != NO_ERROR) {
1428 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1429 return result;
1430 }
1431 int32_t colorModeInt = 0;
1432 result = data.readInt32(&colorModeInt);
1433 if (result != NO_ERROR) {
1434 ALOGE("setActiveColorMode failed to readInt32: %d", result);
1435 return result;
1436 }
1437 result = setActiveColorMode(display,
Peiyong Lina52f0292018-03-14 17:26:31 -07001438 static_cast<ColorMode>(colorModeInt));
Michael Wright28f24d02016-07-12 13:30:53 -07001439 result = reply->writeInt32(result);
1440 return result;
1441 }
Galia Peycheva5492cb52019-10-30 14:13:16 +01001442
1443 case GET_AUTO_LOW_LATENCY_MODE_SUPPORT: {
1444 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1445 sp<IBinder> display = nullptr;
1446 status_t result = data.readStrongBinder(&display);
1447 if (result != NO_ERROR) {
1448 ALOGE("getAutoLowLatencyModeSupport failed to readStrongBinder: %d", result);
1449 return result;
1450 }
1451 bool supported = false;
1452 result = getAutoLowLatencyModeSupport(display, &supported);
1453 if (result == NO_ERROR) {
1454 result = reply->writeBool(supported);
1455 }
1456 return result;
1457 }
1458
1459 case SET_AUTO_LOW_LATENCY_MODE: {
1460 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1461 sp<IBinder> display = nullptr;
1462 status_t result = data.readStrongBinder(&display);
1463 if (result != NO_ERROR) {
1464 ALOGE("setAutoLowLatencyMode failed to readStrongBinder: %d", result);
1465 return result;
1466 }
1467 bool setAllm = false;
1468 result = data.readBool(&setAllm);
1469 if (result != NO_ERROR) {
1470 ALOGE("setAutoLowLatencyMode failed to readBool: %d", result);
1471 return result;
1472 }
1473 setAutoLowLatencyMode(display, setAllm);
1474 return result;
1475 }
1476
1477 case GET_GAME_CONTENT_TYPE_SUPPORT: {
1478 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1479 sp<IBinder> display = nullptr;
1480 status_t result = data.readStrongBinder(&display);
1481 if (result != NO_ERROR) {
1482 ALOGE("getGameContentTypeSupport failed to readStrongBinder: %d", result);
1483 return result;
1484 }
1485 bool supported = false;
1486 result = getGameContentTypeSupport(display, &supported);
1487 if (result == NO_ERROR) {
1488 result = reply->writeBool(supported);
1489 }
1490 return result;
1491 }
1492
1493 case SET_GAME_CONTENT_TYPE: {
1494 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1495 sp<IBinder> display = nullptr;
1496 status_t result = data.readStrongBinder(&display);
1497 if (result != NO_ERROR) {
1498 ALOGE("setGameContentType failed to readStrongBinder: %d", result);
1499 return result;
1500 }
1501 bool setGameContentTypeOn = false;
1502 result = data.readBool(&setGameContentTypeOn);
1503 if (result != NO_ERROR) {
1504 ALOGE("setGameContentType failed to readBool: %d", result);
1505 return result;
1506 }
1507 setGameContentType(display, setGameContentTypeOn);
1508 return result;
1509 }
1510
Svetoslavd85084b2014-03-20 10:28:31 -07001511 case CLEAR_ANIMATION_FRAME_STATS: {
1512 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1513 status_t result = clearAnimationFrameStats();
1514 reply->writeInt32(result);
1515 return NO_ERROR;
1516 }
1517 case GET_ANIMATION_FRAME_STATS: {
1518 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1519 FrameStats stats;
1520 status_t result = getAnimationFrameStats(&stats);
1521 reply->write(stats);
1522 reply->writeInt32(result);
1523 return NO_ERROR;
1524 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -07001525 case SET_POWER_MODE: {
1526 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1527 sp<IBinder> display = data.readStrongBinder();
1528 int32_t mode = data.readInt32();
1529 setPowerMode(display, mode);
1530 return NO_ERROR;
1531 }
Dan Stozac4f471e2016-03-24 09:31:08 -07001532 case GET_HDR_CAPABILITIES: {
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("getHdrCapabilities failed to readStrongBinder: %d",
1538 result);
1539 return result;
1540 }
1541 HdrCapabilities capabilities;
1542 result = getHdrCapabilities(display, &capabilities);
1543 reply->writeInt32(result);
1544 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -08001545 reply->write(capabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -07001546 }
1547 return NO_ERROR;
1548 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -07001549 case ENABLE_VSYNC_INJECTIONS: {
1550 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1551 bool enable = false;
1552 status_t result = data.readBool(&enable);
1553 if (result != NO_ERROR) {
1554 ALOGE("enableVSyncInjections failed to readBool: %d", result);
1555 return result;
1556 }
1557 return enableVSyncInjections(enable);
1558 }
1559 case INJECT_VSYNC: {
1560 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1561 int64_t when = 0;
1562 status_t result = data.readInt64(&when);
1563 if (result != NO_ERROR) {
1564 ALOGE("enableVSyncInjections failed to readInt64: %d", result);
1565 return result;
1566 }
1567 return injectVSync(when);
1568 }
Kalle Raitaa099a242017-01-11 11:17:29 -08001569 case GET_LAYER_DEBUG_INFO: {
1570 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1571 std::vector<LayerDebugInfo> outLayers;
1572 status_t result = getLayerDebugInfo(&outLayers);
1573 reply->writeInt32(result);
1574 if (result == NO_ERROR)
1575 {
1576 result = reply->writeParcelableVector(outLayers);
1577 }
1578 return result;
1579 }
Peiyong Lin0256f722018-08-31 15:45:10 -07001580 case GET_COMPOSITION_PREFERENCE: {
1581 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Linc6780972018-10-28 15:24:08 -07001582 ui::Dataspace defaultDataspace;
1583 ui::PixelFormat defaultPixelFormat;
1584 ui::Dataspace wideColorGamutDataspace;
1585 ui::PixelFormat wideColorGamutPixelFormat;
1586 status_t error =
1587 getCompositionPreference(&defaultDataspace, &defaultPixelFormat,
1588 &wideColorGamutDataspace, &wideColorGamutPixelFormat);
Peiyong Lin0256f722018-08-31 15:45:10 -07001589 reply->writeInt32(error);
1590 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -07001591 reply->writeInt32(static_cast<int32_t>(defaultDataspace));
1592 reply->writeInt32(static_cast<int32_t>(defaultPixelFormat));
1593 reply->writeInt32(static_cast<int32_t>(wideColorGamutDataspace));
Peiyong Linaa3da6a2018-12-12 02:48:43 -08001594 reply->writeInt32(static_cast<int32_t>(wideColorGamutPixelFormat));
Peiyong Lin0256f722018-08-31 15:45:10 -07001595 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001596 return error;
Peiyong Lin0256f722018-08-31 15:45:10 -07001597 }
Ady Abraham37965d42018-11-01 13:43:32 -07001598 case GET_COLOR_MANAGEMENT: {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001599 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Ady Abraham37965d42018-11-01 13:43:32 -07001600 bool result;
1601 status_t error = getColorManagement(&result);
1602 if (error == NO_ERROR) {
1603 reply->writeBool(result);
1604 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001605 return error;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001606 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -07001607 case GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: {
1608 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1609
1610 sp<IBinder> display = data.readStrongBinder();
1611 ui::PixelFormat format;
1612 ui::Dataspace dataspace;
1613 uint8_t component = 0;
1614 auto result =
1615 getDisplayedContentSamplingAttributes(display, &format, &dataspace, &component);
1616 if (result == NO_ERROR) {
1617 reply->writeUint32(static_cast<uint32_t>(format));
1618 reply->writeUint32(static_cast<uint32_t>(dataspace));
1619 reply->writeUint32(static_cast<uint32_t>(component));
1620 }
1621 return result;
1622 }
Kevin DuBois74e53772018-11-19 10:52:38 -08001623 case SET_DISPLAY_CONTENT_SAMPLING_ENABLED: {
1624 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1625
1626 sp<IBinder> display = nullptr;
1627 bool enable = false;
1628 int8_t componentMask = 0;
1629 uint64_t maxFrames = 0;
1630 status_t result = data.readStrongBinder(&display);
1631 if (result != NO_ERROR) {
1632 ALOGE("setDisplayContentSamplingEnabled failure in reading Display token: %d",
1633 result);
1634 return result;
1635 }
1636
1637 result = data.readBool(&enable);
1638 if (result != NO_ERROR) {
1639 ALOGE("setDisplayContentSamplingEnabled failure in reading enable: %d", result);
1640 return result;
1641 }
1642
1643 result = data.readByte(static_cast<int8_t*>(&componentMask));
1644 if (result != NO_ERROR) {
1645 ALOGE("setDisplayContentSamplingEnabled failure in reading component mask: %d",
1646 result);
1647 return result;
1648 }
1649
1650 result = data.readUint64(&maxFrames);
1651 if (result != NO_ERROR) {
1652 ALOGE("setDisplayContentSamplingEnabled failure in reading max frames: %d", result);
1653 return result;
1654 }
1655
1656 return setDisplayContentSamplingEnabled(display, enable,
1657 static_cast<uint8_t>(componentMask), maxFrames);
1658 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001659 case GET_DISPLAYED_CONTENT_SAMPLE: {
1660 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1661
1662 sp<IBinder> display = data.readStrongBinder();
1663 uint64_t maxFrames = 0;
1664 uint64_t timestamp = 0;
1665
1666 status_t result = data.readUint64(&maxFrames);
1667 if (result != NO_ERROR) {
1668 ALOGE("getDisplayedContentSample failure in reading max frames: %d", result);
1669 return result;
1670 }
1671
1672 result = data.readUint64(&timestamp);
1673 if (result != NO_ERROR) {
1674 ALOGE("getDisplayedContentSample failure in reading timestamp: %d", result);
1675 return result;
1676 }
1677
1678 DisplayedFrameStats stats;
1679 result = getDisplayedContentSample(display, maxFrames, timestamp, &stats);
1680 if (result == NO_ERROR) {
1681 reply->writeUint64(stats.numFrames);
Kevin DuBois1d4c6a62018-12-12 13:59:46 -08001682 reply->writeUint64Vector(stats.component_0_sample);
1683 reply->writeUint64Vector(stats.component_1_sample);
1684 reply->writeUint64Vector(stats.component_2_sample);
1685 reply->writeUint64Vector(stats.component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001686 }
1687 return result;
1688 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001689 case GET_PROTECTED_CONTENT_SUPPORT: {
1690 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1691 bool result;
1692 status_t error = getProtectedContentSupport(&result);
1693 if (error == NO_ERROR) {
1694 reply->writeBool(result);
1695 }
1696 return error;
1697 }
Peiyong Lin4f3fddf2019-01-24 17:21:24 -08001698 case IS_WIDE_COLOR_DISPLAY: {
1699 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1700 sp<IBinder> display = nullptr;
1701 status_t error = data.readStrongBinder(&display);
1702 if (error != NO_ERROR) {
1703 return error;
1704 }
1705 bool result;
1706 error = isWideColorDisplay(display, &result);
1707 if (error == NO_ERROR) {
1708 reply->writeBool(result);
1709 }
1710 return error;
1711 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001712 case GET_PHYSICAL_DISPLAY_IDS: {
1713 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marin Shalamanova524a092020-07-27 21:39:55 +02001714 std::vector<PhysicalDisplayId> ids = getPhysicalDisplayIds();
1715 std::vector<uint64_t> rawIds(ids.size());
1716 std::transform(ids.begin(), ids.end(), rawIds.begin(),
1717 [](PhysicalDisplayId id) { return id.value; });
1718 return reply->writeUint64Vector(rawIds);
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001719 }
Dan Stoza84ab9372018-12-17 15:27:57 -08001720 case ADD_REGION_SAMPLING_LISTENER: {
1721 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1722 Rect samplingArea;
1723 status_t result = data.read(samplingArea);
1724 if (result != NO_ERROR) {
1725 ALOGE("addRegionSamplingListener: Failed to read sampling area");
1726 return result;
1727 }
1728 sp<IBinder> stopLayerHandle;
1729 result = data.readNullableStrongBinder(&stopLayerHandle);
1730 if (result != NO_ERROR) {
1731 ALOGE("addRegionSamplingListener: Failed to read stop layer handle");
1732 return result;
1733 }
1734 sp<IRegionSamplingListener> listener;
1735 result = data.readNullableStrongBinder(&listener);
1736 if (result != NO_ERROR) {
1737 ALOGE("addRegionSamplingListener: Failed to read listener");
1738 return result;
1739 }
1740 return addRegionSamplingListener(samplingArea, stopLayerHandle, listener);
1741 }
1742 case REMOVE_REGION_SAMPLING_LISTENER: {
1743 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1744 sp<IRegionSamplingListener> listener;
1745 status_t result = data.readNullableStrongBinder(&listener);
1746 if (result != NO_ERROR) {
1747 ALOGE("removeRegionSamplingListener: Failed to read listener");
1748 return result;
1749 }
1750 return removeRegionSamplingListener(listener);
1751 }
Ana Krulec0782b882019-10-15 17:34:54 -07001752 case SET_DESIRED_DISPLAY_CONFIG_SPECS: {
1753 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1754 sp<IBinder> displayToken = data.readStrongBinder();
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001755 int32_t defaultConfig;
1756 status_t result = data.readInt32(&defaultConfig);
Ana Krulec0782b882019-10-15 17:34:54 -07001757 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001758 ALOGE("setDesiredDisplayConfigSpecs: failed to read defaultConfig: %d", result);
Ana Krulec0782b882019-10-15 17:34:54 -07001759 return result;
1760 }
Steven Thomasf734df42020-04-13 21:09:28 -07001761 float primaryRefreshRateMin;
1762 result = data.readFloat(&primaryRefreshRateMin);
Ana Krulec0782b882019-10-15 17:34:54 -07001763 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001764 ALOGE("setDesiredDisplayConfigSpecs: failed to read primaryRefreshRateMin: %d",
1765 result);
Ana Krulec0782b882019-10-15 17:34:54 -07001766 return result;
1767 }
Steven Thomasf734df42020-04-13 21:09:28 -07001768 float primaryRefreshRateMax;
1769 result = data.readFloat(&primaryRefreshRateMax);
Ana Krulec0782b882019-10-15 17:34:54 -07001770 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001771 ALOGE("setDesiredDisplayConfigSpecs: failed to read primaryRefreshRateMax: %d",
1772 result);
Ana Krulec0782b882019-10-15 17:34:54 -07001773 return result;
1774 }
Steven Thomasf734df42020-04-13 21:09:28 -07001775 float appRequestRefreshRateMin;
1776 result = data.readFloat(&appRequestRefreshRateMin);
1777 if (result != NO_ERROR) {
1778 ALOGE("setDesiredDisplayConfigSpecs: failed to read appRequestRefreshRateMin: %d",
1779 result);
1780 return result;
1781 }
1782 float appRequestRefreshRateMax;
1783 result = data.readFloat(&appRequestRefreshRateMax);
1784 if (result != NO_ERROR) {
1785 ALOGE("setDesiredDisplayConfigSpecs: failed to read appRequestRefreshRateMax: %d",
1786 result);
1787 return result;
1788 }
1789 result =
1790 setDesiredDisplayConfigSpecs(displayToken, defaultConfig, primaryRefreshRateMin,
1791 primaryRefreshRateMax, appRequestRefreshRateMin,
1792 appRequestRefreshRateMax);
Ana Krulec0782b882019-10-15 17:34:54 -07001793 if (result != NO_ERROR) {
1794 ALOGE("setDesiredDisplayConfigSpecs: failed to call setDesiredDisplayConfigSpecs: "
1795 "%d",
1796 result);
1797 return result;
1798 }
1799 reply->writeInt32(result);
1800 return result;
1801 }
Ana Krulec234bb162019-11-10 22:55:55 +01001802 case GET_DESIRED_DISPLAY_CONFIG_SPECS: {
1803 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1804 sp<IBinder> displayToken = data.readStrongBinder();
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001805 int32_t defaultConfig;
Steven Thomasf734df42020-04-13 21:09:28 -07001806 float primaryRefreshRateMin;
1807 float primaryRefreshRateMax;
1808 float appRequestRefreshRateMin;
1809 float appRequestRefreshRateMax;
Ana Krulec234bb162019-11-10 22:55:55 +01001810
Steven Thomasf734df42020-04-13 21:09:28 -07001811 status_t result =
1812 getDesiredDisplayConfigSpecs(displayToken, &defaultConfig,
1813 &primaryRefreshRateMin, &primaryRefreshRateMax,
1814 &appRequestRefreshRateMin,
1815 &appRequestRefreshRateMax);
Ana Krulec234bb162019-11-10 22:55:55 +01001816 if (result != NO_ERROR) {
1817 ALOGE("getDesiredDisplayConfigSpecs: failed to get getDesiredDisplayConfigSpecs: "
1818 "%d",
1819 result);
1820 return result;
1821 }
1822
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001823 result = reply->writeInt32(defaultConfig);
Ana Krulec234bb162019-11-10 22:55:55 +01001824 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001825 ALOGE("getDesiredDisplayConfigSpecs: failed to write defaultConfig: %d", result);
Ana Krulec234bb162019-11-10 22:55:55 +01001826 return result;
1827 }
Steven Thomasf734df42020-04-13 21:09:28 -07001828 result = reply->writeFloat(primaryRefreshRateMin);
Ana Krulec234bb162019-11-10 22:55:55 +01001829 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001830 ALOGE("getDesiredDisplayConfigSpecs: failed to write primaryRefreshRateMin: %d",
1831 result);
Ana Krulec234bb162019-11-10 22:55:55 +01001832 return result;
1833 }
Steven Thomasf734df42020-04-13 21:09:28 -07001834 result = reply->writeFloat(primaryRefreshRateMax);
Ana Krulec234bb162019-11-10 22:55:55 +01001835 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001836 ALOGE("getDesiredDisplayConfigSpecs: failed to write primaryRefreshRateMax: %d",
1837 result);
1838 return result;
1839 }
1840 result = reply->writeFloat(appRequestRefreshRateMin);
1841 if (result != NO_ERROR) {
1842 ALOGE("getDesiredDisplayConfigSpecs: failed to write appRequestRefreshRateMin: %d",
1843 result);
1844 return result;
1845 }
1846 result = reply->writeFloat(appRequestRefreshRateMax);
1847 if (result != NO_ERROR) {
1848 ALOGE("getDesiredDisplayConfigSpecs: failed to write appRequestRefreshRateMax: %d",
1849 result);
Ana Krulec234bb162019-11-10 22:55:55 +01001850 return result;
1851 }
1852 reply->writeInt32(result);
1853 return result;
1854 }
Dan Gittik57e63c52019-01-18 16:37:54 +00001855 case GET_DISPLAY_BRIGHTNESS_SUPPORT: {
1856 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1857 sp<IBinder> displayToken;
1858 status_t error = data.readNullableStrongBinder(&displayToken);
1859 if (error != NO_ERROR) {
1860 ALOGE("getDisplayBrightnessSupport: failed to read display token: %d", error);
1861 return error;
1862 }
1863 bool support = false;
1864 error = getDisplayBrightnessSupport(displayToken, &support);
1865 reply->writeBool(support);
1866 return error;
1867 }
1868 case SET_DISPLAY_BRIGHTNESS: {
1869 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1870 sp<IBinder> displayToken;
1871 status_t error = data.readNullableStrongBinder(&displayToken);
1872 if (error != NO_ERROR) {
1873 ALOGE("setDisplayBrightness: failed to read display token: %d", error);
1874 return error;
1875 }
1876 float brightness = -1.0f;
1877 error = data.readFloat(&brightness);
1878 if (error != NO_ERROR) {
1879 ALOGE("setDisplayBrightness: failed to read brightness: %d", error);
1880 return error;
1881 }
1882 return setDisplayBrightness(displayToken, brightness);
1883 }
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001884 case NOTIFY_POWER_BOOST: {
Ady Abraham8532d012019-05-08 14:50:56 -07001885 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001886 int32_t boostId;
1887 status_t error = data.readInt32(&boostId);
Ady Abraham8532d012019-05-08 14:50:56 -07001888 if (error != NO_ERROR) {
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001889 ALOGE("notifyPowerBoost: failed to read boostId: %d", error);
Ady Abraham8532d012019-05-08 14:50:56 -07001890 return error;
1891 }
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001892 return notifyPowerBoost(boostId);
Ady Abraham8532d012019-05-08 14:50:56 -07001893 }
Vishnu Nairb13bb952019-11-15 10:24:08 -08001894 case SET_GLOBAL_SHADOW_SETTINGS: {
1895 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1896
1897 std::vector<float> shadowConfig;
1898 status_t error = data.readFloatVector(&shadowConfig);
1899 if (error != NO_ERROR || shadowConfig.size() != 11) {
1900 ALOGE("setGlobalShadowSettings: failed to read shadowConfig: %d", error);
1901 return error;
1902 }
1903
1904 half4 ambientColor = {shadowConfig[0], shadowConfig[1], shadowConfig[2],
1905 shadowConfig[3]};
1906 half4 spotColor = {shadowConfig[4], shadowConfig[5], shadowConfig[6], shadowConfig[7]};
1907 float lightPosY = shadowConfig[8];
1908 float lightPosZ = shadowConfig[9];
1909 float lightRadius = shadowConfig[10];
1910 return setGlobalShadowSettings(ambientColor, spotColor, lightPosY, lightPosZ,
1911 lightRadius);
1912 }
Steven Thomas62a4cf82020-01-31 12:04:03 -08001913 case SET_FRAME_RATE: {
1914 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1915 sp<IBinder> binder;
1916 status_t err = data.readStrongBinder(&binder);
1917 if (err != NO_ERROR) {
1918 ALOGE("setFrameRate: failed to read strong binder: %s (%d)", strerror(-err), -err);
1919 return err;
1920 }
1921 sp<IGraphicBufferProducer> surface = interface_cast<IGraphicBufferProducer>(binder);
1922 if (!surface) {
1923 ALOGE("setFrameRate: failed to cast to IGraphicBufferProducer: %s (%d)",
1924 strerror(-err), -err);
1925 return err;
1926 }
1927 float frameRate;
1928 err = data.readFloat(&frameRate);
1929 if (err != NO_ERROR) {
1930 ALOGE("setFrameRate: failed to read float: %s (%d)", strerror(-err), -err);
1931 return err;
1932 }
1933 int8_t compatibility;
1934 err = data.readByte(&compatibility);
1935 if (err != NO_ERROR) {
1936 ALOGE("setFrameRate: failed to read byte: %s (%d)", strerror(-err), -err);
1937 return err;
1938 }
1939 status_t result = setFrameRate(surface, frameRate, compatibility);
1940 reply->writeInt32(result);
1941 return NO_ERROR;
1942 }
Steven Thomasd4071902020-03-24 16:02:53 -07001943 case ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN: {
1944 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1945 sp<IBinder> token;
1946 status_t result = acquireFrameRateFlexibilityToken(&token);
1947 reply->writeInt32(result);
1948 if (result == NO_ERROR) {
1949 reply->writeStrongBinder(token);
1950 }
1951 return NO_ERROR;
1952 }
Jesse Hall6c913be2013-08-08 12:15:49 -07001953 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001954 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -07001955 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001956 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001957}
1958
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001959} // namespace android