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