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