The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 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 Agopian | c5b2c0b | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 23 | #include <binder/Parcel.h> |
Mathias Agopian | c5b2c0b | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 24 | #include <binder/IPCThreadState.h> |
| 25 | #include <binder/IServiceManager.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 27 | #include <gui/IDisplayEventConnection.h> |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 28 | #include <gui/IGraphicBufferProducer.h> |
Dan Stoza | 84ab937 | 2018-12-17 15:27:57 -0800 | [diff] [blame] | 29 | #include <gui/IRegionSamplingListener.h> |
Mathias Agopian | 2b5dd40 | 2017-02-07 17:36:19 -0800 | [diff] [blame] | 30 | #include <gui/ISurfaceComposer.h> |
| 31 | #include <gui/ISurfaceComposerClient.h> |
Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 32 | #include <gui/LayerDebugInfo.h> |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 33 | #include <gui/LayerState.h> |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 34 | |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 35 | #include <system/graphics.h> |
| 36 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | #include <ui/DisplayInfo.h> |
Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 38 | #include <ui/DisplayStatInfo.h> |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 39 | #include <ui/HdrCapabilities.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 41 | #include <utils/Log.h> |
Mathias Agopian | 9cce325 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 42 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | // --------------------------------------------------------------------------- |
| 44 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 45 | namespace android { |
| 46 | |
Peiyong Lin | 9f03447 | 2018-03-28 15:29:00 -0700 | [diff] [blame] | 47 | using ui::ColorMode; |
| 48 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 49 | class BpSurfaceComposer : public BpInterface<ISurfaceComposer> |
| 50 | { |
| 51 | public: |
Chih-Hung Hsieh | e2347b7 | 2016-04-25 15:41:05 -0700 | [diff] [blame] | 52 | explicit BpSurfaceComposer(const sp<IBinder>& impl) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | : BpInterface<ISurfaceComposer>(impl) |
| 54 | { |
| 55 | } |
| 56 | |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 57 | virtual ~BpSurfaceComposer(); |
| 58 | |
Mathias Agopian | 7e27f05 | 2010-05-28 14:22:23 -0700 | [diff] [blame] | 59 | virtual sp<ISurfaceComposerClient> createConnection() |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | Parcel data, reply; |
| 62 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 63 | remote()->transact(BnSurfaceComposer::CREATE_CONNECTION, data, &reply); |
Mathias Agopian | 7e27f05 | 2010-05-28 14:22:23 -0700 | [diff] [blame] | 64 | return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder()); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 65 | } |
| 66 | |
Marissa Wall | 713b63f | 2018-10-17 15:42:43 -0700 | [diff] [blame] | 67 | virtual void setTransactionState(const Vector<ComposerState>& state, |
| 68 | const Vector<DisplayState>& displays, uint32_t flags, |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 69 | const sp<IBinder>& applyToken, |
Marissa Wall | 17b4e45 | 2018-12-26 16:32:34 -0800 | [diff] [blame] | 70 | const InputWindowCommands& commands, |
Marissa Wall | 78b7220 | 2019-03-15 14:58:34 -0700 | [diff] [blame] | 71 | int64_t desiredPresentTime, |
Marissa Wall | 3dad52d | 2019-03-22 14:03:19 -0700 | [diff] [blame^] | 72 | const cached_buffer_t& uncacheBuffer, |
| 73 | const std::vector<ListenerCallbacks>& listenerCallbacks) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 74 | Parcel data, reply; |
| 75 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 76 | |
| 77 | data.writeUint32(static_cast<uint32_t>(state.size())); |
| 78 | for (const auto& s : state) { |
| 79 | s.write(data); |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 80 | } |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 81 | |
| 82 | data.writeUint32(static_cast<uint32_t>(displays.size())); |
| 83 | for (const auto& d : displays) { |
| 84 | d.write(data); |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 85 | } |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 86 | |
| 87 | data.writeUint32(flags); |
Marissa Wall | 713b63f | 2018-10-17 15:42:43 -0700 | [diff] [blame] | 88 | data.writeStrongBinder(applyToken); |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 89 | commands.write(data); |
Marissa Wall | 17b4e45 | 2018-12-26 16:32:34 -0800 | [diff] [blame] | 90 | data.writeInt64(desiredPresentTime); |
Marissa Wall | 78b7220 | 2019-03-15 14:58:34 -0700 | [diff] [blame] | 91 | data.writeStrongBinder(uncacheBuffer.token); |
| 92 | data.writeUint64(uncacheBuffer.cacheId); |
Marissa Wall | 3dad52d | 2019-03-22 14:03:19 -0700 | [diff] [blame^] | 93 | |
| 94 | if (data.writeVectorSize(listenerCallbacks) == NO_ERROR) { |
| 95 | for (const auto& [listener, callbackIds] : listenerCallbacks) { |
| 96 | data.writeStrongBinder(IInterface::asBinder(listener)); |
| 97 | data.writeInt64Vector(callbackIds); |
| 98 | } |
| 99 | } |
| 100 | |
Jamie Gennis | b8d69a5 | 2011-10-10 15:48:06 -0700 | [diff] [blame] | 101 | remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 102 | } |
| 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 | |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 111 | virtual status_t captureScreen(const sp<IBinder>& display, sp<GraphicBuffer>* outBuffer, |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 112 | const ui::Dataspace reqDataspace, |
| 113 | const ui::PixelFormat reqPixelFormat, Rect sourceCrop, |
| 114 | uint32_t reqWidth, uint32_t reqHeight, bool useIdentityTransform, |
Robert Carr | fa8855f | 2019-02-19 10:05:00 -0800 | [diff] [blame] | 115 | ISurfaceComposer::Rotation rotation, bool captureSecureLayers) { |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 116 | Parcel data, reply; |
| 117 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 118 | data.writeStrongBinder(display); |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 119 | data.writeInt32(static_cast<int32_t>(reqDataspace)); |
| 120 | data.writeInt32(static_cast<int32_t>(reqPixelFormat)); |
Dan Stoza | c187900 | 2014-05-22 15:59:05 -0700 | [diff] [blame] | 121 | data.write(sourceCrop); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 122 | data.writeUint32(reqWidth); |
| 123 | data.writeUint32(reqHeight); |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 124 | data.writeInt32(static_cast<int32_t>(useIdentityTransform)); |
Riley Andrews | c3ebe66 | 2014-09-04 16:20:31 -0700 | [diff] [blame] | 125 | data.writeInt32(static_cast<int32_t>(rotation)); |
Robert Carr | fa8855f | 2019-02-19 10:05:00 -0800 | [diff] [blame] | 126 | data.writeInt32(static_cast<int32_t>(captureSecureLayers)); |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 127 | status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply); |
| 128 | if (result != NO_ERROR) { |
| 129 | ALOGE("captureScreen failed to transact: %d", result); |
| 130 | return result; |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 131 | } |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 132 | result = reply.readInt32(); |
| 133 | if (result != NO_ERROR) { |
| 134 | ALOGE("captureScreen failed to readInt32: %d", result); |
| 135 | return result; |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | *outBuffer = new GraphicBuffer(); |
| 139 | reply.read(**outBuffer); |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 140 | |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 141 | return result; |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 142 | } |
| 143 | |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 144 | virtual status_t captureLayers(const sp<IBinder>& layerHandleBinder, |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 145 | sp<GraphicBuffer>* outBuffer, const ui::Dataspace reqDataspace, |
| 146 | const ui::PixelFormat reqPixelFormat, const Rect& sourceCrop, |
Robert Carr | 578038f | 2018-03-09 12:25:24 -0800 | [diff] [blame] | 147 | float frameScale, bool childrenOnly) { |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 148 | Parcel data, reply; |
| 149 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 150 | data.writeStrongBinder(layerHandleBinder); |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 151 | data.writeInt32(static_cast<int32_t>(reqDataspace)); |
| 152 | data.writeInt32(static_cast<int32_t>(reqPixelFormat)); |
chaviw | 7206d49 | 2017-11-10 16:16:12 -0800 | [diff] [blame] | 153 | data.write(sourceCrop); |
| 154 | data.writeFloat(frameScale); |
Robert Carr | 578038f | 2018-03-09 12:25:24 -0800 | [diff] [blame] | 155 | data.writeBool(childrenOnly); |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 156 | status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_LAYERS, data, &reply); |
| 157 | if (result != NO_ERROR) { |
| 158 | ALOGE("captureLayers failed to transact: %d", result); |
| 159 | return result; |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 160 | } |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 161 | result = reply.readInt32(); |
| 162 | if (result != NO_ERROR) { |
| 163 | ALOGE("captureLayers failed to readInt32: %d", result); |
| 164 | return result; |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 165 | } |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 166 | |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 167 | *outBuffer = new GraphicBuffer(); |
| 168 | reply.read(**outBuffer); |
| 169 | |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 170 | return result; |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 171 | } |
| 172 | |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 173 | virtual bool authenticateSurfaceTexture( |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 174 | const sp<IGraphicBufferProducer>& bufferProducer) const |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 175 | { |
| 176 | Parcel data, reply; |
| 177 | int err = NO_ERROR; |
| 178 | err = data.writeInterfaceToken( |
| 179 | ISurfaceComposer::getInterfaceDescriptor()); |
| 180 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 181 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing " |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 182 | "interface descriptor: %s (%d)", strerror(-err), -err); |
| 183 | return false; |
| 184 | } |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 185 | err = data.writeStrongBinder(IInterface::asBinder(bufferProducer)); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 186 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 187 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing " |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 188 | "strong binder to parcel: %s (%d)", strerror(-err), -err); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 189 | return false; |
| 190 | } |
| 191 | err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data, |
| 192 | &reply); |
| 193 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 194 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error " |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 195 | "performing transaction: %s (%d)", strerror(-err), -err); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 196 | return false; |
| 197 | } |
| 198 | int32_t result = 0; |
| 199 | err = reply.readInt32(&result); |
| 200 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 201 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error " |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 202 | "retrieving result: %s (%d)", strerror(-err), -err); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 203 | return false; |
| 204 | } |
| 205 | return result != 0; |
| 206 | } |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 207 | |
Brian Anderson | 6b37671 | 2017-04-04 10:51:39 -0700 | [diff] [blame] | 208 | virtual status_t getSupportedFrameTimestamps( |
| 209 | std::vector<FrameEvent>* outSupported) const { |
| 210 | if (!outSupported) { |
| 211 | return UNEXPECTED_NULL; |
| 212 | } |
| 213 | outSupported->clear(); |
| 214 | |
| 215 | Parcel data, reply; |
| 216 | |
| 217 | status_t err = data.writeInterfaceToken( |
| 218 | ISurfaceComposer::getInterfaceDescriptor()); |
| 219 | if (err != NO_ERROR) { |
| 220 | return err; |
| 221 | } |
| 222 | |
| 223 | err = remote()->transact( |
| 224 | BnSurfaceComposer::GET_SUPPORTED_FRAME_TIMESTAMPS, |
| 225 | data, &reply); |
| 226 | if (err != NO_ERROR) { |
| 227 | return err; |
| 228 | } |
| 229 | |
| 230 | int32_t result = 0; |
| 231 | err = reply.readInt32(&result); |
| 232 | if (err != NO_ERROR) { |
| 233 | return err; |
| 234 | } |
| 235 | if (result != NO_ERROR) { |
| 236 | return result; |
| 237 | } |
| 238 | |
| 239 | std::vector<int32_t> supported; |
| 240 | err = reply.readInt32Vector(&supported); |
| 241 | if (err != NO_ERROR) { |
| 242 | return err; |
| 243 | } |
| 244 | |
| 245 | outSupported->reserve(supported.size()); |
| 246 | for (int32_t s : supported) { |
| 247 | outSupported->push_back(static_cast<FrameEvent>(s)); |
| 248 | } |
| 249 | return NO_ERROR; |
| 250 | } |
| 251 | |
Jorim Jaggi | b1e2f8d | 2017-06-08 15:43:59 -0700 | [diff] [blame] | 252 | virtual sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource) |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 253 | { |
| 254 | Parcel data, reply; |
| 255 | sp<IDisplayEventConnection> result; |
| 256 | int err = data.writeInterfaceToken( |
| 257 | ISurfaceComposer::getInterfaceDescriptor()); |
| 258 | if (err != NO_ERROR) { |
| 259 | return result; |
| 260 | } |
Jorim Jaggi | b1e2f8d | 2017-06-08 15:43:59 -0700 | [diff] [blame] | 261 | data.writeInt32(static_cast<int32_t>(vsyncSource)); |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 262 | err = remote()->transact( |
| 263 | BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION, |
| 264 | data, &reply); |
| 265 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 266 | ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing " |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 267 | "transaction: %s (%d)", strerror(-err), -err); |
| 268 | return result; |
| 269 | } |
| 270 | result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder()); |
| 271 | return result; |
| 272 | } |
Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 273 | |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 274 | virtual sp<IBinder> createDisplay(const String8& displayName, bool secure) |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 275 | { |
| 276 | Parcel data, reply; |
| 277 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Andy McFadden | 8dfa92f | 2012-09-17 18:27:17 -0700 | [diff] [blame] | 278 | data.writeString8(displayName); |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 279 | data.writeInt32(secure ? 1 : 0); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 280 | remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply); |
| 281 | return reply.readStrongBinder(); |
| 282 | } |
| 283 | |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 284 | virtual void destroyDisplay(const sp<IBinder>& display) |
| 285 | { |
| 286 | Parcel data, reply; |
| 287 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 288 | data.writeStrongBinder(display); |
| 289 | remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply); |
| 290 | } |
| 291 | |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 292 | virtual std::vector<PhysicalDisplayId> getPhysicalDisplayIds() const { |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 293 | Parcel data, reply; |
| 294 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 295 | if (remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_IDS, data, &reply) == |
| 296 | NO_ERROR) { |
| 297 | std::vector<PhysicalDisplayId> displayIds; |
| 298 | if (reply.readUint64Vector(&displayIds) == NO_ERROR) { |
| 299 | return displayIds; |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | return {}; |
| 304 | } |
| 305 | |
| 306 | virtual sp<IBinder> getPhysicalDisplayToken(PhysicalDisplayId displayId) const { |
| 307 | Parcel data, reply; |
| 308 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 309 | data.writeUint64(displayId); |
| 310 | remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_TOKEN, data, &reply); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 311 | return reply.readStrongBinder(); |
| 312 | } |
| 313 | |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 314 | virtual void setPowerMode(const sp<IBinder>& display, int mode) |
Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 315 | { |
| 316 | Parcel data, reply; |
| 317 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Andy McFadden | c01a79d | 2012-09-27 16:02:06 -0700 | [diff] [blame] | 318 | data.writeStrongBinder(display); |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 319 | data.writeInt32(mode); |
| 320 | remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply); |
Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 321 | } |
Mathias Agopian | 3094df3 | 2012-06-18 18:06:45 -0700 | [diff] [blame] | 322 | |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 323 | virtual status_t getDisplayConfigs(const sp<IBinder>& display, |
| 324 | Vector<DisplayInfo>* configs) |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 325 | { |
| 326 | Parcel data, reply; |
| 327 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 328 | data.writeStrongBinder(display); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 329 | remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply); |
| 330 | status_t result = reply.readInt32(); |
| 331 | if (result == NO_ERROR) { |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 332 | size_t numConfigs = reply.readUint32(); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 333 | configs->clear(); |
| 334 | configs->resize(numConfigs); |
| 335 | for (size_t c = 0; c < numConfigs; ++c) { |
| 336 | memcpy(&(configs->editItemAt(c)), |
| 337 | reply.readInplace(sizeof(DisplayInfo)), |
| 338 | sizeof(DisplayInfo)); |
| 339 | } |
| 340 | } |
| 341 | return result; |
| 342 | } |
| 343 | |
Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 344 | virtual status_t getDisplayStats(const sp<IBinder>& display, |
| 345 | DisplayStatInfo* stats) |
| 346 | { |
| 347 | Parcel data, reply; |
| 348 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 349 | data.writeStrongBinder(display); |
| 350 | remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply); |
| 351 | status_t result = reply.readInt32(); |
| 352 | if (result == NO_ERROR) { |
| 353 | memcpy(stats, |
| 354 | reply.readInplace(sizeof(DisplayStatInfo)), |
| 355 | sizeof(DisplayStatInfo)); |
| 356 | } |
| 357 | return result; |
| 358 | } |
| 359 | |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 360 | virtual int getActiveConfig(const sp<IBinder>& display) |
| 361 | { |
| 362 | Parcel data, reply; |
| 363 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 364 | data.writeStrongBinder(display); |
| 365 | remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply); |
| 366 | return reply.readInt32(); |
| 367 | } |
| 368 | |
| 369 | virtual status_t setActiveConfig(const sp<IBinder>& display, int id) |
| 370 | { |
| 371 | Parcel data, reply; |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 372 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 373 | if (result != NO_ERROR) { |
| 374 | ALOGE("setActiveConfig failed to writeInterfaceToken: %d", result); |
| 375 | return result; |
| 376 | } |
| 377 | result = data.writeStrongBinder(display); |
| 378 | if (result != NO_ERROR) { |
| 379 | ALOGE("setActiveConfig failed to writeStrongBinder: %d", result); |
| 380 | return result; |
| 381 | } |
| 382 | result = data.writeInt32(id); |
| 383 | if (result != NO_ERROR) { |
| 384 | ALOGE("setActiveConfig failed to writeInt32: %d", result); |
| 385 | return result; |
| 386 | } |
| 387 | result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply); |
| 388 | if (result != NO_ERROR) { |
| 389 | ALOGE("setActiveConfig failed to transact: %d", result); |
| 390 | return result; |
| 391 | } |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 392 | return reply.readInt32(); |
| 393 | } |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 394 | |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 395 | virtual status_t getDisplayColorModes(const sp<IBinder>& display, |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 396 | Vector<ColorMode>* outColorModes) { |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 397 | Parcel data, reply; |
| 398 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 399 | if (result != NO_ERROR) { |
| 400 | ALOGE("getDisplayColorModes failed to writeInterfaceToken: %d", result); |
| 401 | return result; |
| 402 | } |
| 403 | result = data.writeStrongBinder(display); |
| 404 | if (result != NO_ERROR) { |
| 405 | ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result); |
| 406 | return result; |
| 407 | } |
| 408 | result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply); |
| 409 | if (result != NO_ERROR) { |
| 410 | ALOGE("getDisplayColorModes failed to transact: %d", result); |
| 411 | return result; |
| 412 | } |
| 413 | result = static_cast<status_t>(reply.readInt32()); |
| 414 | if (result == NO_ERROR) { |
| 415 | size_t numModes = reply.readUint32(); |
| 416 | outColorModes->clear(); |
| 417 | outColorModes->resize(numModes); |
| 418 | for (size_t i = 0; i < numModes; ++i) { |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 419 | outColorModes->replaceAt(static_cast<ColorMode>(reply.readInt32()), i); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 420 | } |
| 421 | } |
| 422 | return result; |
| 423 | } |
| 424 | |
Daniel Solomon | 42d0456 | 2019-01-20 21:03:19 -0800 | [diff] [blame] | 425 | virtual status_t getDisplayNativePrimaries(const sp<IBinder>& display, |
| 426 | ui::DisplayPrimaries& primaries) { |
| 427 | Parcel data, reply; |
| 428 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 429 | if (result != NO_ERROR) { |
| 430 | ALOGE("getDisplayNativePrimaries failed to writeInterfaceToken: %d", result); |
| 431 | return result; |
| 432 | } |
| 433 | result = data.writeStrongBinder(display); |
| 434 | if (result != NO_ERROR) { |
| 435 | ALOGE("getDisplayNativePrimaries failed to writeStrongBinder: %d", result); |
| 436 | return result; |
| 437 | } |
| 438 | result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_NATIVE_PRIMARIES, data, &reply); |
| 439 | if (result != NO_ERROR) { |
| 440 | ALOGE("getDisplayNativePrimaries failed to transact: %d", result); |
| 441 | return result; |
| 442 | } |
| 443 | result = reply.readInt32(); |
| 444 | if (result == NO_ERROR) { |
| 445 | memcpy(&primaries, reply.readInplace(sizeof(ui::DisplayPrimaries)), |
| 446 | sizeof(ui::DisplayPrimaries)); |
| 447 | } |
| 448 | return result; |
| 449 | } |
| 450 | |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 451 | virtual ColorMode getActiveColorMode(const sp<IBinder>& display) { |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 452 | Parcel data, reply; |
| 453 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 454 | if (result != NO_ERROR) { |
| 455 | ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result); |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 456 | return static_cast<ColorMode>(result); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 457 | } |
| 458 | result = data.writeStrongBinder(display); |
| 459 | if (result != NO_ERROR) { |
| 460 | ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result); |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 461 | return static_cast<ColorMode>(result); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 462 | } |
| 463 | result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply); |
| 464 | if (result != NO_ERROR) { |
| 465 | ALOGE("getActiveColorMode failed to transact: %d", result); |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 466 | return static_cast<ColorMode>(result); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 467 | } |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 468 | return static_cast<ColorMode>(reply.readInt32()); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | virtual status_t setActiveColorMode(const sp<IBinder>& display, |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 472 | ColorMode colorMode) { |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 473 | Parcel data, reply; |
| 474 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 475 | if (result != NO_ERROR) { |
| 476 | ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result); |
| 477 | return result; |
| 478 | } |
| 479 | result = data.writeStrongBinder(display); |
| 480 | if (result != NO_ERROR) { |
| 481 | ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result); |
| 482 | return result; |
| 483 | } |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 484 | result = data.writeInt32(static_cast<int32_t>(colorMode)); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 485 | if (result != NO_ERROR) { |
| 486 | ALOGE("setActiveColorMode failed to writeInt32: %d", result); |
| 487 | return result; |
| 488 | } |
| 489 | result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply); |
| 490 | if (result != NO_ERROR) { |
| 491 | ALOGE("setActiveColorMode failed to transact: %d", result); |
| 492 | return result; |
| 493 | } |
| 494 | return static_cast<status_t>(reply.readInt32()); |
| 495 | } |
| 496 | |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 497 | virtual status_t clearAnimationFrameStats() { |
| 498 | Parcel data, reply; |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 499 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 500 | if (result != NO_ERROR) { |
| 501 | ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result); |
| 502 | return result; |
| 503 | } |
| 504 | result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply); |
| 505 | if (result != NO_ERROR) { |
| 506 | ALOGE("clearAnimationFrameStats failed to transact: %d", result); |
| 507 | return result; |
| 508 | } |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 509 | return reply.readInt32(); |
| 510 | } |
| 511 | |
| 512 | virtual status_t getAnimationFrameStats(FrameStats* outStats) const { |
| 513 | Parcel data, reply; |
| 514 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 515 | remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply); |
| 516 | reply.read(*outStats); |
| 517 | return reply.readInt32(); |
| 518 | } |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 519 | |
| 520 | virtual status_t getHdrCapabilities(const sp<IBinder>& display, |
| 521 | HdrCapabilities* outCapabilities) const { |
| 522 | Parcel data, reply; |
| 523 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 524 | status_t result = data.writeStrongBinder(display); |
| 525 | if (result != NO_ERROR) { |
| 526 | ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result); |
| 527 | return result; |
| 528 | } |
| 529 | result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES, |
| 530 | data, &reply); |
| 531 | if (result != NO_ERROR) { |
| 532 | ALOGE("getHdrCapabilities failed to transact: %d", result); |
| 533 | return result; |
| 534 | } |
| 535 | result = reply.readInt32(); |
| 536 | if (result == NO_ERROR) { |
Mathias Agopian | e1f5e6f | 2017-02-06 16:34:41 -0800 | [diff] [blame] | 537 | result = reply.read(*outCapabilities); |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 538 | } |
| 539 | return result; |
| 540 | } |
Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 541 | |
| 542 | virtual status_t enableVSyncInjections(bool enable) { |
| 543 | Parcel data, reply; |
| 544 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 545 | if (result != NO_ERROR) { |
| 546 | ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result); |
| 547 | return result; |
| 548 | } |
| 549 | result = data.writeBool(enable); |
| 550 | if (result != NO_ERROR) { |
| 551 | ALOGE("enableVSyncInjections failed to writeBool: %d", result); |
| 552 | return result; |
| 553 | } |
| 554 | result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS, |
| 555 | data, &reply, TF_ONE_WAY); |
| 556 | if (result != NO_ERROR) { |
| 557 | ALOGE("enableVSyncInjections failed to transact: %d", result); |
| 558 | return result; |
| 559 | } |
| 560 | return result; |
| 561 | } |
| 562 | |
| 563 | virtual status_t injectVSync(nsecs_t when) { |
| 564 | Parcel data, reply; |
| 565 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 566 | if (result != NO_ERROR) { |
| 567 | ALOGE("injectVSync failed to writeInterfaceToken: %d", result); |
| 568 | return result; |
| 569 | } |
| 570 | result = data.writeInt64(when); |
| 571 | if (result != NO_ERROR) { |
| 572 | ALOGE("injectVSync failed to writeInt64: %d", result); |
| 573 | return result; |
| 574 | } |
| 575 | result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply, TF_ONE_WAY); |
| 576 | if (result != NO_ERROR) { |
| 577 | ALOGE("injectVSync failed to transact: %d", result); |
| 578 | return result; |
| 579 | } |
| 580 | return result; |
| 581 | } |
| 582 | |
Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 583 | virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const |
| 584 | { |
| 585 | if (!outLayers) { |
| 586 | return UNEXPECTED_NULL; |
| 587 | } |
| 588 | |
| 589 | Parcel data, reply; |
| 590 | |
| 591 | status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 592 | if (err != NO_ERROR) { |
| 593 | return err; |
| 594 | } |
| 595 | |
| 596 | err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply); |
| 597 | if (err != NO_ERROR) { |
| 598 | return err; |
| 599 | } |
| 600 | |
| 601 | int32_t result = 0; |
| 602 | err = reply.readInt32(&result); |
| 603 | if (err != NO_ERROR) { |
| 604 | return err; |
| 605 | } |
| 606 | if (result != NO_ERROR) { |
| 607 | return result; |
| 608 | } |
| 609 | |
| 610 | outLayers->clear(); |
| 611 | return reply.readParcelableVector(outLayers); |
| 612 | } |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 613 | |
Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 614 | virtual status_t getCompositionPreference(ui::Dataspace* defaultDataspace, |
| 615 | ui::PixelFormat* defaultPixelFormat, |
| 616 | ui::Dataspace* wideColorGamutDataspace, |
| 617 | ui::PixelFormat* wideColorGamutPixelFormat) const { |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 618 | Parcel data, reply; |
| 619 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 620 | if (error != NO_ERROR) { |
| 621 | return error; |
| 622 | } |
| 623 | error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply); |
| 624 | if (error != NO_ERROR) { |
| 625 | return error; |
| 626 | } |
| 627 | error = static_cast<status_t>(reply.readInt32()); |
| 628 | if (error == NO_ERROR) { |
Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 629 | *defaultDataspace = static_cast<ui::Dataspace>(reply.readInt32()); |
| 630 | *defaultPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32()); |
| 631 | *wideColorGamutDataspace = static_cast<ui::Dataspace>(reply.readInt32()); |
| 632 | *wideColorGamutPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32()); |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 633 | } |
| 634 | return error; |
| 635 | } |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 636 | |
Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 637 | virtual status_t getColorManagement(bool* outGetColorManagement) const { |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 638 | Parcel data, reply; |
| 639 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 640 | remote()->transact(BnSurfaceComposer::GET_COLOR_MANAGEMENT, data, &reply); |
| 641 | bool result; |
| 642 | status_t err = reply.readBool(&result); |
| 643 | if (err == NO_ERROR) { |
| 644 | *outGetColorManagement = result; |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 645 | } |
Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 646 | return err; |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 647 | } |
Kevin DuBois | 9c0a176 | 2018-10-16 13:32:31 -0700 | [diff] [blame] | 648 | |
| 649 | virtual status_t getDisplayedContentSamplingAttributes(const sp<IBinder>& display, |
| 650 | ui::PixelFormat* outFormat, |
| 651 | ui::Dataspace* outDataspace, |
| 652 | uint8_t* outComponentMask) const { |
| 653 | if (!outFormat || !outDataspace || !outComponentMask) return BAD_VALUE; |
| 654 | Parcel data, reply; |
| 655 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 656 | data.writeStrongBinder(display); |
| 657 | |
| 658 | status_t error = |
| 659 | remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES, |
| 660 | data, &reply); |
| 661 | if (error != NO_ERROR) { |
| 662 | return error; |
| 663 | } |
| 664 | |
| 665 | uint32_t value = 0; |
| 666 | error = reply.readUint32(&value); |
| 667 | if (error != NO_ERROR) { |
| 668 | return error; |
| 669 | } |
| 670 | *outFormat = static_cast<ui::PixelFormat>(value); |
| 671 | |
| 672 | error = reply.readUint32(&value); |
| 673 | if (error != NO_ERROR) { |
| 674 | return error; |
| 675 | } |
| 676 | *outDataspace = static_cast<ui::Dataspace>(value); |
| 677 | |
| 678 | error = reply.readUint32(&value); |
| 679 | if (error != NO_ERROR) { |
| 680 | return error; |
| 681 | } |
| 682 | *outComponentMask = static_cast<uint8_t>(value); |
| 683 | return error; |
| 684 | } |
Kevin DuBois | 74e5377 | 2018-11-19 10:52:38 -0800 | [diff] [blame] | 685 | |
| 686 | virtual status_t setDisplayContentSamplingEnabled(const sp<IBinder>& display, bool enable, |
| 687 | uint8_t componentMask, |
| 688 | uint64_t maxFrames) const { |
| 689 | Parcel data, reply; |
| 690 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 691 | data.writeStrongBinder(display); |
| 692 | data.writeBool(enable); |
| 693 | data.writeByte(static_cast<int8_t>(componentMask)); |
| 694 | data.writeUint64(maxFrames); |
| 695 | status_t result = |
| 696 | remote()->transact(BnSurfaceComposer::SET_DISPLAY_CONTENT_SAMPLING_ENABLED, data, |
| 697 | &reply); |
| 698 | return result; |
| 699 | } |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 700 | |
| 701 | virtual status_t getDisplayedContentSample(const sp<IBinder>& display, uint64_t maxFrames, |
| 702 | uint64_t timestamp, |
| 703 | DisplayedFrameStats* outStats) const { |
| 704 | if (!outStats) return BAD_VALUE; |
| 705 | |
| 706 | Parcel data, reply; |
| 707 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 708 | data.writeStrongBinder(display); |
| 709 | data.writeUint64(maxFrames); |
| 710 | data.writeUint64(timestamp); |
| 711 | |
| 712 | status_t result = |
| 713 | remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLE, data, &reply); |
| 714 | |
| 715 | if (result != NO_ERROR) { |
| 716 | return result; |
| 717 | } |
| 718 | |
| 719 | result = reply.readUint64(&outStats->numFrames); |
| 720 | if (result != NO_ERROR) { |
| 721 | return result; |
| 722 | } |
| 723 | |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 724 | result = reply.readUint64Vector(&outStats->component_0_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 725 | if (result != NO_ERROR) { |
| 726 | return result; |
| 727 | } |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 728 | result = reply.readUint64Vector(&outStats->component_1_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 729 | if (result != NO_ERROR) { |
| 730 | return result; |
| 731 | } |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 732 | result = reply.readUint64Vector(&outStats->component_2_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 733 | if (result != NO_ERROR) { |
| 734 | return result; |
| 735 | } |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 736 | result = reply.readUint64Vector(&outStats->component_3_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 737 | return result; |
| 738 | } |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 739 | |
| 740 | virtual status_t getProtectedContentSupport(bool* outSupported) const { |
| 741 | Parcel data, reply; |
| 742 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Peiyong Lin | b6888fa | 2019-01-28 13:20:58 -0800 | [diff] [blame] | 743 | status_t error = |
| 744 | remote()->transact(BnSurfaceComposer::GET_PROTECTED_CONTENT_SUPPORT, data, &reply); |
| 745 | if (error != NO_ERROR) { |
| 746 | return error; |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 747 | } |
Peiyong Lin | b6888fa | 2019-01-28 13:20:58 -0800 | [diff] [blame] | 748 | error = reply.readBool(outSupported); |
| 749 | return error; |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 750 | } |
Marissa Wall | ebc2c05 | 2019-01-16 19:16:55 -0800 | [diff] [blame] | 751 | |
Peiyong Lin | 4f3fddf | 2019-01-24 17:21:24 -0800 | [diff] [blame] | 752 | virtual status_t isWideColorDisplay(const sp<IBinder>& token, |
| 753 | bool* outIsWideColorDisplay) const { |
| 754 | Parcel data, reply; |
| 755 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 756 | if (error != NO_ERROR) { |
| 757 | return error; |
| 758 | } |
| 759 | error = data.writeStrongBinder(token); |
| 760 | if (error != NO_ERROR) { |
| 761 | return error; |
| 762 | } |
| 763 | |
| 764 | error = remote()->transact(BnSurfaceComposer::IS_WIDE_COLOR_DISPLAY, data, &reply); |
| 765 | if (error != NO_ERROR) { |
| 766 | return error; |
| 767 | } |
| 768 | error = reply.readBool(outIsWideColorDisplay); |
| 769 | return error; |
| 770 | } |
Dan Stoza | 84ab937 | 2018-12-17 15:27:57 -0800 | [diff] [blame] | 771 | |
| 772 | virtual status_t addRegionSamplingListener(const Rect& samplingArea, |
| 773 | const sp<IBinder>& stopLayerHandle, |
| 774 | const sp<IRegionSamplingListener>& listener) { |
| 775 | Parcel data, reply; |
| 776 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 777 | if (error != NO_ERROR) { |
| 778 | ALOGE("addRegionSamplingListener: Failed to write interface token"); |
| 779 | return error; |
| 780 | } |
| 781 | error = data.write(samplingArea); |
| 782 | if (error != NO_ERROR) { |
| 783 | ALOGE("addRegionSamplingListener: Failed to write sampling area"); |
| 784 | return error; |
| 785 | } |
| 786 | error = data.writeStrongBinder(stopLayerHandle); |
| 787 | if (error != NO_ERROR) { |
| 788 | ALOGE("addRegionSamplingListener: Failed to write stop layer handle"); |
| 789 | return error; |
| 790 | } |
| 791 | error = data.writeStrongBinder(IInterface::asBinder(listener)); |
| 792 | if (error != NO_ERROR) { |
| 793 | ALOGE("addRegionSamplingListener: Failed to write listener"); |
| 794 | return error; |
| 795 | } |
| 796 | error = remote()->transact(BnSurfaceComposer::ADD_REGION_SAMPLING_LISTENER, data, &reply); |
| 797 | if (error != NO_ERROR) { |
| 798 | ALOGE("addRegionSamplingListener: Failed to transact"); |
| 799 | } |
| 800 | return error; |
| 801 | } |
| 802 | |
| 803 | virtual status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) { |
| 804 | Parcel data, reply; |
| 805 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 806 | if (error != NO_ERROR) { |
tangrobin | af45f01 | 2019-02-26 18:10:10 +0800 | [diff] [blame] | 807 | ALOGE("removeRegionSamplingListener: Failed to write interface token"); |
Dan Stoza | 84ab937 | 2018-12-17 15:27:57 -0800 | [diff] [blame] | 808 | return error; |
| 809 | } |
| 810 | error = data.writeStrongBinder(IInterface::asBinder(listener)); |
| 811 | if (error != NO_ERROR) { |
tangrobin | af45f01 | 2019-02-26 18:10:10 +0800 | [diff] [blame] | 812 | ALOGE("removeRegionSamplingListener: Failed to write listener"); |
Dan Stoza | 84ab937 | 2018-12-17 15:27:57 -0800 | [diff] [blame] | 813 | return error; |
| 814 | } |
| 815 | error = remote()->transact(BnSurfaceComposer::REMOVE_REGION_SAMPLING_LISTENER, data, |
| 816 | &reply); |
| 817 | if (error != NO_ERROR) { |
tangrobin | af45f01 | 2019-02-26 18:10:10 +0800 | [diff] [blame] | 818 | ALOGE("removeRegionSamplingListener: Failed to transact"); |
Dan Stoza | 84ab937 | 2018-12-17 15:27:57 -0800 | [diff] [blame] | 819 | } |
| 820 | return error; |
| 821 | } |
Ady Abraham | 838de06 | 2019-02-04 10:24:03 -0800 | [diff] [blame] | 822 | |
| 823 | virtual status_t setAllowedDisplayConfigs(const sp<IBinder>& displayToken, |
| 824 | const std::vector<int32_t>& allowedConfigs) { |
| 825 | Parcel data, reply; |
| 826 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 827 | if (result != NO_ERROR) { |
| 828 | ALOGE("setAllowedDisplayConfigs failed to writeInterfaceToken: %d", result); |
| 829 | return result; |
| 830 | } |
| 831 | result = data.writeStrongBinder(displayToken); |
| 832 | if (result != NO_ERROR) { |
| 833 | ALOGE("setAllowedDisplayConfigs failed to writeStrongBinder: %d", result); |
| 834 | return result; |
| 835 | } |
| 836 | result = data.writeInt32Vector(allowedConfigs); |
| 837 | if (result != NO_ERROR) { |
| 838 | ALOGE("setAllowedDisplayConfigs failed to writeInt32Vector: %d", result); |
| 839 | return result; |
| 840 | } |
| 841 | result = remote()->transact(BnSurfaceComposer::SET_ALLOWED_DISPLAY_CONFIGS, data, &reply); |
| 842 | if (result != NO_ERROR) { |
| 843 | ALOGE("setAllowedDisplayConfigs failed to transact: %d", result); |
| 844 | return result; |
| 845 | } |
| 846 | return reply.readInt32(); |
| 847 | } |
Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 848 | |
| 849 | virtual status_t getAllowedDisplayConfigs(const sp<IBinder>& displayToken, |
| 850 | std::vector<int32_t>* outAllowedConfigs) { |
| 851 | if (!outAllowedConfigs) return BAD_VALUE; |
| 852 | Parcel data, reply; |
| 853 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 854 | if (result != NO_ERROR) { |
| 855 | ALOGE("getAllowedDisplayConfigs failed to writeInterfaceToken: %d", result); |
| 856 | return result; |
| 857 | } |
| 858 | result = data.writeStrongBinder(displayToken); |
| 859 | if (result != NO_ERROR) { |
| 860 | ALOGE("getAllowedDisplayConfigs failed to writeStrongBinder: %d", result); |
| 861 | return result; |
| 862 | } |
| 863 | result = remote()->transact(BnSurfaceComposer::GET_ALLOWED_DISPLAY_CONFIGS, data, &reply); |
| 864 | if (result != NO_ERROR) { |
| 865 | ALOGE("getAllowedDisplayConfigs failed to transact: %d", result); |
| 866 | return result; |
| 867 | } |
| 868 | result = reply.readInt32Vector(outAllowedConfigs); |
| 869 | if (result != NO_ERROR) { |
| 870 | ALOGE("getAllowedDisplayConfigs failed to readInt32Vector: %d", result); |
| 871 | return result; |
| 872 | } |
| 873 | return reply.readInt32(); |
| 874 | } |
Dan Gittik | 57e63c5 | 2019-01-18 16:37:54 +0000 | [diff] [blame] | 875 | |
| 876 | virtual status_t getDisplayBrightnessSupport(const sp<IBinder>& displayToken, |
| 877 | bool* outSupport) const { |
| 878 | Parcel data, reply; |
| 879 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 880 | if (error != NO_ERROR) { |
| 881 | ALOGE("getDisplayBrightnessSupport: failed to write interface token: %d", error); |
| 882 | return error; |
| 883 | } |
| 884 | error = data.writeStrongBinder(displayToken); |
| 885 | if (error != NO_ERROR) { |
| 886 | ALOGE("getDisplayBrightnessSupport: failed to write display token: %d", error); |
| 887 | return error; |
| 888 | } |
| 889 | error = remote()->transact(BnSurfaceComposer::GET_DISPLAY_BRIGHTNESS_SUPPORT, data, &reply); |
| 890 | if (error != NO_ERROR) { |
| 891 | ALOGE("getDisplayBrightnessSupport: failed to transact: %d", error); |
| 892 | return error; |
| 893 | } |
| 894 | bool support; |
| 895 | error = reply.readBool(&support); |
| 896 | if (error != NO_ERROR) { |
| 897 | ALOGE("getDisplayBrightnessSupport: failed to read support: %d", error); |
| 898 | return error; |
| 899 | } |
| 900 | *outSupport = support; |
| 901 | return NO_ERROR; |
| 902 | } |
| 903 | |
| 904 | virtual status_t setDisplayBrightness(const sp<IBinder>& displayToken, float brightness) const { |
| 905 | Parcel data, reply; |
| 906 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 907 | if (error != NO_ERROR) { |
| 908 | ALOGE("setDisplayBrightness: failed to write interface token: %d", error); |
| 909 | return error; |
| 910 | } |
| 911 | error = data.writeStrongBinder(displayToken); |
| 912 | if (error != NO_ERROR) { |
| 913 | ALOGE("setDisplayBrightness: failed to write display token: %d", error); |
| 914 | return error; |
| 915 | } |
| 916 | error = data.writeFloat(brightness); |
| 917 | if (error != NO_ERROR) { |
| 918 | ALOGE("setDisplayBrightness: failed to write brightness: %d", error); |
| 919 | return error; |
| 920 | } |
| 921 | error = remote()->transact(BnSurfaceComposer::SET_DISPLAY_BRIGHTNESS, data, &reply); |
| 922 | if (error != NO_ERROR) { |
| 923 | ALOGE("setDisplayBrightness: failed to transact: %d", error); |
| 924 | return error; |
| 925 | } |
| 926 | return NO_ERROR; |
| 927 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 928 | }; |
| 929 | |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 930 | // Out-of-line virtual method definition to trigger vtable emission in this |
| 931 | // translation unit (see clang warning -Wweak-vtables) |
| 932 | BpSurfaceComposer::~BpSurfaceComposer() {} |
| 933 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 934 | IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer"); |
| 935 | |
| 936 | // ---------------------------------------------------------------------- |
| 937 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 938 | status_t BnSurfaceComposer::onTransact( |
| 939 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 940 | { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 941 | switch(code) { |
| 942 | case CREATE_CONNECTION: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 943 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 944 | sp<IBinder> b = IInterface::asBinder(createConnection()); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 945 | reply->writeStrongBinder(b); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 946 | return NO_ERROR; |
| 947 | } |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 948 | case SET_TRANSACTION_STATE: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 949 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 950 | |
| 951 | size_t count = data.readUint32(); |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 952 | if (count > data.dataSize()) { |
| 953 | return BAD_VALUE; |
| 954 | } |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 955 | Vector<ComposerState> state; |
| 956 | state.setCapacity(count); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 957 | for (size_t i = 0; i < count; i++) { |
Marissa Wall | c837b5e | 2018-10-12 10:04:44 -0700 | [diff] [blame] | 958 | ComposerState s; |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 959 | if (s.read(data) == BAD_VALUE) { |
| 960 | return BAD_VALUE; |
| 961 | } |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 962 | state.add(s); |
| 963 | } |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 964 | |
| 965 | count = data.readUint32(); |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 966 | if (count > data.dataSize()) { |
| 967 | return BAD_VALUE; |
| 968 | } |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 969 | DisplayState d; |
| 970 | Vector<DisplayState> displays; |
| 971 | displays.setCapacity(count); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 972 | for (size_t i = 0; i < count; i++) { |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 973 | if (d.read(data) == BAD_VALUE) { |
| 974 | return BAD_VALUE; |
| 975 | } |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 976 | displays.add(d); |
| 977 | } |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 978 | |
| 979 | uint32_t stateFlags = data.readUint32(); |
Marissa Wall | 713b63f | 2018-10-17 15:42:43 -0700 | [diff] [blame] | 980 | sp<IBinder> applyToken = data.readStrongBinder(); |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 981 | InputWindowCommands inputWindowCommands; |
| 982 | inputWindowCommands.read(data); |
Marissa Wall | 17b4e45 | 2018-12-26 16:32:34 -0800 | [diff] [blame] | 983 | |
| 984 | int64_t desiredPresentTime = data.readInt64(); |
Marissa Wall | 78b7220 | 2019-03-15 14:58:34 -0700 | [diff] [blame] | 985 | |
| 986 | cached_buffer_t uncachedBuffer; |
| 987 | uncachedBuffer.token = data.readStrongBinder(); |
| 988 | uncachedBuffer.cacheId = data.readUint64(); |
| 989 | |
Marissa Wall | 3dad52d | 2019-03-22 14:03:19 -0700 | [diff] [blame^] | 990 | std::vector<ListenerCallbacks> listenerCallbacks; |
| 991 | int32_t listenersSize = data.readInt32(); |
| 992 | for (int32_t i = 0; i < listenersSize; i++) { |
| 993 | auto listener = |
| 994 | interface_cast<ITransactionCompletedListener>(data.readStrongBinder()); |
| 995 | std::vector<CallbackId> callbackIds; |
| 996 | data.readInt64Vector(&callbackIds); |
| 997 | listenerCallbacks.emplace_back(listener, callbackIds); |
| 998 | } |
| 999 | |
Marissa Wall | 17b4e45 | 2018-12-26 16:32:34 -0800 | [diff] [blame] | 1000 | setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands, |
Marissa Wall | 3dad52d | 2019-03-22 14:03:19 -0700 | [diff] [blame^] | 1001 | desiredPresentTime, uncachedBuffer, listenerCallbacks); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1002 | return NO_ERROR; |
| 1003 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1004 | case BOOT_FINISHED: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 1005 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1006 | bootFinished(); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1007 | return NO_ERROR; |
| 1008 | } |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 1009 | case CAPTURE_SCREEN: { |
| 1010 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1011 | sp<IBinder> display = data.readStrongBinder(); |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 1012 | ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32()); |
| 1013 | ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32()); |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 1014 | sp<GraphicBuffer> outBuffer; |
Pablo Ceballos | 60d6922 | 2015-08-07 14:47:20 -0700 | [diff] [blame] | 1015 | Rect sourceCrop(Rect::EMPTY_RECT); |
Dan Stoza | c187900 | 2014-05-22 15:59:05 -0700 | [diff] [blame] | 1016 | data.read(sourceCrop); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1017 | uint32_t reqWidth = data.readUint32(); |
| 1018 | uint32_t reqHeight = data.readUint32(); |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 1019 | bool useIdentityTransform = static_cast<bool>(data.readInt32()); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1020 | int32_t rotation = data.readInt32(); |
Robert Carr | fa8855f | 2019-02-19 10:05:00 -0800 | [diff] [blame] | 1021 | bool captureSecureLayers = static_cast<bool>(data.readInt32()); |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 1022 | |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 1023 | status_t res = captureScreen(display, &outBuffer, reqDataspace, reqPixelFormat, |
| 1024 | sourceCrop, reqWidth, reqHeight, useIdentityTransform, |
Robert Carr | fa8855f | 2019-02-19 10:05:00 -0800 | [diff] [blame] | 1025 | static_cast<ISurfaceComposer::Rotation>(rotation), captureSecureLayers); |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 1026 | reply->writeInt32(res); |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 1027 | if (res == NO_ERROR) { |
| 1028 | reply->write(*outBuffer); |
| 1029 | } |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1030 | return NO_ERROR; |
| 1031 | } |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 1032 | case CAPTURE_LAYERS: { |
| 1033 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1034 | sp<IBinder> layerHandleBinder = data.readStrongBinder(); |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 1035 | ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32()); |
| 1036 | ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32()); |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 1037 | sp<GraphicBuffer> outBuffer; |
chaviw | 7206d49 | 2017-11-10 16:16:12 -0800 | [diff] [blame] | 1038 | Rect sourceCrop(Rect::EMPTY_RECT); |
| 1039 | data.read(sourceCrop); |
| 1040 | float frameScale = data.readFloat(); |
Robert Carr | 578038f | 2018-03-09 12:25:24 -0800 | [diff] [blame] | 1041 | bool childrenOnly = data.readBool(); |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 1042 | |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 1043 | status_t res = captureLayers(layerHandleBinder, &outBuffer, reqDataspace, |
| 1044 | reqPixelFormat, sourceCrop, frameScale, childrenOnly); |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 1045 | reply->writeInt32(res); |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 1046 | if (res == NO_ERROR) { |
| 1047 | reply->write(*outBuffer); |
| 1048 | } |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 1049 | return NO_ERROR; |
| 1050 | } |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 1051 | case AUTHENTICATE_SURFACE: { |
| 1052 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 1053 | sp<IGraphicBufferProducer> bufferProducer = |
| 1054 | interface_cast<IGraphicBufferProducer>(data.readStrongBinder()); |
| 1055 | int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0; |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 1056 | reply->writeInt32(result); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1057 | return NO_ERROR; |
| 1058 | } |
Brian Anderson | 6b37671 | 2017-04-04 10:51:39 -0700 | [diff] [blame] | 1059 | case GET_SUPPORTED_FRAME_TIMESTAMPS: { |
| 1060 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1061 | std::vector<FrameEvent> supportedTimestamps; |
| 1062 | status_t result = getSupportedFrameTimestamps(&supportedTimestamps); |
| 1063 | status_t err = reply->writeInt32(result); |
| 1064 | if (err != NO_ERROR) { |
| 1065 | return err; |
| 1066 | } |
| 1067 | if (result != NO_ERROR) { |
| 1068 | return result; |
| 1069 | } |
| 1070 | |
| 1071 | std::vector<int32_t> supported; |
| 1072 | supported.reserve(supportedTimestamps.size()); |
| 1073 | for (FrameEvent s : supportedTimestamps) { |
| 1074 | supported.push_back(static_cast<int32_t>(s)); |
| 1075 | } |
| 1076 | return reply->writeInt32Vector(supported); |
| 1077 | } |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 1078 | case CREATE_DISPLAY_EVENT_CONNECTION: { |
| 1079 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Jorim Jaggi | b1e2f8d | 2017-06-08 15:43:59 -0700 | [diff] [blame] | 1080 | sp<IDisplayEventConnection> connection(createDisplayEventConnection( |
| 1081 | static_cast<ISurfaceComposer::VsyncSource>(data.readInt32()))); |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 1082 | reply->writeStrongBinder(IInterface::asBinder(connection)); |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 1083 | return NO_ERROR; |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1084 | } |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 1085 | case CREATE_DISPLAY: { |
| 1086 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Andy McFadden | 8dfa92f | 2012-09-17 18:27:17 -0700 | [diff] [blame] | 1087 | String8 displayName = data.readString8(); |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 1088 | bool secure = bool(data.readInt32()); |
| 1089 | sp<IBinder> display(createDisplay(displayName, secure)); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 1090 | reply->writeStrongBinder(display); |
| 1091 | return NO_ERROR; |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1092 | } |
| 1093 | case DESTROY_DISPLAY: { |
| 1094 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1095 | sp<IBinder> display = data.readStrongBinder(); |
| 1096 | destroyDisplay(display); |
| 1097 | return NO_ERROR; |
| 1098 | } |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 1099 | case GET_PHYSICAL_DISPLAY_TOKEN: { |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 1100 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 1101 | PhysicalDisplayId displayId = data.readUint64(); |
| 1102 | sp<IBinder> display = getPhysicalDisplayToken(displayId); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 1103 | reply->writeStrongBinder(display); |
| 1104 | return NO_ERROR; |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1105 | } |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 1106 | case GET_DISPLAY_CONFIGS: { |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 1107 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 1108 | Vector<DisplayInfo> configs; |
Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 1109 | sp<IBinder> display = data.readStrongBinder(); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 1110 | status_t result = getDisplayConfigs(display, &configs); |
| 1111 | reply->writeInt32(result); |
| 1112 | if (result == NO_ERROR) { |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1113 | reply->writeUint32(static_cast<uint32_t>(configs.size())); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 1114 | for (size_t c = 0; c < configs.size(); ++c) { |
| 1115 | memcpy(reply->writeInplace(sizeof(DisplayInfo)), |
| 1116 | &configs[c], sizeof(DisplayInfo)); |
| 1117 | } |
| 1118 | } |
| 1119 | return NO_ERROR; |
| 1120 | } |
Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 1121 | case GET_DISPLAY_STATS: { |
| 1122 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1123 | DisplayStatInfo stats; |
| 1124 | sp<IBinder> display = data.readStrongBinder(); |
| 1125 | status_t result = getDisplayStats(display, &stats); |
| 1126 | reply->writeInt32(result); |
| 1127 | if (result == NO_ERROR) { |
| 1128 | memcpy(reply->writeInplace(sizeof(DisplayStatInfo)), |
| 1129 | &stats, sizeof(DisplayStatInfo)); |
| 1130 | } |
| 1131 | return NO_ERROR; |
| 1132 | } |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 1133 | case GET_ACTIVE_CONFIG: { |
| 1134 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1135 | sp<IBinder> display = data.readStrongBinder(); |
| 1136 | int id = getActiveConfig(display); |
| 1137 | reply->writeInt32(id); |
| 1138 | return NO_ERROR; |
| 1139 | } |
| 1140 | case SET_ACTIVE_CONFIG: { |
| 1141 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1142 | sp<IBinder> display = data.readStrongBinder(); |
| 1143 | int id = data.readInt32(); |
| 1144 | status_t result = setActiveConfig(display, id); |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 1145 | reply->writeInt32(result); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1146 | return NO_ERROR; |
| 1147 | } |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1148 | case GET_DISPLAY_COLOR_MODES: { |
| 1149 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 1150 | Vector<ColorMode> colorModes; |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1151 | sp<IBinder> display = nullptr; |
| 1152 | status_t result = data.readStrongBinder(&display); |
| 1153 | if (result != NO_ERROR) { |
| 1154 | ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result); |
| 1155 | return result; |
| 1156 | } |
| 1157 | result = getDisplayColorModes(display, &colorModes); |
| 1158 | reply->writeInt32(result); |
| 1159 | if (result == NO_ERROR) { |
| 1160 | reply->writeUint32(static_cast<uint32_t>(colorModes.size())); |
| 1161 | for (size_t i = 0; i < colorModes.size(); ++i) { |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 1162 | reply->writeInt32(static_cast<int32_t>(colorModes[i])); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1163 | } |
| 1164 | } |
| 1165 | return NO_ERROR; |
| 1166 | } |
Daniel Solomon | 42d0456 | 2019-01-20 21:03:19 -0800 | [diff] [blame] | 1167 | case GET_DISPLAY_NATIVE_PRIMARIES: { |
| 1168 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1169 | ui::DisplayPrimaries primaries; |
| 1170 | sp<IBinder> display = nullptr; |
| 1171 | |
| 1172 | status_t result = data.readStrongBinder(&display); |
| 1173 | if (result != NO_ERROR) { |
| 1174 | ALOGE("getDisplayNativePrimaries failed to readStrongBinder: %d", result); |
| 1175 | return result; |
| 1176 | } |
| 1177 | |
| 1178 | result = getDisplayNativePrimaries(display, primaries); |
| 1179 | reply->writeInt32(result); |
| 1180 | if (result == NO_ERROR) { |
| 1181 | memcpy(reply->writeInplace(sizeof(ui::DisplayPrimaries)), &primaries, |
| 1182 | sizeof(ui::DisplayPrimaries)); |
| 1183 | } |
| 1184 | |
| 1185 | return NO_ERROR; |
| 1186 | } |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1187 | case GET_ACTIVE_COLOR_MODE: { |
| 1188 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1189 | sp<IBinder> display = nullptr; |
| 1190 | status_t result = data.readStrongBinder(&display); |
| 1191 | if (result != NO_ERROR) { |
| 1192 | ALOGE("getActiveColorMode failed to readStrongBinder: %d", result); |
| 1193 | return result; |
| 1194 | } |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 1195 | ColorMode colorMode = getActiveColorMode(display); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1196 | result = reply->writeInt32(static_cast<int32_t>(colorMode)); |
| 1197 | return result; |
| 1198 | } |
| 1199 | case SET_ACTIVE_COLOR_MODE: { |
| 1200 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1201 | sp<IBinder> display = nullptr; |
| 1202 | status_t result = data.readStrongBinder(&display); |
| 1203 | if (result != NO_ERROR) { |
| 1204 | ALOGE("getActiveColorMode failed to readStrongBinder: %d", result); |
| 1205 | return result; |
| 1206 | } |
| 1207 | int32_t colorModeInt = 0; |
| 1208 | result = data.readInt32(&colorModeInt); |
| 1209 | if (result != NO_ERROR) { |
| 1210 | ALOGE("setActiveColorMode failed to readInt32: %d", result); |
| 1211 | return result; |
| 1212 | } |
| 1213 | result = setActiveColorMode(display, |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 1214 | static_cast<ColorMode>(colorModeInt)); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1215 | result = reply->writeInt32(result); |
| 1216 | return result; |
| 1217 | } |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 1218 | case CLEAR_ANIMATION_FRAME_STATS: { |
| 1219 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1220 | status_t result = clearAnimationFrameStats(); |
| 1221 | reply->writeInt32(result); |
| 1222 | return NO_ERROR; |
| 1223 | } |
| 1224 | case GET_ANIMATION_FRAME_STATS: { |
| 1225 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1226 | FrameStats stats; |
| 1227 | status_t result = getAnimationFrameStats(&stats); |
| 1228 | reply->write(stats); |
| 1229 | reply->writeInt32(result); |
| 1230 | return NO_ERROR; |
| 1231 | } |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 1232 | case SET_POWER_MODE: { |
| 1233 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1234 | sp<IBinder> display = data.readStrongBinder(); |
| 1235 | int32_t mode = data.readInt32(); |
| 1236 | setPowerMode(display, mode); |
| 1237 | return NO_ERROR; |
| 1238 | } |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 1239 | case GET_HDR_CAPABILITIES: { |
| 1240 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1241 | sp<IBinder> display = nullptr; |
| 1242 | status_t result = data.readStrongBinder(&display); |
| 1243 | if (result != NO_ERROR) { |
| 1244 | ALOGE("getHdrCapabilities failed to readStrongBinder: %d", |
| 1245 | result); |
| 1246 | return result; |
| 1247 | } |
| 1248 | HdrCapabilities capabilities; |
| 1249 | result = getHdrCapabilities(display, &capabilities); |
| 1250 | reply->writeInt32(result); |
| 1251 | if (result == NO_ERROR) { |
Mathias Agopian | e1f5e6f | 2017-02-06 16:34:41 -0800 | [diff] [blame] | 1252 | reply->write(capabilities); |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 1253 | } |
| 1254 | return NO_ERROR; |
| 1255 | } |
Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 1256 | case ENABLE_VSYNC_INJECTIONS: { |
| 1257 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1258 | bool enable = false; |
| 1259 | status_t result = data.readBool(&enable); |
| 1260 | if (result != NO_ERROR) { |
| 1261 | ALOGE("enableVSyncInjections failed to readBool: %d", result); |
| 1262 | return result; |
| 1263 | } |
| 1264 | return enableVSyncInjections(enable); |
| 1265 | } |
| 1266 | case INJECT_VSYNC: { |
| 1267 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1268 | int64_t when = 0; |
| 1269 | status_t result = data.readInt64(&when); |
| 1270 | if (result != NO_ERROR) { |
| 1271 | ALOGE("enableVSyncInjections failed to readInt64: %d", result); |
| 1272 | return result; |
| 1273 | } |
| 1274 | return injectVSync(when); |
| 1275 | } |
Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 1276 | case GET_LAYER_DEBUG_INFO: { |
| 1277 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1278 | std::vector<LayerDebugInfo> outLayers; |
| 1279 | status_t result = getLayerDebugInfo(&outLayers); |
| 1280 | reply->writeInt32(result); |
| 1281 | if (result == NO_ERROR) |
| 1282 | { |
| 1283 | result = reply->writeParcelableVector(outLayers); |
| 1284 | } |
| 1285 | return result; |
| 1286 | } |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1287 | case GET_COMPOSITION_PREFERENCE: { |
| 1288 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 1289 | ui::Dataspace defaultDataspace; |
| 1290 | ui::PixelFormat defaultPixelFormat; |
| 1291 | ui::Dataspace wideColorGamutDataspace; |
| 1292 | ui::PixelFormat wideColorGamutPixelFormat; |
| 1293 | status_t error = |
| 1294 | getCompositionPreference(&defaultDataspace, &defaultPixelFormat, |
| 1295 | &wideColorGamutDataspace, &wideColorGamutPixelFormat); |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1296 | reply->writeInt32(error); |
| 1297 | if (error == NO_ERROR) { |
Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 1298 | reply->writeInt32(static_cast<int32_t>(defaultDataspace)); |
| 1299 | reply->writeInt32(static_cast<int32_t>(defaultPixelFormat)); |
| 1300 | reply->writeInt32(static_cast<int32_t>(wideColorGamutDataspace)); |
Peiyong Lin | aa3da6a | 2018-12-12 02:48:43 -0800 | [diff] [blame] | 1301 | reply->writeInt32(static_cast<int32_t>(wideColorGamutPixelFormat)); |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1302 | } |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 1303 | return error; |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1304 | } |
Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 1305 | case GET_COLOR_MANAGEMENT: { |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 1306 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 1307 | bool result; |
| 1308 | status_t error = getColorManagement(&result); |
| 1309 | if (error == NO_ERROR) { |
| 1310 | reply->writeBool(result); |
| 1311 | } |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 1312 | return error; |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 1313 | } |
Kevin DuBois | 9c0a176 | 2018-10-16 13:32:31 -0700 | [diff] [blame] | 1314 | case GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: { |
| 1315 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1316 | |
| 1317 | sp<IBinder> display = data.readStrongBinder(); |
| 1318 | ui::PixelFormat format; |
| 1319 | ui::Dataspace dataspace; |
| 1320 | uint8_t component = 0; |
| 1321 | auto result = |
| 1322 | getDisplayedContentSamplingAttributes(display, &format, &dataspace, &component); |
| 1323 | if (result == NO_ERROR) { |
| 1324 | reply->writeUint32(static_cast<uint32_t>(format)); |
| 1325 | reply->writeUint32(static_cast<uint32_t>(dataspace)); |
| 1326 | reply->writeUint32(static_cast<uint32_t>(component)); |
| 1327 | } |
| 1328 | return result; |
| 1329 | } |
Kevin DuBois | 74e5377 | 2018-11-19 10:52:38 -0800 | [diff] [blame] | 1330 | case SET_DISPLAY_CONTENT_SAMPLING_ENABLED: { |
| 1331 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1332 | |
| 1333 | sp<IBinder> display = nullptr; |
| 1334 | bool enable = false; |
| 1335 | int8_t componentMask = 0; |
| 1336 | uint64_t maxFrames = 0; |
| 1337 | status_t result = data.readStrongBinder(&display); |
| 1338 | if (result != NO_ERROR) { |
| 1339 | ALOGE("setDisplayContentSamplingEnabled failure in reading Display token: %d", |
| 1340 | result); |
| 1341 | return result; |
| 1342 | } |
| 1343 | |
| 1344 | result = data.readBool(&enable); |
| 1345 | if (result != NO_ERROR) { |
| 1346 | ALOGE("setDisplayContentSamplingEnabled failure in reading enable: %d", result); |
| 1347 | return result; |
| 1348 | } |
| 1349 | |
| 1350 | result = data.readByte(static_cast<int8_t*>(&componentMask)); |
| 1351 | if (result != NO_ERROR) { |
| 1352 | ALOGE("setDisplayContentSamplingEnabled failure in reading component mask: %d", |
| 1353 | result); |
| 1354 | return result; |
| 1355 | } |
| 1356 | |
| 1357 | result = data.readUint64(&maxFrames); |
| 1358 | if (result != NO_ERROR) { |
| 1359 | ALOGE("setDisplayContentSamplingEnabled failure in reading max frames: %d", result); |
| 1360 | return result; |
| 1361 | } |
| 1362 | |
| 1363 | return setDisplayContentSamplingEnabled(display, enable, |
| 1364 | static_cast<uint8_t>(componentMask), maxFrames); |
| 1365 | } |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 1366 | case GET_DISPLAYED_CONTENT_SAMPLE: { |
| 1367 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1368 | |
| 1369 | sp<IBinder> display = data.readStrongBinder(); |
| 1370 | uint64_t maxFrames = 0; |
| 1371 | uint64_t timestamp = 0; |
| 1372 | |
| 1373 | status_t result = data.readUint64(&maxFrames); |
| 1374 | if (result != NO_ERROR) { |
| 1375 | ALOGE("getDisplayedContentSample failure in reading max frames: %d", result); |
| 1376 | return result; |
| 1377 | } |
| 1378 | |
| 1379 | result = data.readUint64(×tamp); |
| 1380 | if (result != NO_ERROR) { |
| 1381 | ALOGE("getDisplayedContentSample failure in reading timestamp: %d", result); |
| 1382 | return result; |
| 1383 | } |
| 1384 | |
| 1385 | DisplayedFrameStats stats; |
| 1386 | result = getDisplayedContentSample(display, maxFrames, timestamp, &stats); |
| 1387 | if (result == NO_ERROR) { |
| 1388 | reply->writeUint64(stats.numFrames); |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 1389 | reply->writeUint64Vector(stats.component_0_sample); |
| 1390 | reply->writeUint64Vector(stats.component_1_sample); |
| 1391 | reply->writeUint64Vector(stats.component_2_sample); |
| 1392 | reply->writeUint64Vector(stats.component_3_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 1393 | } |
| 1394 | return result; |
| 1395 | } |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 1396 | case GET_PROTECTED_CONTENT_SUPPORT: { |
| 1397 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1398 | bool result; |
| 1399 | status_t error = getProtectedContentSupport(&result); |
| 1400 | if (error == NO_ERROR) { |
| 1401 | reply->writeBool(result); |
| 1402 | } |
| 1403 | return error; |
| 1404 | } |
Peiyong Lin | 4f3fddf | 2019-01-24 17:21:24 -0800 | [diff] [blame] | 1405 | case IS_WIDE_COLOR_DISPLAY: { |
| 1406 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1407 | sp<IBinder> display = nullptr; |
| 1408 | status_t error = data.readStrongBinder(&display); |
| 1409 | if (error != NO_ERROR) { |
| 1410 | return error; |
| 1411 | } |
| 1412 | bool result; |
| 1413 | error = isWideColorDisplay(display, &result); |
| 1414 | if (error == NO_ERROR) { |
| 1415 | reply->writeBool(result); |
| 1416 | } |
| 1417 | return error; |
| 1418 | } |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 1419 | case GET_PHYSICAL_DISPLAY_IDS: { |
| 1420 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1421 | return reply->writeUint64Vector(getPhysicalDisplayIds()); |
| 1422 | } |
Dan Stoza | 84ab937 | 2018-12-17 15:27:57 -0800 | [diff] [blame] | 1423 | case ADD_REGION_SAMPLING_LISTENER: { |
| 1424 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1425 | Rect samplingArea; |
| 1426 | status_t result = data.read(samplingArea); |
| 1427 | if (result != NO_ERROR) { |
| 1428 | ALOGE("addRegionSamplingListener: Failed to read sampling area"); |
| 1429 | return result; |
| 1430 | } |
| 1431 | sp<IBinder> stopLayerHandle; |
| 1432 | result = data.readNullableStrongBinder(&stopLayerHandle); |
| 1433 | if (result != NO_ERROR) { |
| 1434 | ALOGE("addRegionSamplingListener: Failed to read stop layer handle"); |
| 1435 | return result; |
| 1436 | } |
| 1437 | sp<IRegionSamplingListener> listener; |
| 1438 | result = data.readNullableStrongBinder(&listener); |
| 1439 | if (result != NO_ERROR) { |
| 1440 | ALOGE("addRegionSamplingListener: Failed to read listener"); |
| 1441 | return result; |
| 1442 | } |
| 1443 | return addRegionSamplingListener(samplingArea, stopLayerHandle, listener); |
| 1444 | } |
| 1445 | case REMOVE_REGION_SAMPLING_LISTENER: { |
| 1446 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1447 | sp<IRegionSamplingListener> listener; |
| 1448 | status_t result = data.readNullableStrongBinder(&listener); |
| 1449 | if (result != NO_ERROR) { |
| 1450 | ALOGE("removeRegionSamplingListener: Failed to read listener"); |
| 1451 | return result; |
| 1452 | } |
| 1453 | return removeRegionSamplingListener(listener); |
| 1454 | } |
Ady Abraham | 838de06 | 2019-02-04 10:24:03 -0800 | [diff] [blame] | 1455 | case SET_ALLOWED_DISPLAY_CONFIGS: { |
| 1456 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1457 | sp<IBinder> displayToken = data.readStrongBinder(); |
| 1458 | std::vector<int32_t> allowedConfigs; |
| 1459 | data.readInt32Vector(&allowedConfigs); |
| 1460 | status_t result = setAllowedDisplayConfigs(displayToken, allowedConfigs); |
| 1461 | reply->writeInt32(result); |
| 1462 | return result; |
| 1463 | } |
Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 1464 | case GET_ALLOWED_DISPLAY_CONFIGS: { |
| 1465 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1466 | sp<IBinder> displayToken = data.readStrongBinder(); |
| 1467 | std::vector<int32_t> allowedConfigs; |
| 1468 | status_t result = getAllowedDisplayConfigs(displayToken, &allowedConfigs); |
| 1469 | reply->writeInt32Vector(allowedConfigs); |
| 1470 | reply->writeInt32(result); |
| 1471 | return result; |
| 1472 | } |
Dan Gittik | 57e63c5 | 2019-01-18 16:37:54 +0000 | [diff] [blame] | 1473 | case GET_DISPLAY_BRIGHTNESS_SUPPORT: { |
| 1474 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1475 | sp<IBinder> displayToken; |
| 1476 | status_t error = data.readNullableStrongBinder(&displayToken); |
| 1477 | if (error != NO_ERROR) { |
| 1478 | ALOGE("getDisplayBrightnessSupport: failed to read display token: %d", error); |
| 1479 | return error; |
| 1480 | } |
| 1481 | bool support = false; |
| 1482 | error = getDisplayBrightnessSupport(displayToken, &support); |
| 1483 | reply->writeBool(support); |
| 1484 | return error; |
| 1485 | } |
| 1486 | case SET_DISPLAY_BRIGHTNESS: { |
| 1487 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1488 | sp<IBinder> displayToken; |
| 1489 | status_t error = data.readNullableStrongBinder(&displayToken); |
| 1490 | if (error != NO_ERROR) { |
| 1491 | ALOGE("setDisplayBrightness: failed to read display token: %d", error); |
| 1492 | return error; |
| 1493 | } |
| 1494 | float brightness = -1.0f; |
| 1495 | error = data.readFloat(&brightness); |
| 1496 | if (error != NO_ERROR) { |
| 1497 | ALOGE("setDisplayBrightness: failed to read brightness: %d", error); |
| 1498 | return error; |
| 1499 | } |
| 1500 | return setDisplayBrightness(displayToken, brightness); |
| 1501 | } |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1502 | default: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 1503 | return BBinder::onTransact(code, data, reply, flags); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1504 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1505 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1506 | } |
| 1507 | |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 1508 | } // namespace android |