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> |
| 24 | #include <binder/IMemory.h> |
| 25 | #include <binder/IPCThreadState.h> |
| 26 | #include <binder/IServiceManager.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 28 | #include <gui/IDisplayEventConnection.h> |
Mathias Agopian | 2b5dd40 | 2017-02-07 17:36:19 -0800 | [diff] [blame] | 29 | #include <gui/IGraphicBufferAlloc.h> |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 30 | #include <gui/IGraphicBufferProducer.h> |
Mathias Agopian | 2b5dd40 | 2017-02-07 17:36:19 -0800 | [diff] [blame] | 31 | #include <gui/ISurfaceComposer.h> |
| 32 | #include <gui/ISurfaceComposerClient.h> |
Mathias Agopian | 90ac799 | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 33 | |
| 34 | #include <private/gui/LayerState.h> |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 35 | |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 36 | #include <system/graphics.h> |
| 37 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | #include <ui/DisplayInfo.h> |
Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 39 | #include <ui/DisplayStatInfo.h> |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 40 | #include <ui/HdrCapabilities.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 42 | #include <utils/Log.h> |
Mathias Agopian | 9cce325 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 43 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | // --------------------------------------------------------------------------- |
| 45 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 46 | namespace android { |
| 47 | |
| 48 | class BpSurfaceComposer : public BpInterface<ISurfaceComposer> |
| 49 | { |
| 50 | public: |
Chih-Hung Hsieh | e2347b7 | 2016-04-25 15:41:05 -0700 | [diff] [blame] | 51 | explicit BpSurfaceComposer(const sp<IBinder>& impl) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | : BpInterface<ISurfaceComposer>(impl) |
| 53 | { |
| 54 | } |
| 55 | |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 56 | virtual ~BpSurfaceComposer(); |
| 57 | |
Mathias Agopian | 7e27f05 | 2010-05-28 14:22:23 -0700 | [diff] [blame] | 58 | virtual sp<ISurfaceComposerClient> createConnection() |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | Parcel data, reply; |
| 61 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 62 | remote()->transact(BnSurfaceComposer::CREATE_CONNECTION, data, &reply); |
Mathias Agopian | 7e27f05 | 2010-05-28 14:22:23 -0700 | [diff] [blame] | 63 | return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder()); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 64 | } |
| 65 | |
Robert Carr | 1db73f6 | 2016-12-21 12:58:51 -0800 | [diff] [blame] | 66 | virtual sp<ISurfaceComposerClient> createScopedConnection( |
| 67 | const sp<IGraphicBufferProducer>& parent) |
| 68 | { |
| 69 | Parcel data, reply; |
| 70 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 71 | data.writeStrongBinder(IInterface::asBinder(parent)); |
| 72 | remote()->transact(BnSurfaceComposer::CREATE_SCOPED_CONNECTION, data, &reply); |
| 73 | return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder()); |
| 74 | } |
| 75 | |
Jamie Gennis | 9a78c90 | 2011-01-12 18:30:40 -0800 | [diff] [blame] | 76 | virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc() |
| 77 | { |
Jamie Gennis | 9a78c90 | 2011-01-12 18:30:40 -0800 | [diff] [blame] | 78 | Parcel data, reply; |
| 79 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 80 | remote()->transact(BnSurfaceComposer::CREATE_GRAPHIC_BUFFER_ALLOC, data, &reply); |
| 81 | return interface_cast<IGraphicBufferAlloc>(reply.readStrongBinder()); |
| 82 | } |
| 83 | |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 84 | virtual void setTransactionState( |
| 85 | const Vector<ComposerState>& state, |
| 86 | const Vector<DisplayState>& displays, |
| 87 | uint32_t flags) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 88 | { |
| 89 | Parcel data, reply; |
| 90 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 91 | |
| 92 | data.writeUint32(static_cast<uint32_t>(state.size())); |
| 93 | for (const auto& s : state) { |
| 94 | s.write(data); |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 95 | } |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 96 | |
| 97 | data.writeUint32(static_cast<uint32_t>(displays.size())); |
| 98 | for (const auto& d : displays) { |
| 99 | d.write(data); |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 100 | } |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 101 | |
| 102 | data.writeUint32(flags); |
Jamie Gennis | b8d69a5 | 2011-10-10 15:48:06 -0700 | [diff] [blame] | 103 | remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | virtual void bootFinished() |
| 107 | { |
| 108 | Parcel data, reply; |
| 109 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 110 | remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply); |
| 111 | } |
| 112 | |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 113 | virtual status_t captureScreen(const sp<IBinder>& display, |
| 114 | const sp<IGraphicBufferProducer>& producer, |
Dan Stoza | c187900 | 2014-05-22 15:59:05 -0700 | [diff] [blame] | 115 | Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight, |
Robert Carr | ae06083 | 2016-11-28 10:51:00 -0800 | [diff] [blame] | 116 | int32_t minLayerZ, int32_t maxLayerZ, |
Riley Andrews | c3ebe66 | 2014-09-04 16:20:31 -0700 | [diff] [blame] | 117 | bool useIdentityTransform, |
| 118 | ISurfaceComposer::Rotation rotation) |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 119 | { |
| 120 | Parcel data, reply; |
| 121 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 122 | data.writeStrongBinder(display); |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 123 | data.writeStrongBinder(IInterface::asBinder(producer)); |
Dan Stoza | c187900 | 2014-05-22 15:59:05 -0700 | [diff] [blame] | 124 | data.write(sourceCrop); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 125 | data.writeUint32(reqWidth); |
| 126 | data.writeUint32(reqHeight); |
Robert Carr | ae06083 | 2016-11-28 10:51:00 -0800 | [diff] [blame] | 127 | data.writeInt32(minLayerZ); |
| 128 | data.writeInt32(maxLayerZ); |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 129 | data.writeInt32(static_cast<int32_t>(useIdentityTransform)); |
Riley Andrews | c3ebe66 | 2014-09-04 16:20:31 -0700 | [diff] [blame] | 130 | data.writeInt32(static_cast<int32_t>(rotation)); |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 131 | remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply); |
| 132 | return reply.readInt32(); |
| 133 | } |
| 134 | |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 135 | virtual bool authenticateSurfaceTexture( |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 136 | const sp<IGraphicBufferProducer>& bufferProducer) const |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 137 | { |
| 138 | Parcel data, reply; |
| 139 | int err = NO_ERROR; |
| 140 | err = data.writeInterfaceToken( |
| 141 | ISurfaceComposer::getInterfaceDescriptor()); |
| 142 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 143 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing " |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 144 | "interface descriptor: %s (%d)", strerror(-err), -err); |
| 145 | return false; |
| 146 | } |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 147 | err = data.writeStrongBinder(IInterface::asBinder(bufferProducer)); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 148 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 149 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing " |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 150 | "strong binder to parcel: %s (%d)", strerror(-err), -err); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 151 | return false; |
| 152 | } |
| 153 | err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data, |
| 154 | &reply); |
| 155 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 156 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error " |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 157 | "performing transaction: %s (%d)", strerror(-err), -err); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 158 | return false; |
| 159 | } |
| 160 | int32_t result = 0; |
| 161 | err = reply.readInt32(&result); |
| 162 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 163 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error " |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 164 | "retrieving result: %s (%d)", strerror(-err), -err); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 165 | return false; |
| 166 | } |
| 167 | return result != 0; |
| 168 | } |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 169 | |
Brian Anderson | 069b365 | 2016-07-22 10:32:47 -0700 | [diff] [blame] | 170 | virtual status_t getSupportedFrameTimestamps( |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 171 | std::vector<FrameEvent>* outSupported) const { |
Brian Anderson | 069b365 | 2016-07-22 10:32:47 -0700 | [diff] [blame] | 172 | if (!outSupported) { |
| 173 | return UNEXPECTED_NULL; |
| 174 | } |
| 175 | outSupported->clear(); |
| 176 | |
| 177 | Parcel data, reply; |
| 178 | |
| 179 | status_t err = data.writeInterfaceToken( |
| 180 | ISurfaceComposer::getInterfaceDescriptor()); |
| 181 | if (err != NO_ERROR) { |
| 182 | return err; |
| 183 | } |
| 184 | |
| 185 | err = remote()->transact( |
| 186 | BnSurfaceComposer::GET_SUPPORTED_FRAME_TIMESTAMPS, |
| 187 | data, &reply); |
| 188 | if (err != NO_ERROR) { |
| 189 | return err; |
| 190 | } |
| 191 | |
| 192 | int32_t result = 0; |
| 193 | err = reply.readInt32(&result); |
| 194 | if (err != NO_ERROR) { |
| 195 | return err; |
| 196 | } |
| 197 | if (result != NO_ERROR) { |
| 198 | return result; |
| 199 | } |
| 200 | |
| 201 | std::vector<int32_t> supported; |
| 202 | err = reply.readInt32Vector(&supported); |
| 203 | if (err != NO_ERROR) { |
| 204 | return err; |
| 205 | } |
| 206 | |
| 207 | outSupported->reserve(supported.size()); |
| 208 | for (int32_t s : supported) { |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 209 | outSupported->push_back(static_cast<FrameEvent>(s)); |
Brian Anderson | 069b365 | 2016-07-22 10:32:47 -0700 | [diff] [blame] | 210 | } |
| 211 | return NO_ERROR; |
| 212 | } |
| 213 | |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 214 | virtual sp<IDisplayEventConnection> createDisplayEventConnection() |
| 215 | { |
| 216 | Parcel data, reply; |
| 217 | sp<IDisplayEventConnection> result; |
| 218 | int err = data.writeInterfaceToken( |
| 219 | ISurfaceComposer::getInterfaceDescriptor()); |
| 220 | if (err != NO_ERROR) { |
| 221 | return result; |
| 222 | } |
| 223 | err = remote()->transact( |
| 224 | BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION, |
| 225 | data, &reply); |
| 226 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 227 | ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing " |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 228 | "transaction: %s (%d)", strerror(-err), -err); |
| 229 | return result; |
| 230 | } |
| 231 | result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder()); |
| 232 | return result; |
| 233 | } |
Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 234 | |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 235 | virtual sp<IBinder> createDisplay(const String8& displayName, bool secure) |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 236 | { |
| 237 | Parcel data, reply; |
| 238 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Andy McFadden | 8dfa92f | 2012-09-17 18:27:17 -0700 | [diff] [blame] | 239 | data.writeString8(displayName); |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 240 | data.writeInt32(secure ? 1 : 0); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 241 | remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply); |
| 242 | return reply.readStrongBinder(); |
| 243 | } |
| 244 | |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 245 | virtual void destroyDisplay(const sp<IBinder>& display) |
| 246 | { |
| 247 | Parcel data, reply; |
| 248 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 249 | data.writeStrongBinder(display); |
| 250 | remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply); |
| 251 | } |
| 252 | |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 253 | virtual sp<IBinder> getBuiltInDisplay(int32_t id) |
| 254 | { |
| 255 | Parcel data, reply; |
| 256 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 257 | data.writeInt32(id); |
| 258 | remote()->transact(BnSurfaceComposer::GET_BUILT_IN_DISPLAY, data, &reply); |
| 259 | return reply.readStrongBinder(); |
| 260 | } |
| 261 | |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 262 | virtual void setPowerMode(const sp<IBinder>& display, int mode) |
Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 263 | { |
| 264 | Parcel data, reply; |
| 265 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Andy McFadden | c01a79d | 2012-09-27 16:02:06 -0700 | [diff] [blame] | 266 | data.writeStrongBinder(display); |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 267 | data.writeInt32(mode); |
| 268 | remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply); |
Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 269 | } |
Mathias Agopian | 3094df3 | 2012-06-18 18:06:45 -0700 | [diff] [blame] | 270 | |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 271 | virtual status_t getDisplayConfigs(const sp<IBinder>& display, |
| 272 | Vector<DisplayInfo>* configs) |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 273 | { |
| 274 | Parcel data, reply; |
| 275 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 276 | data.writeStrongBinder(display); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 277 | remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply); |
| 278 | status_t result = reply.readInt32(); |
| 279 | if (result == NO_ERROR) { |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 280 | size_t numConfigs = reply.readUint32(); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 281 | configs->clear(); |
| 282 | configs->resize(numConfigs); |
| 283 | for (size_t c = 0; c < numConfigs; ++c) { |
| 284 | memcpy(&(configs->editItemAt(c)), |
| 285 | reply.readInplace(sizeof(DisplayInfo)), |
| 286 | sizeof(DisplayInfo)); |
| 287 | } |
| 288 | } |
| 289 | return result; |
| 290 | } |
| 291 | |
Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 292 | virtual status_t getDisplayStats(const sp<IBinder>& display, |
| 293 | DisplayStatInfo* stats) |
| 294 | { |
| 295 | Parcel data, reply; |
| 296 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 297 | data.writeStrongBinder(display); |
| 298 | remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply); |
| 299 | status_t result = reply.readInt32(); |
| 300 | if (result == NO_ERROR) { |
| 301 | memcpy(stats, |
| 302 | reply.readInplace(sizeof(DisplayStatInfo)), |
| 303 | sizeof(DisplayStatInfo)); |
| 304 | } |
| 305 | return result; |
| 306 | } |
| 307 | |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 308 | virtual int getActiveConfig(const sp<IBinder>& display) |
| 309 | { |
| 310 | Parcel data, reply; |
| 311 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 312 | data.writeStrongBinder(display); |
| 313 | remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply); |
| 314 | return reply.readInt32(); |
| 315 | } |
| 316 | |
| 317 | virtual status_t setActiveConfig(const sp<IBinder>& display, int id) |
| 318 | { |
| 319 | Parcel data, reply; |
| 320 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 321 | data.writeStrongBinder(display); |
| 322 | data.writeInt32(id); |
| 323 | remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply); |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 324 | return reply.readInt32(); |
| 325 | } |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 326 | |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 327 | virtual status_t getDisplayColorModes(const sp<IBinder>& display, |
| 328 | Vector<android_color_mode_t>* outColorModes) { |
| 329 | Parcel data, reply; |
| 330 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 331 | if (result != NO_ERROR) { |
| 332 | ALOGE("getDisplayColorModes failed to writeInterfaceToken: %d", result); |
| 333 | return result; |
| 334 | } |
| 335 | result = data.writeStrongBinder(display); |
| 336 | if (result != NO_ERROR) { |
| 337 | ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result); |
| 338 | return result; |
| 339 | } |
| 340 | result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply); |
| 341 | if (result != NO_ERROR) { |
| 342 | ALOGE("getDisplayColorModes failed to transact: %d", result); |
| 343 | return result; |
| 344 | } |
| 345 | result = static_cast<status_t>(reply.readInt32()); |
| 346 | if (result == NO_ERROR) { |
| 347 | size_t numModes = reply.readUint32(); |
| 348 | outColorModes->clear(); |
| 349 | outColorModes->resize(numModes); |
| 350 | for (size_t i = 0; i < numModes; ++i) { |
| 351 | outColorModes->replaceAt(static_cast<android_color_mode_t>(reply.readInt32()), i); |
| 352 | } |
| 353 | } |
| 354 | return result; |
| 355 | } |
| 356 | |
| 357 | virtual android_color_mode_t getActiveColorMode(const sp<IBinder>& display) { |
| 358 | Parcel data, reply; |
| 359 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 360 | if (result != NO_ERROR) { |
| 361 | ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result); |
| 362 | return static_cast<android_color_mode_t>(result); |
| 363 | } |
| 364 | result = data.writeStrongBinder(display); |
| 365 | if (result != NO_ERROR) { |
| 366 | ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result); |
| 367 | return static_cast<android_color_mode_t>(result); |
| 368 | } |
| 369 | result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply); |
| 370 | if (result != NO_ERROR) { |
| 371 | ALOGE("getActiveColorMode failed to transact: %d", result); |
| 372 | return static_cast<android_color_mode_t>(result); |
| 373 | } |
| 374 | return static_cast<android_color_mode_t>(reply.readInt32()); |
| 375 | } |
| 376 | |
| 377 | virtual status_t setActiveColorMode(const sp<IBinder>& display, |
| 378 | android_color_mode_t colorMode) { |
| 379 | Parcel data, reply; |
| 380 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 381 | if (result != NO_ERROR) { |
| 382 | ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result); |
| 383 | return result; |
| 384 | } |
| 385 | result = data.writeStrongBinder(display); |
| 386 | if (result != NO_ERROR) { |
| 387 | ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result); |
| 388 | return result; |
| 389 | } |
| 390 | result = data.writeInt32(colorMode); |
| 391 | if (result != NO_ERROR) { |
| 392 | ALOGE("setActiveColorMode failed to writeInt32: %d", result); |
| 393 | return result; |
| 394 | } |
| 395 | result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply); |
| 396 | if (result != NO_ERROR) { |
| 397 | ALOGE("setActiveColorMode failed to transact: %d", result); |
| 398 | return result; |
| 399 | } |
| 400 | return static_cast<status_t>(reply.readInt32()); |
| 401 | } |
| 402 | |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 403 | virtual status_t clearAnimationFrameStats() { |
| 404 | Parcel data, reply; |
| 405 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 406 | remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply); |
| 407 | return reply.readInt32(); |
| 408 | } |
| 409 | |
| 410 | virtual status_t getAnimationFrameStats(FrameStats* outStats) const { |
| 411 | Parcel data, reply; |
| 412 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 413 | remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply); |
| 414 | reply.read(*outStats); |
| 415 | return reply.readInt32(); |
| 416 | } |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 417 | |
| 418 | virtual status_t getHdrCapabilities(const sp<IBinder>& display, |
| 419 | HdrCapabilities* outCapabilities) const { |
| 420 | Parcel data, reply; |
| 421 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 422 | status_t result = data.writeStrongBinder(display); |
| 423 | if (result != NO_ERROR) { |
| 424 | ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result); |
| 425 | return result; |
| 426 | } |
| 427 | result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES, |
| 428 | data, &reply); |
| 429 | if (result != NO_ERROR) { |
| 430 | ALOGE("getHdrCapabilities failed to transact: %d", result); |
| 431 | return result; |
| 432 | } |
| 433 | result = reply.readInt32(); |
| 434 | if (result == NO_ERROR) { |
Mathias Agopian | e1f5e6f | 2017-02-06 16:34:41 -0800 | [diff] [blame^] | 435 | result = reply.read(*outCapabilities); |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 436 | } |
| 437 | return result; |
| 438 | } |
Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 439 | |
| 440 | virtual status_t enableVSyncInjections(bool enable) { |
| 441 | Parcel data, reply; |
| 442 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 443 | if (result != NO_ERROR) { |
| 444 | ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result); |
| 445 | return result; |
| 446 | } |
| 447 | result = data.writeBool(enable); |
| 448 | if (result != NO_ERROR) { |
| 449 | ALOGE("enableVSyncInjections failed to writeBool: %d", result); |
| 450 | return result; |
| 451 | } |
| 452 | result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS, |
| 453 | data, &reply, TF_ONE_WAY); |
| 454 | if (result != NO_ERROR) { |
| 455 | ALOGE("enableVSyncInjections failed to transact: %d", result); |
| 456 | return result; |
| 457 | } |
| 458 | return result; |
| 459 | } |
| 460 | |
| 461 | virtual status_t injectVSync(nsecs_t when) { |
| 462 | Parcel data, reply; |
| 463 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 464 | if (result != NO_ERROR) { |
| 465 | ALOGE("injectVSync failed to writeInterfaceToken: %d", result); |
| 466 | return result; |
| 467 | } |
| 468 | result = data.writeInt64(when); |
| 469 | if (result != NO_ERROR) { |
| 470 | ALOGE("injectVSync failed to writeInt64: %d", result); |
| 471 | return result; |
| 472 | } |
| 473 | result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply, TF_ONE_WAY); |
| 474 | if (result != NO_ERROR) { |
| 475 | ALOGE("injectVSync failed to transact: %d", result); |
| 476 | return result; |
| 477 | } |
| 478 | return result; |
| 479 | } |
| 480 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 481 | }; |
| 482 | |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 483 | // Out-of-line virtual method definition to trigger vtable emission in this |
| 484 | // translation unit (see clang warning -Wweak-vtables) |
| 485 | BpSurfaceComposer::~BpSurfaceComposer() {} |
| 486 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 487 | IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer"); |
| 488 | |
| 489 | // ---------------------------------------------------------------------- |
| 490 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 491 | status_t BnSurfaceComposer::onTransact( |
| 492 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 493 | { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 494 | switch(code) { |
| 495 | case CREATE_CONNECTION: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 496 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 497 | sp<IBinder> b = IInterface::asBinder(createConnection()); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 498 | reply->writeStrongBinder(b); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 499 | return NO_ERROR; |
| 500 | } |
Robert Carr | 1db73f6 | 2016-12-21 12:58:51 -0800 | [diff] [blame] | 501 | case CREATE_SCOPED_CONNECTION: { |
| 502 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 503 | sp<IGraphicBufferProducer> bufferProducer = |
| 504 | interface_cast<IGraphicBufferProducer>(data.readStrongBinder()); |
| 505 | sp<IBinder> b = IInterface::asBinder(createScopedConnection(bufferProducer)); |
| 506 | reply->writeStrongBinder(b); |
| 507 | return NO_ERROR; |
| 508 | } |
Jamie Gennis | 9a78c90 | 2011-01-12 18:30:40 -0800 | [diff] [blame] | 509 | case CREATE_GRAPHIC_BUFFER_ALLOC: { |
| 510 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 511 | sp<IBinder> b = IInterface::asBinder(createGraphicBufferAlloc()); |
Jamie Gennis | 9a78c90 | 2011-01-12 18:30:40 -0800 | [diff] [blame] | 512 | reply->writeStrongBinder(b); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 513 | return NO_ERROR; |
| 514 | } |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 515 | case SET_TRANSACTION_STATE: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 516 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 517 | |
| 518 | size_t count = data.readUint32(); |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 519 | if (count > data.dataSize()) { |
| 520 | return BAD_VALUE; |
| 521 | } |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 522 | ComposerState s; |
| 523 | Vector<ComposerState> state; |
| 524 | state.setCapacity(count); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 525 | for (size_t i = 0; i < count; i++) { |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 526 | if (s.read(data) == BAD_VALUE) { |
| 527 | return BAD_VALUE; |
| 528 | } |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 529 | state.add(s); |
| 530 | } |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 531 | |
| 532 | count = data.readUint32(); |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 533 | if (count > data.dataSize()) { |
| 534 | return BAD_VALUE; |
| 535 | } |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 536 | DisplayState d; |
| 537 | Vector<DisplayState> displays; |
| 538 | displays.setCapacity(count); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 539 | for (size_t i = 0; i < count; i++) { |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 540 | if (d.read(data) == BAD_VALUE) { |
| 541 | return BAD_VALUE; |
| 542 | } |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 543 | displays.add(d); |
| 544 | } |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 545 | |
| 546 | uint32_t stateFlags = data.readUint32(); |
| 547 | setTransactionState(state, displays, stateFlags); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 548 | return NO_ERROR; |
| 549 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 550 | case BOOT_FINISHED: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 551 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 552 | bootFinished(); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 553 | return NO_ERROR; |
| 554 | } |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 555 | case CAPTURE_SCREEN: { |
| 556 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 557 | sp<IBinder> display = data.readStrongBinder(); |
| 558 | sp<IGraphicBufferProducer> producer = |
| 559 | interface_cast<IGraphicBufferProducer>(data.readStrongBinder()); |
Pablo Ceballos | 60d6922 | 2015-08-07 14:47:20 -0700 | [diff] [blame] | 560 | Rect sourceCrop(Rect::EMPTY_RECT); |
Dan Stoza | c187900 | 2014-05-22 15:59:05 -0700 | [diff] [blame] | 561 | data.read(sourceCrop); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 562 | uint32_t reqWidth = data.readUint32(); |
| 563 | uint32_t reqHeight = data.readUint32(); |
Robert Carr | ae06083 | 2016-11-28 10:51:00 -0800 | [diff] [blame] | 564 | int32_t minLayerZ = data.readInt32(); |
| 565 | int32_t maxLayerZ = data.readInt32(); |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 566 | bool useIdentityTransform = static_cast<bool>(data.readInt32()); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 567 | int32_t rotation = data.readInt32(); |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 568 | |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 569 | status_t res = captureScreen(display, producer, |
Dan Stoza | c187900 | 2014-05-22 15:59:05 -0700 | [diff] [blame] | 570 | sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ, |
Riley Andrews | c3ebe66 | 2014-09-04 16:20:31 -0700 | [diff] [blame] | 571 | useIdentityTransform, |
| 572 | static_cast<ISurfaceComposer::Rotation>(rotation)); |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 573 | reply->writeInt32(res); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 574 | return NO_ERROR; |
| 575 | } |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 576 | case AUTHENTICATE_SURFACE: { |
| 577 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 578 | sp<IGraphicBufferProducer> bufferProducer = |
| 579 | interface_cast<IGraphicBufferProducer>(data.readStrongBinder()); |
| 580 | int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0; |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 581 | reply->writeInt32(result); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 582 | return NO_ERROR; |
| 583 | } |
Brian Anderson | 069b365 | 2016-07-22 10:32:47 -0700 | [diff] [blame] | 584 | case GET_SUPPORTED_FRAME_TIMESTAMPS: { |
| 585 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 586 | std::vector<FrameEvent> supportedTimestamps; |
Brian Anderson | 069b365 | 2016-07-22 10:32:47 -0700 | [diff] [blame] | 587 | status_t result = getSupportedFrameTimestamps(&supportedTimestamps); |
| 588 | status_t err = reply->writeInt32(result); |
| 589 | if (err != NO_ERROR) { |
| 590 | return err; |
| 591 | } |
| 592 | if (result != NO_ERROR) { |
| 593 | return result; |
| 594 | } |
| 595 | |
| 596 | std::vector<int32_t> supported; |
| 597 | supported.reserve(supportedTimestamps.size()); |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 598 | for (FrameEvent s : supportedTimestamps) { |
Brian Anderson | 069b365 | 2016-07-22 10:32:47 -0700 | [diff] [blame] | 599 | supported.push_back(static_cast<int32_t>(s)); |
| 600 | } |
| 601 | return reply->writeInt32Vector(supported); |
| 602 | } |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 603 | case CREATE_DISPLAY_EVENT_CONNECTION: { |
| 604 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 605 | sp<IDisplayEventConnection> connection(createDisplayEventConnection()); |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 606 | reply->writeStrongBinder(IInterface::asBinder(connection)); |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 607 | return NO_ERROR; |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 608 | } |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 609 | case CREATE_DISPLAY: { |
| 610 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Andy McFadden | 8dfa92f | 2012-09-17 18:27:17 -0700 | [diff] [blame] | 611 | String8 displayName = data.readString8(); |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 612 | bool secure = bool(data.readInt32()); |
| 613 | sp<IBinder> display(createDisplay(displayName, secure)); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 614 | reply->writeStrongBinder(display); |
| 615 | return NO_ERROR; |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 616 | } |
| 617 | case DESTROY_DISPLAY: { |
| 618 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 619 | sp<IBinder> display = data.readStrongBinder(); |
| 620 | destroyDisplay(display); |
| 621 | return NO_ERROR; |
| 622 | } |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 623 | case GET_BUILT_IN_DISPLAY: { |
| 624 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 625 | int32_t id = data.readInt32(); |
| 626 | sp<IBinder> display(getBuiltInDisplay(id)); |
| 627 | reply->writeStrongBinder(display); |
| 628 | return NO_ERROR; |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 629 | } |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 630 | case GET_DISPLAY_CONFIGS: { |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 631 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 632 | Vector<DisplayInfo> configs; |
Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 633 | sp<IBinder> display = data.readStrongBinder(); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 634 | status_t result = getDisplayConfigs(display, &configs); |
| 635 | reply->writeInt32(result); |
| 636 | if (result == NO_ERROR) { |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 637 | reply->writeUint32(static_cast<uint32_t>(configs.size())); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 638 | for (size_t c = 0; c < configs.size(); ++c) { |
| 639 | memcpy(reply->writeInplace(sizeof(DisplayInfo)), |
| 640 | &configs[c], sizeof(DisplayInfo)); |
| 641 | } |
| 642 | } |
| 643 | return NO_ERROR; |
| 644 | } |
Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 645 | case GET_DISPLAY_STATS: { |
| 646 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 647 | DisplayStatInfo stats; |
| 648 | sp<IBinder> display = data.readStrongBinder(); |
| 649 | status_t result = getDisplayStats(display, &stats); |
| 650 | reply->writeInt32(result); |
| 651 | if (result == NO_ERROR) { |
| 652 | memcpy(reply->writeInplace(sizeof(DisplayStatInfo)), |
| 653 | &stats, sizeof(DisplayStatInfo)); |
| 654 | } |
| 655 | return NO_ERROR; |
| 656 | } |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 657 | case GET_ACTIVE_CONFIG: { |
| 658 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 659 | sp<IBinder> display = data.readStrongBinder(); |
| 660 | int id = getActiveConfig(display); |
| 661 | reply->writeInt32(id); |
| 662 | return NO_ERROR; |
| 663 | } |
| 664 | case SET_ACTIVE_CONFIG: { |
| 665 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 666 | sp<IBinder> display = data.readStrongBinder(); |
| 667 | int id = data.readInt32(); |
| 668 | status_t result = setActiveConfig(display, id); |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 669 | reply->writeInt32(result); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 670 | return NO_ERROR; |
| 671 | } |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 672 | case GET_DISPLAY_COLOR_MODES: { |
| 673 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 674 | Vector<android_color_mode_t> colorModes; |
| 675 | sp<IBinder> display = nullptr; |
| 676 | status_t result = data.readStrongBinder(&display); |
| 677 | if (result != NO_ERROR) { |
| 678 | ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result); |
| 679 | return result; |
| 680 | } |
| 681 | result = getDisplayColorModes(display, &colorModes); |
| 682 | reply->writeInt32(result); |
| 683 | if (result == NO_ERROR) { |
| 684 | reply->writeUint32(static_cast<uint32_t>(colorModes.size())); |
| 685 | for (size_t i = 0; i < colorModes.size(); ++i) { |
| 686 | reply->writeInt32(colorModes[i]); |
| 687 | } |
| 688 | } |
| 689 | return NO_ERROR; |
| 690 | } |
| 691 | case GET_ACTIVE_COLOR_MODE: { |
| 692 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 693 | sp<IBinder> display = nullptr; |
| 694 | status_t result = data.readStrongBinder(&display); |
| 695 | if (result != NO_ERROR) { |
| 696 | ALOGE("getActiveColorMode failed to readStrongBinder: %d", result); |
| 697 | return result; |
| 698 | } |
| 699 | android_color_mode_t colorMode = getActiveColorMode(display); |
| 700 | result = reply->writeInt32(static_cast<int32_t>(colorMode)); |
| 701 | return result; |
| 702 | } |
| 703 | case SET_ACTIVE_COLOR_MODE: { |
| 704 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 705 | sp<IBinder> display = nullptr; |
| 706 | status_t result = data.readStrongBinder(&display); |
| 707 | if (result != NO_ERROR) { |
| 708 | ALOGE("getActiveColorMode failed to readStrongBinder: %d", result); |
| 709 | return result; |
| 710 | } |
| 711 | int32_t colorModeInt = 0; |
| 712 | result = data.readInt32(&colorModeInt); |
| 713 | if (result != NO_ERROR) { |
| 714 | ALOGE("setActiveColorMode failed to readInt32: %d", result); |
| 715 | return result; |
| 716 | } |
| 717 | result = setActiveColorMode(display, |
| 718 | static_cast<android_color_mode_t>(colorModeInt)); |
| 719 | result = reply->writeInt32(result); |
| 720 | return result; |
| 721 | } |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 722 | case CLEAR_ANIMATION_FRAME_STATS: { |
| 723 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 724 | status_t result = clearAnimationFrameStats(); |
| 725 | reply->writeInt32(result); |
| 726 | return NO_ERROR; |
| 727 | } |
| 728 | case GET_ANIMATION_FRAME_STATS: { |
| 729 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 730 | FrameStats stats; |
| 731 | status_t result = getAnimationFrameStats(&stats); |
| 732 | reply->write(stats); |
| 733 | reply->writeInt32(result); |
| 734 | return NO_ERROR; |
| 735 | } |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 736 | case SET_POWER_MODE: { |
| 737 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 738 | sp<IBinder> display = data.readStrongBinder(); |
| 739 | int32_t mode = data.readInt32(); |
| 740 | setPowerMode(display, mode); |
| 741 | return NO_ERROR; |
| 742 | } |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 743 | case GET_HDR_CAPABILITIES: { |
| 744 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 745 | sp<IBinder> display = nullptr; |
| 746 | status_t result = data.readStrongBinder(&display); |
| 747 | if (result != NO_ERROR) { |
| 748 | ALOGE("getHdrCapabilities failed to readStrongBinder: %d", |
| 749 | result); |
| 750 | return result; |
| 751 | } |
| 752 | HdrCapabilities capabilities; |
| 753 | result = getHdrCapabilities(display, &capabilities); |
| 754 | reply->writeInt32(result); |
| 755 | if (result == NO_ERROR) { |
Mathias Agopian | e1f5e6f | 2017-02-06 16:34:41 -0800 | [diff] [blame^] | 756 | reply->write(capabilities); |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 757 | } |
| 758 | return NO_ERROR; |
| 759 | } |
Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 760 | case ENABLE_VSYNC_INJECTIONS: { |
| 761 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 762 | bool enable = false; |
| 763 | status_t result = data.readBool(&enable); |
| 764 | if (result != NO_ERROR) { |
| 765 | ALOGE("enableVSyncInjections failed to readBool: %d", result); |
| 766 | return result; |
| 767 | } |
| 768 | return enableVSyncInjections(enable); |
| 769 | } |
| 770 | case INJECT_VSYNC: { |
| 771 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 772 | int64_t when = 0; |
| 773 | status_t result = data.readInt64(&when); |
| 774 | if (result != NO_ERROR) { |
| 775 | ALOGE("enableVSyncInjections failed to readInt64: %d", result); |
| 776 | return result; |
| 777 | } |
| 778 | return injectVSync(when); |
| 779 | } |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 780 | default: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 781 | return BBinder::onTransact(code, data, reply, flags); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 782 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 783 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 784 | } |
| 785 | |
| 786 | // ---------------------------------------------------------------------------- |
| 787 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 788 | }; |