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