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