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