blob: 2c50acccf841800f34fdadc5f27bdc3cd70f9d5f [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,
112 ScreenCaptureResults& captureResults) {
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800113 Parcel data, reply;
114 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
chaviwd2432892020-07-24 17:42:39 -0700115
chaviw308ddba2020-08-11 16:23:51 -0700116 SAFE_PARCEL(args.write, data);
117 status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_DISPLAY, data, &reply);
chaviwd2432892020-07-24 17:42:39 -0700118 if (result != NO_ERROR) {
119 ALOGE("captureDisplay failed to transact: %d", result);
Ana Krulec2d41e422018-07-26 12:07:43 -0700120 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000121 }
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000122
chaviw308ddba2020-08-11 16:23:51 -0700123 SAFE_PARCEL(captureResults.read, reply);
124 return NO_ERROR;
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800125 }
126
chaviwd2432892020-07-24 17:42:39 -0700127 virtual status_t captureDisplay(uint64_t displayOrLayerStack,
128 ScreenCaptureResults& captureResults) {
chaviw93df2ea2019-04-30 16:45:12 -0700129 Parcel data, reply;
130 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
chaviw308ddba2020-08-11 16:23:51 -0700131 SAFE_PARCEL(data.writeUint64, displayOrLayerStack)
chaviwd2432892020-07-24 17:42:39 -0700132 status_t result =
133 remote()->transact(BnSurfaceComposer::CAPTURE_DISPLAY_BY_ID, data, &reply);
chaviw93df2ea2019-04-30 16:45:12 -0700134 if (result != NO_ERROR) {
chaviwd2432892020-07-24 17:42:39 -0700135 ALOGE("captureDisplay failed to transact: %d", result);
chaviw93df2ea2019-04-30 16:45:12 -0700136 return result;
137 }
chaviw93df2ea2019-04-30 16:45:12 -0700138
chaviw308ddba2020-08-11 16:23:51 -0700139 SAFE_PARCEL(captureResults.read, reply);
140 return NO_ERROR;
chaviw93df2ea2019-04-30 16:45:12 -0700141 }
142
chaviw3efadb12020-07-27 10:07:15 -0700143 virtual status_t captureLayers(const LayerCaptureArgs& args,
144 ScreenCaptureResults& captureResults) {
chaviwa76b2712017-09-20 12:02:26 -0700145 Parcel data, reply;
146 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
chaviw3efadb12020-07-27 10:07:15 -0700147
chaviw308ddba2020-08-11 16:23:51 -0700148 SAFE_PARCEL(args.write, data);
chaviw3efadb12020-07-27 10:07:15 -0700149
chaviw308ddba2020-08-11 16:23:51 -0700150 status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_LAYERS, data, &reply);
Ana Krulec2d41e422018-07-26 12:07:43 -0700151 if (result != NO_ERROR) {
152 ALOGE("captureLayers failed to transact: %d", result);
153 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000154 }
Peiyong Lin0e003c92018-09-17 11:09:51 -0700155
chaviw308ddba2020-08-11 16:23:51 -0700156 SAFE_PARCEL(captureResults.read, reply);
157 return NO_ERROR;
chaviwa76b2712017-09-20 12:02:26 -0700158 }
159
Jamie Gennis582270d2011-08-17 18:19:00 -0700160 virtual bool authenticateSurfaceTexture(
Andy McFadden2adaf042012-12-18 09:49:45 -0800161 const sp<IGraphicBufferProducer>& bufferProducer) const
Jamie Gennis134f0422011-03-08 12:18:54 -0800162 {
163 Parcel data, reply;
164 int err = NO_ERROR;
165 err = data.writeInterfaceToken(
166 ISurfaceComposer::getInterfaceDescriptor());
167 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000168 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis134f0422011-03-08 12:18:54 -0800169 "interface descriptor: %s (%d)", strerror(-err), -err);
170 return false;
171 }
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800172 err = data.writeStrongBinder(IInterface::asBinder(bufferProducer));
Jamie Gennis134f0422011-03-08 12:18:54 -0800173 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000174 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis582270d2011-08-17 18:19:00 -0700175 "strong binder to parcel: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800176 return false;
177 }
178 err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
179 &reply);
180 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000181 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700182 "performing transaction: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800183 return false;
184 }
185 int32_t result = 0;
186 err = reply.readInt32(&result);
187 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000188 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700189 "retrieving result: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800190 return false;
191 }
192 return result != 0;
193 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800194
Brian Anderson6b376712017-04-04 10:51:39 -0700195 virtual status_t getSupportedFrameTimestamps(
196 std::vector<FrameEvent>* outSupported) const {
197 if (!outSupported) {
198 return UNEXPECTED_NULL;
199 }
200 outSupported->clear();
201
202 Parcel data, reply;
203
204 status_t err = data.writeInterfaceToken(
205 ISurfaceComposer::getInterfaceDescriptor());
206 if (err != NO_ERROR) {
207 return err;
208 }
209
210 err = remote()->transact(
211 BnSurfaceComposer::GET_SUPPORTED_FRAME_TIMESTAMPS,
212 data, &reply);
213 if (err != NO_ERROR) {
214 return err;
215 }
216
217 int32_t result = 0;
218 err = reply.readInt32(&result);
219 if (err != NO_ERROR) {
220 return err;
221 }
222 if (result != NO_ERROR) {
223 return result;
224 }
225
226 std::vector<int32_t> supported;
227 err = reply.readInt32Vector(&supported);
228 if (err != NO_ERROR) {
229 return err;
230 }
231
232 outSupported->reserve(supported.size());
233 for (int32_t s : supported) {
234 outSupported->push_back(static_cast<FrameEvent>(s));
235 }
236 return NO_ERROR;
237 }
238
Ady Abraham0f4a1b12019-06-04 16:04:04 -0700239 virtual sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource,
240 ConfigChanged configChanged) {
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800241 Parcel data, reply;
242 sp<IDisplayEventConnection> result;
243 int err = data.writeInterfaceToken(
244 ISurfaceComposer::getInterfaceDescriptor());
245 if (err != NO_ERROR) {
246 return result;
247 }
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700248 data.writeInt32(static_cast<int32_t>(vsyncSource));
Ady Abraham0f4a1b12019-06-04 16:04:04 -0700249 data.writeInt32(static_cast<int32_t>(configChanged));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800250 err = remote()->transact(
251 BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION,
252 data, &reply);
253 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000254 ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing "
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800255 "transaction: %s (%d)", strerror(-err), -err);
256 return result;
257 }
258 result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder());
259 return result;
260 }
Colin Cross8e533062012-06-07 13:17:52 -0700261
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700262 virtual sp<IBinder> createDisplay(const String8& displayName, bool secure)
Mathias Agopiane57f2922012-08-09 16:29:12 -0700263 {
264 Parcel data, reply;
265 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700266 data.writeString8(displayName);
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700267 data.writeInt32(secure ? 1 : 0);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700268 remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply);
269 return reply.readStrongBinder();
270 }
271
Jesse Hall6c913be2013-08-08 12:15:49 -0700272 virtual void destroyDisplay(const sp<IBinder>& display)
273 {
274 Parcel data, reply;
275 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
276 data.writeStrongBinder(display);
277 remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply);
278 }
279
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800280 virtual std::vector<PhysicalDisplayId> getPhysicalDisplayIds() const {
Mathias Agopiane57f2922012-08-09 16:29:12 -0700281 Parcel data, reply;
282 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800283 if (remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_IDS, data, &reply) ==
284 NO_ERROR) {
Marin Shalamanova524a092020-07-27 21:39:55 +0200285 std::vector<uint64_t> rawIds;
286 if (reply.readUint64Vector(&rawIds) == NO_ERROR) {
287 std::vector<PhysicalDisplayId> displayIds(rawIds.size());
288 std::transform(rawIds.begin(), rawIds.end(), displayIds.begin(),
289 [](uint64_t rawId) { return PhysicalDisplayId(rawId); });
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800290 return displayIds;
291 }
292 }
293
294 return {};
295 }
296
297 virtual sp<IBinder> getPhysicalDisplayToken(PhysicalDisplayId displayId) const {
298 Parcel data, reply;
299 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Marin Shalamanova524a092020-07-27 21:39:55 +0200300 data.writeUint64(displayId.value);
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800301 remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_TOKEN, data, &reply);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700302 return reply.readStrongBinder();
303 }
304
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700305 virtual void setPowerMode(const sp<IBinder>& display, int mode)
Colin Cross8e533062012-06-07 13:17:52 -0700306 {
307 Parcel data, reply;
308 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700309 data.writeStrongBinder(display);
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700310 data.writeInt32(mode);
311 remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply);
Colin Cross8e533062012-06-07 13:17:52 -0700312 }
Mathias Agopian3094df32012-06-18 18:06:45 -0700313
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800314 virtual status_t getDisplayState(const sp<IBinder>& display, ui::DisplayState* state) {
315 Parcel data, reply;
316 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
317 data.writeStrongBinder(display);
318 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATE, data, &reply);
319 const status_t result = reply.readInt32();
320 if (result == NO_ERROR) {
321 memcpy(state, reply.readInplace(sizeof(ui::DisplayState)), sizeof(ui::DisplayState));
322 }
323 return result;
324 }
325
326 virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) {
327 Parcel data, reply;
328 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
329 data.writeStrongBinder(display);
330 remote()->transact(BnSurfaceComposer::GET_DISPLAY_INFO, data, &reply);
331 const status_t result = reply.readInt32();
Marin Shalamanov359a7e72020-02-17 17:03:07 +0100332 if (result != NO_ERROR) return result;
333 return reply.read(*info);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800334 }
335
336 virtual status_t getDisplayConfigs(const sp<IBinder>& display, Vector<DisplayConfig>* configs) {
Mathias Agopianc666cae2012-07-25 18:56:13 -0700337 Parcel data, reply;
338 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700339 data.writeStrongBinder(display);
Dan Stoza7f7da322014-05-02 15:26:25 -0700340 remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800341 const status_t result = reply.readInt32();
Dan Stoza7f7da322014-05-02 15:26:25 -0700342 if (result == NO_ERROR) {
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800343 const size_t numConfigs = reply.readUint32();
Dan Stoza7f7da322014-05-02 15:26:25 -0700344 configs->clear();
345 configs->resize(numConfigs);
346 for (size_t c = 0; c < numConfigs; ++c) {
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800347 memcpy(&(configs->editItemAt(c)), reply.readInplace(sizeof(DisplayConfig)),
348 sizeof(DisplayConfig));
Dan Stoza7f7da322014-05-02 15:26:25 -0700349 }
350 }
351 return result;
352 }
353
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700354 virtual status_t getDisplayStats(const sp<IBinder>& display,
355 DisplayStatInfo* stats)
356 {
357 Parcel data, reply;
358 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
359 data.writeStrongBinder(display);
360 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply);
361 status_t result = reply.readInt32();
362 if (result == NO_ERROR) {
363 memcpy(stats,
364 reply.readInplace(sizeof(DisplayStatInfo)),
365 sizeof(DisplayStatInfo));
366 }
367 return result;
368 }
369
Dan Stoza7f7da322014-05-02 15:26:25 -0700370 virtual int getActiveConfig(const sp<IBinder>& display)
371 {
372 Parcel data, reply;
373 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
374 data.writeStrongBinder(display);
375 remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply);
376 return reply.readInt32();
377 }
378
Michael Wright28f24d02016-07-12 13:30:53 -0700379 virtual status_t getDisplayColorModes(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700380 Vector<ColorMode>* outColorModes) {
Michael Wright28f24d02016-07-12 13:30:53 -0700381 Parcel data, reply;
382 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
383 if (result != NO_ERROR) {
384 ALOGE("getDisplayColorModes failed to writeInterfaceToken: %d", result);
385 return result;
386 }
387 result = data.writeStrongBinder(display);
388 if (result != NO_ERROR) {
389 ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result);
390 return result;
391 }
392 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply);
393 if (result != NO_ERROR) {
394 ALOGE("getDisplayColorModes failed to transact: %d", result);
395 return result;
396 }
397 result = static_cast<status_t>(reply.readInt32());
398 if (result == NO_ERROR) {
399 size_t numModes = reply.readUint32();
400 outColorModes->clear();
401 outColorModes->resize(numModes);
402 for (size_t i = 0; i < numModes; ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -0700403 outColorModes->replaceAt(static_cast<ColorMode>(reply.readInt32()), i);
Michael Wright28f24d02016-07-12 13:30:53 -0700404 }
405 }
406 return result;
407 }
408
Daniel Solomon42d04562019-01-20 21:03:19 -0800409 virtual status_t getDisplayNativePrimaries(const sp<IBinder>& display,
410 ui::DisplayPrimaries& primaries) {
411 Parcel data, reply;
412 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
413 if (result != NO_ERROR) {
414 ALOGE("getDisplayNativePrimaries failed to writeInterfaceToken: %d", result);
415 return result;
416 }
417 result = data.writeStrongBinder(display);
418 if (result != NO_ERROR) {
419 ALOGE("getDisplayNativePrimaries failed to writeStrongBinder: %d", result);
420 return result;
421 }
422 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_NATIVE_PRIMARIES, data, &reply);
423 if (result != NO_ERROR) {
424 ALOGE("getDisplayNativePrimaries failed to transact: %d", result);
425 return result;
426 }
427 result = reply.readInt32();
428 if (result == NO_ERROR) {
429 memcpy(&primaries, reply.readInplace(sizeof(ui::DisplayPrimaries)),
430 sizeof(ui::DisplayPrimaries));
431 }
432 return result;
433 }
434
Peiyong Lina52f0292018-03-14 17:26:31 -0700435 virtual ColorMode getActiveColorMode(const sp<IBinder>& display) {
Michael Wright28f24d02016-07-12 13:30:53 -0700436 Parcel data, reply;
437 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
438 if (result != NO_ERROR) {
439 ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700440 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700441 }
442 result = data.writeStrongBinder(display);
443 if (result != NO_ERROR) {
444 ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700445 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700446 }
447 result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply);
448 if (result != NO_ERROR) {
449 ALOGE("getActiveColorMode failed to transact: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700450 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700451 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700452 return static_cast<ColorMode>(reply.readInt32());
Michael Wright28f24d02016-07-12 13:30:53 -0700453 }
454
455 virtual status_t setActiveColorMode(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700456 ColorMode colorMode) {
Michael Wright28f24d02016-07-12 13:30:53 -0700457 Parcel data, reply;
458 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
459 if (result != NO_ERROR) {
460 ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result);
461 return result;
462 }
463 result = data.writeStrongBinder(display);
464 if (result != NO_ERROR) {
465 ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result);
466 return result;
467 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700468 result = data.writeInt32(static_cast<int32_t>(colorMode));
Michael Wright28f24d02016-07-12 13:30:53 -0700469 if (result != NO_ERROR) {
470 ALOGE("setActiveColorMode failed to writeInt32: %d", result);
471 return result;
472 }
473 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply);
474 if (result != NO_ERROR) {
475 ALOGE("setActiveColorMode failed to transact: %d", result);
476 return result;
477 }
478 return static_cast<status_t>(reply.readInt32());
479 }
480
Galia Peycheva5492cb52019-10-30 14:13:16 +0100481 virtual status_t getAutoLowLatencyModeSupport(const sp<IBinder>& display,
482 bool* outSupport) const {
483 Parcel data, reply;
484 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
485 status_t result = data.writeStrongBinder(display);
486 if (result != NO_ERROR) {
487 ALOGE("getAutoLowLatencyModeSupport failed to writeStrongBinder: %d", result);
488 return result;
489 }
490 result = remote()->transact(BnSurfaceComposer::GET_AUTO_LOW_LATENCY_MODE_SUPPORT, data,
491 &reply);
492 if (result != NO_ERROR) {
493 ALOGE("getAutoLowLatencyModeSupport failed to transact: %d", result);
494 return result;
495 }
496 return reply.readBool(outSupport);
497 }
498
499 virtual void setAutoLowLatencyMode(const sp<IBinder>& display, bool on) {
500 Parcel data, reply;
501 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
502 if (result != NO_ERROR) {
503 ALOGE("setAutoLowLatencyMode failed to writeInterfaceToken: %d", result);
504 return;
505 }
506
507 result = data.writeStrongBinder(display);
508 if (result != NO_ERROR) {
509 ALOGE("setAutoLowLatencyMode failed to writeStrongBinder: %d", result);
510 return;
511 }
512 result = data.writeBool(on);
513 if (result != NO_ERROR) {
514 ALOGE("setAutoLowLatencyMode failed to writeBool: %d", result);
515 return;
516 }
517 result = remote()->transact(BnSurfaceComposer::SET_AUTO_LOW_LATENCY_MODE, data, &reply);
518 if (result != NO_ERROR) {
519 ALOGE("setAutoLowLatencyMode failed to transact: %d", result);
520 return;
521 }
522 }
523
524 virtual status_t getGameContentTypeSupport(const sp<IBinder>& display, bool* outSupport) const {
525 Parcel data, reply;
526 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
527 status_t result = data.writeStrongBinder(display);
528 if (result != NO_ERROR) {
529 ALOGE("getGameContentTypeSupport failed to writeStrongBinder: %d", result);
530 return result;
531 }
532 result = remote()->transact(BnSurfaceComposer::GET_GAME_CONTENT_TYPE_SUPPORT, data, &reply);
533 if (result != NO_ERROR) {
534 ALOGE("getGameContentTypeSupport failed to transact: %d", result);
535 return result;
536 }
537 return reply.readBool(outSupport);
538 }
539
540 virtual void setGameContentType(const sp<IBinder>& display, bool on) {
541 Parcel data, reply;
542 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
543 if (result != NO_ERROR) {
544 ALOGE("setGameContentType failed to writeInterfaceToken: %d", result);
545 return;
546 }
547 result = data.writeStrongBinder(display);
548 if (result != NO_ERROR) {
549 ALOGE("setGameContentType failed to writeStrongBinder: %d", result);
550 return;
551 }
552 result = data.writeBool(on);
553 if (result != NO_ERROR) {
554 ALOGE("setGameContentType failed to writeBool: %d", result);
555 return;
556 }
557 result = remote()->transact(BnSurfaceComposer::SET_GAME_CONTENT_TYPE, data, &reply);
558 if (result != NO_ERROR) {
559 ALOGE("setGameContentType failed to transact: %d", result);
560 }
561 }
562
Svetoslavd85084b2014-03-20 10:28:31 -0700563 virtual status_t clearAnimationFrameStats() {
564 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700565 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
566 if (result != NO_ERROR) {
567 ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result);
568 return result;
569 }
570 result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply);
571 if (result != NO_ERROR) {
572 ALOGE("clearAnimationFrameStats failed to transact: %d", result);
573 return result;
574 }
Svetoslavd85084b2014-03-20 10:28:31 -0700575 return reply.readInt32();
576 }
577
578 virtual status_t getAnimationFrameStats(FrameStats* outStats) const {
579 Parcel data, reply;
580 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
581 remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply);
582 reply.read(*outStats);
583 return reply.readInt32();
584 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700585
586 virtual status_t getHdrCapabilities(const sp<IBinder>& display,
587 HdrCapabilities* outCapabilities) const {
588 Parcel data, reply;
589 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
590 status_t result = data.writeStrongBinder(display);
591 if (result != NO_ERROR) {
592 ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result);
593 return result;
594 }
595 result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES,
596 data, &reply);
597 if (result != NO_ERROR) {
598 ALOGE("getHdrCapabilities failed to transact: %d", result);
599 return result;
600 }
601 result = reply.readInt32();
602 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800603 result = reply.read(*outCapabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700604 }
605 return result;
606 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700607
608 virtual status_t enableVSyncInjections(bool enable) {
609 Parcel data, reply;
610 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
611 if (result != NO_ERROR) {
612 ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result);
613 return result;
614 }
615 result = data.writeBool(enable);
616 if (result != NO_ERROR) {
617 ALOGE("enableVSyncInjections failed to writeBool: %d", result);
618 return result;
619 }
Steven Moreland366eb422019-04-01 19:22:32 -0700620 result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS, data, &reply,
621 IBinder::FLAG_ONEWAY);
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700622 if (result != NO_ERROR) {
623 ALOGE("enableVSyncInjections failed to transact: %d", result);
624 return result;
625 }
626 return result;
627 }
628
629 virtual status_t injectVSync(nsecs_t when) {
630 Parcel data, reply;
631 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
632 if (result != NO_ERROR) {
633 ALOGE("injectVSync failed to writeInterfaceToken: %d", result);
634 return result;
635 }
636 result = data.writeInt64(when);
637 if (result != NO_ERROR) {
638 ALOGE("injectVSync failed to writeInt64: %d", result);
639 return result;
640 }
Steven Moreland366eb422019-04-01 19:22:32 -0700641 result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply,
642 IBinder::FLAG_ONEWAY);
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700643 if (result != NO_ERROR) {
644 ALOGE("injectVSync failed to transact: %d", result);
645 return result;
646 }
647 return result;
648 }
649
Vishnu Nair43bccf82020-06-05 10:53:37 -0700650 virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) {
Kalle Raitaa099a242017-01-11 11:17:29 -0800651 if (!outLayers) {
652 return UNEXPECTED_NULL;
653 }
654
655 Parcel data, reply;
656
657 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
658 if (err != NO_ERROR) {
659 return err;
660 }
661
662 err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply);
663 if (err != NO_ERROR) {
664 return err;
665 }
666
667 int32_t result = 0;
668 err = reply.readInt32(&result);
669 if (err != NO_ERROR) {
670 return err;
671 }
672 if (result != NO_ERROR) {
673 return result;
674 }
675
676 outLayers->clear();
677 return reply.readParcelableVector(outLayers);
678 }
Peiyong Lin0256f722018-08-31 15:45:10 -0700679
Peiyong Linc6780972018-10-28 15:24:08 -0700680 virtual status_t getCompositionPreference(ui::Dataspace* defaultDataspace,
681 ui::PixelFormat* defaultPixelFormat,
682 ui::Dataspace* wideColorGamutDataspace,
683 ui::PixelFormat* wideColorGamutPixelFormat) const {
Peiyong Lin0256f722018-08-31 15:45:10 -0700684 Parcel data, reply;
685 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
686 if (error != NO_ERROR) {
687 return error;
688 }
689 error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply);
690 if (error != NO_ERROR) {
691 return error;
692 }
693 error = static_cast<status_t>(reply.readInt32());
694 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -0700695 *defaultDataspace = static_cast<ui::Dataspace>(reply.readInt32());
696 *defaultPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
697 *wideColorGamutDataspace = static_cast<ui::Dataspace>(reply.readInt32());
698 *wideColorGamutPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
Peiyong Lin0256f722018-08-31 15:45:10 -0700699 }
700 return error;
701 }
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700702
Ady Abraham37965d42018-11-01 13:43:32 -0700703 virtual status_t getColorManagement(bool* outGetColorManagement) const {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700704 Parcel data, reply;
705 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Ady Abraham37965d42018-11-01 13:43:32 -0700706 remote()->transact(BnSurfaceComposer::GET_COLOR_MANAGEMENT, data, &reply);
707 bool result;
708 status_t err = reply.readBool(&result);
709 if (err == NO_ERROR) {
710 *outGetColorManagement = result;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700711 }
Ady Abraham37965d42018-11-01 13:43:32 -0700712 return err;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700713 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -0700714
715 virtual status_t getDisplayedContentSamplingAttributes(const sp<IBinder>& display,
716 ui::PixelFormat* outFormat,
717 ui::Dataspace* outDataspace,
718 uint8_t* outComponentMask) const {
719 if (!outFormat || !outDataspace || !outComponentMask) return BAD_VALUE;
720 Parcel data, reply;
721 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
722 data.writeStrongBinder(display);
723
724 status_t error =
725 remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES,
726 data, &reply);
727 if (error != NO_ERROR) {
728 return error;
729 }
730
731 uint32_t value = 0;
732 error = reply.readUint32(&value);
733 if (error != NO_ERROR) {
734 return error;
735 }
736 *outFormat = static_cast<ui::PixelFormat>(value);
737
738 error = reply.readUint32(&value);
739 if (error != NO_ERROR) {
740 return error;
741 }
742 *outDataspace = static_cast<ui::Dataspace>(value);
743
744 error = reply.readUint32(&value);
745 if (error != NO_ERROR) {
746 return error;
747 }
748 *outComponentMask = static_cast<uint8_t>(value);
749 return error;
750 }
Kevin DuBois74e53772018-11-19 10:52:38 -0800751
752 virtual status_t setDisplayContentSamplingEnabled(const sp<IBinder>& display, bool enable,
Dominik Laskowski470df5f2020-04-02 22:27:42 -0700753 uint8_t componentMask, uint64_t maxFrames) {
Kevin DuBois74e53772018-11-19 10:52:38 -0800754 Parcel data, reply;
755 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
756 data.writeStrongBinder(display);
757 data.writeBool(enable);
758 data.writeByte(static_cast<int8_t>(componentMask));
759 data.writeUint64(maxFrames);
760 status_t result =
761 remote()->transact(BnSurfaceComposer::SET_DISPLAY_CONTENT_SAMPLING_ENABLED, data,
762 &reply);
763 return result;
764 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700765
766 virtual status_t getDisplayedContentSample(const sp<IBinder>& display, uint64_t maxFrames,
767 uint64_t timestamp,
768 DisplayedFrameStats* outStats) const {
769 if (!outStats) return BAD_VALUE;
770
771 Parcel data, reply;
772 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
773 data.writeStrongBinder(display);
774 data.writeUint64(maxFrames);
775 data.writeUint64(timestamp);
776
777 status_t result =
778 remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLE, data, &reply);
779
780 if (result != NO_ERROR) {
781 return result;
782 }
783
784 result = reply.readUint64(&outStats->numFrames);
785 if (result != NO_ERROR) {
786 return result;
787 }
788
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800789 result = reply.readUint64Vector(&outStats->component_0_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700790 if (result != NO_ERROR) {
791 return result;
792 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800793 result = reply.readUint64Vector(&outStats->component_1_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700794 if (result != NO_ERROR) {
795 return result;
796 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800797 result = reply.readUint64Vector(&outStats->component_2_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700798 if (result != NO_ERROR) {
799 return result;
800 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800801 result = reply.readUint64Vector(&outStats->component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700802 return result;
803 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800804
805 virtual status_t getProtectedContentSupport(bool* outSupported) const {
806 Parcel data, reply;
807 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Peiyong Linb6888fa2019-01-28 13:20:58 -0800808 status_t error =
809 remote()->transact(BnSurfaceComposer::GET_PROTECTED_CONTENT_SUPPORT, data, &reply);
810 if (error != NO_ERROR) {
811 return error;
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800812 }
Peiyong Linb6888fa2019-01-28 13:20:58 -0800813 error = reply.readBool(outSupported);
814 return error;
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800815 }
Marissa Wallebc2c052019-01-16 19:16:55 -0800816
Peiyong Lin4f3fddf2019-01-24 17:21:24 -0800817 virtual status_t isWideColorDisplay(const sp<IBinder>& token,
818 bool* outIsWideColorDisplay) const {
819 Parcel data, reply;
820 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
821 if (error != NO_ERROR) {
822 return error;
823 }
824 error = data.writeStrongBinder(token);
825 if (error != NO_ERROR) {
826 return error;
827 }
828
829 error = remote()->transact(BnSurfaceComposer::IS_WIDE_COLOR_DISPLAY, data, &reply);
830 if (error != NO_ERROR) {
831 return error;
832 }
833 error = reply.readBool(outIsWideColorDisplay);
834 return error;
835 }
Dan Stoza84ab9372018-12-17 15:27:57 -0800836
837 virtual status_t addRegionSamplingListener(const Rect& samplingArea,
838 const sp<IBinder>& stopLayerHandle,
839 const sp<IRegionSamplingListener>& listener) {
840 Parcel data, reply;
841 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
842 if (error != NO_ERROR) {
843 ALOGE("addRegionSamplingListener: Failed to write interface token");
844 return error;
845 }
846 error = data.write(samplingArea);
847 if (error != NO_ERROR) {
848 ALOGE("addRegionSamplingListener: Failed to write sampling area");
849 return error;
850 }
851 error = data.writeStrongBinder(stopLayerHandle);
852 if (error != NO_ERROR) {
853 ALOGE("addRegionSamplingListener: Failed to write stop layer handle");
854 return error;
855 }
856 error = data.writeStrongBinder(IInterface::asBinder(listener));
857 if (error != NO_ERROR) {
858 ALOGE("addRegionSamplingListener: Failed to write listener");
859 return error;
860 }
861 error = remote()->transact(BnSurfaceComposer::ADD_REGION_SAMPLING_LISTENER, data, &reply);
862 if (error != NO_ERROR) {
863 ALOGE("addRegionSamplingListener: Failed to transact");
864 }
865 return error;
866 }
867
868 virtual status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) {
869 Parcel data, reply;
870 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
871 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800872 ALOGE("removeRegionSamplingListener: Failed to write interface token");
Dan Stoza84ab9372018-12-17 15:27:57 -0800873 return error;
874 }
875 error = data.writeStrongBinder(IInterface::asBinder(listener));
876 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800877 ALOGE("removeRegionSamplingListener: Failed to write listener");
Dan Stoza84ab9372018-12-17 15:27:57 -0800878 return error;
879 }
880 error = remote()->transact(BnSurfaceComposer::REMOVE_REGION_SAMPLING_LISTENER, data,
881 &reply);
882 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800883 ALOGE("removeRegionSamplingListener: Failed to transact");
Dan Stoza84ab9372018-12-17 15:27:57 -0800884 }
885 return error;
886 }
Ady Abraham838de062019-02-04 10:24:03 -0800887
Ana Krulec0782b882019-10-15 17:34:54 -0700888 virtual status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
Steven Thomasf734df42020-04-13 21:09:28 -0700889 int32_t defaultConfig,
890 float primaryRefreshRateMin,
891 float primaryRefreshRateMax,
892 float appRequestRefreshRateMin,
893 float appRequestRefreshRateMax) {
Ana Krulec0782b882019-10-15 17:34:54 -0700894 Parcel data, reply;
895 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
896 if (result != NO_ERROR) {
897 ALOGE("setDesiredDisplayConfigSpecs: failed to writeInterfaceToken: %d", result);
898 return result;
899 }
900 result = data.writeStrongBinder(displayToken);
901 if (result != NO_ERROR) {
902 ALOGE("setDesiredDisplayConfigSpecs: failed to write display token: %d", result);
903 return result;
904 }
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100905 result = data.writeInt32(defaultConfig);
Ana Krulec0782b882019-10-15 17:34:54 -0700906 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100907 ALOGE("setDesiredDisplayConfigSpecs failed to write defaultConfig: %d", result);
Ana Krulec0782b882019-10-15 17:34:54 -0700908 return result;
909 }
Steven Thomasf734df42020-04-13 21:09:28 -0700910 result = data.writeFloat(primaryRefreshRateMin);
Ana Krulec0782b882019-10-15 17:34:54 -0700911 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -0700912 ALOGE("setDesiredDisplayConfigSpecs failed to write primaryRefreshRateMin: %d", result);
Ana Krulec0782b882019-10-15 17:34:54 -0700913 return result;
914 }
Steven Thomasf734df42020-04-13 21:09:28 -0700915 result = data.writeFloat(primaryRefreshRateMax);
Ana Krulec0782b882019-10-15 17:34:54 -0700916 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -0700917 ALOGE("setDesiredDisplayConfigSpecs failed to write primaryRefreshRateMax: %d", result);
918 return result;
919 }
920 result = data.writeFloat(appRequestRefreshRateMin);
921 if (result != NO_ERROR) {
922 ALOGE("setDesiredDisplayConfigSpecs failed to write appRequestRefreshRateMin: %d",
923 result);
924 return result;
925 }
926 result = data.writeFloat(appRequestRefreshRateMax);
927 if (result != NO_ERROR) {
928 ALOGE("setDesiredDisplayConfigSpecs failed to write appRequestRefreshRateMax: %d",
929 result);
Ana Krulec0782b882019-10-15 17:34:54 -0700930 return result;
931 }
932
933 result = remote()->transact(BnSurfaceComposer::SET_DESIRED_DISPLAY_CONFIG_SPECS, data,
934 &reply);
935 if (result != NO_ERROR) {
936 ALOGE("setDesiredDisplayConfigSpecs failed to transact: %d", result);
937 return result;
938 }
939 return reply.readInt32();
940 }
941
Ana Krulec234bb162019-11-10 22:55:55 +0100942 virtual status_t getDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100943 int32_t* outDefaultConfig,
Steven Thomasf734df42020-04-13 21:09:28 -0700944 float* outPrimaryRefreshRateMin,
945 float* outPrimaryRefreshRateMax,
946 float* outAppRequestRefreshRateMin,
947 float* outAppRequestRefreshRateMax) {
948 if (!outDefaultConfig || !outPrimaryRefreshRateMin || !outPrimaryRefreshRateMax ||
949 !outAppRequestRefreshRateMin || !outAppRequestRefreshRateMax) {
950 return BAD_VALUE;
951 }
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800952 Parcel data, reply;
953 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
954 if (result != NO_ERROR) {
Ana Krulec234bb162019-11-10 22:55:55 +0100955 ALOGE("getDesiredDisplayConfigSpecs failed to writeInterfaceToken: %d", result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800956 return result;
957 }
958 result = data.writeStrongBinder(displayToken);
959 if (result != NO_ERROR) {
Ana Krulec234bb162019-11-10 22:55:55 +0100960 ALOGE("getDesiredDisplayConfigSpecs failed to writeStrongBinder: %d", result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800961 return result;
962 }
Ana Krulec234bb162019-11-10 22:55:55 +0100963 result = remote()->transact(BnSurfaceComposer::GET_DESIRED_DISPLAY_CONFIG_SPECS, data,
964 &reply);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800965 if (result != NO_ERROR) {
Ana Krulec234bb162019-11-10 22:55:55 +0100966 ALOGE("getDesiredDisplayConfigSpecs failed to transact: %d", result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800967 return result;
968 }
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100969 result = reply.readInt32(outDefaultConfig);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800970 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100971 ALOGE("getDesiredDisplayConfigSpecs failed to read defaultConfig: %d", result);
Ana Krulec234bb162019-11-10 22:55:55 +0100972 return result;
973 }
Steven Thomasf734df42020-04-13 21:09:28 -0700974 result = reply.readFloat(outPrimaryRefreshRateMin);
Ana Krulec234bb162019-11-10 22:55:55 +0100975 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -0700976 ALOGE("getDesiredDisplayConfigSpecs failed to read primaryRefreshRateMin: %d", result);
Ana Krulec234bb162019-11-10 22:55:55 +0100977 return result;
978 }
Steven Thomasf734df42020-04-13 21:09:28 -0700979 result = reply.readFloat(outPrimaryRefreshRateMax);
Ana Krulec234bb162019-11-10 22:55:55 +0100980 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -0700981 ALOGE("getDesiredDisplayConfigSpecs failed to read primaryRefreshRateMax: %d", result);
982 return result;
983 }
984 result = reply.readFloat(outAppRequestRefreshRateMin);
985 if (result != NO_ERROR) {
986 ALOGE("getDesiredDisplayConfigSpecs failed to read appRequestRefreshRateMin: %d",
987 result);
988 return result;
989 }
990 result = reply.readFloat(outAppRequestRefreshRateMax);
991 if (result != NO_ERROR) {
992 ALOGE("getDesiredDisplayConfigSpecs failed to read appRequestRefreshRateMax: %d",
993 result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800994 return result;
995 }
996 return reply.readInt32();
997 }
Dan Gittik57e63c52019-01-18 16:37:54 +0000998
999 virtual status_t getDisplayBrightnessSupport(const sp<IBinder>& displayToken,
1000 bool* outSupport) const {
1001 Parcel data, reply;
1002 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1003 if (error != NO_ERROR) {
1004 ALOGE("getDisplayBrightnessSupport: failed to write interface token: %d", error);
1005 return error;
1006 }
1007 error = data.writeStrongBinder(displayToken);
1008 if (error != NO_ERROR) {
1009 ALOGE("getDisplayBrightnessSupport: failed to write display token: %d", error);
1010 return error;
1011 }
1012 error = remote()->transact(BnSurfaceComposer::GET_DISPLAY_BRIGHTNESS_SUPPORT, data, &reply);
1013 if (error != NO_ERROR) {
1014 ALOGE("getDisplayBrightnessSupport: failed to transact: %d", error);
1015 return error;
1016 }
1017 bool support;
1018 error = reply.readBool(&support);
1019 if (error != NO_ERROR) {
1020 ALOGE("getDisplayBrightnessSupport: failed to read support: %d", error);
1021 return error;
1022 }
1023 *outSupport = support;
1024 return NO_ERROR;
1025 }
1026
Dominik Laskowski470df5f2020-04-02 22:27:42 -07001027 virtual status_t setDisplayBrightness(const sp<IBinder>& displayToken, float brightness) {
Dan Gittik57e63c52019-01-18 16:37:54 +00001028 Parcel data, reply;
1029 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1030 if (error != NO_ERROR) {
1031 ALOGE("setDisplayBrightness: failed to write interface token: %d", error);
1032 return error;
1033 }
1034 error = data.writeStrongBinder(displayToken);
1035 if (error != NO_ERROR) {
1036 ALOGE("setDisplayBrightness: failed to write display token: %d", error);
1037 return error;
1038 }
1039 error = data.writeFloat(brightness);
1040 if (error != NO_ERROR) {
1041 ALOGE("setDisplayBrightness: failed to write brightness: %d", error);
1042 return error;
1043 }
1044 error = remote()->transact(BnSurfaceComposer::SET_DISPLAY_BRIGHTNESS, data, &reply);
1045 if (error != NO_ERROR) {
1046 ALOGE("setDisplayBrightness: failed to transact: %d", error);
1047 return error;
1048 }
1049 return NO_ERROR;
1050 }
Ady Abraham8532d012019-05-08 14:50:56 -07001051
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001052 virtual status_t notifyPowerBoost(int32_t boostId) {
Ady Abraham8532d012019-05-08 14:50:56 -07001053 Parcel data, reply;
1054 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1055 if (error != NO_ERROR) {
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001056 ALOGE("notifyPowerBoost: failed to write interface token: %d", error);
Ady Abraham8532d012019-05-08 14:50:56 -07001057 return error;
1058 }
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001059 error = data.writeInt32(boostId);
Ady Abraham8532d012019-05-08 14:50:56 -07001060 if (error != NO_ERROR) {
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001061 ALOGE("notifyPowerBoost: failed to write boostId: %d", error);
Ady Abraham8532d012019-05-08 14:50:56 -07001062 return error;
1063 }
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001064 error = remote()->transact(BnSurfaceComposer::NOTIFY_POWER_BOOST, data, &reply,
Ady Abraham8532d012019-05-08 14:50:56 -07001065 IBinder::FLAG_ONEWAY);
1066 if (error != NO_ERROR) {
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001067 ALOGE("notifyPowerBoost: failed to transact: %d", error);
Ady Abraham8532d012019-05-08 14:50:56 -07001068 return error;
1069 }
1070 return NO_ERROR;
1071 }
Vishnu Nairb13bb952019-11-15 10:24:08 -08001072
1073 virtual status_t setGlobalShadowSettings(const half4& ambientColor, const half4& spotColor,
1074 float lightPosY, float lightPosZ, float lightRadius) {
1075 Parcel data, reply;
1076 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1077 if (error != NO_ERROR) {
1078 ALOGE("setGlobalShadowSettings: failed to write interface token: %d", error);
1079 return error;
1080 }
1081
1082 std::vector<float> shadowConfig = {ambientColor.r, ambientColor.g, ambientColor.b,
1083 ambientColor.a, spotColor.r, spotColor.g,
1084 spotColor.b, spotColor.a, lightPosY,
1085 lightPosZ, lightRadius};
1086
1087 error = data.writeFloatVector(shadowConfig);
1088 if (error != NO_ERROR) {
1089 ALOGE("setGlobalShadowSettings: failed to write shadowConfig: %d", error);
1090 return error;
1091 }
1092
1093 error = remote()->transact(BnSurfaceComposer::SET_GLOBAL_SHADOW_SETTINGS, data, &reply,
1094 IBinder::FLAG_ONEWAY);
1095 if (error != NO_ERROR) {
1096 ALOGE("setGlobalShadowSettings: failed to transact: %d", error);
1097 return error;
1098 }
1099 return NO_ERROR;
1100 }
Steven Thomas62a4cf82020-01-31 12:04:03 -08001101
1102 virtual status_t setFrameRate(const sp<IGraphicBufferProducer>& surface, float frameRate,
1103 int8_t compatibility) {
1104 Parcel data, reply;
1105 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1106 if (err != NO_ERROR) {
1107 ALOGE("setFrameRate: failed writing interface token: %s (%d)", strerror(-err), -err);
1108 return err;
1109 }
1110
1111 err = data.writeStrongBinder(IInterface::asBinder(surface));
1112 if (err != NO_ERROR) {
1113 ALOGE("setFrameRate: failed writing strong binder: %s (%d)", strerror(-err), -err);
1114 return err;
1115 }
1116
1117 err = data.writeFloat(frameRate);
1118 if (err != NO_ERROR) {
1119 ALOGE("setFrameRate: failed writing float: %s (%d)", strerror(-err), -err);
1120 return err;
1121 }
1122
1123 err = data.writeByte(compatibility);
1124 if (err != NO_ERROR) {
1125 ALOGE("setFrameRate: failed writing byte: %s (%d)", strerror(-err), -err);
1126 return err;
1127 }
1128
Ady Abraham60e42ea2020-03-09 19:17:31 -07001129 err = remote()->transact(BnSurfaceComposer::SET_FRAME_RATE, data, &reply);
Steven Thomas62a4cf82020-01-31 12:04:03 -08001130 if (err != NO_ERROR) {
1131 ALOGE("setFrameRate: failed to transact: %s (%d)", strerror(-err), err);
1132 return err;
1133 }
Steven Thomasd4071902020-03-24 16:02:53 -07001134
1135 return reply.readInt32();
1136 }
1137
1138 virtual status_t acquireFrameRateFlexibilityToken(sp<IBinder>* outToken) {
1139 if (!outToken) return BAD_VALUE;
1140
1141 Parcel data, reply;
1142 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1143 if (err != NO_ERROR) {
1144 ALOGE("acquireFrameRateFlexibilityToken: failed writing interface token: %s (%d)",
1145 strerror(-err), -err);
1146 return err;
1147 }
1148
1149 err = remote()->transact(BnSurfaceComposer::ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN, data,
1150 &reply);
1151 if (err != NO_ERROR) {
1152 ALOGE("acquireFrameRateFlexibilityToken: failed to transact: %s (%d)", strerror(-err),
1153 err);
1154 return err;
1155 }
1156
1157 err = reply.readInt32();
1158 if (err != NO_ERROR) {
1159 ALOGE("acquireFrameRateFlexibilityToken: call failed: %s (%d)", strerror(-err), err);
1160 return err;
1161 }
1162
1163 err = reply.readStrongBinder(outToken);
1164 if (err != NO_ERROR) {
1165 ALOGE("acquireFrameRateFlexibilityToken: failed reading binder token: %s (%d)",
1166 strerror(-err), err);
1167 return err;
1168 }
1169
Steven Thomas62a4cf82020-01-31 12:04:03 -08001170 return NO_ERROR;
1171 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001172};
1173
Dan Stozad723bd72014-11-18 10:24:03 -08001174// Out-of-line virtual method definition to trigger vtable emission in this
1175// translation unit (see clang warning -Wweak-vtables)
1176BpSurfaceComposer::~BpSurfaceComposer() {}
1177
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001178IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
1179
1180// ----------------------------------------------------------------------
1181
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001182status_t BnSurfaceComposer::onTransact(
1183 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
1184{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001185 switch(code) {
1186 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001187 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -08001188 sp<IBinder> b = IInterface::asBinder(createConnection());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001189 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -07001190 return NO_ERROR;
1191 }
Mathias Agopian698c0872011-06-28 19:09:31 -07001192 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001193 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -08001194
chaviw308ddba2020-08-11 16:23:51 -07001195 uint32_t count = 0;
1196 SAFE_PARCEL_READ_SIZE(data.readUint32, &count, data.dataSize());
Mathias Agopian698c0872011-06-28 19:09:31 -07001197 Vector<ComposerState> state;
1198 state.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -08001199 for (size_t i = 0; i < count; i++) {
Marissa Wallc837b5e2018-10-12 10:04:44 -07001200 ComposerState s;
chaviw308ddba2020-08-11 16:23:51 -07001201 SAFE_PARCEL(s.read, data);
Mathias Agopian698c0872011-06-28 19:09:31 -07001202 state.add(s);
1203 }
Dan Stozad723bd72014-11-18 10:24:03 -08001204
chaviw308ddba2020-08-11 16:23:51 -07001205 SAFE_PARCEL_READ_SIZE(data.readUint32, &count, data.dataSize());
Mathias Agopian8b33f032012-07-24 20:43:54 -07001206 DisplayState d;
1207 Vector<DisplayState> displays;
1208 displays.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -08001209 for (size_t i = 0; i < count; i++) {
chaviw308ddba2020-08-11 16:23:51 -07001210 SAFE_PARCEL(d.read, data);
Mathias Agopian8b33f032012-07-24 20:43:54 -07001211 displays.add(d);
1212 }
Dan Stozad723bd72014-11-18 10:24:03 -08001213
chaviw308ddba2020-08-11 16:23:51 -07001214 uint32_t stateFlags = 0;
1215 SAFE_PARCEL(data.readUint32, &stateFlags);
1216 sp<IBinder> applyToken;
1217 SAFE_PARCEL(data.readStrongBinder, &applyToken);
chaviw273171b2018-12-26 11:46:30 -08001218 InputWindowCommands inputWindowCommands;
chaviw308ddba2020-08-11 16:23:51 -07001219 SAFE_PARCEL(inputWindowCommands.read, data);
Marissa Wall17b4e452018-12-26 16:32:34 -08001220
chaviw308ddba2020-08-11 16:23:51 -07001221 int64_t desiredPresentTime = 0;
1222 SAFE_PARCEL(data.readInt64, &desiredPresentTime);
Marissa Wall78b72202019-03-15 14:58:34 -07001223
Marissa Wall947d34e2019-03-29 14:03:53 -07001224 client_cache_t uncachedBuffer;
chaviw308ddba2020-08-11 16:23:51 -07001225 sp<IBinder> tmpBinder;
1226 SAFE_PARCEL(data.readNullableStrongBinder, &tmpBinder);
1227 uncachedBuffer.token = tmpBinder;
1228 SAFE_PARCEL(data.readUint64, &uncachedBuffer.id);
Marissa Wall78b72202019-03-15 14:58:34 -07001229
chaviw308ddba2020-08-11 16:23:51 -07001230 bool hasListenerCallbacks = false;
1231 SAFE_PARCEL(data.readBool, &hasListenerCallbacks);
Valerie Hau9dab9732019-08-20 09:29:25 -07001232
Marissa Wall3dad52d2019-03-22 14:03:19 -07001233 std::vector<ListenerCallbacks> listenerCallbacks;
chaviw308ddba2020-08-11 16:23:51 -07001234 int32_t listenersSize = 0;
1235 SAFE_PARCEL_READ_SIZE(data.readInt32, &listenersSize, data.dataSize());
Marissa Wall3dad52d2019-03-22 14:03:19 -07001236 for (int32_t i = 0; i < listenersSize; i++) {
chaviw308ddba2020-08-11 16:23:51 -07001237 SAFE_PARCEL(data.readStrongBinder, &tmpBinder);
Marissa Wall3dad52d2019-03-22 14:03:19 -07001238 std::vector<CallbackId> callbackIds;
chaviw308ddba2020-08-11 16:23:51 -07001239 SAFE_PARCEL(data.readInt64Vector, &callbackIds);
1240 listenerCallbacks.emplace_back(tmpBinder, callbackIds);
Marissa Wall3dad52d2019-03-22 14:03:19 -07001241 }
chaviw308ddba2020-08-11 16:23:51 -07001242 return setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands,
1243 desiredPresentTime, uncachedBuffer, hasListenerCallbacks,
1244 listenerCallbacks);
Jesse Hall6c913be2013-08-08 12:15:49 -07001245 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001246 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001247 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001248 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -07001249 return NO_ERROR;
1250 }
chaviwd2432892020-07-24 17:42:39 -07001251 case CAPTURE_DISPLAY: {
Mathias Agopian2a9fc492013-03-01 13:42:57 -08001252 CHECK_INTERFACE(ISurfaceComposer, data, reply);
chaviwd2432892020-07-24 17:42:39 -07001253 DisplayCaptureArgs args;
1254 ScreenCaptureResults captureResults;
Dan Stozac7014012014-02-14 15:03:43 -08001255
chaviw308ddba2020-08-11 16:23:51 -07001256 SAFE_PARCEL(args.read, data);
1257 status_t res = captureDisplay(args, captureResults);
Chavi Weingarten40482ff2017-11-30 01:51:40 +00001258 if (res == NO_ERROR) {
chaviw308ddba2020-08-11 16:23:51 -07001259 SAFE_PARCEL(captureResults.write, *reply);
Chavi Weingarten40482ff2017-11-30 01:51:40 +00001260 }
chaviw308ddba2020-08-11 16:23:51 -07001261 return res;
Jesse Hall6c913be2013-08-08 12:15:49 -07001262 }
chaviwd2432892020-07-24 17:42:39 -07001263 case CAPTURE_DISPLAY_BY_ID: {
chaviw93df2ea2019-04-30 16:45:12 -07001264 CHECK_INTERFACE(ISurfaceComposer, data, reply);
chaviw308ddba2020-08-11 16:23:51 -07001265 uint64_t displayOrLayerStack = 0;
1266 SAFE_PARCEL(data.readUint64, &displayOrLayerStack);
chaviwd2432892020-07-24 17:42:39 -07001267 ScreenCaptureResults captureResults;
1268 status_t res = captureDisplay(displayOrLayerStack, captureResults);
chaviw93df2ea2019-04-30 16:45:12 -07001269 if (res == NO_ERROR) {
chaviw308ddba2020-08-11 16:23:51 -07001270 SAFE_PARCEL(captureResults.write, *reply);
chaviw93df2ea2019-04-30 16:45:12 -07001271 }
chaviw308ddba2020-08-11 16:23:51 -07001272 return res;
chaviw93df2ea2019-04-30 16:45:12 -07001273 }
chaviwa76b2712017-09-20 12:02:26 -07001274 case CAPTURE_LAYERS: {
1275 CHECK_INTERFACE(ISurfaceComposer, data, reply);
chaviw3efadb12020-07-27 10:07:15 -07001276 LayerCaptureArgs args;
1277 ScreenCaptureResults captureResults;
Robert Carr866455f2019-04-02 16:28:26 -07001278
chaviw308ddba2020-08-11 16:23:51 -07001279 SAFE_PARCEL(args.read, data);
1280 status_t res = captureLayers(args, captureResults);
Chavi Weingarten40482ff2017-11-30 01:51:40 +00001281 if (res == NO_ERROR) {
chaviw308ddba2020-08-11 16:23:51 -07001282 SAFE_PARCEL(captureResults.write, *reply);
Chavi Weingarten40482ff2017-11-30 01:51:40 +00001283 }
chaviw308ddba2020-08-11 16:23:51 -07001284 return res;
chaviwa76b2712017-09-20 12:02:26 -07001285 }
Jamie Gennis134f0422011-03-08 12:18:54 -08001286 case AUTHENTICATE_SURFACE: {
1287 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -08001288 sp<IGraphicBufferProducer> bufferProducer =
1289 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
1290 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -08001291 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -07001292 return NO_ERROR;
1293 }
Brian Anderson6b376712017-04-04 10:51:39 -07001294 case GET_SUPPORTED_FRAME_TIMESTAMPS: {
1295 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1296 std::vector<FrameEvent> supportedTimestamps;
1297 status_t result = getSupportedFrameTimestamps(&supportedTimestamps);
1298 status_t err = reply->writeInt32(result);
1299 if (err != NO_ERROR) {
1300 return err;
1301 }
1302 if (result != NO_ERROR) {
1303 return result;
1304 }
1305
1306 std::vector<int32_t> supported;
1307 supported.reserve(supportedTimestamps.size());
1308 for (FrameEvent s : supportedTimestamps) {
1309 supported.push_back(static_cast<int32_t>(s));
1310 }
1311 return reply->writeInt32Vector(supported);
1312 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001313 case CREATE_DISPLAY_EVENT_CONNECTION: {
1314 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Ady Abraham0f4a1b12019-06-04 16:04:04 -07001315 auto vsyncSource = static_cast<ISurfaceComposer::VsyncSource>(data.readInt32());
1316 auto configChanged = static_cast<ISurfaceComposer::ConfigChanged>(data.readInt32());
1317
1318 sp<IDisplayEventConnection> connection(
1319 createDisplayEventConnection(vsyncSource, configChanged));
Marco Nelissen2ea926b2014-11-14 08:01:01 -08001320 reply->writeStrongBinder(IInterface::asBinder(connection));
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001321 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001322 }
Mathias Agopiane57f2922012-08-09 16:29:12 -07001323 case CREATE_DISPLAY: {
1324 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden8dfa92f2012-09-17 18:27:17 -07001325 String8 displayName = data.readString8();
Jamie Gennisdd3cb842012-10-19 18:19:11 -07001326 bool secure = bool(data.readInt32());
1327 sp<IBinder> display(createDisplay(displayName, secure));
Mathias Agopiane57f2922012-08-09 16:29:12 -07001328 reply->writeStrongBinder(display);
1329 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001330 }
1331 case DESTROY_DISPLAY: {
1332 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1333 sp<IBinder> display = data.readStrongBinder();
1334 destroyDisplay(display);
1335 return NO_ERROR;
1336 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001337 case GET_PHYSICAL_DISPLAY_TOKEN: {
Mathias Agopiane57f2922012-08-09 16:29:12 -07001338 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marin Shalamanova524a092020-07-27 21:39:55 +02001339 PhysicalDisplayId displayId(data.readUint64());
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001340 sp<IBinder> display = getPhysicalDisplayToken(displayId);
Mathias Agopiane57f2922012-08-09 16:29:12 -07001341 reply->writeStrongBinder(display);
1342 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001343 }
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001344 case GET_DISPLAY_STATE: {
1345 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1346 ui::DisplayState state;
1347 const sp<IBinder> display = data.readStrongBinder();
1348 const status_t result = getDisplayState(display, &state);
1349 reply->writeInt32(result);
1350 if (result == NO_ERROR) {
1351 memcpy(reply->writeInplace(sizeof(ui::DisplayState)), &state,
1352 sizeof(ui::DisplayState));
1353 }
1354 return NO_ERROR;
1355 }
1356 case GET_DISPLAY_INFO: {
1357 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1358 DisplayInfo info;
1359 const sp<IBinder> display = data.readStrongBinder();
1360 const status_t result = getDisplayInfo(display, &info);
1361 reply->writeInt32(result);
Marin Shalamanov359a7e72020-02-17 17:03:07 +01001362 if (result != NO_ERROR) return result;
1363 return reply->write(info);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001364 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001365 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -07001366 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001367 Vector<DisplayConfig> configs;
1368 const sp<IBinder> display = data.readStrongBinder();
1369 const status_t result = getDisplayConfigs(display, &configs);
Dan Stoza7f7da322014-05-02 15:26:25 -07001370 reply->writeInt32(result);
1371 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -08001372 reply->writeUint32(static_cast<uint32_t>(configs.size()));
Dan Stoza7f7da322014-05-02 15:26:25 -07001373 for (size_t c = 0; c < configs.size(); ++c) {
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001374 memcpy(reply->writeInplace(sizeof(DisplayConfig)), &configs[c],
1375 sizeof(DisplayConfig));
Dan Stoza7f7da322014-05-02 15:26:25 -07001376 }
1377 }
1378 return NO_ERROR;
1379 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -07001380 case GET_DISPLAY_STATS: {
1381 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1382 DisplayStatInfo stats;
1383 sp<IBinder> display = data.readStrongBinder();
1384 status_t result = getDisplayStats(display, &stats);
1385 reply->writeInt32(result);
1386 if (result == NO_ERROR) {
1387 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
1388 &stats, sizeof(DisplayStatInfo));
1389 }
1390 return NO_ERROR;
1391 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001392 case GET_ACTIVE_CONFIG: {
1393 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1394 sp<IBinder> display = data.readStrongBinder();
1395 int id = getActiveConfig(display);
1396 reply->writeInt32(id);
1397 return NO_ERROR;
1398 }
Michael Wright28f24d02016-07-12 13:30:53 -07001399 case GET_DISPLAY_COLOR_MODES: {
1400 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Lina52f0292018-03-14 17:26:31 -07001401 Vector<ColorMode> colorModes;
Michael Wright28f24d02016-07-12 13:30:53 -07001402 sp<IBinder> display = nullptr;
1403 status_t result = data.readStrongBinder(&display);
1404 if (result != NO_ERROR) {
1405 ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result);
1406 return result;
1407 }
1408 result = getDisplayColorModes(display, &colorModes);
1409 reply->writeInt32(result);
1410 if (result == NO_ERROR) {
1411 reply->writeUint32(static_cast<uint32_t>(colorModes.size()));
1412 for (size_t i = 0; i < colorModes.size(); ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -07001413 reply->writeInt32(static_cast<int32_t>(colorModes[i]));
Michael Wright28f24d02016-07-12 13:30:53 -07001414 }
1415 }
1416 return NO_ERROR;
1417 }
Daniel Solomon42d04562019-01-20 21:03:19 -08001418 case GET_DISPLAY_NATIVE_PRIMARIES: {
1419 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1420 ui::DisplayPrimaries primaries;
1421 sp<IBinder> display = nullptr;
1422
1423 status_t result = data.readStrongBinder(&display);
1424 if (result != NO_ERROR) {
1425 ALOGE("getDisplayNativePrimaries failed to readStrongBinder: %d", result);
1426 return result;
1427 }
1428
1429 result = getDisplayNativePrimaries(display, primaries);
1430 reply->writeInt32(result);
1431 if (result == NO_ERROR) {
1432 memcpy(reply->writeInplace(sizeof(ui::DisplayPrimaries)), &primaries,
1433 sizeof(ui::DisplayPrimaries));
1434 }
1435
1436 return NO_ERROR;
1437 }
Michael Wright28f24d02016-07-12 13:30:53 -07001438 case GET_ACTIVE_COLOR_MODE: {
1439 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1440 sp<IBinder> display = nullptr;
1441 status_t result = data.readStrongBinder(&display);
1442 if (result != NO_ERROR) {
1443 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1444 return result;
1445 }
Peiyong Lina52f0292018-03-14 17:26:31 -07001446 ColorMode colorMode = getActiveColorMode(display);
Michael Wright28f24d02016-07-12 13:30:53 -07001447 result = reply->writeInt32(static_cast<int32_t>(colorMode));
1448 return result;
1449 }
1450 case SET_ACTIVE_COLOR_MODE: {
1451 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1452 sp<IBinder> display = nullptr;
1453 status_t result = data.readStrongBinder(&display);
1454 if (result != NO_ERROR) {
1455 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1456 return result;
1457 }
1458 int32_t colorModeInt = 0;
1459 result = data.readInt32(&colorModeInt);
1460 if (result != NO_ERROR) {
1461 ALOGE("setActiveColorMode failed to readInt32: %d", result);
1462 return result;
1463 }
1464 result = setActiveColorMode(display,
Peiyong Lina52f0292018-03-14 17:26:31 -07001465 static_cast<ColorMode>(colorModeInt));
Michael Wright28f24d02016-07-12 13:30:53 -07001466 result = reply->writeInt32(result);
1467 return result;
1468 }
Galia Peycheva5492cb52019-10-30 14:13:16 +01001469
1470 case GET_AUTO_LOW_LATENCY_MODE_SUPPORT: {
1471 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1472 sp<IBinder> display = nullptr;
1473 status_t result = data.readStrongBinder(&display);
1474 if (result != NO_ERROR) {
1475 ALOGE("getAutoLowLatencyModeSupport failed to readStrongBinder: %d", result);
1476 return result;
1477 }
1478 bool supported = false;
1479 result = getAutoLowLatencyModeSupport(display, &supported);
1480 if (result == NO_ERROR) {
1481 result = reply->writeBool(supported);
1482 }
1483 return result;
1484 }
1485
1486 case SET_AUTO_LOW_LATENCY_MODE: {
1487 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1488 sp<IBinder> display = nullptr;
1489 status_t result = data.readStrongBinder(&display);
1490 if (result != NO_ERROR) {
1491 ALOGE("setAutoLowLatencyMode failed to readStrongBinder: %d", result);
1492 return result;
1493 }
1494 bool setAllm = false;
1495 result = data.readBool(&setAllm);
1496 if (result != NO_ERROR) {
1497 ALOGE("setAutoLowLatencyMode failed to readBool: %d", result);
1498 return result;
1499 }
1500 setAutoLowLatencyMode(display, setAllm);
1501 return result;
1502 }
1503
1504 case GET_GAME_CONTENT_TYPE_SUPPORT: {
1505 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1506 sp<IBinder> display = nullptr;
1507 status_t result = data.readStrongBinder(&display);
1508 if (result != NO_ERROR) {
1509 ALOGE("getGameContentTypeSupport failed to readStrongBinder: %d", result);
1510 return result;
1511 }
1512 bool supported = false;
1513 result = getGameContentTypeSupport(display, &supported);
1514 if (result == NO_ERROR) {
1515 result = reply->writeBool(supported);
1516 }
1517 return result;
1518 }
1519
1520 case SET_GAME_CONTENT_TYPE: {
1521 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1522 sp<IBinder> display = nullptr;
1523 status_t result = data.readStrongBinder(&display);
1524 if (result != NO_ERROR) {
1525 ALOGE("setGameContentType failed to readStrongBinder: %d", result);
1526 return result;
1527 }
1528 bool setGameContentTypeOn = false;
1529 result = data.readBool(&setGameContentTypeOn);
1530 if (result != NO_ERROR) {
1531 ALOGE("setGameContentType failed to readBool: %d", result);
1532 return result;
1533 }
1534 setGameContentType(display, setGameContentTypeOn);
1535 return result;
1536 }
1537
Svetoslavd85084b2014-03-20 10:28:31 -07001538 case CLEAR_ANIMATION_FRAME_STATS: {
1539 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1540 status_t result = clearAnimationFrameStats();
1541 reply->writeInt32(result);
1542 return NO_ERROR;
1543 }
1544 case GET_ANIMATION_FRAME_STATS: {
1545 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1546 FrameStats stats;
1547 status_t result = getAnimationFrameStats(&stats);
1548 reply->write(stats);
1549 reply->writeInt32(result);
1550 return NO_ERROR;
1551 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -07001552 case SET_POWER_MODE: {
1553 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1554 sp<IBinder> display = data.readStrongBinder();
1555 int32_t mode = data.readInt32();
1556 setPowerMode(display, mode);
1557 return NO_ERROR;
1558 }
Dan Stozac4f471e2016-03-24 09:31:08 -07001559 case GET_HDR_CAPABILITIES: {
1560 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1561 sp<IBinder> display = nullptr;
1562 status_t result = data.readStrongBinder(&display);
1563 if (result != NO_ERROR) {
1564 ALOGE("getHdrCapabilities failed to readStrongBinder: %d",
1565 result);
1566 return result;
1567 }
1568 HdrCapabilities capabilities;
1569 result = getHdrCapabilities(display, &capabilities);
1570 reply->writeInt32(result);
1571 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -08001572 reply->write(capabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -07001573 }
1574 return NO_ERROR;
1575 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -07001576 case ENABLE_VSYNC_INJECTIONS: {
1577 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1578 bool enable = false;
1579 status_t result = data.readBool(&enable);
1580 if (result != NO_ERROR) {
1581 ALOGE("enableVSyncInjections failed to readBool: %d", result);
1582 return result;
1583 }
1584 return enableVSyncInjections(enable);
1585 }
1586 case INJECT_VSYNC: {
1587 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1588 int64_t when = 0;
1589 status_t result = data.readInt64(&when);
1590 if (result != NO_ERROR) {
1591 ALOGE("enableVSyncInjections failed to readInt64: %d", result);
1592 return result;
1593 }
1594 return injectVSync(when);
1595 }
Kalle Raitaa099a242017-01-11 11:17:29 -08001596 case GET_LAYER_DEBUG_INFO: {
1597 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1598 std::vector<LayerDebugInfo> outLayers;
1599 status_t result = getLayerDebugInfo(&outLayers);
1600 reply->writeInt32(result);
1601 if (result == NO_ERROR)
1602 {
1603 result = reply->writeParcelableVector(outLayers);
1604 }
1605 return result;
1606 }
Peiyong Lin0256f722018-08-31 15:45:10 -07001607 case GET_COMPOSITION_PREFERENCE: {
1608 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Linc6780972018-10-28 15:24:08 -07001609 ui::Dataspace defaultDataspace;
1610 ui::PixelFormat defaultPixelFormat;
1611 ui::Dataspace wideColorGamutDataspace;
1612 ui::PixelFormat wideColorGamutPixelFormat;
1613 status_t error =
1614 getCompositionPreference(&defaultDataspace, &defaultPixelFormat,
1615 &wideColorGamutDataspace, &wideColorGamutPixelFormat);
Peiyong Lin0256f722018-08-31 15:45:10 -07001616 reply->writeInt32(error);
1617 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -07001618 reply->writeInt32(static_cast<int32_t>(defaultDataspace));
1619 reply->writeInt32(static_cast<int32_t>(defaultPixelFormat));
1620 reply->writeInt32(static_cast<int32_t>(wideColorGamutDataspace));
Peiyong Linaa3da6a2018-12-12 02:48:43 -08001621 reply->writeInt32(static_cast<int32_t>(wideColorGamutPixelFormat));
Peiyong Lin0256f722018-08-31 15:45:10 -07001622 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001623 return error;
Peiyong Lin0256f722018-08-31 15:45:10 -07001624 }
Ady Abraham37965d42018-11-01 13:43:32 -07001625 case GET_COLOR_MANAGEMENT: {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001626 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Ady Abraham37965d42018-11-01 13:43:32 -07001627 bool result;
1628 status_t error = getColorManagement(&result);
1629 if (error == NO_ERROR) {
1630 reply->writeBool(result);
1631 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001632 return error;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001633 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -07001634 case GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: {
1635 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1636
1637 sp<IBinder> display = data.readStrongBinder();
1638 ui::PixelFormat format;
1639 ui::Dataspace dataspace;
1640 uint8_t component = 0;
1641 auto result =
1642 getDisplayedContentSamplingAttributes(display, &format, &dataspace, &component);
1643 if (result == NO_ERROR) {
1644 reply->writeUint32(static_cast<uint32_t>(format));
1645 reply->writeUint32(static_cast<uint32_t>(dataspace));
1646 reply->writeUint32(static_cast<uint32_t>(component));
1647 }
1648 return result;
1649 }
Kevin DuBois74e53772018-11-19 10:52:38 -08001650 case SET_DISPLAY_CONTENT_SAMPLING_ENABLED: {
1651 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1652
1653 sp<IBinder> display = nullptr;
1654 bool enable = false;
1655 int8_t componentMask = 0;
1656 uint64_t maxFrames = 0;
1657 status_t result = data.readStrongBinder(&display);
1658 if (result != NO_ERROR) {
1659 ALOGE("setDisplayContentSamplingEnabled failure in reading Display token: %d",
1660 result);
1661 return result;
1662 }
1663
1664 result = data.readBool(&enable);
1665 if (result != NO_ERROR) {
1666 ALOGE("setDisplayContentSamplingEnabled failure in reading enable: %d", result);
1667 return result;
1668 }
1669
1670 result = data.readByte(static_cast<int8_t*>(&componentMask));
1671 if (result != NO_ERROR) {
1672 ALOGE("setDisplayContentSamplingEnabled failure in reading component mask: %d",
1673 result);
1674 return result;
1675 }
1676
1677 result = data.readUint64(&maxFrames);
1678 if (result != NO_ERROR) {
1679 ALOGE("setDisplayContentSamplingEnabled failure in reading max frames: %d", result);
1680 return result;
1681 }
1682
1683 return setDisplayContentSamplingEnabled(display, enable,
1684 static_cast<uint8_t>(componentMask), maxFrames);
1685 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001686 case GET_DISPLAYED_CONTENT_SAMPLE: {
1687 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1688
1689 sp<IBinder> display = data.readStrongBinder();
1690 uint64_t maxFrames = 0;
1691 uint64_t timestamp = 0;
1692
1693 status_t result = data.readUint64(&maxFrames);
1694 if (result != NO_ERROR) {
1695 ALOGE("getDisplayedContentSample failure in reading max frames: %d", result);
1696 return result;
1697 }
1698
1699 result = data.readUint64(&timestamp);
1700 if (result != NO_ERROR) {
1701 ALOGE("getDisplayedContentSample failure in reading timestamp: %d", result);
1702 return result;
1703 }
1704
1705 DisplayedFrameStats stats;
1706 result = getDisplayedContentSample(display, maxFrames, timestamp, &stats);
1707 if (result == NO_ERROR) {
1708 reply->writeUint64(stats.numFrames);
Kevin DuBois1d4c6a62018-12-12 13:59:46 -08001709 reply->writeUint64Vector(stats.component_0_sample);
1710 reply->writeUint64Vector(stats.component_1_sample);
1711 reply->writeUint64Vector(stats.component_2_sample);
1712 reply->writeUint64Vector(stats.component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001713 }
1714 return result;
1715 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001716 case GET_PROTECTED_CONTENT_SUPPORT: {
1717 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1718 bool result;
1719 status_t error = getProtectedContentSupport(&result);
1720 if (error == NO_ERROR) {
1721 reply->writeBool(result);
1722 }
1723 return error;
1724 }
Peiyong Lin4f3fddf2019-01-24 17:21:24 -08001725 case IS_WIDE_COLOR_DISPLAY: {
1726 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1727 sp<IBinder> display = nullptr;
1728 status_t error = data.readStrongBinder(&display);
1729 if (error != NO_ERROR) {
1730 return error;
1731 }
1732 bool result;
1733 error = isWideColorDisplay(display, &result);
1734 if (error == NO_ERROR) {
1735 reply->writeBool(result);
1736 }
1737 return error;
1738 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001739 case GET_PHYSICAL_DISPLAY_IDS: {
1740 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marin Shalamanova524a092020-07-27 21:39:55 +02001741 std::vector<PhysicalDisplayId> ids = getPhysicalDisplayIds();
1742 std::vector<uint64_t> rawIds(ids.size());
1743 std::transform(ids.begin(), ids.end(), rawIds.begin(),
1744 [](PhysicalDisplayId id) { return id.value; });
1745 return reply->writeUint64Vector(rawIds);
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001746 }
Dan Stoza84ab9372018-12-17 15:27:57 -08001747 case ADD_REGION_SAMPLING_LISTENER: {
1748 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1749 Rect samplingArea;
1750 status_t result = data.read(samplingArea);
1751 if (result != NO_ERROR) {
1752 ALOGE("addRegionSamplingListener: Failed to read sampling area");
1753 return result;
1754 }
1755 sp<IBinder> stopLayerHandle;
1756 result = data.readNullableStrongBinder(&stopLayerHandle);
1757 if (result != NO_ERROR) {
1758 ALOGE("addRegionSamplingListener: Failed to read stop layer handle");
1759 return result;
1760 }
1761 sp<IRegionSamplingListener> listener;
1762 result = data.readNullableStrongBinder(&listener);
1763 if (result != NO_ERROR) {
1764 ALOGE("addRegionSamplingListener: Failed to read listener");
1765 return result;
1766 }
1767 return addRegionSamplingListener(samplingArea, stopLayerHandle, listener);
1768 }
1769 case REMOVE_REGION_SAMPLING_LISTENER: {
1770 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1771 sp<IRegionSamplingListener> listener;
1772 status_t result = data.readNullableStrongBinder(&listener);
1773 if (result != NO_ERROR) {
1774 ALOGE("removeRegionSamplingListener: Failed to read listener");
1775 return result;
1776 }
1777 return removeRegionSamplingListener(listener);
1778 }
Ana Krulec0782b882019-10-15 17:34:54 -07001779 case SET_DESIRED_DISPLAY_CONFIG_SPECS: {
1780 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1781 sp<IBinder> displayToken = data.readStrongBinder();
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001782 int32_t defaultConfig;
1783 status_t result = data.readInt32(&defaultConfig);
Ana Krulec0782b882019-10-15 17:34:54 -07001784 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001785 ALOGE("setDesiredDisplayConfigSpecs: failed to read defaultConfig: %d", result);
Ana Krulec0782b882019-10-15 17:34:54 -07001786 return result;
1787 }
Steven Thomasf734df42020-04-13 21:09:28 -07001788 float primaryRefreshRateMin;
1789 result = data.readFloat(&primaryRefreshRateMin);
Ana Krulec0782b882019-10-15 17:34:54 -07001790 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001791 ALOGE("setDesiredDisplayConfigSpecs: failed to read primaryRefreshRateMin: %d",
1792 result);
Ana Krulec0782b882019-10-15 17:34:54 -07001793 return result;
1794 }
Steven Thomasf734df42020-04-13 21:09:28 -07001795 float primaryRefreshRateMax;
1796 result = data.readFloat(&primaryRefreshRateMax);
Ana Krulec0782b882019-10-15 17:34:54 -07001797 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001798 ALOGE("setDesiredDisplayConfigSpecs: failed to read primaryRefreshRateMax: %d",
1799 result);
Ana Krulec0782b882019-10-15 17:34:54 -07001800 return result;
1801 }
Steven Thomasf734df42020-04-13 21:09:28 -07001802 float appRequestRefreshRateMin;
1803 result = data.readFloat(&appRequestRefreshRateMin);
1804 if (result != NO_ERROR) {
1805 ALOGE("setDesiredDisplayConfigSpecs: failed to read appRequestRefreshRateMin: %d",
1806 result);
1807 return result;
1808 }
1809 float appRequestRefreshRateMax;
1810 result = data.readFloat(&appRequestRefreshRateMax);
1811 if (result != NO_ERROR) {
1812 ALOGE("setDesiredDisplayConfigSpecs: failed to read appRequestRefreshRateMax: %d",
1813 result);
1814 return result;
1815 }
1816 result =
1817 setDesiredDisplayConfigSpecs(displayToken, defaultConfig, primaryRefreshRateMin,
1818 primaryRefreshRateMax, appRequestRefreshRateMin,
1819 appRequestRefreshRateMax);
Ana Krulec0782b882019-10-15 17:34:54 -07001820 if (result != NO_ERROR) {
1821 ALOGE("setDesiredDisplayConfigSpecs: failed to call setDesiredDisplayConfigSpecs: "
1822 "%d",
1823 result);
1824 return result;
1825 }
1826 reply->writeInt32(result);
1827 return result;
1828 }
Ana Krulec234bb162019-11-10 22:55:55 +01001829 case GET_DESIRED_DISPLAY_CONFIG_SPECS: {
1830 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1831 sp<IBinder> displayToken = data.readStrongBinder();
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001832 int32_t defaultConfig;
Steven Thomasf734df42020-04-13 21:09:28 -07001833 float primaryRefreshRateMin;
1834 float primaryRefreshRateMax;
1835 float appRequestRefreshRateMin;
1836 float appRequestRefreshRateMax;
Ana Krulec234bb162019-11-10 22:55:55 +01001837
Steven Thomasf734df42020-04-13 21:09:28 -07001838 status_t result =
1839 getDesiredDisplayConfigSpecs(displayToken, &defaultConfig,
1840 &primaryRefreshRateMin, &primaryRefreshRateMax,
1841 &appRequestRefreshRateMin,
1842 &appRequestRefreshRateMax);
Ana Krulec234bb162019-11-10 22:55:55 +01001843 if (result != NO_ERROR) {
1844 ALOGE("getDesiredDisplayConfigSpecs: failed to get getDesiredDisplayConfigSpecs: "
1845 "%d",
1846 result);
1847 return result;
1848 }
1849
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001850 result = reply->writeInt32(defaultConfig);
Ana Krulec234bb162019-11-10 22:55:55 +01001851 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001852 ALOGE("getDesiredDisplayConfigSpecs: failed to write defaultConfig: %d", result);
Ana Krulec234bb162019-11-10 22:55:55 +01001853 return result;
1854 }
Steven Thomasf734df42020-04-13 21:09:28 -07001855 result = reply->writeFloat(primaryRefreshRateMin);
Ana Krulec234bb162019-11-10 22:55:55 +01001856 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001857 ALOGE("getDesiredDisplayConfigSpecs: failed to write primaryRefreshRateMin: %d",
1858 result);
Ana Krulec234bb162019-11-10 22:55:55 +01001859 return result;
1860 }
Steven Thomasf734df42020-04-13 21:09:28 -07001861 result = reply->writeFloat(primaryRefreshRateMax);
Ana Krulec234bb162019-11-10 22:55:55 +01001862 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001863 ALOGE("getDesiredDisplayConfigSpecs: failed to write primaryRefreshRateMax: %d",
1864 result);
1865 return result;
1866 }
1867 result = reply->writeFloat(appRequestRefreshRateMin);
1868 if (result != NO_ERROR) {
1869 ALOGE("getDesiredDisplayConfigSpecs: failed to write appRequestRefreshRateMin: %d",
1870 result);
1871 return result;
1872 }
1873 result = reply->writeFloat(appRequestRefreshRateMax);
1874 if (result != NO_ERROR) {
1875 ALOGE("getDesiredDisplayConfigSpecs: failed to write appRequestRefreshRateMax: %d",
1876 result);
Ana Krulec234bb162019-11-10 22:55:55 +01001877 return result;
1878 }
1879 reply->writeInt32(result);
1880 return result;
1881 }
Dan Gittik57e63c52019-01-18 16:37:54 +00001882 case GET_DISPLAY_BRIGHTNESS_SUPPORT: {
1883 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1884 sp<IBinder> displayToken;
1885 status_t error = data.readNullableStrongBinder(&displayToken);
1886 if (error != NO_ERROR) {
1887 ALOGE("getDisplayBrightnessSupport: failed to read display token: %d", error);
1888 return error;
1889 }
1890 bool support = false;
1891 error = getDisplayBrightnessSupport(displayToken, &support);
1892 reply->writeBool(support);
1893 return error;
1894 }
1895 case SET_DISPLAY_BRIGHTNESS: {
1896 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1897 sp<IBinder> displayToken;
1898 status_t error = data.readNullableStrongBinder(&displayToken);
1899 if (error != NO_ERROR) {
1900 ALOGE("setDisplayBrightness: failed to read display token: %d", error);
1901 return error;
1902 }
1903 float brightness = -1.0f;
1904 error = data.readFloat(&brightness);
1905 if (error != NO_ERROR) {
1906 ALOGE("setDisplayBrightness: failed to read brightness: %d", error);
1907 return error;
1908 }
1909 return setDisplayBrightness(displayToken, brightness);
1910 }
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001911 case NOTIFY_POWER_BOOST: {
Ady Abraham8532d012019-05-08 14:50:56 -07001912 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001913 int32_t boostId;
1914 status_t error = data.readInt32(&boostId);
Ady Abraham8532d012019-05-08 14:50:56 -07001915 if (error != NO_ERROR) {
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001916 ALOGE("notifyPowerBoost: failed to read boostId: %d", error);
Ady Abraham8532d012019-05-08 14:50:56 -07001917 return error;
1918 }
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001919 return notifyPowerBoost(boostId);
Ady Abraham8532d012019-05-08 14:50:56 -07001920 }
Vishnu Nairb13bb952019-11-15 10:24:08 -08001921 case SET_GLOBAL_SHADOW_SETTINGS: {
1922 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1923
1924 std::vector<float> shadowConfig;
1925 status_t error = data.readFloatVector(&shadowConfig);
1926 if (error != NO_ERROR || shadowConfig.size() != 11) {
1927 ALOGE("setGlobalShadowSettings: failed to read shadowConfig: %d", error);
1928 return error;
1929 }
1930
1931 half4 ambientColor = {shadowConfig[0], shadowConfig[1], shadowConfig[2],
1932 shadowConfig[3]};
1933 half4 spotColor = {shadowConfig[4], shadowConfig[5], shadowConfig[6], shadowConfig[7]};
1934 float lightPosY = shadowConfig[8];
1935 float lightPosZ = shadowConfig[9];
1936 float lightRadius = shadowConfig[10];
1937 return setGlobalShadowSettings(ambientColor, spotColor, lightPosY, lightPosZ,
1938 lightRadius);
1939 }
Steven Thomas62a4cf82020-01-31 12:04:03 -08001940 case SET_FRAME_RATE: {
1941 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1942 sp<IBinder> binder;
1943 status_t err = data.readStrongBinder(&binder);
1944 if (err != NO_ERROR) {
1945 ALOGE("setFrameRate: failed to read strong binder: %s (%d)", strerror(-err), -err);
1946 return err;
1947 }
1948 sp<IGraphicBufferProducer> surface = interface_cast<IGraphicBufferProducer>(binder);
1949 if (!surface) {
1950 ALOGE("setFrameRate: failed to cast to IGraphicBufferProducer: %s (%d)",
1951 strerror(-err), -err);
1952 return err;
1953 }
1954 float frameRate;
1955 err = data.readFloat(&frameRate);
1956 if (err != NO_ERROR) {
1957 ALOGE("setFrameRate: failed to read float: %s (%d)", strerror(-err), -err);
1958 return err;
1959 }
1960 int8_t compatibility;
1961 err = data.readByte(&compatibility);
1962 if (err != NO_ERROR) {
1963 ALOGE("setFrameRate: failed to read byte: %s (%d)", strerror(-err), -err);
1964 return err;
1965 }
1966 status_t result = setFrameRate(surface, frameRate, compatibility);
1967 reply->writeInt32(result);
1968 return NO_ERROR;
1969 }
Steven Thomasd4071902020-03-24 16:02:53 -07001970 case ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN: {
1971 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1972 sp<IBinder> token;
1973 status_t result = acquireFrameRateFlexibilityToken(&token);
1974 reply->writeInt32(result);
1975 if (result == NO_ERROR) {
1976 reply->writeStrongBinder(token);
1977 }
1978 return NO_ERROR;
1979 }
Jesse Hall6c913be2013-08-08 12:15:49 -07001980 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001981 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -07001982 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001983 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001984}
1985
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001986} // namespace android