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