blob: 4df80f4105fb26bc21b5cb20d427c42a3b690001 [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
Marissa Wall713b63f2018-10-17 15:42:43 -070069 virtual void setTransactionState(const Vector<ComposerState>& state,
70 const Vector<DisplayState>& displays, uint32_t flags,
chaviw273171b2018-12-26 11:46:30 -080071 const sp<IBinder>& applyToken,
Marissa Wall17b4e452018-12-26 16:32:34 -080072 const InputWindowCommands& commands,
Marissa Wall78b72202019-03-15 14:58:34 -070073 int64_t desiredPresentTime,
Valerie Hau9dab9732019-08-20 09:29:25 -070074 const client_cache_t& uncacheBuffer, bool hasListenerCallbacks,
Marissa Wall3dad52d2019-03-22 14:03:19 -070075 const std::vector<ListenerCallbacks>& listenerCallbacks) {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080076 Parcel data, reply;
77 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Dan Stozad723bd72014-11-18 10:24:03 -080078
79 data.writeUint32(static_cast<uint32_t>(state.size()));
80 for (const auto& s : state) {
81 s.write(data);
Mathias Agopian698c0872011-06-28 19:09:31 -070082 }
Dan Stozad723bd72014-11-18 10:24:03 -080083
84 data.writeUint32(static_cast<uint32_t>(displays.size()));
85 for (const auto& d : displays) {
86 d.write(data);
Mathias Agopian8b33f032012-07-24 20:43:54 -070087 }
Dan Stozad723bd72014-11-18 10:24:03 -080088
89 data.writeUint32(flags);
Marissa Wall713b63f2018-10-17 15:42:43 -070090 data.writeStrongBinder(applyToken);
chaviw273171b2018-12-26 11:46:30 -080091 commands.write(data);
Marissa Wall17b4e452018-12-26 16:32:34 -080092 data.writeInt64(desiredPresentTime);
Steven Moreland9d4ce9b2019-07-17 15:23:38 -070093 data.writeStrongBinder(uncacheBuffer.token.promote());
Marissa Wall947d34e2019-03-29 14:03:53 -070094 data.writeUint64(uncacheBuffer.id);
Valerie Hau9dab9732019-08-20 09:29:25 -070095 data.writeBool(hasListenerCallbacks);
Marissa Wall3dad52d2019-03-22 14:03:19 -070096
97 if (data.writeVectorSize(listenerCallbacks) == NO_ERROR) {
98 for (const auto& [listener, callbackIds] : listenerCallbacks) {
Valerie Hau5de3ad22019-08-20 07:47:43 -070099 data.writeStrongBinder(listener);
Marissa Wall3dad52d2019-03-22 14:03:19 -0700100 data.writeInt64Vector(callbackIds);
101 }
102 }
103
Jamie Gennisb8d69a52011-10-10 15:48:06 -0700104 remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800105 }
106
107 virtual void bootFinished()
108 {
109 Parcel data, reply;
110 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
111 remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply);
112 }
113
chaviwd2432892020-07-24 17:42:39 -0700114 virtual status_t captureDisplay(const DisplayCaptureArgs& args,
115 ScreenCaptureResults& captureResults) {
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800116 Parcel data, reply;
117 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
chaviwd2432892020-07-24 17:42:39 -0700118
119 status_t result = args.write(data);
Ana Krulec2d41e422018-07-26 12:07:43 -0700120 if (result != NO_ERROR) {
chaviwd2432892020-07-24 17:42:39 -0700121 ALOGE("captureDisplay failed to parcel args: %d", result);
122 return result;
123 }
124 result = remote()->transact(BnSurfaceComposer::CAPTURE_DISPLAY, data, &reply);
125 if (result != NO_ERROR) {
126 ALOGE("captureDisplay failed to transact: %d", result);
Ana Krulec2d41e422018-07-26 12:07:43 -0700127 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000128 }
Ana Krulec2d41e422018-07-26 12:07:43 -0700129 result = reply.readInt32();
130 if (result != NO_ERROR) {
chaviwd2432892020-07-24 17:42:39 -0700131 ALOGE("captureDisplay failed to readInt32: %d", result);
Ana Krulec2d41e422018-07-26 12:07:43 -0700132 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000133 }
134
chaviwd2432892020-07-24 17:42:39 -0700135 captureResults.read(reply);
Ana Krulec2d41e422018-07-26 12:07:43 -0700136 return result;
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800137 }
138
chaviwd2432892020-07-24 17:42:39 -0700139 virtual status_t captureDisplay(uint64_t displayOrLayerStack,
140 ScreenCaptureResults& captureResults) {
chaviw93df2ea2019-04-30 16:45:12 -0700141 Parcel data, reply;
142 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
143 data.writeUint64(displayOrLayerStack);
chaviwd2432892020-07-24 17:42:39 -0700144 status_t result =
145 remote()->transact(BnSurfaceComposer::CAPTURE_DISPLAY_BY_ID, data, &reply);
chaviw93df2ea2019-04-30 16:45:12 -0700146 if (result != NO_ERROR) {
chaviwd2432892020-07-24 17:42:39 -0700147 ALOGE("captureDisplay failed to transact: %d", result);
chaviw93df2ea2019-04-30 16:45:12 -0700148 return result;
149 }
150 result = reply.readInt32();
151 if (result != NO_ERROR) {
chaviwd2432892020-07-24 17:42:39 -0700152 ALOGE("captureDisplay failed to readInt32: %d", result);
chaviw93df2ea2019-04-30 16:45:12 -0700153 return result;
154 }
155
chaviwd2432892020-07-24 17:42:39 -0700156 captureResults.read(reply);
chaviw93df2ea2019-04-30 16:45:12 -0700157 return result;
158 }
159
chaviw3efadb12020-07-27 10:07:15 -0700160 virtual status_t captureLayers(const LayerCaptureArgs& args,
161 ScreenCaptureResults& captureResults) {
chaviwa76b2712017-09-20 12:02:26 -0700162 Parcel data, reply;
163 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
chaviw3efadb12020-07-27 10:07:15 -0700164
165 status_t result = args.write(data);
166 if (result != NO_ERROR) {
167 ALOGE("captureLayers failed to parcel args: %d", result);
168 return result;
Robert Carr866455f2019-04-02 16:28:26 -0700169 }
chaviw3efadb12020-07-27 10:07:15 -0700170
171 result = remote()->transact(BnSurfaceComposer::CAPTURE_LAYERS, data, &reply);
Ana Krulec2d41e422018-07-26 12:07:43 -0700172 if (result != NO_ERROR) {
173 ALOGE("captureLayers failed to transact: %d", result);
174 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000175 }
Ana Krulec2d41e422018-07-26 12:07:43 -0700176 result = reply.readInt32();
177 if (result != NO_ERROR) {
178 ALOGE("captureLayers failed to readInt32: %d", result);
179 return result;
Chavi Weingarten40482ff2017-11-30 01:51:40 +0000180 }
Peiyong Lin0e003c92018-09-17 11:09:51 -0700181
chaviw3efadb12020-07-27 10:07:15 -0700182 captureResults.read(reply);
Ana Krulec2d41e422018-07-26 12:07:43 -0700183 return result;
chaviwa76b2712017-09-20 12:02:26 -0700184 }
185
Jamie Gennis582270d2011-08-17 18:19:00 -0700186 virtual bool authenticateSurfaceTexture(
Andy McFadden2adaf042012-12-18 09:49:45 -0800187 const sp<IGraphicBufferProducer>& bufferProducer) const
Jamie Gennis134f0422011-03-08 12:18:54 -0800188 {
189 Parcel data, reply;
190 int err = NO_ERROR;
191 err = data.writeInterfaceToken(
192 ISurfaceComposer::getInterfaceDescriptor());
193 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000194 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis134f0422011-03-08 12:18:54 -0800195 "interface descriptor: %s (%d)", strerror(-err), -err);
196 return false;
197 }
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800198 err = data.writeStrongBinder(IInterface::asBinder(bufferProducer));
Jamie Gennis134f0422011-03-08 12:18:54 -0800199 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000200 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis582270d2011-08-17 18:19:00 -0700201 "strong binder to parcel: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800202 return false;
203 }
204 err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
205 &reply);
206 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000207 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700208 "performing transaction: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800209 return false;
210 }
211 int32_t result = 0;
212 err = reply.readInt32(&result);
213 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000214 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700215 "retrieving result: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800216 return false;
217 }
218 return result != 0;
219 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800220
Brian Anderson6b376712017-04-04 10:51:39 -0700221 virtual status_t getSupportedFrameTimestamps(
222 std::vector<FrameEvent>* outSupported) const {
223 if (!outSupported) {
224 return UNEXPECTED_NULL;
225 }
226 outSupported->clear();
227
228 Parcel data, reply;
229
230 status_t err = data.writeInterfaceToken(
231 ISurfaceComposer::getInterfaceDescriptor());
232 if (err != NO_ERROR) {
233 return err;
234 }
235
236 err = remote()->transact(
237 BnSurfaceComposer::GET_SUPPORTED_FRAME_TIMESTAMPS,
238 data, &reply);
239 if (err != NO_ERROR) {
240 return err;
241 }
242
243 int32_t result = 0;
244 err = reply.readInt32(&result);
245 if (err != NO_ERROR) {
246 return err;
247 }
248 if (result != NO_ERROR) {
249 return result;
250 }
251
252 std::vector<int32_t> supported;
253 err = reply.readInt32Vector(&supported);
254 if (err != NO_ERROR) {
255 return err;
256 }
257
258 outSupported->reserve(supported.size());
259 for (int32_t s : supported) {
260 outSupported->push_back(static_cast<FrameEvent>(s));
261 }
262 return NO_ERROR;
263 }
264
Ady Abraham0f4a1b12019-06-04 16:04:04 -0700265 virtual sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource,
266 ConfigChanged configChanged) {
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800267 Parcel data, reply;
268 sp<IDisplayEventConnection> result;
269 int err = data.writeInterfaceToken(
270 ISurfaceComposer::getInterfaceDescriptor());
271 if (err != NO_ERROR) {
272 return result;
273 }
Jorim Jaggib1e2f8d2017-06-08 15:43:59 -0700274 data.writeInt32(static_cast<int32_t>(vsyncSource));
Ady Abraham0f4a1b12019-06-04 16:04:04 -0700275 data.writeInt32(static_cast<int32_t>(configChanged));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800276 err = remote()->transact(
277 BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION,
278 data, &reply);
279 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000280 ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing "
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800281 "transaction: %s (%d)", strerror(-err), -err);
282 return result;
283 }
284 result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder());
285 return result;
286 }
Colin Cross8e533062012-06-07 13:17:52 -0700287
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700288 virtual sp<IBinder> createDisplay(const String8& displayName, bool secure)
Mathias Agopiane57f2922012-08-09 16:29:12 -0700289 {
290 Parcel data, reply;
291 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700292 data.writeString8(displayName);
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700293 data.writeInt32(secure ? 1 : 0);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700294 remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply);
295 return reply.readStrongBinder();
296 }
297
Jesse Hall6c913be2013-08-08 12:15:49 -0700298 virtual void destroyDisplay(const sp<IBinder>& display)
299 {
300 Parcel data, reply;
301 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
302 data.writeStrongBinder(display);
303 remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply);
304 }
305
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800306 virtual std::vector<PhysicalDisplayId> getPhysicalDisplayIds() const {
Mathias Agopiane57f2922012-08-09 16:29:12 -0700307 Parcel data, reply;
308 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800309 if (remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_IDS, data, &reply) ==
310 NO_ERROR) {
311 std::vector<PhysicalDisplayId> displayIds;
312 if (reply.readUint64Vector(&displayIds) == NO_ERROR) {
313 return displayIds;
314 }
315 }
316
317 return {};
318 }
319
320 virtual sp<IBinder> getPhysicalDisplayToken(PhysicalDisplayId displayId) const {
321 Parcel data, reply;
322 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
323 data.writeUint64(displayId);
324 remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_TOKEN, data, &reply);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700325 return reply.readStrongBinder();
326 }
327
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700328 virtual void setPowerMode(const sp<IBinder>& display, int mode)
Colin Cross8e533062012-06-07 13:17:52 -0700329 {
330 Parcel data, reply;
331 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700332 data.writeStrongBinder(display);
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700333 data.writeInt32(mode);
334 remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply);
Colin Cross8e533062012-06-07 13:17:52 -0700335 }
Mathias Agopian3094df32012-06-18 18:06:45 -0700336
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800337 virtual status_t getDisplayState(const sp<IBinder>& display, ui::DisplayState* state) {
338 Parcel data, reply;
339 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
340 data.writeStrongBinder(display);
341 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATE, data, &reply);
342 const status_t result = reply.readInt32();
343 if (result == NO_ERROR) {
344 memcpy(state, reply.readInplace(sizeof(ui::DisplayState)), sizeof(ui::DisplayState));
345 }
346 return result;
347 }
348
349 virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) {
350 Parcel data, reply;
351 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
352 data.writeStrongBinder(display);
353 remote()->transact(BnSurfaceComposer::GET_DISPLAY_INFO, data, &reply);
354 const status_t result = reply.readInt32();
Marin Shalamanov359a7e72020-02-17 17:03:07 +0100355 if (result != NO_ERROR) return result;
356 return reply.read(*info);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800357 }
358
359 virtual status_t getDisplayConfigs(const sp<IBinder>& display, Vector<DisplayConfig>* configs) {
Mathias Agopianc666cae2012-07-25 18:56:13 -0700360 Parcel data, reply;
361 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700362 data.writeStrongBinder(display);
Dan Stoza7f7da322014-05-02 15:26:25 -0700363 remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800364 const status_t result = reply.readInt32();
Dan Stoza7f7da322014-05-02 15:26:25 -0700365 if (result == NO_ERROR) {
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800366 const size_t numConfigs = reply.readUint32();
Dan Stoza7f7da322014-05-02 15:26:25 -0700367 configs->clear();
368 configs->resize(numConfigs);
369 for (size_t c = 0; c < numConfigs; ++c) {
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800370 memcpy(&(configs->editItemAt(c)), reply.readInplace(sizeof(DisplayConfig)),
371 sizeof(DisplayConfig));
Dan Stoza7f7da322014-05-02 15:26:25 -0700372 }
373 }
374 return result;
375 }
376
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700377 virtual status_t getDisplayStats(const sp<IBinder>& display,
378 DisplayStatInfo* stats)
379 {
380 Parcel data, reply;
381 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
382 data.writeStrongBinder(display);
383 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply);
384 status_t result = reply.readInt32();
385 if (result == NO_ERROR) {
386 memcpy(stats,
387 reply.readInplace(sizeof(DisplayStatInfo)),
388 sizeof(DisplayStatInfo));
389 }
390 return result;
391 }
392
Dan Stoza7f7da322014-05-02 15:26:25 -0700393 virtual int getActiveConfig(const sp<IBinder>& display)
394 {
395 Parcel data, reply;
396 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
397 data.writeStrongBinder(display);
398 remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply);
399 return reply.readInt32();
400 }
401
Michael Wright28f24d02016-07-12 13:30:53 -0700402 virtual status_t getDisplayColorModes(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700403 Vector<ColorMode>* outColorModes) {
Michael Wright28f24d02016-07-12 13:30:53 -0700404 Parcel data, reply;
405 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
406 if (result != NO_ERROR) {
407 ALOGE("getDisplayColorModes failed to writeInterfaceToken: %d", result);
408 return result;
409 }
410 result = data.writeStrongBinder(display);
411 if (result != NO_ERROR) {
412 ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result);
413 return result;
414 }
415 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply);
416 if (result != NO_ERROR) {
417 ALOGE("getDisplayColorModes failed to transact: %d", result);
418 return result;
419 }
420 result = static_cast<status_t>(reply.readInt32());
421 if (result == NO_ERROR) {
422 size_t numModes = reply.readUint32();
423 outColorModes->clear();
424 outColorModes->resize(numModes);
425 for (size_t i = 0; i < numModes; ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -0700426 outColorModes->replaceAt(static_cast<ColorMode>(reply.readInt32()), i);
Michael Wright28f24d02016-07-12 13:30:53 -0700427 }
428 }
429 return result;
430 }
431
Daniel Solomon42d04562019-01-20 21:03:19 -0800432 virtual status_t getDisplayNativePrimaries(const sp<IBinder>& display,
433 ui::DisplayPrimaries& primaries) {
434 Parcel data, reply;
435 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
436 if (result != NO_ERROR) {
437 ALOGE("getDisplayNativePrimaries failed to writeInterfaceToken: %d", result);
438 return result;
439 }
440 result = data.writeStrongBinder(display);
441 if (result != NO_ERROR) {
442 ALOGE("getDisplayNativePrimaries failed to writeStrongBinder: %d", result);
443 return result;
444 }
445 result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_NATIVE_PRIMARIES, data, &reply);
446 if (result != NO_ERROR) {
447 ALOGE("getDisplayNativePrimaries failed to transact: %d", result);
448 return result;
449 }
450 result = reply.readInt32();
451 if (result == NO_ERROR) {
452 memcpy(&primaries, reply.readInplace(sizeof(ui::DisplayPrimaries)),
453 sizeof(ui::DisplayPrimaries));
454 }
455 return result;
456 }
457
Peiyong Lina52f0292018-03-14 17:26:31 -0700458 virtual ColorMode getActiveColorMode(const sp<IBinder>& display) {
Michael Wright28f24d02016-07-12 13:30:53 -0700459 Parcel data, reply;
460 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
461 if (result != NO_ERROR) {
462 ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700463 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700464 }
465 result = data.writeStrongBinder(display);
466 if (result != NO_ERROR) {
467 ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700468 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700469 }
470 result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply);
471 if (result != NO_ERROR) {
472 ALOGE("getActiveColorMode failed to transact: %d", result);
Peiyong Lina52f0292018-03-14 17:26:31 -0700473 return static_cast<ColorMode>(result);
Michael Wright28f24d02016-07-12 13:30:53 -0700474 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700475 return static_cast<ColorMode>(reply.readInt32());
Michael Wright28f24d02016-07-12 13:30:53 -0700476 }
477
478 virtual status_t setActiveColorMode(const sp<IBinder>& display,
Peiyong Lina52f0292018-03-14 17:26:31 -0700479 ColorMode colorMode) {
Michael Wright28f24d02016-07-12 13:30:53 -0700480 Parcel data, reply;
481 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
482 if (result != NO_ERROR) {
483 ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result);
484 return result;
485 }
486 result = data.writeStrongBinder(display);
487 if (result != NO_ERROR) {
488 ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result);
489 return result;
490 }
Peiyong Lina52f0292018-03-14 17:26:31 -0700491 result = data.writeInt32(static_cast<int32_t>(colorMode));
Michael Wright28f24d02016-07-12 13:30:53 -0700492 if (result != NO_ERROR) {
493 ALOGE("setActiveColorMode failed to writeInt32: %d", result);
494 return result;
495 }
496 result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply);
497 if (result != NO_ERROR) {
498 ALOGE("setActiveColorMode failed to transact: %d", result);
499 return result;
500 }
501 return static_cast<status_t>(reply.readInt32());
502 }
503
Galia Peycheva5492cb52019-10-30 14:13:16 +0100504 virtual status_t getAutoLowLatencyModeSupport(const sp<IBinder>& display,
505 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("getAutoLowLatencyModeSupport failed to writeStrongBinder: %d", result);
511 return result;
512 }
513 result = remote()->transact(BnSurfaceComposer::GET_AUTO_LOW_LATENCY_MODE_SUPPORT, data,
514 &reply);
515 if (result != NO_ERROR) {
516 ALOGE("getAutoLowLatencyModeSupport failed to transact: %d", result);
517 return result;
518 }
519 return reply.readBool(outSupport);
520 }
521
522 virtual void setAutoLowLatencyMode(const sp<IBinder>& display, bool on) {
523 Parcel data, reply;
524 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
525 if (result != NO_ERROR) {
526 ALOGE("setAutoLowLatencyMode failed to writeInterfaceToken: %d", result);
527 return;
528 }
529
530 result = data.writeStrongBinder(display);
531 if (result != NO_ERROR) {
532 ALOGE("setAutoLowLatencyMode failed to writeStrongBinder: %d", result);
533 return;
534 }
535 result = data.writeBool(on);
536 if (result != NO_ERROR) {
537 ALOGE("setAutoLowLatencyMode failed to writeBool: %d", result);
538 return;
539 }
540 result = remote()->transact(BnSurfaceComposer::SET_AUTO_LOW_LATENCY_MODE, data, &reply);
541 if (result != NO_ERROR) {
542 ALOGE("setAutoLowLatencyMode failed to transact: %d", result);
543 return;
544 }
545 }
546
547 virtual status_t getGameContentTypeSupport(const sp<IBinder>& display, bool* outSupport) const {
548 Parcel data, reply;
549 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
550 status_t result = data.writeStrongBinder(display);
551 if (result != NO_ERROR) {
552 ALOGE("getGameContentTypeSupport failed to writeStrongBinder: %d", result);
553 return result;
554 }
555 result = remote()->transact(BnSurfaceComposer::GET_GAME_CONTENT_TYPE_SUPPORT, data, &reply);
556 if (result != NO_ERROR) {
557 ALOGE("getGameContentTypeSupport failed to transact: %d", result);
558 return result;
559 }
560 return reply.readBool(outSupport);
561 }
562
563 virtual void setGameContentType(const sp<IBinder>& display, bool on) {
564 Parcel data, reply;
565 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
566 if (result != NO_ERROR) {
567 ALOGE("setGameContentType failed to writeInterfaceToken: %d", result);
568 return;
569 }
570 result = data.writeStrongBinder(display);
571 if (result != NO_ERROR) {
572 ALOGE("setGameContentType failed to writeStrongBinder: %d", result);
573 return;
574 }
575 result = data.writeBool(on);
576 if (result != NO_ERROR) {
577 ALOGE("setGameContentType failed to writeBool: %d", result);
578 return;
579 }
580 result = remote()->transact(BnSurfaceComposer::SET_GAME_CONTENT_TYPE, data, &reply);
581 if (result != NO_ERROR) {
582 ALOGE("setGameContentType failed to transact: %d", result);
583 }
584 }
585
Svetoslavd85084b2014-03-20 10:28:31 -0700586 virtual status_t clearAnimationFrameStats() {
587 Parcel data, reply;
Ana Krulec2d41e422018-07-26 12:07:43 -0700588 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
589 if (result != NO_ERROR) {
590 ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result);
591 return result;
592 }
593 result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply);
594 if (result != NO_ERROR) {
595 ALOGE("clearAnimationFrameStats failed to transact: %d", result);
596 return result;
597 }
Svetoslavd85084b2014-03-20 10:28:31 -0700598 return reply.readInt32();
599 }
600
601 virtual status_t getAnimationFrameStats(FrameStats* outStats) const {
602 Parcel data, reply;
603 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
604 remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply);
605 reply.read(*outStats);
606 return reply.readInt32();
607 }
Dan Stozac4f471e2016-03-24 09:31:08 -0700608
609 virtual status_t getHdrCapabilities(const sp<IBinder>& display,
610 HdrCapabilities* outCapabilities) const {
611 Parcel data, reply;
612 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
613 status_t result = data.writeStrongBinder(display);
614 if (result != NO_ERROR) {
615 ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result);
616 return result;
617 }
618 result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES,
619 data, &reply);
620 if (result != NO_ERROR) {
621 ALOGE("getHdrCapabilities failed to transact: %d", result);
622 return result;
623 }
624 result = reply.readInt32();
625 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -0800626 result = reply.read(*outCapabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -0700627 }
628 return result;
629 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700630
631 virtual status_t enableVSyncInjections(bool enable) {
632 Parcel data, reply;
633 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
634 if (result != NO_ERROR) {
635 ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result);
636 return result;
637 }
638 result = data.writeBool(enable);
639 if (result != NO_ERROR) {
640 ALOGE("enableVSyncInjections failed to writeBool: %d", result);
641 return result;
642 }
Steven Moreland366eb422019-04-01 19:22:32 -0700643 result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS, data, &reply,
644 IBinder::FLAG_ONEWAY);
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700645 if (result != NO_ERROR) {
646 ALOGE("enableVSyncInjections failed to transact: %d", result);
647 return result;
648 }
649 return result;
650 }
651
652 virtual status_t injectVSync(nsecs_t when) {
653 Parcel data, reply;
654 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
655 if (result != NO_ERROR) {
656 ALOGE("injectVSync failed to writeInterfaceToken: %d", result);
657 return result;
658 }
659 result = data.writeInt64(when);
660 if (result != NO_ERROR) {
661 ALOGE("injectVSync failed to writeInt64: %d", result);
662 return result;
663 }
Steven Moreland366eb422019-04-01 19:22:32 -0700664 result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply,
665 IBinder::FLAG_ONEWAY);
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -0700666 if (result != NO_ERROR) {
667 ALOGE("injectVSync failed to transact: %d", result);
668 return result;
669 }
670 return result;
671 }
672
Vishnu Nair43bccf82020-06-05 10:53:37 -0700673 virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) {
Kalle Raitaa099a242017-01-11 11:17:29 -0800674 if (!outLayers) {
675 return UNEXPECTED_NULL;
676 }
677
678 Parcel data, reply;
679
680 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
681 if (err != NO_ERROR) {
682 return err;
683 }
684
685 err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply);
686 if (err != NO_ERROR) {
687 return err;
688 }
689
690 int32_t result = 0;
691 err = reply.readInt32(&result);
692 if (err != NO_ERROR) {
693 return err;
694 }
695 if (result != NO_ERROR) {
696 return result;
697 }
698
699 outLayers->clear();
700 return reply.readParcelableVector(outLayers);
701 }
Peiyong Lin0256f722018-08-31 15:45:10 -0700702
Peiyong Linc6780972018-10-28 15:24:08 -0700703 virtual status_t getCompositionPreference(ui::Dataspace* defaultDataspace,
704 ui::PixelFormat* defaultPixelFormat,
705 ui::Dataspace* wideColorGamutDataspace,
706 ui::PixelFormat* wideColorGamutPixelFormat) const {
Peiyong Lin0256f722018-08-31 15:45:10 -0700707 Parcel data, reply;
708 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
709 if (error != NO_ERROR) {
710 return error;
711 }
712 error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply);
713 if (error != NO_ERROR) {
714 return error;
715 }
716 error = static_cast<status_t>(reply.readInt32());
717 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -0700718 *defaultDataspace = static_cast<ui::Dataspace>(reply.readInt32());
719 *defaultPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
720 *wideColorGamutDataspace = static_cast<ui::Dataspace>(reply.readInt32());
721 *wideColorGamutPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
Peiyong Lin0256f722018-08-31 15:45:10 -0700722 }
723 return error;
724 }
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700725
Ady Abraham37965d42018-11-01 13:43:32 -0700726 virtual status_t getColorManagement(bool* outGetColorManagement) const {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700727 Parcel data, reply;
728 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Ady Abraham37965d42018-11-01 13:43:32 -0700729 remote()->transact(BnSurfaceComposer::GET_COLOR_MANAGEMENT, data, &reply);
730 bool result;
731 status_t err = reply.readBool(&result);
732 if (err == NO_ERROR) {
733 *outGetColorManagement = result;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700734 }
Ady Abraham37965d42018-11-01 13:43:32 -0700735 return err;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -0700736 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -0700737
738 virtual status_t getDisplayedContentSamplingAttributes(const sp<IBinder>& display,
739 ui::PixelFormat* outFormat,
740 ui::Dataspace* outDataspace,
741 uint8_t* outComponentMask) const {
742 if (!outFormat || !outDataspace || !outComponentMask) return BAD_VALUE;
743 Parcel data, reply;
744 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
745 data.writeStrongBinder(display);
746
747 status_t error =
748 remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES,
749 data, &reply);
750 if (error != NO_ERROR) {
751 return error;
752 }
753
754 uint32_t value = 0;
755 error = reply.readUint32(&value);
756 if (error != NO_ERROR) {
757 return error;
758 }
759 *outFormat = static_cast<ui::PixelFormat>(value);
760
761 error = reply.readUint32(&value);
762 if (error != NO_ERROR) {
763 return error;
764 }
765 *outDataspace = static_cast<ui::Dataspace>(value);
766
767 error = reply.readUint32(&value);
768 if (error != NO_ERROR) {
769 return error;
770 }
771 *outComponentMask = static_cast<uint8_t>(value);
772 return error;
773 }
Kevin DuBois74e53772018-11-19 10:52:38 -0800774
775 virtual status_t setDisplayContentSamplingEnabled(const sp<IBinder>& display, bool enable,
Dominik Laskowski470df5f2020-04-02 22:27:42 -0700776 uint8_t componentMask, uint64_t maxFrames) {
Kevin DuBois74e53772018-11-19 10:52:38 -0800777 Parcel data, reply;
778 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
779 data.writeStrongBinder(display);
780 data.writeBool(enable);
781 data.writeByte(static_cast<int8_t>(componentMask));
782 data.writeUint64(maxFrames);
783 status_t result =
784 remote()->transact(BnSurfaceComposer::SET_DISPLAY_CONTENT_SAMPLING_ENABLED, data,
785 &reply);
786 return result;
787 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700788
789 virtual status_t getDisplayedContentSample(const sp<IBinder>& display, uint64_t maxFrames,
790 uint64_t timestamp,
791 DisplayedFrameStats* outStats) const {
792 if (!outStats) return BAD_VALUE;
793
794 Parcel data, reply;
795 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
796 data.writeStrongBinder(display);
797 data.writeUint64(maxFrames);
798 data.writeUint64(timestamp);
799
800 status_t result =
801 remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLE, data, &reply);
802
803 if (result != NO_ERROR) {
804 return result;
805 }
806
807 result = reply.readUint64(&outStats->numFrames);
808 if (result != NO_ERROR) {
809 return result;
810 }
811
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800812 result = reply.readUint64Vector(&outStats->component_0_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700813 if (result != NO_ERROR) {
814 return result;
815 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800816 result = reply.readUint64Vector(&outStats->component_1_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700817 if (result != NO_ERROR) {
818 return result;
819 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800820 result = reply.readUint64Vector(&outStats->component_2_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700821 if (result != NO_ERROR) {
822 return result;
823 }
Kevin DuBois1d4c6a62018-12-12 13:59:46 -0800824 result = reply.readUint64Vector(&outStats->component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700825 return result;
826 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800827
828 virtual status_t getProtectedContentSupport(bool* outSupported) const {
829 Parcel data, reply;
830 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Peiyong Linb6888fa2019-01-28 13:20:58 -0800831 status_t error =
832 remote()->transact(BnSurfaceComposer::GET_PROTECTED_CONTENT_SUPPORT, data, &reply);
833 if (error != NO_ERROR) {
834 return error;
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800835 }
Peiyong Linb6888fa2019-01-28 13:20:58 -0800836 error = reply.readBool(outSupported);
837 return error;
Peiyong Lin3c2791e2019-01-14 17:05:18 -0800838 }
Marissa Wallebc2c052019-01-16 19:16:55 -0800839
Peiyong Lin4f3fddf2019-01-24 17:21:24 -0800840 virtual status_t isWideColorDisplay(const sp<IBinder>& token,
841 bool* outIsWideColorDisplay) const {
842 Parcel data, reply;
843 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
844 if (error != NO_ERROR) {
845 return error;
846 }
847 error = data.writeStrongBinder(token);
848 if (error != NO_ERROR) {
849 return error;
850 }
851
852 error = remote()->transact(BnSurfaceComposer::IS_WIDE_COLOR_DISPLAY, data, &reply);
853 if (error != NO_ERROR) {
854 return error;
855 }
856 error = reply.readBool(outIsWideColorDisplay);
857 return error;
858 }
Dan Stoza84ab9372018-12-17 15:27:57 -0800859
860 virtual status_t addRegionSamplingListener(const Rect& samplingArea,
861 const sp<IBinder>& stopLayerHandle,
862 const sp<IRegionSamplingListener>& listener) {
863 Parcel data, reply;
864 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
865 if (error != NO_ERROR) {
866 ALOGE("addRegionSamplingListener: Failed to write interface token");
867 return error;
868 }
869 error = data.write(samplingArea);
870 if (error != NO_ERROR) {
871 ALOGE("addRegionSamplingListener: Failed to write sampling area");
872 return error;
873 }
874 error = data.writeStrongBinder(stopLayerHandle);
875 if (error != NO_ERROR) {
876 ALOGE("addRegionSamplingListener: Failed to write stop layer handle");
877 return error;
878 }
879 error = data.writeStrongBinder(IInterface::asBinder(listener));
880 if (error != NO_ERROR) {
881 ALOGE("addRegionSamplingListener: Failed to write listener");
882 return error;
883 }
884 error = remote()->transact(BnSurfaceComposer::ADD_REGION_SAMPLING_LISTENER, data, &reply);
885 if (error != NO_ERROR) {
886 ALOGE("addRegionSamplingListener: Failed to transact");
887 }
888 return error;
889 }
890
891 virtual status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) {
892 Parcel data, reply;
893 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
894 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800895 ALOGE("removeRegionSamplingListener: Failed to write interface token");
Dan Stoza84ab9372018-12-17 15:27:57 -0800896 return error;
897 }
898 error = data.writeStrongBinder(IInterface::asBinder(listener));
899 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800900 ALOGE("removeRegionSamplingListener: Failed to write listener");
Dan Stoza84ab9372018-12-17 15:27:57 -0800901 return error;
902 }
903 error = remote()->transact(BnSurfaceComposer::REMOVE_REGION_SAMPLING_LISTENER, data,
904 &reply);
905 if (error != NO_ERROR) {
tangrobinaf45f012019-02-26 18:10:10 +0800906 ALOGE("removeRegionSamplingListener: Failed to transact");
Dan Stoza84ab9372018-12-17 15:27:57 -0800907 }
908 return error;
909 }
Ady Abraham838de062019-02-04 10:24:03 -0800910
Ana Krulec0782b882019-10-15 17:34:54 -0700911 virtual status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
Steven Thomasf734df42020-04-13 21:09:28 -0700912 int32_t defaultConfig,
913 float primaryRefreshRateMin,
914 float primaryRefreshRateMax,
915 float appRequestRefreshRateMin,
916 float appRequestRefreshRateMax) {
Ana Krulec0782b882019-10-15 17:34:54 -0700917 Parcel data, reply;
918 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
919 if (result != NO_ERROR) {
920 ALOGE("setDesiredDisplayConfigSpecs: failed to writeInterfaceToken: %d", result);
921 return result;
922 }
923 result = data.writeStrongBinder(displayToken);
924 if (result != NO_ERROR) {
925 ALOGE("setDesiredDisplayConfigSpecs: failed to write display token: %d", result);
926 return result;
927 }
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100928 result = data.writeInt32(defaultConfig);
Ana Krulec0782b882019-10-15 17:34:54 -0700929 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100930 ALOGE("setDesiredDisplayConfigSpecs failed to write defaultConfig: %d", result);
Ana Krulec0782b882019-10-15 17:34:54 -0700931 return result;
932 }
Steven Thomasf734df42020-04-13 21:09:28 -0700933 result = data.writeFloat(primaryRefreshRateMin);
Ana Krulec0782b882019-10-15 17:34:54 -0700934 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -0700935 ALOGE("setDesiredDisplayConfigSpecs failed to write primaryRefreshRateMin: %d", result);
Ana Krulec0782b882019-10-15 17:34:54 -0700936 return result;
937 }
Steven Thomasf734df42020-04-13 21:09:28 -0700938 result = data.writeFloat(primaryRefreshRateMax);
Ana Krulec0782b882019-10-15 17:34:54 -0700939 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -0700940 ALOGE("setDesiredDisplayConfigSpecs failed to write primaryRefreshRateMax: %d", result);
941 return result;
942 }
943 result = data.writeFloat(appRequestRefreshRateMin);
944 if (result != NO_ERROR) {
945 ALOGE("setDesiredDisplayConfigSpecs failed to write appRequestRefreshRateMin: %d",
946 result);
947 return result;
948 }
949 result = data.writeFloat(appRequestRefreshRateMax);
950 if (result != NO_ERROR) {
951 ALOGE("setDesiredDisplayConfigSpecs failed to write appRequestRefreshRateMax: %d",
952 result);
Ana Krulec0782b882019-10-15 17:34:54 -0700953 return result;
954 }
955
956 result = remote()->transact(BnSurfaceComposer::SET_DESIRED_DISPLAY_CONFIG_SPECS, data,
957 &reply);
958 if (result != NO_ERROR) {
959 ALOGE("setDesiredDisplayConfigSpecs failed to transact: %d", result);
960 return result;
961 }
962 return reply.readInt32();
963 }
964
Ana Krulec234bb162019-11-10 22:55:55 +0100965 virtual status_t getDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100966 int32_t* outDefaultConfig,
Steven Thomasf734df42020-04-13 21:09:28 -0700967 float* outPrimaryRefreshRateMin,
968 float* outPrimaryRefreshRateMax,
969 float* outAppRequestRefreshRateMin,
970 float* outAppRequestRefreshRateMax) {
971 if (!outDefaultConfig || !outPrimaryRefreshRateMin || !outPrimaryRefreshRateMax ||
972 !outAppRequestRefreshRateMin || !outAppRequestRefreshRateMax) {
973 return BAD_VALUE;
974 }
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800975 Parcel data, reply;
976 status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
977 if (result != NO_ERROR) {
Ana Krulec234bb162019-11-10 22:55:55 +0100978 ALOGE("getDesiredDisplayConfigSpecs failed to writeInterfaceToken: %d", result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800979 return result;
980 }
981 result = data.writeStrongBinder(displayToken);
982 if (result != NO_ERROR) {
Ana Krulec234bb162019-11-10 22:55:55 +0100983 ALOGE("getDesiredDisplayConfigSpecs failed to writeStrongBinder: %d", result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800984 return result;
985 }
Ana Krulec234bb162019-11-10 22:55:55 +0100986 result = remote()->transact(BnSurfaceComposer::GET_DESIRED_DISPLAY_CONFIG_SPECS, data,
987 &reply);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800988 if (result != NO_ERROR) {
Ana Krulec234bb162019-11-10 22:55:55 +0100989 ALOGE("getDesiredDisplayConfigSpecs failed to transact: %d", result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800990 return result;
991 }
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100992 result = reply.readInt32(outDefaultConfig);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -0800993 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100994 ALOGE("getDesiredDisplayConfigSpecs failed to read defaultConfig: %d", result);
Ana Krulec234bb162019-11-10 22:55:55 +0100995 return result;
996 }
Steven Thomasf734df42020-04-13 21:09:28 -0700997 result = reply.readFloat(outPrimaryRefreshRateMin);
Ana Krulec234bb162019-11-10 22:55:55 +0100998 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -0700999 ALOGE("getDesiredDisplayConfigSpecs failed to read primaryRefreshRateMin: %d", result);
Ana Krulec234bb162019-11-10 22:55:55 +01001000 return result;
1001 }
Steven Thomasf734df42020-04-13 21:09:28 -07001002 result = reply.readFloat(outPrimaryRefreshRateMax);
Ana Krulec234bb162019-11-10 22:55:55 +01001003 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001004 ALOGE("getDesiredDisplayConfigSpecs failed to read primaryRefreshRateMax: %d", result);
1005 return result;
1006 }
1007 result = reply.readFloat(outAppRequestRefreshRateMin);
1008 if (result != NO_ERROR) {
1009 ALOGE("getDesiredDisplayConfigSpecs failed to read appRequestRefreshRateMin: %d",
1010 result);
1011 return result;
1012 }
1013 result = reply.readFloat(outAppRequestRefreshRateMax);
1014 if (result != NO_ERROR) {
1015 ALOGE("getDesiredDisplayConfigSpecs failed to read appRequestRefreshRateMax: %d",
1016 result);
Ady Abrahamd9b3ea62019-02-26 14:08:03 -08001017 return result;
1018 }
1019 return reply.readInt32();
1020 }
Dan Gittik57e63c52019-01-18 16:37:54 +00001021
1022 virtual status_t getDisplayBrightnessSupport(const sp<IBinder>& displayToken,
1023 bool* outSupport) const {
1024 Parcel data, reply;
1025 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1026 if (error != NO_ERROR) {
1027 ALOGE("getDisplayBrightnessSupport: failed to write interface token: %d", error);
1028 return error;
1029 }
1030 error = data.writeStrongBinder(displayToken);
1031 if (error != NO_ERROR) {
1032 ALOGE("getDisplayBrightnessSupport: failed to write display token: %d", error);
1033 return error;
1034 }
1035 error = remote()->transact(BnSurfaceComposer::GET_DISPLAY_BRIGHTNESS_SUPPORT, data, &reply);
1036 if (error != NO_ERROR) {
1037 ALOGE("getDisplayBrightnessSupport: failed to transact: %d", error);
1038 return error;
1039 }
1040 bool support;
1041 error = reply.readBool(&support);
1042 if (error != NO_ERROR) {
1043 ALOGE("getDisplayBrightnessSupport: failed to read support: %d", error);
1044 return error;
1045 }
1046 *outSupport = support;
1047 return NO_ERROR;
1048 }
1049
Dominik Laskowski470df5f2020-04-02 22:27:42 -07001050 virtual status_t setDisplayBrightness(const sp<IBinder>& displayToken, float brightness) {
Dan Gittik57e63c52019-01-18 16:37:54 +00001051 Parcel data, reply;
1052 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1053 if (error != NO_ERROR) {
1054 ALOGE("setDisplayBrightness: failed to write interface token: %d", error);
1055 return error;
1056 }
1057 error = data.writeStrongBinder(displayToken);
1058 if (error != NO_ERROR) {
1059 ALOGE("setDisplayBrightness: failed to write display token: %d", error);
1060 return error;
1061 }
1062 error = data.writeFloat(brightness);
1063 if (error != NO_ERROR) {
1064 ALOGE("setDisplayBrightness: failed to write brightness: %d", error);
1065 return error;
1066 }
1067 error = remote()->transact(BnSurfaceComposer::SET_DISPLAY_BRIGHTNESS, data, &reply);
1068 if (error != NO_ERROR) {
1069 ALOGE("setDisplayBrightness: failed to transact: %d", error);
1070 return error;
1071 }
1072 return NO_ERROR;
1073 }
Ady Abraham8532d012019-05-08 14:50:56 -07001074
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001075 virtual status_t notifyPowerBoost(int32_t boostId) {
Ady Abraham8532d012019-05-08 14:50:56 -07001076 Parcel data, reply;
1077 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1078 if (error != NO_ERROR) {
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001079 ALOGE("notifyPowerBoost: failed to write interface token: %d", error);
Ady Abraham8532d012019-05-08 14:50:56 -07001080 return error;
1081 }
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001082 error = data.writeInt32(boostId);
Ady Abraham8532d012019-05-08 14:50:56 -07001083 if (error != NO_ERROR) {
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001084 ALOGE("notifyPowerBoost: failed to write boostId: %d", error);
Ady Abraham8532d012019-05-08 14:50:56 -07001085 return error;
1086 }
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001087 error = remote()->transact(BnSurfaceComposer::NOTIFY_POWER_BOOST, data, &reply,
Ady Abraham8532d012019-05-08 14:50:56 -07001088 IBinder::FLAG_ONEWAY);
1089 if (error != NO_ERROR) {
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001090 ALOGE("notifyPowerBoost: failed to transact: %d", error);
Ady Abraham8532d012019-05-08 14:50:56 -07001091 return error;
1092 }
1093 return NO_ERROR;
1094 }
Vishnu Nairb13bb952019-11-15 10:24:08 -08001095
1096 virtual status_t setGlobalShadowSettings(const half4& ambientColor, const half4& spotColor,
1097 float lightPosY, float lightPosZ, float lightRadius) {
1098 Parcel data, reply;
1099 status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1100 if (error != NO_ERROR) {
1101 ALOGE("setGlobalShadowSettings: failed to write interface token: %d", error);
1102 return error;
1103 }
1104
1105 std::vector<float> shadowConfig = {ambientColor.r, ambientColor.g, ambientColor.b,
1106 ambientColor.a, spotColor.r, spotColor.g,
1107 spotColor.b, spotColor.a, lightPosY,
1108 lightPosZ, lightRadius};
1109
1110 error = data.writeFloatVector(shadowConfig);
1111 if (error != NO_ERROR) {
1112 ALOGE("setGlobalShadowSettings: failed to write shadowConfig: %d", error);
1113 return error;
1114 }
1115
1116 error = remote()->transact(BnSurfaceComposer::SET_GLOBAL_SHADOW_SETTINGS, data, &reply,
1117 IBinder::FLAG_ONEWAY);
1118 if (error != NO_ERROR) {
1119 ALOGE("setGlobalShadowSettings: failed to transact: %d", error);
1120 return error;
1121 }
1122 return NO_ERROR;
1123 }
Steven Thomas62a4cf82020-01-31 12:04:03 -08001124
1125 virtual status_t setFrameRate(const sp<IGraphicBufferProducer>& surface, float frameRate,
1126 int8_t compatibility) {
1127 Parcel data, reply;
1128 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1129 if (err != NO_ERROR) {
1130 ALOGE("setFrameRate: failed writing interface token: %s (%d)", strerror(-err), -err);
1131 return err;
1132 }
1133
1134 err = data.writeStrongBinder(IInterface::asBinder(surface));
1135 if (err != NO_ERROR) {
1136 ALOGE("setFrameRate: failed writing strong binder: %s (%d)", strerror(-err), -err);
1137 return err;
1138 }
1139
1140 err = data.writeFloat(frameRate);
1141 if (err != NO_ERROR) {
1142 ALOGE("setFrameRate: failed writing float: %s (%d)", strerror(-err), -err);
1143 return err;
1144 }
1145
1146 err = data.writeByte(compatibility);
1147 if (err != NO_ERROR) {
1148 ALOGE("setFrameRate: failed writing byte: %s (%d)", strerror(-err), -err);
1149 return err;
1150 }
1151
Ady Abraham60e42ea2020-03-09 19:17:31 -07001152 err = remote()->transact(BnSurfaceComposer::SET_FRAME_RATE, data, &reply);
Steven Thomas62a4cf82020-01-31 12:04:03 -08001153 if (err != NO_ERROR) {
1154 ALOGE("setFrameRate: failed to transact: %s (%d)", strerror(-err), err);
1155 return err;
1156 }
Steven Thomasd4071902020-03-24 16:02:53 -07001157
1158 return reply.readInt32();
1159 }
1160
1161 virtual status_t acquireFrameRateFlexibilityToken(sp<IBinder>* outToken) {
1162 if (!outToken) return BAD_VALUE;
1163
1164 Parcel data, reply;
1165 status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
1166 if (err != NO_ERROR) {
1167 ALOGE("acquireFrameRateFlexibilityToken: failed writing interface token: %s (%d)",
1168 strerror(-err), -err);
1169 return err;
1170 }
1171
1172 err = remote()->transact(BnSurfaceComposer::ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN, data,
1173 &reply);
1174 if (err != NO_ERROR) {
1175 ALOGE("acquireFrameRateFlexibilityToken: failed to transact: %s (%d)", strerror(-err),
1176 err);
1177 return err;
1178 }
1179
1180 err = reply.readInt32();
1181 if (err != NO_ERROR) {
1182 ALOGE("acquireFrameRateFlexibilityToken: call failed: %s (%d)", strerror(-err), err);
1183 return err;
1184 }
1185
1186 err = reply.readStrongBinder(outToken);
1187 if (err != NO_ERROR) {
1188 ALOGE("acquireFrameRateFlexibilityToken: failed reading binder token: %s (%d)",
1189 strerror(-err), err);
1190 return err;
1191 }
1192
Steven Thomas62a4cf82020-01-31 12:04:03 -08001193 return NO_ERROR;
1194 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001195};
1196
Dan Stozad723bd72014-11-18 10:24:03 -08001197// Out-of-line virtual method definition to trigger vtable emission in this
1198// translation unit (see clang warning -Wweak-vtables)
1199BpSurfaceComposer::~BpSurfaceComposer() {}
1200
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001201IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
1202
1203// ----------------------------------------------------------------------
1204
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001205status_t BnSurfaceComposer::onTransact(
1206 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
1207{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001208 switch(code) {
1209 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001210 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -08001211 sp<IBinder> b = IInterface::asBinder(createConnection());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001212 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -07001213 return NO_ERROR;
1214 }
Mathias Agopian698c0872011-06-28 19:09:31 -07001215 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001216 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -08001217
1218 size_t count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -07001219 if (count > data.dataSize()) {
1220 return BAD_VALUE;
1221 }
Mathias Agopian698c0872011-06-28 19:09:31 -07001222 Vector<ComposerState> state;
1223 state.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -08001224 for (size_t i = 0; i < count; i++) {
Marissa Wallc837b5e2018-10-12 10:04:44 -07001225 ComposerState s;
Michael Lentine8afa1c42014-10-31 11:10:13 -07001226 if (s.read(data) == BAD_VALUE) {
1227 return BAD_VALUE;
1228 }
Mathias Agopian698c0872011-06-28 19:09:31 -07001229 state.add(s);
1230 }
Dan Stozad723bd72014-11-18 10:24:03 -08001231
1232 count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -07001233 if (count > data.dataSize()) {
1234 return BAD_VALUE;
1235 }
Mathias Agopian8b33f032012-07-24 20:43:54 -07001236 DisplayState d;
1237 Vector<DisplayState> displays;
1238 displays.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -08001239 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -07001240 if (d.read(data) == BAD_VALUE) {
1241 return BAD_VALUE;
1242 }
Mathias Agopian8b33f032012-07-24 20:43:54 -07001243 displays.add(d);
1244 }
Dan Stozad723bd72014-11-18 10:24:03 -08001245
1246 uint32_t stateFlags = data.readUint32();
Marissa Wall713b63f2018-10-17 15:42:43 -07001247 sp<IBinder> applyToken = data.readStrongBinder();
chaviw273171b2018-12-26 11:46:30 -08001248 InputWindowCommands inputWindowCommands;
1249 inputWindowCommands.read(data);
Marissa Wall17b4e452018-12-26 16:32:34 -08001250
1251 int64_t desiredPresentTime = data.readInt64();
Marissa Wall78b72202019-03-15 14:58:34 -07001252
Marissa Wall947d34e2019-03-29 14:03:53 -07001253 client_cache_t uncachedBuffer;
Steven Moreland9d4ce9b2019-07-17 15:23:38 -07001254 uncachedBuffer.token = data.readStrongBinder();
Marissa Wall947d34e2019-03-29 14:03:53 -07001255 uncachedBuffer.id = data.readUint64();
Marissa Wall78b72202019-03-15 14:58:34 -07001256
Valerie Hau9dab9732019-08-20 09:29:25 -07001257 bool hasListenerCallbacks = data.readBool();
1258
Marissa Wall3dad52d2019-03-22 14:03:19 -07001259 std::vector<ListenerCallbacks> listenerCallbacks;
1260 int32_t listenersSize = data.readInt32();
1261 for (int32_t i = 0; i < listenersSize; i++) {
Valerie Hau5de3ad22019-08-20 07:47:43 -07001262 auto listener = data.readStrongBinder();
Marissa Wall3dad52d2019-03-22 14:03:19 -07001263 std::vector<CallbackId> callbackIds;
1264 data.readInt64Vector(&callbackIds);
1265 listenerCallbacks.emplace_back(listener, callbackIds);
1266 }
Marissa Wall17b4e452018-12-26 16:32:34 -08001267 setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands,
Valerie Hau9dab9732019-08-20 09:29:25 -07001268 desiredPresentTime, uncachedBuffer, hasListenerCallbacks,
1269 listenerCallbacks);
Jesse Hall6c913be2013-08-08 12:15:49 -07001270 return NO_ERROR;
1271 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001272 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -07001273 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001274 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -07001275 return NO_ERROR;
1276 }
chaviwd2432892020-07-24 17:42:39 -07001277 case CAPTURE_DISPLAY: {
Mathias Agopian2a9fc492013-03-01 13:42:57 -08001278 CHECK_INTERFACE(ISurfaceComposer, data, reply);
chaviwd2432892020-07-24 17:42:39 -07001279 DisplayCaptureArgs args;
1280 ScreenCaptureResults captureResults;
Dan Stozac7014012014-02-14 15:03:43 -08001281
chaviwd2432892020-07-24 17:42:39 -07001282 status_t res = args.read(data);
1283 if (res != NO_ERROR) {
1284 reply->writeInt32(res);
1285 return NO_ERROR;
1286 }
1287
1288 res = captureDisplay(args, captureResults);
Robert Carr108b2c72019-04-02 16:32:58 -07001289
Mathias Agopian2a9fc492013-03-01 13:42:57 -08001290 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +00001291 if (res == NO_ERROR) {
chaviwd2432892020-07-24 17:42:39 -07001292 captureResults.write(*reply);
Chavi Weingarten40482ff2017-11-30 01:51:40 +00001293 }
Jesse Hall6c913be2013-08-08 12:15:49 -07001294 return NO_ERROR;
1295 }
chaviwd2432892020-07-24 17:42:39 -07001296 case CAPTURE_DISPLAY_BY_ID: {
chaviw93df2ea2019-04-30 16:45:12 -07001297 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1298 uint64_t displayOrLayerStack = data.readUint64();
chaviwd2432892020-07-24 17:42:39 -07001299 ScreenCaptureResults captureResults;
1300 status_t res = captureDisplay(displayOrLayerStack, captureResults);
chaviw93df2ea2019-04-30 16:45:12 -07001301 reply->writeInt32(res);
1302 if (res == NO_ERROR) {
chaviwd2432892020-07-24 17:42:39 -07001303 captureResults.write(*reply);
chaviw93df2ea2019-04-30 16:45:12 -07001304 }
1305 return NO_ERROR;
1306 }
chaviwa76b2712017-09-20 12:02:26 -07001307 case CAPTURE_LAYERS: {
1308 CHECK_INTERFACE(ISurfaceComposer, data, reply);
chaviw3efadb12020-07-27 10:07:15 -07001309 LayerCaptureArgs args;
1310 ScreenCaptureResults captureResults;
Robert Carr866455f2019-04-02 16:28:26 -07001311
chaviw3efadb12020-07-27 10:07:15 -07001312 status_t res = args.read(data);
1313 if (res != NO_ERROR) {
1314 reply->writeInt32(res);
1315 return NO_ERROR;
Robert Carr866455f2019-04-02 16:28:26 -07001316 }
1317
chaviw3efadb12020-07-27 10:07:15 -07001318 res = captureLayers(args, captureResults);
chaviwa76b2712017-09-20 12:02:26 -07001319 reply->writeInt32(res);
Chavi Weingarten40482ff2017-11-30 01:51:40 +00001320 if (res == NO_ERROR) {
chaviw3efadb12020-07-27 10:07:15 -07001321 captureResults.write(*reply);
Chavi Weingarten40482ff2017-11-30 01:51:40 +00001322 }
chaviwa76b2712017-09-20 12:02:26 -07001323 return NO_ERROR;
1324 }
Jamie Gennis134f0422011-03-08 12:18:54 -08001325 case AUTHENTICATE_SURFACE: {
1326 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -08001327 sp<IGraphicBufferProducer> bufferProducer =
1328 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
1329 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -08001330 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -07001331 return NO_ERROR;
1332 }
Brian Anderson6b376712017-04-04 10:51:39 -07001333 case GET_SUPPORTED_FRAME_TIMESTAMPS: {
1334 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1335 std::vector<FrameEvent> supportedTimestamps;
1336 status_t result = getSupportedFrameTimestamps(&supportedTimestamps);
1337 status_t err = reply->writeInt32(result);
1338 if (err != NO_ERROR) {
1339 return err;
1340 }
1341 if (result != NO_ERROR) {
1342 return result;
1343 }
1344
1345 std::vector<int32_t> supported;
1346 supported.reserve(supportedTimestamps.size());
1347 for (FrameEvent s : supportedTimestamps) {
1348 supported.push_back(static_cast<int32_t>(s));
1349 }
1350 return reply->writeInt32Vector(supported);
1351 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001352 case CREATE_DISPLAY_EVENT_CONNECTION: {
1353 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Ady Abraham0f4a1b12019-06-04 16:04:04 -07001354 auto vsyncSource = static_cast<ISurfaceComposer::VsyncSource>(data.readInt32());
1355 auto configChanged = static_cast<ISurfaceComposer::ConfigChanged>(data.readInt32());
1356
1357 sp<IDisplayEventConnection> connection(
1358 createDisplayEventConnection(vsyncSource, configChanged));
Marco Nelissen2ea926b2014-11-14 08:01:01 -08001359 reply->writeStrongBinder(IInterface::asBinder(connection));
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001360 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001361 }
Mathias Agopiane57f2922012-08-09 16:29:12 -07001362 case CREATE_DISPLAY: {
1363 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden8dfa92f2012-09-17 18:27:17 -07001364 String8 displayName = data.readString8();
Jamie Gennisdd3cb842012-10-19 18:19:11 -07001365 bool secure = bool(data.readInt32());
1366 sp<IBinder> display(createDisplay(displayName, secure));
Mathias Agopiane57f2922012-08-09 16:29:12 -07001367 reply->writeStrongBinder(display);
1368 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001369 }
1370 case DESTROY_DISPLAY: {
1371 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1372 sp<IBinder> display = data.readStrongBinder();
1373 destroyDisplay(display);
1374 return NO_ERROR;
1375 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001376 case GET_PHYSICAL_DISPLAY_TOKEN: {
Mathias Agopiane57f2922012-08-09 16:29:12 -07001377 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001378 PhysicalDisplayId displayId = data.readUint64();
1379 sp<IBinder> display = getPhysicalDisplayToken(displayId);
Mathias Agopiane57f2922012-08-09 16:29:12 -07001380 reply->writeStrongBinder(display);
1381 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -07001382 }
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001383 case GET_DISPLAY_STATE: {
1384 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1385 ui::DisplayState state;
1386 const sp<IBinder> display = data.readStrongBinder();
1387 const status_t result = getDisplayState(display, &state);
1388 reply->writeInt32(result);
1389 if (result == NO_ERROR) {
1390 memcpy(reply->writeInplace(sizeof(ui::DisplayState)), &state,
1391 sizeof(ui::DisplayState));
1392 }
1393 return NO_ERROR;
1394 }
1395 case GET_DISPLAY_INFO: {
1396 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1397 DisplayInfo info;
1398 const sp<IBinder> display = data.readStrongBinder();
1399 const status_t result = getDisplayInfo(display, &info);
1400 reply->writeInt32(result);
Marin Shalamanov359a7e72020-02-17 17:03:07 +01001401 if (result != NO_ERROR) return result;
1402 return reply->write(info);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001403 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001404 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -07001405 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001406 Vector<DisplayConfig> configs;
1407 const sp<IBinder> display = data.readStrongBinder();
1408 const status_t result = getDisplayConfigs(display, &configs);
Dan Stoza7f7da322014-05-02 15:26:25 -07001409 reply->writeInt32(result);
1410 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -08001411 reply->writeUint32(static_cast<uint32_t>(configs.size()));
Dan Stoza7f7da322014-05-02 15:26:25 -07001412 for (size_t c = 0; c < configs.size(); ++c) {
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -08001413 memcpy(reply->writeInplace(sizeof(DisplayConfig)), &configs[c],
1414 sizeof(DisplayConfig));
Dan Stoza7f7da322014-05-02 15:26:25 -07001415 }
1416 }
1417 return NO_ERROR;
1418 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -07001419 case GET_DISPLAY_STATS: {
1420 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1421 DisplayStatInfo stats;
1422 sp<IBinder> display = data.readStrongBinder();
1423 status_t result = getDisplayStats(display, &stats);
1424 reply->writeInt32(result);
1425 if (result == NO_ERROR) {
1426 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
1427 &stats, sizeof(DisplayStatInfo));
1428 }
1429 return NO_ERROR;
1430 }
Dan Stoza7f7da322014-05-02 15:26:25 -07001431 case GET_ACTIVE_CONFIG: {
1432 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1433 sp<IBinder> display = data.readStrongBinder();
1434 int id = getActiveConfig(display);
1435 reply->writeInt32(id);
1436 return NO_ERROR;
1437 }
Michael Wright28f24d02016-07-12 13:30:53 -07001438 case GET_DISPLAY_COLOR_MODES: {
1439 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Lina52f0292018-03-14 17:26:31 -07001440 Vector<ColorMode> colorModes;
Michael Wright28f24d02016-07-12 13:30:53 -07001441 sp<IBinder> display = nullptr;
1442 status_t result = data.readStrongBinder(&display);
1443 if (result != NO_ERROR) {
1444 ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result);
1445 return result;
1446 }
1447 result = getDisplayColorModes(display, &colorModes);
1448 reply->writeInt32(result);
1449 if (result == NO_ERROR) {
1450 reply->writeUint32(static_cast<uint32_t>(colorModes.size()));
1451 for (size_t i = 0; i < colorModes.size(); ++i) {
Peiyong Lina52f0292018-03-14 17:26:31 -07001452 reply->writeInt32(static_cast<int32_t>(colorModes[i]));
Michael Wright28f24d02016-07-12 13:30:53 -07001453 }
1454 }
1455 return NO_ERROR;
1456 }
Daniel Solomon42d04562019-01-20 21:03:19 -08001457 case GET_DISPLAY_NATIVE_PRIMARIES: {
1458 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1459 ui::DisplayPrimaries primaries;
1460 sp<IBinder> display = nullptr;
1461
1462 status_t result = data.readStrongBinder(&display);
1463 if (result != NO_ERROR) {
1464 ALOGE("getDisplayNativePrimaries failed to readStrongBinder: %d", result);
1465 return result;
1466 }
1467
1468 result = getDisplayNativePrimaries(display, primaries);
1469 reply->writeInt32(result);
1470 if (result == NO_ERROR) {
1471 memcpy(reply->writeInplace(sizeof(ui::DisplayPrimaries)), &primaries,
1472 sizeof(ui::DisplayPrimaries));
1473 }
1474
1475 return NO_ERROR;
1476 }
Michael Wright28f24d02016-07-12 13:30:53 -07001477 case GET_ACTIVE_COLOR_MODE: {
1478 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1479 sp<IBinder> display = nullptr;
1480 status_t result = data.readStrongBinder(&display);
1481 if (result != NO_ERROR) {
1482 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1483 return result;
1484 }
Peiyong Lina52f0292018-03-14 17:26:31 -07001485 ColorMode colorMode = getActiveColorMode(display);
Michael Wright28f24d02016-07-12 13:30:53 -07001486 result = reply->writeInt32(static_cast<int32_t>(colorMode));
1487 return result;
1488 }
1489 case SET_ACTIVE_COLOR_MODE: {
1490 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1491 sp<IBinder> display = nullptr;
1492 status_t result = data.readStrongBinder(&display);
1493 if (result != NO_ERROR) {
1494 ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);
1495 return result;
1496 }
1497 int32_t colorModeInt = 0;
1498 result = data.readInt32(&colorModeInt);
1499 if (result != NO_ERROR) {
1500 ALOGE("setActiveColorMode failed to readInt32: %d", result);
1501 return result;
1502 }
1503 result = setActiveColorMode(display,
Peiyong Lina52f0292018-03-14 17:26:31 -07001504 static_cast<ColorMode>(colorModeInt));
Michael Wright28f24d02016-07-12 13:30:53 -07001505 result = reply->writeInt32(result);
1506 return result;
1507 }
Galia Peycheva5492cb52019-10-30 14:13:16 +01001508
1509 case GET_AUTO_LOW_LATENCY_MODE_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("getAutoLowLatencyModeSupport failed to readStrongBinder: %d", result);
1515 return result;
1516 }
1517 bool supported = false;
1518 result = getAutoLowLatencyModeSupport(display, &supported);
1519 if (result == NO_ERROR) {
1520 result = reply->writeBool(supported);
1521 }
1522 return result;
1523 }
1524
1525 case SET_AUTO_LOW_LATENCY_MODE: {
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("setAutoLowLatencyMode failed to readStrongBinder: %d", result);
1531 return result;
1532 }
1533 bool setAllm = false;
1534 result = data.readBool(&setAllm);
1535 if (result != NO_ERROR) {
1536 ALOGE("setAutoLowLatencyMode failed to readBool: %d", result);
1537 return result;
1538 }
1539 setAutoLowLatencyMode(display, setAllm);
1540 return result;
1541 }
1542
1543 case GET_GAME_CONTENT_TYPE_SUPPORT: {
1544 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1545 sp<IBinder> display = nullptr;
1546 status_t result = data.readStrongBinder(&display);
1547 if (result != NO_ERROR) {
1548 ALOGE("getGameContentTypeSupport failed to readStrongBinder: %d", result);
1549 return result;
1550 }
1551 bool supported = false;
1552 result = getGameContentTypeSupport(display, &supported);
1553 if (result == NO_ERROR) {
1554 result = reply->writeBool(supported);
1555 }
1556 return result;
1557 }
1558
1559 case SET_GAME_CONTENT_TYPE: {
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("setGameContentType failed to readStrongBinder: %d", result);
1565 return result;
1566 }
1567 bool setGameContentTypeOn = false;
1568 result = data.readBool(&setGameContentTypeOn);
1569 if (result != NO_ERROR) {
1570 ALOGE("setGameContentType failed to readBool: %d", result);
1571 return result;
1572 }
1573 setGameContentType(display, setGameContentTypeOn);
1574 return result;
1575 }
1576
Svetoslavd85084b2014-03-20 10:28:31 -07001577 case CLEAR_ANIMATION_FRAME_STATS: {
1578 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1579 status_t result = clearAnimationFrameStats();
1580 reply->writeInt32(result);
1581 return NO_ERROR;
1582 }
1583 case GET_ANIMATION_FRAME_STATS: {
1584 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1585 FrameStats stats;
1586 status_t result = getAnimationFrameStats(&stats);
1587 reply->write(stats);
1588 reply->writeInt32(result);
1589 return NO_ERROR;
1590 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -07001591 case SET_POWER_MODE: {
1592 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1593 sp<IBinder> display = data.readStrongBinder();
1594 int32_t mode = data.readInt32();
1595 setPowerMode(display, mode);
1596 return NO_ERROR;
1597 }
Dan Stozac4f471e2016-03-24 09:31:08 -07001598 case GET_HDR_CAPABILITIES: {
1599 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1600 sp<IBinder> display = nullptr;
1601 status_t result = data.readStrongBinder(&display);
1602 if (result != NO_ERROR) {
1603 ALOGE("getHdrCapabilities failed to readStrongBinder: %d",
1604 result);
1605 return result;
1606 }
1607 HdrCapabilities capabilities;
1608 result = getHdrCapabilities(display, &capabilities);
1609 reply->writeInt32(result);
1610 if (result == NO_ERROR) {
Mathias Agopiane1f5e6f2017-02-06 16:34:41 -08001611 reply->write(capabilities);
Dan Stozac4f471e2016-03-24 09:31:08 -07001612 }
1613 return NO_ERROR;
1614 }
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -07001615 case ENABLE_VSYNC_INJECTIONS: {
1616 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1617 bool enable = false;
1618 status_t result = data.readBool(&enable);
1619 if (result != NO_ERROR) {
1620 ALOGE("enableVSyncInjections failed to readBool: %d", result);
1621 return result;
1622 }
1623 return enableVSyncInjections(enable);
1624 }
1625 case INJECT_VSYNC: {
1626 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1627 int64_t when = 0;
1628 status_t result = data.readInt64(&when);
1629 if (result != NO_ERROR) {
1630 ALOGE("enableVSyncInjections failed to readInt64: %d", result);
1631 return result;
1632 }
1633 return injectVSync(when);
1634 }
Kalle Raitaa099a242017-01-11 11:17:29 -08001635 case GET_LAYER_DEBUG_INFO: {
1636 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1637 std::vector<LayerDebugInfo> outLayers;
1638 status_t result = getLayerDebugInfo(&outLayers);
1639 reply->writeInt32(result);
1640 if (result == NO_ERROR)
1641 {
1642 result = reply->writeParcelableVector(outLayers);
1643 }
1644 return result;
1645 }
Peiyong Lin0256f722018-08-31 15:45:10 -07001646 case GET_COMPOSITION_PREFERENCE: {
1647 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Peiyong Linc6780972018-10-28 15:24:08 -07001648 ui::Dataspace defaultDataspace;
1649 ui::PixelFormat defaultPixelFormat;
1650 ui::Dataspace wideColorGamutDataspace;
1651 ui::PixelFormat wideColorGamutPixelFormat;
1652 status_t error =
1653 getCompositionPreference(&defaultDataspace, &defaultPixelFormat,
1654 &wideColorGamutDataspace, &wideColorGamutPixelFormat);
Peiyong Lin0256f722018-08-31 15:45:10 -07001655 reply->writeInt32(error);
1656 if (error == NO_ERROR) {
Peiyong Linc6780972018-10-28 15:24:08 -07001657 reply->writeInt32(static_cast<int32_t>(defaultDataspace));
1658 reply->writeInt32(static_cast<int32_t>(defaultPixelFormat));
1659 reply->writeInt32(static_cast<int32_t>(wideColorGamutDataspace));
Peiyong Linaa3da6a2018-12-12 02:48:43 -08001660 reply->writeInt32(static_cast<int32_t>(wideColorGamutPixelFormat));
Peiyong Lin0256f722018-08-31 15:45:10 -07001661 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001662 return error;
Peiyong Lin0256f722018-08-31 15:45:10 -07001663 }
Ady Abraham37965d42018-11-01 13:43:32 -07001664 case GET_COLOR_MANAGEMENT: {
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001665 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Ady Abraham37965d42018-11-01 13:43:32 -07001666 bool result;
1667 status_t error = getColorManagement(&result);
1668 if (error == NO_ERROR) {
1669 reply->writeBool(result);
1670 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001671 return error;
Ady Abraham2a6ab2a2018-10-26 14:25:30 -07001672 }
Kevin DuBois9c0a1762018-10-16 13:32:31 -07001673 case GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: {
1674 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1675
1676 sp<IBinder> display = data.readStrongBinder();
1677 ui::PixelFormat format;
1678 ui::Dataspace dataspace;
1679 uint8_t component = 0;
1680 auto result =
1681 getDisplayedContentSamplingAttributes(display, &format, &dataspace, &component);
1682 if (result == NO_ERROR) {
1683 reply->writeUint32(static_cast<uint32_t>(format));
1684 reply->writeUint32(static_cast<uint32_t>(dataspace));
1685 reply->writeUint32(static_cast<uint32_t>(component));
1686 }
1687 return result;
1688 }
Kevin DuBois74e53772018-11-19 10:52:38 -08001689 case SET_DISPLAY_CONTENT_SAMPLING_ENABLED: {
1690 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1691
1692 sp<IBinder> display = nullptr;
1693 bool enable = false;
1694 int8_t componentMask = 0;
1695 uint64_t maxFrames = 0;
1696 status_t result = data.readStrongBinder(&display);
1697 if (result != NO_ERROR) {
1698 ALOGE("setDisplayContentSamplingEnabled failure in reading Display token: %d",
1699 result);
1700 return result;
1701 }
1702
1703 result = data.readBool(&enable);
1704 if (result != NO_ERROR) {
1705 ALOGE("setDisplayContentSamplingEnabled failure in reading enable: %d", result);
1706 return result;
1707 }
1708
1709 result = data.readByte(static_cast<int8_t*>(&componentMask));
1710 if (result != NO_ERROR) {
1711 ALOGE("setDisplayContentSamplingEnabled failure in reading component mask: %d",
1712 result);
1713 return result;
1714 }
1715
1716 result = data.readUint64(&maxFrames);
1717 if (result != NO_ERROR) {
1718 ALOGE("setDisplayContentSamplingEnabled failure in reading max frames: %d", result);
1719 return result;
1720 }
1721
1722 return setDisplayContentSamplingEnabled(display, enable,
1723 static_cast<uint8_t>(componentMask), maxFrames);
1724 }
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001725 case GET_DISPLAYED_CONTENT_SAMPLE: {
1726 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1727
1728 sp<IBinder> display = data.readStrongBinder();
1729 uint64_t maxFrames = 0;
1730 uint64_t timestamp = 0;
1731
1732 status_t result = data.readUint64(&maxFrames);
1733 if (result != NO_ERROR) {
1734 ALOGE("getDisplayedContentSample failure in reading max frames: %d", result);
1735 return result;
1736 }
1737
1738 result = data.readUint64(&timestamp);
1739 if (result != NO_ERROR) {
1740 ALOGE("getDisplayedContentSample failure in reading timestamp: %d", result);
1741 return result;
1742 }
1743
1744 DisplayedFrameStats stats;
1745 result = getDisplayedContentSample(display, maxFrames, timestamp, &stats);
1746 if (result == NO_ERROR) {
1747 reply->writeUint64(stats.numFrames);
Kevin DuBois1d4c6a62018-12-12 13:59:46 -08001748 reply->writeUint64Vector(stats.component_0_sample);
1749 reply->writeUint64Vector(stats.component_1_sample);
1750 reply->writeUint64Vector(stats.component_2_sample);
1751 reply->writeUint64Vector(stats.component_3_sample);
Kevin DuBois1d4249a2018-08-29 10:45:14 -07001752 }
1753 return result;
1754 }
Peiyong Lin3c2791e2019-01-14 17:05:18 -08001755 case GET_PROTECTED_CONTENT_SUPPORT: {
1756 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1757 bool result;
1758 status_t error = getProtectedContentSupport(&result);
1759 if (error == NO_ERROR) {
1760 reply->writeBool(result);
1761 }
1762 return error;
1763 }
Peiyong Lin4f3fddf2019-01-24 17:21:24 -08001764 case IS_WIDE_COLOR_DISPLAY: {
1765 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1766 sp<IBinder> display = nullptr;
1767 status_t error = data.readStrongBinder(&display);
1768 if (error != NO_ERROR) {
1769 return error;
1770 }
1771 bool result;
1772 error = isWideColorDisplay(display, &result);
1773 if (error == NO_ERROR) {
1774 reply->writeBool(result);
1775 }
1776 return error;
1777 }
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08001778 case GET_PHYSICAL_DISPLAY_IDS: {
1779 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1780 return reply->writeUint64Vector(getPhysicalDisplayIds());
1781 }
Dan Stoza84ab9372018-12-17 15:27:57 -08001782 case ADD_REGION_SAMPLING_LISTENER: {
1783 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1784 Rect samplingArea;
1785 status_t result = data.read(samplingArea);
1786 if (result != NO_ERROR) {
1787 ALOGE("addRegionSamplingListener: Failed to read sampling area");
1788 return result;
1789 }
1790 sp<IBinder> stopLayerHandle;
1791 result = data.readNullableStrongBinder(&stopLayerHandle);
1792 if (result != NO_ERROR) {
1793 ALOGE("addRegionSamplingListener: Failed to read stop layer handle");
1794 return result;
1795 }
1796 sp<IRegionSamplingListener> listener;
1797 result = data.readNullableStrongBinder(&listener);
1798 if (result != NO_ERROR) {
1799 ALOGE("addRegionSamplingListener: Failed to read listener");
1800 return result;
1801 }
1802 return addRegionSamplingListener(samplingArea, stopLayerHandle, listener);
1803 }
1804 case REMOVE_REGION_SAMPLING_LISTENER: {
1805 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1806 sp<IRegionSamplingListener> listener;
1807 status_t result = data.readNullableStrongBinder(&listener);
1808 if (result != NO_ERROR) {
1809 ALOGE("removeRegionSamplingListener: Failed to read listener");
1810 return result;
1811 }
1812 return removeRegionSamplingListener(listener);
1813 }
Ana Krulec0782b882019-10-15 17:34:54 -07001814 case SET_DESIRED_DISPLAY_CONFIG_SPECS: {
1815 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1816 sp<IBinder> displayToken = data.readStrongBinder();
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001817 int32_t defaultConfig;
1818 status_t result = data.readInt32(&defaultConfig);
Ana Krulec0782b882019-10-15 17:34:54 -07001819 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001820 ALOGE("setDesiredDisplayConfigSpecs: failed to read defaultConfig: %d", result);
Ana Krulec0782b882019-10-15 17:34:54 -07001821 return result;
1822 }
Steven Thomasf734df42020-04-13 21:09:28 -07001823 float primaryRefreshRateMin;
1824 result = data.readFloat(&primaryRefreshRateMin);
Ana Krulec0782b882019-10-15 17:34:54 -07001825 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001826 ALOGE("setDesiredDisplayConfigSpecs: failed to read primaryRefreshRateMin: %d",
1827 result);
Ana Krulec0782b882019-10-15 17:34:54 -07001828 return result;
1829 }
Steven Thomasf734df42020-04-13 21:09:28 -07001830 float primaryRefreshRateMax;
1831 result = data.readFloat(&primaryRefreshRateMax);
Ana Krulec0782b882019-10-15 17:34:54 -07001832 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001833 ALOGE("setDesiredDisplayConfigSpecs: failed to read primaryRefreshRateMax: %d",
1834 result);
Ana Krulec0782b882019-10-15 17:34:54 -07001835 return result;
1836 }
Steven Thomasf734df42020-04-13 21:09:28 -07001837 float appRequestRefreshRateMin;
1838 result = data.readFloat(&appRequestRefreshRateMin);
1839 if (result != NO_ERROR) {
1840 ALOGE("setDesiredDisplayConfigSpecs: failed to read appRequestRefreshRateMin: %d",
1841 result);
1842 return result;
1843 }
1844 float appRequestRefreshRateMax;
1845 result = data.readFloat(&appRequestRefreshRateMax);
1846 if (result != NO_ERROR) {
1847 ALOGE("setDesiredDisplayConfigSpecs: failed to read appRequestRefreshRateMax: %d",
1848 result);
1849 return result;
1850 }
1851 result =
1852 setDesiredDisplayConfigSpecs(displayToken, defaultConfig, primaryRefreshRateMin,
1853 primaryRefreshRateMax, appRequestRefreshRateMin,
1854 appRequestRefreshRateMax);
Ana Krulec0782b882019-10-15 17:34:54 -07001855 if (result != NO_ERROR) {
1856 ALOGE("setDesiredDisplayConfigSpecs: failed to call setDesiredDisplayConfigSpecs: "
1857 "%d",
1858 result);
1859 return result;
1860 }
1861 reply->writeInt32(result);
1862 return result;
1863 }
Ana Krulec234bb162019-11-10 22:55:55 +01001864 case GET_DESIRED_DISPLAY_CONFIG_SPECS: {
1865 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1866 sp<IBinder> displayToken = data.readStrongBinder();
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001867 int32_t defaultConfig;
Steven Thomasf734df42020-04-13 21:09:28 -07001868 float primaryRefreshRateMin;
1869 float primaryRefreshRateMax;
1870 float appRequestRefreshRateMin;
1871 float appRequestRefreshRateMax;
Ana Krulec234bb162019-11-10 22:55:55 +01001872
Steven Thomasf734df42020-04-13 21:09:28 -07001873 status_t result =
1874 getDesiredDisplayConfigSpecs(displayToken, &defaultConfig,
1875 &primaryRefreshRateMin, &primaryRefreshRateMax,
1876 &appRequestRefreshRateMin,
1877 &appRequestRefreshRateMax);
Ana Krulec234bb162019-11-10 22:55:55 +01001878 if (result != NO_ERROR) {
1879 ALOGE("getDesiredDisplayConfigSpecs: failed to get getDesiredDisplayConfigSpecs: "
1880 "%d",
1881 result);
1882 return result;
1883 }
1884
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001885 result = reply->writeInt32(defaultConfig);
Ana Krulec234bb162019-11-10 22:55:55 +01001886 if (result != NO_ERROR) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +01001887 ALOGE("getDesiredDisplayConfigSpecs: failed to write defaultConfig: %d", result);
Ana Krulec234bb162019-11-10 22:55:55 +01001888 return result;
1889 }
Steven Thomasf734df42020-04-13 21:09:28 -07001890 result = reply->writeFloat(primaryRefreshRateMin);
Ana Krulec234bb162019-11-10 22:55:55 +01001891 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001892 ALOGE("getDesiredDisplayConfigSpecs: failed to write primaryRefreshRateMin: %d",
1893 result);
Ana Krulec234bb162019-11-10 22:55:55 +01001894 return result;
1895 }
Steven Thomasf734df42020-04-13 21:09:28 -07001896 result = reply->writeFloat(primaryRefreshRateMax);
Ana Krulec234bb162019-11-10 22:55:55 +01001897 if (result != NO_ERROR) {
Steven Thomasf734df42020-04-13 21:09:28 -07001898 ALOGE("getDesiredDisplayConfigSpecs: failed to write primaryRefreshRateMax: %d",
1899 result);
1900 return result;
1901 }
1902 result = reply->writeFloat(appRequestRefreshRateMin);
1903 if (result != NO_ERROR) {
1904 ALOGE("getDesiredDisplayConfigSpecs: failed to write appRequestRefreshRateMin: %d",
1905 result);
1906 return result;
1907 }
1908 result = reply->writeFloat(appRequestRefreshRateMax);
1909 if (result != NO_ERROR) {
1910 ALOGE("getDesiredDisplayConfigSpecs: failed to write appRequestRefreshRateMax: %d",
1911 result);
Ana Krulec234bb162019-11-10 22:55:55 +01001912 return result;
1913 }
1914 reply->writeInt32(result);
1915 return result;
1916 }
Dan Gittik57e63c52019-01-18 16:37:54 +00001917 case GET_DISPLAY_BRIGHTNESS_SUPPORT: {
1918 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1919 sp<IBinder> displayToken;
1920 status_t error = data.readNullableStrongBinder(&displayToken);
1921 if (error != NO_ERROR) {
1922 ALOGE("getDisplayBrightnessSupport: failed to read display token: %d", error);
1923 return error;
1924 }
1925 bool support = false;
1926 error = getDisplayBrightnessSupport(displayToken, &support);
1927 reply->writeBool(support);
1928 return error;
1929 }
1930 case SET_DISPLAY_BRIGHTNESS: {
1931 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1932 sp<IBinder> displayToken;
1933 status_t error = data.readNullableStrongBinder(&displayToken);
1934 if (error != NO_ERROR) {
1935 ALOGE("setDisplayBrightness: failed to read display token: %d", error);
1936 return error;
1937 }
1938 float brightness = -1.0f;
1939 error = data.readFloat(&brightness);
1940 if (error != NO_ERROR) {
1941 ALOGE("setDisplayBrightness: failed to read brightness: %d", error);
1942 return error;
1943 }
1944 return setDisplayBrightness(displayToken, brightness);
1945 }
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001946 case NOTIFY_POWER_BOOST: {
Ady Abraham8532d012019-05-08 14:50:56 -07001947 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001948 int32_t boostId;
1949 status_t error = data.readInt32(&boostId);
Ady Abraham8532d012019-05-08 14:50:56 -07001950 if (error != NO_ERROR) {
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001951 ALOGE("notifyPowerBoost: failed to read boostId: %d", error);
Ady Abraham8532d012019-05-08 14:50:56 -07001952 return error;
1953 }
Lais Andrade3a6e47d2020-04-02 11:20:16 +01001954 return notifyPowerBoost(boostId);
Ady Abraham8532d012019-05-08 14:50:56 -07001955 }
Vishnu Nairb13bb952019-11-15 10:24:08 -08001956 case SET_GLOBAL_SHADOW_SETTINGS: {
1957 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1958
1959 std::vector<float> shadowConfig;
1960 status_t error = data.readFloatVector(&shadowConfig);
1961 if (error != NO_ERROR || shadowConfig.size() != 11) {
1962 ALOGE("setGlobalShadowSettings: failed to read shadowConfig: %d", error);
1963 return error;
1964 }
1965
1966 half4 ambientColor = {shadowConfig[0], shadowConfig[1], shadowConfig[2],
1967 shadowConfig[3]};
1968 half4 spotColor = {shadowConfig[4], shadowConfig[5], shadowConfig[6], shadowConfig[7]};
1969 float lightPosY = shadowConfig[8];
1970 float lightPosZ = shadowConfig[9];
1971 float lightRadius = shadowConfig[10];
1972 return setGlobalShadowSettings(ambientColor, spotColor, lightPosY, lightPosZ,
1973 lightRadius);
1974 }
Steven Thomas62a4cf82020-01-31 12:04:03 -08001975 case SET_FRAME_RATE: {
1976 CHECK_INTERFACE(ISurfaceComposer, data, reply);
1977 sp<IBinder> binder;
1978 status_t err = data.readStrongBinder(&binder);
1979 if (err != NO_ERROR) {
1980 ALOGE("setFrameRate: failed to read strong binder: %s (%d)", strerror(-err), -err);
1981 return err;
1982 }
1983 sp<IGraphicBufferProducer> surface = interface_cast<IGraphicBufferProducer>(binder);
1984 if (!surface) {
1985 ALOGE("setFrameRate: failed to cast to IGraphicBufferProducer: %s (%d)",
1986 strerror(-err), -err);
1987 return err;
1988 }
1989 float frameRate;
1990 err = data.readFloat(&frameRate);
1991 if (err != NO_ERROR) {
1992 ALOGE("setFrameRate: failed to read float: %s (%d)", strerror(-err), -err);
1993 return err;
1994 }
1995 int8_t compatibility;
1996 err = data.readByte(&compatibility);
1997 if (err != NO_ERROR) {
1998 ALOGE("setFrameRate: failed to read byte: %s (%d)", strerror(-err), -err);
1999 return err;
2000 }
2001 status_t result = setFrameRate(surface, frameRate, compatibility);
2002 reply->writeInt32(result);
2003 return NO_ERROR;
2004 }
Steven Thomasd4071902020-03-24 16:02:53 -07002005 case ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN: {
2006 CHECK_INTERFACE(ISurfaceComposer, data, reply);
2007 sp<IBinder> token;
2008 status_t result = acquireFrameRateFlexibilityToken(&token);
2009 reply->writeInt32(result);
2010 if (result == NO_ERROR) {
2011 reply->writeStrongBinder(token);
2012 }
2013 return NO_ERROR;
2014 }
Jesse Hall6c913be2013-08-08 12:15:49 -07002015 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -07002016 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -07002017 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08002018 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08002019}
2020
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -08002021} // namespace android