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