blob: 8b65ea1cbeabb14ac9e3c814fd48902cf754891d [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 }
Ady Abraham74e17562020-08-24 18:18:19 -07001153
1154 virtual status_t setFrameTimelineVsync(const sp<IGraphicBufferProducer>& surface,
1155 int64_t frameTimelineVsyncId) {
1156 Parcel data, reply;
1157 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1158 if (err != NO_ERROR) {
1159 ALOGE("setFrameTimelineVsync: failed writing interface token: %s (%d)", strerror(-err),
1160 -err);
1161 return err;
1162 }
1163
1164 err = data.writeStrongBinder(IInterface::asBinder(surface));
1165 if (err != NO_ERROR) {
1166 ALOGE("setFrameTimelineVsync: failed writing strong binder: %s (%d)", strerror(-err),
1167 -err);
1168 return err;
1169 }
1170
1171 err = data.writeInt64(frameTimelineVsyncId);
1172 if (err != NO_ERROR) {
1173 ALOGE("setFrameTimelineVsync: failed writing int64_t: %s (%d)", strerror(-err), -err);
1174 return err;
1175 }
1176
1177 err = remote()->transact(BnSurfaceComposer::SET_FRAME_TIMELINE_VSYNC, data, &reply);
1178 if (err != NO_ERROR) {
1179 ALOGE("setFrameTimelineVsync: failed to transact: %s (%d)", strerror(-err), err);
1180 return err;
1181 }
1182
1183 return reply.readInt32();
1184 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001185};
1186
Dan Stozad723bd72014-11-18 10:24:03 -08001187// Out-of-line virtual method definition to trigger vtable emission in this
1188// translation unit (see clang warning -Wweak-vtables)
1189BpSurfaceComposer::~BpSurfaceComposer() {}
1190
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001191IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
1192
1193// ----------------------------------------------------------------------
1194
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001195status_t BnSurfaceComposer::onTransact(
1196 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
1197{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001198 switch(code) {
1199 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001200 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -08001201 sp<IBinder> b = IInterface::asBinder(createConnection());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001202 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -07001203 return NO_ERROR;
1204 }
Mathias Agopian698c0872011-06-28 19:09:31 -07001205 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001206 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -08001207
chaviw308ddba2020-08-11 16:23:51 -07001208 uint32_t count = 0;
1209 SAFE_PARCEL_READ_SIZE(data.readUint32, &count, data.dataSize());
Mathias Agopian698c0872011-06-28 19:09:31 -07001210 Vector<ComposerState> state;
1211 state.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -08001212 for (size_t i = 0; i < count; i++) {
Marissa Wallc837b5e2018-10-12 10:04:44 -07001213 ComposerState s;
chaviw308ddba2020-08-11 16:23:51 -07001214 SAFE_PARCEL(s.read, data);
Mathias Agopian698c0872011-06-28 19:09:31 -07001215 state.add(s);
1216 }
Dan Stozad723bd72014-11-18 10:24:03 -08001217
chaviw308ddba2020-08-11 16:23:51 -07001218 SAFE_PARCEL_READ_SIZE(data.readUint32, &count, data.dataSize());
Mathias Agopian8b33f032012-07-24 20:43:54 -07001219 DisplayState d;
1220 Vector<DisplayState> displays;
1221 displays.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -08001222 for (size_t i = 0; i < count; i++) {
chaviw308ddba2020-08-11 16:23:51 -07001223 SAFE_PARCEL(d.read, data);
Mathias Agopian8b33f032012-07-24 20:43:54 -07001224 displays.add(d);
1225 }
Dan Stozad723bd72014-11-18 10:24:03 -08001226
chaviw308ddba2020-08-11 16:23:51 -07001227 uint32_t stateFlags = 0;
1228 SAFE_PARCEL(data.readUint32, &stateFlags);
1229 sp<IBinder> applyToken;
1230 SAFE_PARCEL(data.readStrongBinder, &applyToken);
chaviw273171b2018-12-26 11:46:30 -08001231 InputWindowCommands inputWindowCommands;
chaviw308ddba2020-08-11 16:23:51 -07001232 SAFE_PARCEL(inputWindowCommands.read, data);
Marissa Wall17b4e452018-12-26 16:32:34 -08001233
chaviw308ddba2020-08-11 16:23:51 -07001234 int64_t desiredPresentTime = 0;
1235 SAFE_PARCEL(data.readInt64, &desiredPresentTime);
Marissa Wall78b72202019-03-15 14:58:34 -07001236
Marissa Wall947d34e2019-03-29 14:03:53 -07001237 client_cache_t uncachedBuffer;
chaviw308ddba2020-08-11 16:23:51 -07001238 sp<IBinder> tmpBinder;
1239 SAFE_PARCEL(data.readNullableStrongBinder, &tmpBinder);
1240 uncachedBuffer.token = tmpBinder;
1241 SAFE_PARCEL(data.readUint64, &uncachedBuffer.id);
Marissa Wall78b72202019-03-15 14:58:34 -07001242
chaviw308ddba2020-08-11 16:23:51 -07001243 bool hasListenerCallbacks = false;
1244 SAFE_PARCEL(data.readBool, &hasListenerCallbacks);
Valerie Hau9dab9732019-08-20 09:29:25 -07001245
Marissa Wall3dad52d2019-03-22 14:03:19 -07001246 std::vector<ListenerCallbacks> listenerCallbacks;
chaviw308ddba2020-08-11 16:23:51 -07001247 int32_t listenersSize = 0;
1248 SAFE_PARCEL_READ_SIZE(data.readInt32, &listenersSize, data.dataSize());
Marissa Wall3dad52d2019-03-22 14:03:19 -07001249 for (int32_t i = 0; i < listenersSize; i++) {
chaviw308ddba2020-08-11 16:23:51 -07001250 SAFE_PARCEL(data.readStrongBinder, &tmpBinder);
Marissa Wall3dad52d2019-03-22 14:03:19 -07001251 std::vector<CallbackId> callbackIds;
chaviw308ddba2020-08-11 16:23:51 -07001252 SAFE_PARCEL(data.readInt64Vector, &callbackIds);
1253 listenerCallbacks.emplace_back(tmpBinder, callbackIds);
Marissa Wall3dad52d2019-03-22 14:03:19 -07001254 }
chaviw308ddba2020-08-11 16:23:51 -07001255 return setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands,
1256 desiredPresentTime, uncachedBuffer, hasListenerCallbacks,
1257 listenerCallbacks);
Jesse Hall6c913be2013-08-08 12:15:49 -07001258 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001259 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001260 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001261 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -07001262 return NO_ERROR;
1263 }
chaviwd2432892020-07-24 17:42:39 -07001264 case CAPTURE_DISPLAY: {
Mathias Agopian2a9fc492013-03-01 13:42:57 -08001265 CHECK_INTERFACE(ISurfaceComposer, data, reply);
chaviwd2432892020-07-24 17:42:39 -07001266 DisplayCaptureArgs args;
chaviw8ffc7b82020-08-18 11:25:37 -07001267 sp<IScreenCaptureListener> captureListener;
chaviw308ddba2020-08-11 16:23:51 -07001268 SAFE_PARCEL(args.read, data);
chaviw8ffc7b82020-08-18 11:25:37 -07001269 SAFE_PARCEL(data.readStrongBinder, &captureListener);
1270
1271 return captureDisplay(args, captureListener);
Jesse Hall6c913be2013-08-08 12:15:49 -07001272 }
chaviwd2432892020-07-24 17:42:39 -07001273 case CAPTURE_DISPLAY_BY_ID: {
chaviw93df2ea2019-04-30 16:45:12 -07001274 CHECK_INTERFACE(ISurfaceComposer, data, reply);
chaviw308ddba2020-08-11 16:23:51 -07001275 uint64_t displayOrLayerStack = 0;
chaviw8ffc7b82020-08-18 11:25:37 -07001276 sp<IScreenCaptureListener> captureListener;
chaviw308ddba2020-08-11 16:23:51 -07001277 SAFE_PARCEL(data.readUint64, &displayOrLayerStack);
chaviw8ffc7b82020-08-18 11:25:37 -07001278 SAFE_PARCEL(data.readStrongBinder, &captureListener);
1279
1280 return captureDisplay(displayOrLayerStack, captureListener);
chaviw93df2ea2019-04-30 16:45:12 -07001281 }
chaviwa76b2712017-09-20 12:02:26 -07001282 case CAPTURE_LAYERS: {
1283 CHECK_INTERFACE(ISurfaceComposer, data, reply);
chaviw3efadb12020-07-27 10:07:15 -07001284 LayerCaptureArgs args;
chaviw8ffc7b82020-08-18 11:25:37 -07001285 sp<IScreenCaptureListener> captureListener;
chaviw308ddba2020-08-11 16:23:51 -07001286 SAFE_PARCEL(args.read, data);
chaviw8ffc7b82020-08-18 11:25:37 -07001287 SAFE_PARCEL(data.readStrongBinder, &captureListener);
1288
1289 return captureLayers(args, captureListener);
chaviwa76b2712017-09-20 12:02:26 -07001290 }
Jamie Gennis134f0422011-03-08 12:18:54 -08001291 case AUTHENTICATE_SURFACE: {
1292 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -08001293 sp<IGraphicBufferProducer> bufferProducer =
1294 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
1295 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -08001296 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -07001297 return NO_ERROR;
1298 }
Brian Anderson6b376712017-04-04 10:51:39 -07001299 case GET_SUPPORTED_FRAME_TIMESTAMPS: {
1300 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1301 std::vector<FrameEvent> supportedTimestamps;
1302 status_t result = getSupportedFrameTimestamps(&supportedTimestamps);
1303 status_t err = reply->writeInt32(result);
1304 if (err != NO_ERROR) {
1305 return err;
1306 }
1307 if (result != NO_ERROR) {
1308 return result;
1309 }
1310
1311 std::vector<int32_t> supported;
1312 supported.reserve(supportedTimestamps.size());
1313 for (FrameEvent s : supportedTimestamps) {
1314 supported.push_back(static_cast<int32_t>(s));
1315 }
1316 return reply->writeInt32Vector(supported);
1317 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001318 case CREATE_DISPLAY_EVENT_CONNECTION: {
1319 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Ady Abraham0f4a1b12019-06-04 16:04:04 -07001320 auto vsyncSource = static_cast<ISurfaceComposer::VsyncSource>(data.readInt32());
1321 auto configChanged = static_cast<ISurfaceComposer::ConfigChanged>(data.readInt32());
1322
1323 sp<IDisplayEventConnection> connection(
1324 createDisplayEventConnection(vsyncSource, configChanged));
Marco Nelissen2ea926b2014-11-14 08:01:01 -08001325 reply->writeStrongBinder(IInterface::asBinder(connection));
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001326 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001327 }
Mathias Agopiane57f2922012-08-09 16:29:12 -07001328 case CREATE_DISPLAY: {
1329 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden8dfa92f2012-09-17 18:27:17 -07001330 String8 displayName = data.readString8();
Jamie Gennisdd3cb842012-10-19 18:19:11 -07001331 bool secure = bool(data.readInt32());
1332 sp<IBinder> display(createDisplay(displayName, secure));
Mathias Agopiane57f2922012-08-09 16:29:12 -07001333 reply->writeStrongBinder(display);
1334 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001335 }
1336 case DESTROY_DISPLAY: {
1337 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1338 sp<IBinder> display = data.readStrongBinder();
1339 destroyDisplay(display);
1340 return NO_ERROR;
1341 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001342 case GET_PHYSICAL_DISPLAY_TOKEN: {
Mathias Agopiane57f2922012-08-09 16:29:12 -07001343 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marin Shalamanova524a092020-07-27 21:39:55 +02001344 PhysicalDisplayId displayId(data.readUint64());
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001345 sp<IBinder> display = getPhysicalDisplayToken(displayId);
Mathias Agopiane57f2922012-08-09 16:29:12 -07001346 reply->writeStrongBinder(display);
1347 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001348 }
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001349 case GET_DISPLAY_STATE: {
1350 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1351 ui::DisplayState state;
1352 const sp<IBinder> display = data.readStrongBinder();
1353 const status_t result = getDisplayState(display, &state);
1354 reply->writeInt32(result);
1355 if (result == NO_ERROR) {
1356 memcpy(reply->writeInplace(sizeof(ui::DisplayState)), &state,
1357 sizeof(ui::DisplayState));
1358 }
1359 return NO_ERROR;
1360 }
1361 case GET_DISPLAY_INFO: {
1362 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1363 DisplayInfo info;
1364 const sp<IBinder> display = data.readStrongBinder();
1365 const status_t result = getDisplayInfo(display, &info);
1366 reply->writeInt32(result);
Marin Shalamanov359a7e72020-02-17 17:03:07 +01001367 if (result != NO_ERROR) return result;
1368 return reply->write(info);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001369 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001370 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -07001371 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001372 Vector<DisplayConfig> configs;
1373 const sp<IBinder> display = data.readStrongBinder();
1374 const status_t result = getDisplayConfigs(display, &configs);
Dan Stoza7f7da322014-05-02 15:26:25 -07001375 reply->writeInt32(result);
1376 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -08001377 reply->writeUint32(static_cast<uint32_t>(configs.size()));
Dan Stoza7f7da322014-05-02 15:26:25 -07001378 for (size_t c = 0; c < configs.size(); ++c) {
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001379 memcpy(reply->writeInplace(sizeof(DisplayConfig)), &configs[c],
1380 sizeof(DisplayConfig));
Dan Stoza7f7da322014-05-02 15:26:25 -07001381 }
1382 }
1383 return NO_ERROR;
1384 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -07001385 case GET_DISPLAY_STATS: {
1386 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1387 DisplayStatInfo stats;
1388 sp<IBinder> display = data.readStrongBinder();
1389 status_t result = getDisplayStats(display, &stats);
1390 reply->writeInt32(result);
1391 if (result == NO_ERROR) {
1392 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
1393 &stats, sizeof(DisplayStatInfo));
1394 }
1395 return NO_ERROR;
1396 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001397 case GET_ACTIVE_CONFIG: {
1398 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1399 sp<IBinder> display = data.readStrongBinder();
1400 int id = getActiveConfig(display);
1401 reply->writeInt32(id);
1402 return NO_ERROR;
1403 }
Michael Wright28f24d02016-07-12 13:30:53 -07001404 case GET_DISPLAY_COLOR_MODES: {
1405 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Lina52f0292018-03-14 17:26:31 -07001406 Vector<ColorMode> colorModes;
Michael Wright28f24d02016-07-12 13:30:53 -07001407 sp<IBinder> display = nullptr;
1408 status_t result = data.readStrongBinder(&display);
1409 if (result != NO_ERROR) {
1410 ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result);
1411 return result;
1412 }
1413 result = getDisplayColorModes(display, &colorModes);
1414 reply->writeInt32(result);
1415 if (result == NO_ERROR) {
1416 reply->writeUint32(static_cast<uint32_t>(colorModes.size()));
1417 for (size_t i = 0; i < colorModes.size(); ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -07001418 reply->writeInt32(static_cast<int32_t>(colorModes[i]));
Michael Wright28f24d02016-07-12 13:30:53 -07001419 }
1420 }
1421 return NO_ERROR;
1422 }
Daniel Solomon42d04562019-01-20 21:03:19 -08001423 case GET_DISPLAY_NATIVE_PRIMARIES: {
1424 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1425 ui::DisplayPrimaries primaries;
1426 sp<IBinder> display = nullptr;
1427
1428 status_t result = data.readStrongBinder(&display);
1429 if (result != NO_ERROR) {
1430 ALOGE("getDisplayNativePrimaries failed to readStrongBinder: %d", result);
1431 return result;
1432 }
1433
1434 result = getDisplayNativePrimaries(display, primaries);
1435 reply->writeInt32(result);
1436 if (result == NO_ERROR) {
1437 memcpy(reply->writeInplace(sizeof(ui::DisplayPrimaries)), &primaries,
1438 sizeof(ui::DisplayPrimaries));
1439 }
1440
1441 return NO_ERROR;
1442 }
Michael Wright28f24d02016-07-12 13:30:53 -07001443 case GET_ACTIVE_COLOR_MODE: {
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("getActiveColorMode failed to readStrongBinder: %d", result);
1449 return result;
1450 }
Peiyong Lina52f0292018-03-14 17:26:31 -07001451 ColorMode colorMode = getActiveColorMode(display);
Michael Wright28f24d02016-07-12 13:30:53 -07001452 result = reply->writeInt32(static_cast<int32_t>(colorMode));
1453 return result;
1454 }
1455 case SET_ACTIVE_COLOR_MODE: {
1456 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1457 sp<IBinder> display = nullptr;
1458 status_t result = data.readStrongBinder(&display);
1459 if (result != NO_ERROR) {
1460 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1461 return result;
1462 }
1463 int32_t colorModeInt = 0;
1464 result = data.readInt32(&colorModeInt);
1465 if (result != NO_ERROR) {
1466 ALOGE("setActiveColorMode failed to readInt32: %d", result);
1467 return result;
1468 }
1469 result = setActiveColorMode(display,
Peiyong Lina52f0292018-03-14 17:26:31 -07001470 static_cast<ColorMode>(colorModeInt));
Michael Wright28f24d02016-07-12 13:30:53 -07001471 result = reply->writeInt32(result);
1472 return result;
1473 }
Galia Peycheva5492cb52019-10-30 14:13:16 +01001474
1475 case GET_AUTO_LOW_LATENCY_MODE_SUPPORT: {
1476 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1477 sp<IBinder> display = nullptr;
1478 status_t result = data.readStrongBinder(&display);
1479 if (result != NO_ERROR) {
1480 ALOGE("getAutoLowLatencyModeSupport failed to readStrongBinder: %d", result);
1481 return result;
1482 }
1483 bool supported = false;
1484 result = getAutoLowLatencyModeSupport(display, &supported);
1485 if (result == NO_ERROR) {
1486 result = reply->writeBool(supported);
1487 }
1488 return result;
1489 }
1490
1491 case SET_AUTO_LOW_LATENCY_MODE: {
1492 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1493 sp<IBinder> display = nullptr;
1494 status_t result = data.readStrongBinder(&display);
1495 if (result != NO_ERROR) {
1496 ALOGE("setAutoLowLatencyMode failed to readStrongBinder: %d", result);
1497 return result;
1498 }
1499 bool setAllm = false;
1500 result = data.readBool(&setAllm);
1501 if (result != NO_ERROR) {
1502 ALOGE("setAutoLowLatencyMode failed to readBool: %d", result);
1503 return result;
1504 }
1505 setAutoLowLatencyMode(display, setAllm);
1506 return result;
1507 }
1508
1509 case GET_GAME_CONTENT_TYPE_SUPPORT: {
1510 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1511 sp<IBinder> display = nullptr;
1512 status_t result = data.readStrongBinder(&display);
1513 if (result != NO_ERROR) {
1514 ALOGE("getGameContentTypeSupport failed to readStrongBinder: %d", result);
1515 return result;
1516 }
1517 bool supported = false;
1518 result = getGameContentTypeSupport(display, &supported);
1519 if (result == NO_ERROR) {
1520 result = reply->writeBool(supported);
1521 }
1522 return result;
1523 }
1524
1525 case SET_GAME_CONTENT_TYPE: {
1526 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1527 sp<IBinder> display = nullptr;
1528 status_t result = data.readStrongBinder(&display);
1529 if (result != NO_ERROR) {
1530 ALOGE("setGameContentType failed to readStrongBinder: %d", result);
1531 return result;
1532 }
1533 bool setGameContentTypeOn = false;
1534 result = data.readBool(&setGameContentTypeOn);
1535 if (result != NO_ERROR) {
1536 ALOGE("setGameContentType failed to readBool: %d", result);
1537 return result;
1538 }
1539 setGameContentType(display, setGameContentTypeOn);
1540 return result;
1541 }
1542
Svetoslavd85084b2014-03-20 10:28:31 -07001543 case CLEAR_ANIMATION_FRAME_STATS: {
1544 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1545 status_t result = clearAnimationFrameStats();
1546 reply->writeInt32(result);
1547 return NO_ERROR;
1548 }
1549 case GET_ANIMATION_FRAME_STATS: {
1550 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1551 FrameStats stats;
1552 status_t result = getAnimationFrameStats(&stats);
1553 reply->write(stats);
1554 reply->writeInt32(result);
1555 return NO_ERROR;
1556 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -07001557 case SET_POWER_MODE: {
1558 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1559 sp<IBinder> display = data.readStrongBinder();
1560 int32_t mode = data.readInt32();
1561 setPowerMode(display, mode);
1562 return NO_ERROR;
1563 }
Dan Stozac4f471e2016-03-24 09:31:08 -07001564 case GET_HDR_CAPABILITIES: {
1565 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1566 sp<IBinder> display = nullptr;
1567 status_t result = data.readStrongBinder(&display);
1568 if (result != NO_ERROR) {
1569 ALOGE("getHdrCapabilities failed to readStrongBinder: %d",
1570 result);
1571 return result;
1572 }
1573 HdrCapabilities capabilities;
1574 result = getHdrCapabilities(display, &capabilities);
1575 reply->writeInt32(result);
1576 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -08001577 reply->write(capabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -07001578 }
1579 return NO_ERROR;
1580 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -07001581 case ENABLE_VSYNC_INJECTIONS: {
1582 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1583 bool enable = false;
1584 status_t result = data.readBool(&enable);
1585 if (result != NO_ERROR) {
1586 ALOGE("enableVSyncInjections failed to readBool: %d", result);
1587 return result;
1588 }
1589 return enableVSyncInjections(enable);
1590 }
1591 case INJECT_VSYNC: {
1592 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1593 int64_t when = 0;
1594 status_t result = data.readInt64(&when);
1595 if (result != NO_ERROR) {
1596 ALOGE("enableVSyncInjections failed to readInt64: %d", result);
1597 return result;
1598 }
1599 return injectVSync(when);
1600 }
Kalle Raitaa099a242017-01-11 11:17:29 -08001601 case GET_LAYER_DEBUG_INFO: {
1602 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1603 std::vector<LayerDebugInfo> outLayers;
1604 status_t result = getLayerDebugInfo(&outLayers);
1605 reply->writeInt32(result);
1606 if (result == NO_ERROR)
1607 {
1608 result = reply->writeParcelableVector(outLayers);
1609 }
1610 return result;
1611 }
Peiyong Lin0256f722018-08-31 15:45:10 -07001612 case GET_COMPOSITION_PREFERENCE: {
1613 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Linc6780972018-10-28 15:24:08 -07001614 ui::Dataspace defaultDataspace;
1615 ui::PixelFormat defaultPixelFormat;
1616 ui::Dataspace wideColorGamutDataspace;
1617 ui::PixelFormat wideColorGamutPixelFormat;
1618 status_t error =
1619 getCompositionPreference(&defaultDataspace, &defaultPixelFormat,
1620 &wideColorGamutDataspace, &wideColorGamutPixelFormat);
Peiyong Lin0256f722018-08-31 15:45:10 -07001621 reply->writeInt32(error);
1622 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -07001623 reply->writeInt32(static_cast<int32_t>(defaultDataspace));
1624 reply->writeInt32(static_cast<int32_t>(defaultPixelFormat));
1625 reply->writeInt32(static_cast<int32_t>(wideColorGamutDataspace));
Peiyong Linaa3da6a2018-12-12 02:48:43 -08001626 reply->writeInt32(static_cast<int32_t>(wideColorGamutPixelFormat));
Peiyong Lin0256f722018-08-31 15:45:10 -07001627 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001628 return error;
Peiyong Lin0256f722018-08-31 15:45:10 -07001629 }
Ady Abraham37965d42018-11-01 13:43:32 -07001630 case GET_COLOR_MANAGEMENT: {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001631 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Ady Abraham37965d42018-11-01 13:43:32 -07001632 bool result;
1633 status_t error = getColorManagement(&result);
1634 if (error == NO_ERROR) {
1635 reply->writeBool(result);
1636 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001637 return error;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001638 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -07001639 case GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: {
1640 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1641
1642 sp<IBinder> display = data.readStrongBinder();
1643 ui::PixelFormat format;
1644 ui::Dataspace dataspace;
1645 uint8_t component = 0;
1646 auto result =
1647 getDisplayedContentSamplingAttributes(display, &format, &dataspace, &component);
1648 if (result == NO_ERROR) {
1649 reply->writeUint32(static_cast<uint32_t>(format));
1650 reply->writeUint32(static_cast<uint32_t>(dataspace));
1651 reply->writeUint32(static_cast<uint32_t>(component));
1652 }
1653 return result;
1654 }
Kevin DuBois74e53772018-11-19 10:52:38 -08001655 case SET_DISPLAY_CONTENT_SAMPLING_ENABLED: {
1656 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1657
1658 sp<IBinder> display = nullptr;
1659 bool enable = false;
1660 int8_t componentMask = 0;
1661 uint64_t maxFrames = 0;
1662 status_t result = data.readStrongBinder(&display);
1663 if (result != NO_ERROR) {
1664 ALOGE("setDisplayContentSamplingEnabled failure in reading Display token: %d",
1665 result);
1666 return result;
1667 }
1668
1669 result = data.readBool(&enable);
1670 if (result != NO_ERROR) {
1671 ALOGE("setDisplayContentSamplingEnabled failure in reading enable: %d", result);
1672 return result;
1673 }
1674
1675 result = data.readByte(static_cast<int8_t*>(&componentMask));
1676 if (result != NO_ERROR) {
1677 ALOGE("setDisplayContentSamplingEnabled failure in reading component mask: %d",
1678 result);
1679 return result;
1680 }
1681
1682 result = data.readUint64(&maxFrames);
1683 if (result != NO_ERROR) {
1684 ALOGE("setDisplayContentSamplingEnabled failure in reading max frames: %d", result);
1685 return result;
1686 }
1687
1688 return setDisplayContentSamplingEnabled(display, enable,
1689 static_cast<uint8_t>(componentMask), maxFrames);
1690 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001691 case GET_DISPLAYED_CONTENT_SAMPLE: {
1692 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1693
1694 sp<IBinder> display = data.readStrongBinder();
1695 uint64_t maxFrames = 0;
1696 uint64_t timestamp = 0;
1697
1698 status_t result = data.readUint64(&maxFrames);
1699 if (result != NO_ERROR) {
1700 ALOGE("getDisplayedContentSample failure in reading max frames: %d", result);
1701 return result;
1702 }
1703
1704 result = data.readUint64(&timestamp);
1705 if (result != NO_ERROR) {
1706 ALOGE("getDisplayedContentSample failure in reading timestamp: %d", result);
1707 return result;
1708 }
1709
1710 DisplayedFrameStats stats;
1711 result = getDisplayedContentSample(display, maxFrames, timestamp, &stats);
1712 if (result == NO_ERROR) {
1713 reply->writeUint64(stats.numFrames);
Kevin DuBois1d4c6a62018-12-12 13:59:46 -08001714 reply->writeUint64Vector(stats.component_0_sample);
1715 reply->writeUint64Vector(stats.component_1_sample);
1716 reply->writeUint64Vector(stats.component_2_sample);
1717 reply->writeUint64Vector(stats.component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001718 }
1719 return result;
1720 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001721 case GET_PROTECTED_CONTENT_SUPPORT: {
1722 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1723 bool result;
1724 status_t error = getProtectedContentSupport(&result);
1725 if (error == NO_ERROR) {
1726 reply->writeBool(result);
1727 }
1728 return error;
1729 }
Peiyong Lin4f3fddf2019-01-24 17:21:24 -08001730 case IS_WIDE_COLOR_DISPLAY: {
1731 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1732 sp<IBinder> display = nullptr;
1733 status_t error = data.readStrongBinder(&display);
1734 if (error != NO_ERROR) {
1735 return error;
1736 }
1737 bool result;
1738 error = isWideColorDisplay(display, &result);
1739 if (error == NO_ERROR) {
1740 reply->writeBool(result);
1741 }
1742 return error;
1743 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001744 case GET_PHYSICAL_DISPLAY_IDS: {
1745 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marin Shalamanova524a092020-07-27 21:39:55 +02001746 std::vector<PhysicalDisplayId> ids = getPhysicalDisplayIds();
1747 std::vector<uint64_t> rawIds(ids.size());
1748 std::transform(ids.begin(), ids.end(), rawIds.begin(),
1749 [](PhysicalDisplayId id) { return id.value; });
1750 return reply->writeUint64Vector(rawIds);
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001751 }
Dan Stoza84ab9372018-12-17 15:27:57 -08001752 case ADD_REGION_SAMPLING_LISTENER: {
1753 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1754 Rect samplingArea;
1755 status_t result = data.read(samplingArea);
1756 if (result != NO_ERROR) {
1757 ALOGE("addRegionSamplingListener: Failed to read sampling area");
1758 return result;
1759 }
1760 sp<IBinder> stopLayerHandle;
1761 result = data.readNullableStrongBinder(&stopLayerHandle);
1762 if (result != NO_ERROR) {
1763 ALOGE("addRegionSamplingListener: Failed to read stop layer handle");
1764 return result;
1765 }
1766 sp<IRegionSamplingListener> listener;
1767 result = data.readNullableStrongBinder(&listener);
1768 if (result != NO_ERROR) {
1769 ALOGE("addRegionSamplingListener: Failed to read listener");
1770 return result;
1771 }
1772 return addRegionSamplingListener(samplingArea, stopLayerHandle, listener);
1773 }
1774 case REMOVE_REGION_SAMPLING_LISTENER: {
1775 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1776 sp<IRegionSamplingListener> listener;
1777 status_t result = data.readNullableStrongBinder(&listener);
1778 if (result != NO_ERROR) {
1779 ALOGE("removeRegionSamplingListener: Failed to read listener");
1780 return result;
1781 }
1782 return removeRegionSamplingListener(listener);
1783 }
Ana Krulec0782b882019-10-15 17:34:54 -07001784 case SET_DESIRED_DISPLAY_CONFIG_SPECS: {
1785 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1786 sp<IBinder> displayToken = data.readStrongBinder();
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001787 int32_t defaultConfig;
1788 status_t result = data.readInt32(&defaultConfig);
Ana Krulec0782b882019-10-15 17:34:54 -07001789 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001790 ALOGE("setDesiredDisplayConfigSpecs: failed to read defaultConfig: %d", result);
Ana Krulec0782b882019-10-15 17:34:54 -07001791 return result;
1792 }
Steven Thomasf734df42020-04-13 21:09:28 -07001793 float primaryRefreshRateMin;
1794 result = data.readFloat(&primaryRefreshRateMin);
Ana Krulec0782b882019-10-15 17:34:54 -07001795 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001796 ALOGE("setDesiredDisplayConfigSpecs: failed to read primaryRefreshRateMin: %d",
1797 result);
Ana Krulec0782b882019-10-15 17:34:54 -07001798 return result;
1799 }
Steven Thomasf734df42020-04-13 21:09:28 -07001800 float primaryRefreshRateMax;
1801 result = data.readFloat(&primaryRefreshRateMax);
Ana Krulec0782b882019-10-15 17:34:54 -07001802 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001803 ALOGE("setDesiredDisplayConfigSpecs: failed to read primaryRefreshRateMax: %d",
1804 result);
Ana Krulec0782b882019-10-15 17:34:54 -07001805 return result;
1806 }
Steven Thomasf734df42020-04-13 21:09:28 -07001807 float appRequestRefreshRateMin;
1808 result = data.readFloat(&appRequestRefreshRateMin);
1809 if (result != NO_ERROR) {
1810 ALOGE("setDesiredDisplayConfigSpecs: failed to read appRequestRefreshRateMin: %d",
1811 result);
1812 return result;
1813 }
1814 float appRequestRefreshRateMax;
1815 result = data.readFloat(&appRequestRefreshRateMax);
1816 if (result != NO_ERROR) {
1817 ALOGE("setDesiredDisplayConfigSpecs: failed to read appRequestRefreshRateMax: %d",
1818 result);
1819 return result;
1820 }
1821 result =
1822 setDesiredDisplayConfigSpecs(displayToken, defaultConfig, primaryRefreshRateMin,
1823 primaryRefreshRateMax, appRequestRefreshRateMin,
1824 appRequestRefreshRateMax);
Ana Krulec0782b882019-10-15 17:34:54 -07001825 if (result != NO_ERROR) {
1826 ALOGE("setDesiredDisplayConfigSpecs: failed to call setDesiredDisplayConfigSpecs: "
1827 "%d",
1828 result);
1829 return result;
1830 }
1831 reply->writeInt32(result);
1832 return result;
1833 }
Ana Krulec234bb162019-11-10 22:55:55 +01001834 case GET_DESIRED_DISPLAY_CONFIG_SPECS: {
1835 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1836 sp<IBinder> displayToken = data.readStrongBinder();
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001837 int32_t defaultConfig;
Steven Thomasf734df42020-04-13 21:09:28 -07001838 float primaryRefreshRateMin;
1839 float primaryRefreshRateMax;
1840 float appRequestRefreshRateMin;
1841 float appRequestRefreshRateMax;
Ana Krulec234bb162019-11-10 22:55:55 +01001842
Steven Thomasf734df42020-04-13 21:09:28 -07001843 status_t result =
1844 getDesiredDisplayConfigSpecs(displayToken, &defaultConfig,
1845 &primaryRefreshRateMin, &primaryRefreshRateMax,
1846 &appRequestRefreshRateMin,
1847 &appRequestRefreshRateMax);
Ana Krulec234bb162019-11-10 22:55:55 +01001848 if (result != NO_ERROR) {
1849 ALOGE("getDesiredDisplayConfigSpecs: failed to get getDesiredDisplayConfigSpecs: "
1850 "%d",
1851 result);
1852 return result;
1853 }
1854
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001855 result = reply->writeInt32(defaultConfig);
Ana Krulec234bb162019-11-10 22:55:55 +01001856 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001857 ALOGE("getDesiredDisplayConfigSpecs: failed to write defaultConfig: %d", result);
Ana Krulec234bb162019-11-10 22:55:55 +01001858 return result;
1859 }
Steven Thomasf734df42020-04-13 21:09:28 -07001860 result = reply->writeFloat(primaryRefreshRateMin);
Ana Krulec234bb162019-11-10 22:55:55 +01001861 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001862 ALOGE("getDesiredDisplayConfigSpecs: failed to write primaryRefreshRateMin: %d",
1863 result);
Ana Krulec234bb162019-11-10 22:55:55 +01001864 return result;
1865 }
Steven Thomasf734df42020-04-13 21:09:28 -07001866 result = reply->writeFloat(primaryRefreshRateMax);
Ana Krulec234bb162019-11-10 22:55:55 +01001867 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001868 ALOGE("getDesiredDisplayConfigSpecs: failed to write primaryRefreshRateMax: %d",
1869 result);
1870 return result;
1871 }
1872 result = reply->writeFloat(appRequestRefreshRateMin);
1873 if (result != NO_ERROR) {
1874 ALOGE("getDesiredDisplayConfigSpecs: failed to write appRequestRefreshRateMin: %d",
1875 result);
1876 return result;
1877 }
1878 result = reply->writeFloat(appRequestRefreshRateMax);
1879 if (result != NO_ERROR) {
1880 ALOGE("getDesiredDisplayConfigSpecs: failed to write appRequestRefreshRateMax: %d",
1881 result);
Ana Krulec234bb162019-11-10 22:55:55 +01001882 return result;
1883 }
1884 reply->writeInt32(result);
1885 return result;
1886 }
Dan Gittik57e63c52019-01-18 16:37:54 +00001887 case GET_DISPLAY_BRIGHTNESS_SUPPORT: {
1888 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1889 sp<IBinder> displayToken;
1890 status_t error = data.readNullableStrongBinder(&displayToken);
1891 if (error != NO_ERROR) {
1892 ALOGE("getDisplayBrightnessSupport: failed to read display token: %d", error);
1893 return error;
1894 }
1895 bool support = false;
1896 error = getDisplayBrightnessSupport(displayToken, &support);
1897 reply->writeBool(support);
1898 return error;
1899 }
1900 case SET_DISPLAY_BRIGHTNESS: {
1901 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1902 sp<IBinder> displayToken;
1903 status_t error = data.readNullableStrongBinder(&displayToken);
1904 if (error != NO_ERROR) {
1905 ALOGE("setDisplayBrightness: failed to read display token: %d", error);
1906 return error;
1907 }
1908 float brightness = -1.0f;
1909 error = data.readFloat(&brightness);
1910 if (error != NO_ERROR) {
1911 ALOGE("setDisplayBrightness: failed to read brightness: %d", error);
1912 return error;
1913 }
1914 return setDisplayBrightness(displayToken, brightness);
1915 }
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001916 case NOTIFY_POWER_BOOST: {
Ady Abraham8532d012019-05-08 14:50:56 -07001917 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001918 int32_t boostId;
1919 status_t error = data.readInt32(&boostId);
Ady Abraham8532d012019-05-08 14:50:56 -07001920 if (error != NO_ERROR) {
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001921 ALOGE("notifyPowerBoost: failed to read boostId: %d", error);
Ady Abraham8532d012019-05-08 14:50:56 -07001922 return error;
1923 }
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001924 return notifyPowerBoost(boostId);
Ady Abraham8532d012019-05-08 14:50:56 -07001925 }
Vishnu Nairb13bb952019-11-15 10:24:08 -08001926 case SET_GLOBAL_SHADOW_SETTINGS: {
1927 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1928
1929 std::vector<float> shadowConfig;
1930 status_t error = data.readFloatVector(&shadowConfig);
1931 if (error != NO_ERROR || shadowConfig.size() != 11) {
1932 ALOGE("setGlobalShadowSettings: failed to read shadowConfig: %d", error);
1933 return error;
1934 }
1935
1936 half4 ambientColor = {shadowConfig[0], shadowConfig[1], shadowConfig[2],
1937 shadowConfig[3]};
1938 half4 spotColor = {shadowConfig[4], shadowConfig[5], shadowConfig[6], shadowConfig[7]};
1939 float lightPosY = shadowConfig[8];
1940 float lightPosZ = shadowConfig[9];
1941 float lightRadius = shadowConfig[10];
1942 return setGlobalShadowSettings(ambientColor, spotColor, lightPosY, lightPosZ,
1943 lightRadius);
1944 }
Steven Thomas62a4cf82020-01-31 12:04:03 -08001945 case SET_FRAME_RATE: {
1946 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1947 sp<IBinder> binder;
1948 status_t err = data.readStrongBinder(&binder);
1949 if (err != NO_ERROR) {
1950 ALOGE("setFrameRate: failed to read strong binder: %s (%d)", strerror(-err), -err);
1951 return err;
1952 }
1953 sp<IGraphicBufferProducer> surface = interface_cast<IGraphicBufferProducer>(binder);
1954 if (!surface) {
1955 ALOGE("setFrameRate: failed to cast to IGraphicBufferProducer: %s (%d)",
1956 strerror(-err), -err);
1957 return err;
1958 }
1959 float frameRate;
1960 err = data.readFloat(&frameRate);
1961 if (err != NO_ERROR) {
1962 ALOGE("setFrameRate: failed to read float: %s (%d)", strerror(-err), -err);
1963 return err;
1964 }
1965 int8_t compatibility;
1966 err = data.readByte(&compatibility);
1967 if (err != NO_ERROR) {
1968 ALOGE("setFrameRate: failed to read byte: %s (%d)", strerror(-err), -err);
1969 return err;
1970 }
1971 status_t result = setFrameRate(surface, frameRate, compatibility);
1972 reply->writeInt32(result);
1973 return NO_ERROR;
1974 }
Steven Thomasd4071902020-03-24 16:02:53 -07001975 case ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN: {
1976 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1977 sp<IBinder> token;
1978 status_t result = acquireFrameRateFlexibilityToken(&token);
1979 reply->writeInt32(result);
1980 if (result == NO_ERROR) {
1981 reply->writeStrongBinder(token);
1982 }
1983 return NO_ERROR;
1984 }
Ady Abraham74e17562020-08-24 18:18:19 -07001985 case SET_FRAME_TIMELINE_VSYNC: {
1986 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1987 sp<IBinder> binder;
1988 status_t err = data.readStrongBinder(&binder);
1989 if (err != NO_ERROR) {
1990 ALOGE("setFrameTimelineVsync: failed to read strong binder: %s (%d)",
1991 strerror(-err), -err);
1992 return err;
1993 }
1994 sp<IGraphicBufferProducer> surface = interface_cast<IGraphicBufferProducer>(binder);
1995 if (!surface) {
1996 ALOGE("setFrameTimelineVsync: failed to cast to IGraphicBufferProducer: %s (%d)",
1997 strerror(-err), -err);
1998 return err;
1999 }
2000 int64_t frameTimelineVsyncId;
2001 err = data.readInt64(&frameTimelineVsyncId);
2002 if (err != NO_ERROR) {
2003 ALOGE("setFrameTimelineVsync: failed to read int64_t: %s (%d)", strerror(-err),
2004 -err);
2005 return err;
2006 }
2007
2008 status_t result = setFrameTimelineVsync(surface, frameTimelineVsyncId);
2009 reply->writeInt32(result);
2010 return NO_ERROR;
2011 }
Jesse Hall6c913be2013-08-08 12:15:49 -07002012 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -07002013 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -07002014 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08002015 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08002016}
2017
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08002018} // namespace android