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