The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | // tag as surfaceflinger |
| 18 | #define LOG_TAG "SurfaceFlinger" |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | |
Mathias Agopian | c5b2c0b | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 23 | #include <binder/Parcel.h> |
Mathias Agopian | c5b2c0b | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 24 | #include <binder/IPCThreadState.h> |
| 25 | #include <binder/IServiceManager.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 27 | #include <gui/IDisplayEventConnection.h> |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 28 | #include <gui/IGraphicBufferProducer.h> |
Mathias Agopian | 2b5dd40 | 2017-02-07 17:36:19 -0800 | [diff] [blame] | 29 | #include <gui/ISurfaceComposer.h> |
| 30 | #include <gui/ISurfaceComposerClient.h> |
Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 31 | #include <gui/LayerDebugInfo.h> |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 32 | #include <gui/LayerState.h> |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 33 | |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 34 | #include <system/graphics.h> |
| 35 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | #include <ui/DisplayInfo.h> |
Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 37 | #include <ui/DisplayStatInfo.h> |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 38 | #include <ui/HdrCapabilities.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 40 | #include <utils/Log.h> |
Mathias Agopian | 9cce325 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 41 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 42 | // --------------------------------------------------------------------------- |
| 43 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | namespace android { |
| 45 | |
Peiyong Lin | 9f03447 | 2018-03-28 15:29:00 -0700 | [diff] [blame] | 46 | using ui::ColorMode; |
| 47 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | class BpSurfaceComposer : public BpInterface<ISurfaceComposer> |
| 49 | { |
| 50 | public: |
Chih-Hung Hsieh | e2347b7 | 2016-04-25 15:41:05 -0700 | [diff] [blame] | 51 | explicit BpSurfaceComposer(const sp<IBinder>& impl) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | : BpInterface<ISurfaceComposer>(impl) |
| 53 | { |
| 54 | } |
| 55 | |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 56 | virtual ~BpSurfaceComposer(); |
| 57 | |
Mathias Agopian | 7e27f05 | 2010-05-28 14:22:23 -0700 | [diff] [blame] | 58 | virtual sp<ISurfaceComposerClient> createConnection() |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | Parcel data, reply; |
| 61 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 62 | remote()->transact(BnSurfaceComposer::CREATE_CONNECTION, data, &reply); |
Mathias Agopian | 7e27f05 | 2010-05-28 14:22:23 -0700 | [diff] [blame] | 63 | return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder()); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 64 | } |
| 65 | |
Marissa Wall | 713b63f | 2018-10-17 15:42:43 -0700 | [diff] [blame] | 66 | virtual void setTransactionState(const Vector<ComposerState>& state, |
| 67 | const Vector<DisplayState>& displays, uint32_t flags, |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 68 | const sp<IBinder>& applyToken, |
Marissa Wall | 17b4e45 | 2018-12-26 16:32:34 -0800 | [diff] [blame] | 69 | const InputWindowCommands& commands, |
| 70 | int64_t desiredPresentTime) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 71 | Parcel data, reply; |
| 72 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 73 | |
| 74 | data.writeUint32(static_cast<uint32_t>(state.size())); |
| 75 | for (const auto& s : state) { |
| 76 | s.write(data); |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 77 | } |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 78 | |
| 79 | data.writeUint32(static_cast<uint32_t>(displays.size())); |
| 80 | for (const auto& d : displays) { |
| 81 | d.write(data); |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 82 | } |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 83 | |
| 84 | data.writeUint32(flags); |
Marissa Wall | 713b63f | 2018-10-17 15:42:43 -0700 | [diff] [blame] | 85 | data.writeStrongBinder(applyToken); |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 86 | commands.write(data); |
Marissa Wall | 17b4e45 | 2018-12-26 16:32:34 -0800 | [diff] [blame] | 87 | data.writeInt64(desiredPresentTime); |
Jamie Gennis | b8d69a5 | 2011-10-10 15:48:06 -0700 | [diff] [blame] | 88 | remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | virtual void bootFinished() |
| 92 | { |
| 93 | Parcel data, reply; |
| 94 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 95 | remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply); |
| 96 | } |
| 97 | |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 98 | virtual status_t captureScreen(const sp<IBinder>& display, sp<GraphicBuffer>* outBuffer, |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 99 | const ui::Dataspace reqDataspace, |
| 100 | const ui::PixelFormat reqPixelFormat, Rect sourceCrop, |
| 101 | uint32_t reqWidth, uint32_t reqHeight, bool useIdentityTransform, |
| 102 | ISurfaceComposer::Rotation rotation) { |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 103 | Parcel data, reply; |
| 104 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 105 | data.writeStrongBinder(display); |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 106 | data.writeInt32(static_cast<int32_t>(reqDataspace)); |
| 107 | data.writeInt32(static_cast<int32_t>(reqPixelFormat)); |
Dan Stoza | c187900 | 2014-05-22 15:59:05 -0700 | [diff] [blame] | 108 | data.write(sourceCrop); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 109 | data.writeUint32(reqWidth); |
| 110 | data.writeUint32(reqHeight); |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 111 | data.writeInt32(static_cast<int32_t>(useIdentityTransform)); |
Riley Andrews | c3ebe66 | 2014-09-04 16:20:31 -0700 | [diff] [blame] | 112 | data.writeInt32(static_cast<int32_t>(rotation)); |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 113 | status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply); |
| 114 | if (result != NO_ERROR) { |
| 115 | ALOGE("captureScreen failed to transact: %d", result); |
| 116 | return result; |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 117 | } |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 118 | result = reply.readInt32(); |
| 119 | if (result != NO_ERROR) { |
| 120 | ALOGE("captureScreen failed to readInt32: %d", result); |
| 121 | return result; |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | *outBuffer = new GraphicBuffer(); |
| 125 | reply.read(**outBuffer); |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 126 | |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 127 | return result; |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 128 | } |
| 129 | |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 130 | virtual status_t captureLayers(const sp<IBinder>& layerHandleBinder, |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 131 | sp<GraphicBuffer>* outBuffer, const ui::Dataspace reqDataspace, |
| 132 | const ui::PixelFormat reqPixelFormat, const Rect& sourceCrop, |
Robert Carr | 578038f | 2018-03-09 12:25:24 -0800 | [diff] [blame] | 133 | float frameScale, bool childrenOnly) { |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 134 | Parcel data, reply; |
| 135 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 136 | data.writeStrongBinder(layerHandleBinder); |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 137 | data.writeInt32(static_cast<int32_t>(reqDataspace)); |
| 138 | data.writeInt32(static_cast<int32_t>(reqPixelFormat)); |
chaviw | 7206d49 | 2017-11-10 16:16:12 -0800 | [diff] [blame] | 139 | data.write(sourceCrop); |
| 140 | data.writeFloat(frameScale); |
Robert Carr | 578038f | 2018-03-09 12:25:24 -0800 | [diff] [blame] | 141 | data.writeBool(childrenOnly); |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 142 | status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_LAYERS, data, &reply); |
| 143 | if (result != NO_ERROR) { |
| 144 | ALOGE("captureLayers failed to transact: %d", result); |
| 145 | return result; |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 146 | } |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 147 | result = reply.readInt32(); |
| 148 | if (result != NO_ERROR) { |
| 149 | ALOGE("captureLayers failed to readInt32: %d", result); |
| 150 | return result; |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 151 | } |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 152 | |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 153 | *outBuffer = new GraphicBuffer(); |
| 154 | reply.read(**outBuffer); |
| 155 | |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 156 | return result; |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 157 | } |
| 158 | |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 159 | virtual bool authenticateSurfaceTexture( |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 160 | const sp<IGraphicBufferProducer>& bufferProducer) const |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 161 | { |
| 162 | Parcel data, reply; |
| 163 | int err = NO_ERROR; |
| 164 | err = data.writeInterfaceToken( |
| 165 | ISurfaceComposer::getInterfaceDescriptor()); |
| 166 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 167 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing " |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 168 | "interface descriptor: %s (%d)", strerror(-err), -err); |
| 169 | return false; |
| 170 | } |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 171 | err = data.writeStrongBinder(IInterface::asBinder(bufferProducer)); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 172 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 173 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing " |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 174 | "strong binder to parcel: %s (%d)", strerror(-err), -err); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 175 | return false; |
| 176 | } |
| 177 | err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data, |
| 178 | &reply); |
| 179 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 180 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error " |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 181 | "performing transaction: %s (%d)", strerror(-err), -err); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 182 | return false; |
| 183 | } |
| 184 | int32_t result = 0; |
| 185 | err = reply.readInt32(&result); |
| 186 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 187 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error " |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 188 | "retrieving result: %s (%d)", strerror(-err), -err); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 189 | return false; |
| 190 | } |
| 191 | return result != 0; |
| 192 | } |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 193 | |
Brian Anderson | 6b37671 | 2017-04-04 10:51:39 -0700 | [diff] [blame] | 194 | virtual status_t getSupportedFrameTimestamps( |
| 195 | std::vector<FrameEvent>* outSupported) const { |
| 196 | if (!outSupported) { |
| 197 | return UNEXPECTED_NULL; |
| 198 | } |
| 199 | outSupported->clear(); |
| 200 | |
| 201 | Parcel data, reply; |
| 202 | |
| 203 | status_t err = data.writeInterfaceToken( |
| 204 | ISurfaceComposer::getInterfaceDescriptor()); |
| 205 | if (err != NO_ERROR) { |
| 206 | return err; |
| 207 | } |
| 208 | |
| 209 | err = remote()->transact( |
| 210 | BnSurfaceComposer::GET_SUPPORTED_FRAME_TIMESTAMPS, |
| 211 | data, &reply); |
| 212 | if (err != NO_ERROR) { |
| 213 | return err; |
| 214 | } |
| 215 | |
| 216 | int32_t result = 0; |
| 217 | err = reply.readInt32(&result); |
| 218 | if (err != NO_ERROR) { |
| 219 | return err; |
| 220 | } |
| 221 | if (result != NO_ERROR) { |
| 222 | return result; |
| 223 | } |
| 224 | |
| 225 | std::vector<int32_t> supported; |
| 226 | err = reply.readInt32Vector(&supported); |
| 227 | if (err != NO_ERROR) { |
| 228 | return err; |
| 229 | } |
| 230 | |
| 231 | outSupported->reserve(supported.size()); |
| 232 | for (int32_t s : supported) { |
| 233 | outSupported->push_back(static_cast<FrameEvent>(s)); |
| 234 | } |
| 235 | return NO_ERROR; |
| 236 | } |
| 237 | |
Jorim Jaggi | b1e2f8d | 2017-06-08 15:43:59 -0700 | [diff] [blame] | 238 | virtual sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource) |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 239 | { |
| 240 | Parcel data, reply; |
| 241 | sp<IDisplayEventConnection> result; |
| 242 | int err = data.writeInterfaceToken( |
| 243 | ISurfaceComposer::getInterfaceDescriptor()); |
| 244 | if (err != NO_ERROR) { |
| 245 | return result; |
| 246 | } |
Jorim Jaggi | b1e2f8d | 2017-06-08 15:43:59 -0700 | [diff] [blame] | 247 | data.writeInt32(static_cast<int32_t>(vsyncSource)); |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 248 | err = remote()->transact( |
| 249 | BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION, |
| 250 | data, &reply); |
| 251 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 252 | ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing " |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 253 | "transaction: %s (%d)", strerror(-err), -err); |
| 254 | return result; |
| 255 | } |
| 256 | result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder()); |
| 257 | return result; |
| 258 | } |
Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 259 | |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 260 | virtual sp<IBinder> createDisplay(const String8& displayName, bool secure) |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 261 | { |
| 262 | Parcel data, reply; |
| 263 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Andy McFadden | 8dfa92f | 2012-09-17 18:27:17 -0700 | [diff] [blame] | 264 | data.writeString8(displayName); |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 265 | data.writeInt32(secure ? 1 : 0); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 266 | remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply); |
| 267 | return reply.readStrongBinder(); |
| 268 | } |
| 269 | |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 270 | virtual void destroyDisplay(const sp<IBinder>& display) |
| 271 | { |
| 272 | Parcel data, reply; |
| 273 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 274 | data.writeStrongBinder(display); |
| 275 | remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply); |
| 276 | } |
| 277 | |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 278 | virtual sp<IBinder> getBuiltInDisplay(int32_t id) |
| 279 | { |
| 280 | Parcel data, reply; |
| 281 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 282 | data.writeInt32(id); |
| 283 | remote()->transact(BnSurfaceComposer::GET_BUILT_IN_DISPLAY, data, &reply); |
| 284 | return reply.readStrongBinder(); |
| 285 | } |
| 286 | |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 287 | virtual void setPowerMode(const sp<IBinder>& display, int mode) |
Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 288 | { |
| 289 | Parcel data, reply; |
| 290 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Andy McFadden | c01a79d | 2012-09-27 16:02:06 -0700 | [diff] [blame] | 291 | data.writeStrongBinder(display); |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 292 | data.writeInt32(mode); |
| 293 | remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply); |
Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 294 | } |
Mathias Agopian | 3094df3 | 2012-06-18 18:06:45 -0700 | [diff] [blame] | 295 | |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 296 | virtual status_t getDisplayConfigs(const sp<IBinder>& display, |
| 297 | Vector<DisplayInfo>* configs) |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 298 | { |
| 299 | Parcel data, reply; |
| 300 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 301 | data.writeStrongBinder(display); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 302 | remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply); |
| 303 | status_t result = reply.readInt32(); |
| 304 | if (result == NO_ERROR) { |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 305 | size_t numConfigs = reply.readUint32(); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 306 | configs->clear(); |
| 307 | configs->resize(numConfigs); |
| 308 | for (size_t c = 0; c < numConfigs; ++c) { |
| 309 | memcpy(&(configs->editItemAt(c)), |
| 310 | reply.readInplace(sizeof(DisplayInfo)), |
| 311 | sizeof(DisplayInfo)); |
| 312 | } |
| 313 | } |
| 314 | return result; |
| 315 | } |
| 316 | |
Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 317 | virtual status_t getDisplayStats(const sp<IBinder>& display, |
| 318 | DisplayStatInfo* stats) |
| 319 | { |
| 320 | Parcel data, reply; |
| 321 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 322 | data.writeStrongBinder(display); |
| 323 | remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply); |
| 324 | status_t result = reply.readInt32(); |
| 325 | if (result == NO_ERROR) { |
| 326 | memcpy(stats, |
| 327 | reply.readInplace(sizeof(DisplayStatInfo)), |
| 328 | sizeof(DisplayStatInfo)); |
| 329 | } |
| 330 | return result; |
| 331 | } |
| 332 | |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 333 | virtual int getActiveConfig(const sp<IBinder>& display) |
| 334 | { |
| 335 | Parcel data, reply; |
| 336 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 337 | data.writeStrongBinder(display); |
| 338 | remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply); |
| 339 | return reply.readInt32(); |
| 340 | } |
| 341 | |
| 342 | virtual status_t setActiveConfig(const sp<IBinder>& display, int id) |
| 343 | { |
| 344 | Parcel data, reply; |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 345 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 346 | if (result != NO_ERROR) { |
| 347 | ALOGE("setActiveConfig failed to writeInterfaceToken: %d", result); |
| 348 | return result; |
| 349 | } |
| 350 | result = data.writeStrongBinder(display); |
| 351 | if (result != NO_ERROR) { |
| 352 | ALOGE("setActiveConfig failed to writeStrongBinder: %d", result); |
| 353 | return result; |
| 354 | } |
| 355 | result = data.writeInt32(id); |
| 356 | if (result != NO_ERROR) { |
| 357 | ALOGE("setActiveConfig failed to writeInt32: %d", result); |
| 358 | return result; |
| 359 | } |
| 360 | result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply); |
| 361 | if (result != NO_ERROR) { |
| 362 | ALOGE("setActiveConfig failed to transact: %d", result); |
| 363 | return result; |
| 364 | } |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 365 | return reply.readInt32(); |
| 366 | } |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 367 | |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 368 | virtual status_t getDisplayColorModes(const sp<IBinder>& display, |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 369 | Vector<ColorMode>* outColorModes) { |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 370 | Parcel data, reply; |
| 371 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 372 | if (result != NO_ERROR) { |
| 373 | ALOGE("getDisplayColorModes failed to writeInterfaceToken: %d", result); |
| 374 | return result; |
| 375 | } |
| 376 | result = data.writeStrongBinder(display); |
| 377 | if (result != NO_ERROR) { |
| 378 | ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result); |
| 379 | return result; |
| 380 | } |
| 381 | result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply); |
| 382 | if (result != NO_ERROR) { |
| 383 | ALOGE("getDisplayColorModes failed to transact: %d", result); |
| 384 | return result; |
| 385 | } |
| 386 | result = static_cast<status_t>(reply.readInt32()); |
| 387 | if (result == NO_ERROR) { |
| 388 | size_t numModes = reply.readUint32(); |
| 389 | outColorModes->clear(); |
| 390 | outColorModes->resize(numModes); |
| 391 | for (size_t i = 0; i < numModes; ++i) { |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 392 | outColorModes->replaceAt(static_cast<ColorMode>(reply.readInt32()), i); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 393 | } |
| 394 | } |
| 395 | return result; |
| 396 | } |
| 397 | |
Daniel Solomon | 42d0456 | 2019-01-20 21:03:19 -0800 | [diff] [blame^] | 398 | virtual status_t getDisplayNativePrimaries(const sp<IBinder>& display, |
| 399 | ui::DisplayPrimaries& primaries) { |
| 400 | Parcel data, reply; |
| 401 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 402 | if (result != NO_ERROR) { |
| 403 | ALOGE("getDisplayNativePrimaries failed to writeInterfaceToken: %d", result); |
| 404 | return result; |
| 405 | } |
| 406 | result = data.writeStrongBinder(display); |
| 407 | if (result != NO_ERROR) { |
| 408 | ALOGE("getDisplayNativePrimaries failed to writeStrongBinder: %d", result); |
| 409 | return result; |
| 410 | } |
| 411 | result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_NATIVE_PRIMARIES, data, &reply); |
| 412 | if (result != NO_ERROR) { |
| 413 | ALOGE("getDisplayNativePrimaries failed to transact: %d", result); |
| 414 | return result; |
| 415 | } |
| 416 | result = reply.readInt32(); |
| 417 | if (result == NO_ERROR) { |
| 418 | memcpy(&primaries, reply.readInplace(sizeof(ui::DisplayPrimaries)), |
| 419 | sizeof(ui::DisplayPrimaries)); |
| 420 | } |
| 421 | return result; |
| 422 | } |
| 423 | |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 424 | virtual ColorMode getActiveColorMode(const sp<IBinder>& display) { |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 425 | Parcel data, reply; |
| 426 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 427 | if (result != NO_ERROR) { |
| 428 | ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result); |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 429 | return static_cast<ColorMode>(result); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 430 | } |
| 431 | result = data.writeStrongBinder(display); |
| 432 | if (result != NO_ERROR) { |
| 433 | ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result); |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 434 | return static_cast<ColorMode>(result); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 435 | } |
| 436 | result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply); |
| 437 | if (result != NO_ERROR) { |
| 438 | ALOGE("getActiveColorMode failed to transact: %d", result); |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 439 | return static_cast<ColorMode>(result); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 440 | } |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 441 | return static_cast<ColorMode>(reply.readInt32()); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | virtual status_t setActiveColorMode(const sp<IBinder>& display, |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 445 | ColorMode colorMode) { |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 446 | Parcel data, reply; |
| 447 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 448 | if (result != NO_ERROR) { |
| 449 | ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result); |
| 450 | return result; |
| 451 | } |
| 452 | result = data.writeStrongBinder(display); |
| 453 | if (result != NO_ERROR) { |
| 454 | ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result); |
| 455 | return result; |
| 456 | } |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 457 | result = data.writeInt32(static_cast<int32_t>(colorMode)); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 458 | if (result != NO_ERROR) { |
| 459 | ALOGE("setActiveColorMode failed to writeInt32: %d", result); |
| 460 | return result; |
| 461 | } |
| 462 | result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply); |
| 463 | if (result != NO_ERROR) { |
| 464 | ALOGE("setActiveColorMode failed to transact: %d", result); |
| 465 | return result; |
| 466 | } |
| 467 | return static_cast<status_t>(reply.readInt32()); |
| 468 | } |
| 469 | |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 470 | virtual status_t clearAnimationFrameStats() { |
| 471 | Parcel data, reply; |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 472 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 473 | if (result != NO_ERROR) { |
| 474 | ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result); |
| 475 | return result; |
| 476 | } |
| 477 | result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply); |
| 478 | if (result != NO_ERROR) { |
| 479 | ALOGE("clearAnimationFrameStats failed to transact: %d", result); |
| 480 | return result; |
| 481 | } |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 482 | return reply.readInt32(); |
| 483 | } |
| 484 | |
| 485 | virtual status_t getAnimationFrameStats(FrameStats* outStats) const { |
| 486 | Parcel data, reply; |
| 487 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 488 | remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply); |
| 489 | reply.read(*outStats); |
| 490 | return reply.readInt32(); |
| 491 | } |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 492 | |
| 493 | virtual status_t getHdrCapabilities(const sp<IBinder>& display, |
| 494 | HdrCapabilities* outCapabilities) const { |
| 495 | Parcel data, reply; |
| 496 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 497 | status_t result = data.writeStrongBinder(display); |
| 498 | if (result != NO_ERROR) { |
| 499 | ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result); |
| 500 | return result; |
| 501 | } |
| 502 | result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES, |
| 503 | data, &reply); |
| 504 | if (result != NO_ERROR) { |
| 505 | ALOGE("getHdrCapabilities failed to transact: %d", result); |
| 506 | return result; |
| 507 | } |
| 508 | result = reply.readInt32(); |
| 509 | if (result == NO_ERROR) { |
Mathias Agopian | e1f5e6f | 2017-02-06 16:34:41 -0800 | [diff] [blame] | 510 | result = reply.read(*outCapabilities); |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 511 | } |
| 512 | return result; |
| 513 | } |
Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 514 | |
| 515 | virtual status_t enableVSyncInjections(bool enable) { |
| 516 | Parcel data, reply; |
| 517 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 518 | if (result != NO_ERROR) { |
| 519 | ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result); |
| 520 | return result; |
| 521 | } |
| 522 | result = data.writeBool(enable); |
| 523 | if (result != NO_ERROR) { |
| 524 | ALOGE("enableVSyncInjections failed to writeBool: %d", result); |
| 525 | return result; |
| 526 | } |
| 527 | result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS, |
| 528 | data, &reply, TF_ONE_WAY); |
| 529 | if (result != NO_ERROR) { |
| 530 | ALOGE("enableVSyncInjections failed to transact: %d", result); |
| 531 | return result; |
| 532 | } |
| 533 | return result; |
| 534 | } |
| 535 | |
| 536 | virtual status_t injectVSync(nsecs_t when) { |
| 537 | Parcel data, reply; |
| 538 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 539 | if (result != NO_ERROR) { |
| 540 | ALOGE("injectVSync failed to writeInterfaceToken: %d", result); |
| 541 | return result; |
| 542 | } |
| 543 | result = data.writeInt64(when); |
| 544 | if (result != NO_ERROR) { |
| 545 | ALOGE("injectVSync failed to writeInt64: %d", result); |
| 546 | return result; |
| 547 | } |
| 548 | result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply, TF_ONE_WAY); |
| 549 | if (result != NO_ERROR) { |
| 550 | ALOGE("injectVSync failed to transact: %d", result); |
| 551 | return result; |
| 552 | } |
| 553 | return result; |
| 554 | } |
| 555 | |
Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 556 | virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const |
| 557 | { |
| 558 | if (!outLayers) { |
| 559 | return UNEXPECTED_NULL; |
| 560 | } |
| 561 | |
| 562 | Parcel data, reply; |
| 563 | |
| 564 | status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 565 | if (err != NO_ERROR) { |
| 566 | return err; |
| 567 | } |
| 568 | |
| 569 | err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply); |
| 570 | if (err != NO_ERROR) { |
| 571 | return err; |
| 572 | } |
| 573 | |
| 574 | int32_t result = 0; |
| 575 | err = reply.readInt32(&result); |
| 576 | if (err != NO_ERROR) { |
| 577 | return err; |
| 578 | } |
| 579 | if (result != NO_ERROR) { |
| 580 | return result; |
| 581 | } |
| 582 | |
| 583 | outLayers->clear(); |
| 584 | return reply.readParcelableVector(outLayers); |
| 585 | } |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 586 | |
Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 587 | virtual status_t getCompositionPreference(ui::Dataspace* defaultDataspace, |
| 588 | ui::PixelFormat* defaultPixelFormat, |
| 589 | ui::Dataspace* wideColorGamutDataspace, |
| 590 | ui::PixelFormat* wideColorGamutPixelFormat) const { |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 591 | Parcel data, reply; |
| 592 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 593 | if (error != NO_ERROR) { |
| 594 | return error; |
| 595 | } |
| 596 | error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply); |
| 597 | if (error != NO_ERROR) { |
| 598 | return error; |
| 599 | } |
| 600 | error = static_cast<status_t>(reply.readInt32()); |
| 601 | if (error == NO_ERROR) { |
Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 602 | *defaultDataspace = static_cast<ui::Dataspace>(reply.readInt32()); |
| 603 | *defaultPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32()); |
| 604 | *wideColorGamutDataspace = static_cast<ui::Dataspace>(reply.readInt32()); |
| 605 | *wideColorGamutPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32()); |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 606 | } |
| 607 | return error; |
| 608 | } |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 609 | |
Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 610 | virtual status_t getColorManagement(bool* outGetColorManagement) const { |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 611 | Parcel data, reply; |
| 612 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 613 | remote()->transact(BnSurfaceComposer::GET_COLOR_MANAGEMENT, data, &reply); |
| 614 | bool result; |
| 615 | status_t err = reply.readBool(&result); |
| 616 | if (err == NO_ERROR) { |
| 617 | *outGetColorManagement = result; |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 618 | } |
Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 619 | return err; |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 620 | } |
Kevin DuBois | 9c0a176 | 2018-10-16 13:32:31 -0700 | [diff] [blame] | 621 | |
| 622 | virtual status_t getDisplayedContentSamplingAttributes(const sp<IBinder>& display, |
| 623 | ui::PixelFormat* outFormat, |
| 624 | ui::Dataspace* outDataspace, |
| 625 | uint8_t* outComponentMask) const { |
| 626 | if (!outFormat || !outDataspace || !outComponentMask) return BAD_VALUE; |
| 627 | Parcel data, reply; |
| 628 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 629 | data.writeStrongBinder(display); |
| 630 | |
| 631 | status_t error = |
| 632 | remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES, |
| 633 | data, &reply); |
| 634 | if (error != NO_ERROR) { |
| 635 | return error; |
| 636 | } |
| 637 | |
| 638 | uint32_t value = 0; |
| 639 | error = reply.readUint32(&value); |
| 640 | if (error != NO_ERROR) { |
| 641 | return error; |
| 642 | } |
| 643 | *outFormat = static_cast<ui::PixelFormat>(value); |
| 644 | |
| 645 | error = reply.readUint32(&value); |
| 646 | if (error != NO_ERROR) { |
| 647 | return error; |
| 648 | } |
| 649 | *outDataspace = static_cast<ui::Dataspace>(value); |
| 650 | |
| 651 | error = reply.readUint32(&value); |
| 652 | if (error != NO_ERROR) { |
| 653 | return error; |
| 654 | } |
| 655 | *outComponentMask = static_cast<uint8_t>(value); |
| 656 | return error; |
| 657 | } |
Kevin DuBois | 74e5377 | 2018-11-19 10:52:38 -0800 | [diff] [blame] | 658 | |
| 659 | virtual status_t setDisplayContentSamplingEnabled(const sp<IBinder>& display, bool enable, |
| 660 | uint8_t componentMask, |
| 661 | uint64_t maxFrames) const { |
| 662 | Parcel data, reply; |
| 663 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 664 | data.writeStrongBinder(display); |
| 665 | data.writeBool(enable); |
| 666 | data.writeByte(static_cast<int8_t>(componentMask)); |
| 667 | data.writeUint64(maxFrames); |
| 668 | status_t result = |
| 669 | remote()->transact(BnSurfaceComposer::SET_DISPLAY_CONTENT_SAMPLING_ENABLED, data, |
| 670 | &reply); |
| 671 | return result; |
| 672 | } |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 673 | |
| 674 | virtual status_t getDisplayedContentSample(const sp<IBinder>& display, uint64_t maxFrames, |
| 675 | uint64_t timestamp, |
| 676 | DisplayedFrameStats* outStats) const { |
| 677 | if (!outStats) return BAD_VALUE; |
| 678 | |
| 679 | Parcel data, reply; |
| 680 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 681 | data.writeStrongBinder(display); |
| 682 | data.writeUint64(maxFrames); |
| 683 | data.writeUint64(timestamp); |
| 684 | |
| 685 | status_t result = |
| 686 | remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLE, data, &reply); |
| 687 | |
| 688 | if (result != NO_ERROR) { |
| 689 | return result; |
| 690 | } |
| 691 | |
| 692 | result = reply.readUint64(&outStats->numFrames); |
| 693 | if (result != NO_ERROR) { |
| 694 | return result; |
| 695 | } |
| 696 | |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 697 | result = reply.readUint64Vector(&outStats->component_0_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 698 | if (result != NO_ERROR) { |
| 699 | return result; |
| 700 | } |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 701 | result = reply.readUint64Vector(&outStats->component_1_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 702 | if (result != NO_ERROR) { |
| 703 | return result; |
| 704 | } |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 705 | result = reply.readUint64Vector(&outStats->component_2_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 706 | if (result != NO_ERROR) { |
| 707 | return result; |
| 708 | } |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 709 | result = reply.readUint64Vector(&outStats->component_3_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 710 | return result; |
| 711 | } |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 712 | |
| 713 | virtual status_t getProtectedContentSupport(bool* outSupported) const { |
| 714 | Parcel data, reply; |
| 715 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Peiyong Lin | b6888fa | 2019-01-28 13:20:58 -0800 | [diff] [blame] | 716 | status_t error = |
| 717 | remote()->transact(BnSurfaceComposer::GET_PROTECTED_CONTENT_SUPPORT, data, &reply); |
| 718 | if (error != NO_ERROR) { |
| 719 | return error; |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 720 | } |
Peiyong Lin | b6888fa | 2019-01-28 13:20:58 -0800 | [diff] [blame] | 721 | error = reply.readBool(outSupported); |
| 722 | return error; |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 723 | } |
Marissa Wall | ebc2c05 | 2019-01-16 19:16:55 -0800 | [diff] [blame] | 724 | |
| 725 | virtual status_t cacheBuffer(const sp<IBinder>& token, const sp<GraphicBuffer>& buffer, |
| 726 | int32_t* outBufferId) { |
| 727 | Parcel data, reply; |
| 728 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 729 | |
| 730 | data.writeStrongBinder(token); |
| 731 | if (buffer) { |
| 732 | data.writeBool(true); |
| 733 | data.write(*buffer); |
| 734 | } else { |
| 735 | data.writeBool(false); |
| 736 | } |
| 737 | |
| 738 | status_t result = remote()->transact(BnSurfaceComposer::CACHE_BUFFER, data, &reply); |
| 739 | if (result != NO_ERROR) { |
| 740 | return result; |
| 741 | } |
| 742 | |
| 743 | int32_t id = -1; |
| 744 | result = reply.readInt32(&id); |
| 745 | if (result == NO_ERROR) { |
| 746 | *outBufferId = id; |
| 747 | } |
| 748 | return result; |
| 749 | } |
| 750 | |
| 751 | virtual status_t uncacheBuffer(const sp<IBinder>& token, int32_t bufferId) { |
| 752 | Parcel data, reply; |
| 753 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 754 | |
| 755 | data.writeStrongBinder(token); |
| 756 | data.writeInt32(bufferId); |
| 757 | |
| 758 | return remote()->transact(BnSurfaceComposer::UNCACHE_BUFFER, data, &reply); |
| 759 | } |
Peiyong Lin | 4f3fddf | 2019-01-24 17:21:24 -0800 | [diff] [blame] | 760 | |
| 761 | virtual status_t isWideColorDisplay(const sp<IBinder>& token, |
| 762 | bool* outIsWideColorDisplay) const { |
| 763 | Parcel data, reply; |
| 764 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 765 | if (error != NO_ERROR) { |
| 766 | return error; |
| 767 | } |
| 768 | error = data.writeStrongBinder(token); |
| 769 | if (error != NO_ERROR) { |
| 770 | return error; |
| 771 | } |
| 772 | |
| 773 | error = remote()->transact(BnSurfaceComposer::IS_WIDE_COLOR_DISPLAY, data, &reply); |
| 774 | if (error != NO_ERROR) { |
| 775 | return error; |
| 776 | } |
| 777 | error = reply.readBool(outIsWideColorDisplay); |
| 778 | return error; |
| 779 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 780 | }; |
| 781 | |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 782 | // Out-of-line virtual method definition to trigger vtable emission in this |
| 783 | // translation unit (see clang warning -Wweak-vtables) |
| 784 | BpSurfaceComposer::~BpSurfaceComposer() {} |
| 785 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 786 | IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer"); |
| 787 | |
| 788 | // ---------------------------------------------------------------------- |
| 789 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 790 | status_t BnSurfaceComposer::onTransact( |
| 791 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 792 | { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 793 | switch(code) { |
| 794 | case CREATE_CONNECTION: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 795 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 796 | sp<IBinder> b = IInterface::asBinder(createConnection()); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 797 | reply->writeStrongBinder(b); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 798 | return NO_ERROR; |
| 799 | } |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 800 | case SET_TRANSACTION_STATE: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 801 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 802 | |
| 803 | size_t count = data.readUint32(); |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 804 | if (count > data.dataSize()) { |
| 805 | return BAD_VALUE; |
| 806 | } |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 807 | Vector<ComposerState> state; |
| 808 | state.setCapacity(count); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 809 | for (size_t i = 0; i < count; i++) { |
Marissa Wall | c837b5e | 2018-10-12 10:04:44 -0700 | [diff] [blame] | 810 | ComposerState s; |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 811 | if (s.read(data) == BAD_VALUE) { |
| 812 | return BAD_VALUE; |
| 813 | } |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 814 | state.add(s); |
| 815 | } |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 816 | |
| 817 | count = data.readUint32(); |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 818 | if (count > data.dataSize()) { |
| 819 | return BAD_VALUE; |
| 820 | } |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 821 | DisplayState d; |
| 822 | Vector<DisplayState> displays; |
| 823 | displays.setCapacity(count); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 824 | for (size_t i = 0; i < count; i++) { |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 825 | if (d.read(data) == BAD_VALUE) { |
| 826 | return BAD_VALUE; |
| 827 | } |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 828 | displays.add(d); |
| 829 | } |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 830 | |
| 831 | uint32_t stateFlags = data.readUint32(); |
Marissa Wall | 713b63f | 2018-10-17 15:42:43 -0700 | [diff] [blame] | 832 | sp<IBinder> applyToken = data.readStrongBinder(); |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 833 | InputWindowCommands inputWindowCommands; |
| 834 | inputWindowCommands.read(data); |
Marissa Wall | 17b4e45 | 2018-12-26 16:32:34 -0800 | [diff] [blame] | 835 | |
| 836 | int64_t desiredPresentTime = data.readInt64(); |
| 837 | setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands, |
| 838 | desiredPresentTime); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 839 | return NO_ERROR; |
| 840 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 841 | case BOOT_FINISHED: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 842 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 843 | bootFinished(); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 844 | return NO_ERROR; |
| 845 | } |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 846 | case CAPTURE_SCREEN: { |
| 847 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 848 | sp<IBinder> display = data.readStrongBinder(); |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 849 | ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32()); |
| 850 | ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32()); |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 851 | sp<GraphicBuffer> outBuffer; |
Pablo Ceballos | 60d6922 | 2015-08-07 14:47:20 -0700 | [diff] [blame] | 852 | Rect sourceCrop(Rect::EMPTY_RECT); |
Dan Stoza | c187900 | 2014-05-22 15:59:05 -0700 | [diff] [blame] | 853 | data.read(sourceCrop); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 854 | uint32_t reqWidth = data.readUint32(); |
| 855 | uint32_t reqHeight = data.readUint32(); |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 856 | bool useIdentityTransform = static_cast<bool>(data.readInt32()); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 857 | int32_t rotation = data.readInt32(); |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 858 | |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 859 | status_t res = captureScreen(display, &outBuffer, reqDataspace, reqPixelFormat, |
| 860 | sourceCrop, reqWidth, reqHeight, useIdentityTransform, |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 861 | static_cast<ISurfaceComposer::Rotation>(rotation)); |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 862 | reply->writeInt32(res); |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 863 | if (res == NO_ERROR) { |
| 864 | reply->write(*outBuffer); |
| 865 | } |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 866 | return NO_ERROR; |
| 867 | } |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 868 | case CAPTURE_LAYERS: { |
| 869 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 870 | sp<IBinder> layerHandleBinder = data.readStrongBinder(); |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 871 | ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32()); |
| 872 | ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32()); |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 873 | sp<GraphicBuffer> outBuffer; |
chaviw | 7206d49 | 2017-11-10 16:16:12 -0800 | [diff] [blame] | 874 | Rect sourceCrop(Rect::EMPTY_RECT); |
| 875 | data.read(sourceCrop); |
| 876 | float frameScale = data.readFloat(); |
Robert Carr | 578038f | 2018-03-09 12:25:24 -0800 | [diff] [blame] | 877 | bool childrenOnly = data.readBool(); |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 878 | |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 879 | status_t res = captureLayers(layerHandleBinder, &outBuffer, reqDataspace, |
| 880 | reqPixelFormat, sourceCrop, frameScale, childrenOnly); |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 881 | reply->writeInt32(res); |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 882 | if (res == NO_ERROR) { |
| 883 | reply->write(*outBuffer); |
| 884 | } |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 885 | return NO_ERROR; |
| 886 | } |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 887 | case AUTHENTICATE_SURFACE: { |
| 888 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 889 | sp<IGraphicBufferProducer> bufferProducer = |
| 890 | interface_cast<IGraphicBufferProducer>(data.readStrongBinder()); |
| 891 | int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0; |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 892 | reply->writeInt32(result); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 893 | return NO_ERROR; |
| 894 | } |
Brian Anderson | 6b37671 | 2017-04-04 10:51:39 -0700 | [diff] [blame] | 895 | case GET_SUPPORTED_FRAME_TIMESTAMPS: { |
| 896 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 897 | std::vector<FrameEvent> supportedTimestamps; |
| 898 | status_t result = getSupportedFrameTimestamps(&supportedTimestamps); |
| 899 | status_t err = reply->writeInt32(result); |
| 900 | if (err != NO_ERROR) { |
| 901 | return err; |
| 902 | } |
| 903 | if (result != NO_ERROR) { |
| 904 | return result; |
| 905 | } |
| 906 | |
| 907 | std::vector<int32_t> supported; |
| 908 | supported.reserve(supportedTimestamps.size()); |
| 909 | for (FrameEvent s : supportedTimestamps) { |
| 910 | supported.push_back(static_cast<int32_t>(s)); |
| 911 | } |
| 912 | return reply->writeInt32Vector(supported); |
| 913 | } |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 914 | case CREATE_DISPLAY_EVENT_CONNECTION: { |
| 915 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Jorim Jaggi | b1e2f8d | 2017-06-08 15:43:59 -0700 | [diff] [blame] | 916 | sp<IDisplayEventConnection> connection(createDisplayEventConnection( |
| 917 | static_cast<ISurfaceComposer::VsyncSource>(data.readInt32()))); |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 918 | reply->writeStrongBinder(IInterface::asBinder(connection)); |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 919 | return NO_ERROR; |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 920 | } |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 921 | case CREATE_DISPLAY: { |
| 922 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Andy McFadden | 8dfa92f | 2012-09-17 18:27:17 -0700 | [diff] [blame] | 923 | String8 displayName = data.readString8(); |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 924 | bool secure = bool(data.readInt32()); |
| 925 | sp<IBinder> display(createDisplay(displayName, secure)); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 926 | reply->writeStrongBinder(display); |
| 927 | return NO_ERROR; |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 928 | } |
| 929 | case DESTROY_DISPLAY: { |
| 930 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 931 | sp<IBinder> display = data.readStrongBinder(); |
| 932 | destroyDisplay(display); |
| 933 | return NO_ERROR; |
| 934 | } |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 935 | case GET_BUILT_IN_DISPLAY: { |
| 936 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 937 | int32_t id = data.readInt32(); |
| 938 | sp<IBinder> display(getBuiltInDisplay(id)); |
| 939 | reply->writeStrongBinder(display); |
| 940 | return NO_ERROR; |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 941 | } |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 942 | case GET_DISPLAY_CONFIGS: { |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 943 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 944 | Vector<DisplayInfo> configs; |
Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 945 | sp<IBinder> display = data.readStrongBinder(); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 946 | status_t result = getDisplayConfigs(display, &configs); |
| 947 | reply->writeInt32(result); |
| 948 | if (result == NO_ERROR) { |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 949 | reply->writeUint32(static_cast<uint32_t>(configs.size())); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 950 | for (size_t c = 0; c < configs.size(); ++c) { |
| 951 | memcpy(reply->writeInplace(sizeof(DisplayInfo)), |
| 952 | &configs[c], sizeof(DisplayInfo)); |
| 953 | } |
| 954 | } |
| 955 | return NO_ERROR; |
| 956 | } |
Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 957 | case GET_DISPLAY_STATS: { |
| 958 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 959 | DisplayStatInfo stats; |
| 960 | sp<IBinder> display = data.readStrongBinder(); |
| 961 | status_t result = getDisplayStats(display, &stats); |
| 962 | reply->writeInt32(result); |
| 963 | if (result == NO_ERROR) { |
| 964 | memcpy(reply->writeInplace(sizeof(DisplayStatInfo)), |
| 965 | &stats, sizeof(DisplayStatInfo)); |
| 966 | } |
| 967 | return NO_ERROR; |
| 968 | } |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 969 | case GET_ACTIVE_CONFIG: { |
| 970 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 971 | sp<IBinder> display = data.readStrongBinder(); |
| 972 | int id = getActiveConfig(display); |
| 973 | reply->writeInt32(id); |
| 974 | return NO_ERROR; |
| 975 | } |
| 976 | case SET_ACTIVE_CONFIG: { |
| 977 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 978 | sp<IBinder> display = data.readStrongBinder(); |
| 979 | int id = data.readInt32(); |
| 980 | status_t result = setActiveConfig(display, id); |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 981 | reply->writeInt32(result); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 982 | return NO_ERROR; |
| 983 | } |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 984 | case GET_DISPLAY_COLOR_MODES: { |
| 985 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 986 | Vector<ColorMode> colorModes; |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 987 | sp<IBinder> display = nullptr; |
| 988 | status_t result = data.readStrongBinder(&display); |
| 989 | if (result != NO_ERROR) { |
| 990 | ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result); |
| 991 | return result; |
| 992 | } |
| 993 | result = getDisplayColorModes(display, &colorModes); |
| 994 | reply->writeInt32(result); |
| 995 | if (result == NO_ERROR) { |
| 996 | reply->writeUint32(static_cast<uint32_t>(colorModes.size())); |
| 997 | for (size_t i = 0; i < colorModes.size(); ++i) { |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 998 | reply->writeInt32(static_cast<int32_t>(colorModes[i])); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 999 | } |
| 1000 | } |
| 1001 | return NO_ERROR; |
| 1002 | } |
Daniel Solomon | 42d0456 | 2019-01-20 21:03:19 -0800 | [diff] [blame^] | 1003 | case GET_DISPLAY_NATIVE_PRIMARIES: { |
| 1004 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1005 | ui::DisplayPrimaries primaries; |
| 1006 | sp<IBinder> display = nullptr; |
| 1007 | |
| 1008 | status_t result = data.readStrongBinder(&display); |
| 1009 | if (result != NO_ERROR) { |
| 1010 | ALOGE("getDisplayNativePrimaries failed to readStrongBinder: %d", result); |
| 1011 | return result; |
| 1012 | } |
| 1013 | |
| 1014 | result = getDisplayNativePrimaries(display, primaries); |
| 1015 | reply->writeInt32(result); |
| 1016 | if (result == NO_ERROR) { |
| 1017 | memcpy(reply->writeInplace(sizeof(ui::DisplayPrimaries)), &primaries, |
| 1018 | sizeof(ui::DisplayPrimaries)); |
| 1019 | } |
| 1020 | |
| 1021 | return NO_ERROR; |
| 1022 | } |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1023 | case GET_ACTIVE_COLOR_MODE: { |
| 1024 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1025 | sp<IBinder> display = nullptr; |
| 1026 | status_t result = data.readStrongBinder(&display); |
| 1027 | if (result != NO_ERROR) { |
| 1028 | ALOGE("getActiveColorMode failed to readStrongBinder: %d", result); |
| 1029 | return result; |
| 1030 | } |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 1031 | ColorMode colorMode = getActiveColorMode(display); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1032 | result = reply->writeInt32(static_cast<int32_t>(colorMode)); |
| 1033 | return result; |
| 1034 | } |
| 1035 | case SET_ACTIVE_COLOR_MODE: { |
| 1036 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1037 | sp<IBinder> display = nullptr; |
| 1038 | status_t result = data.readStrongBinder(&display); |
| 1039 | if (result != NO_ERROR) { |
| 1040 | ALOGE("getActiveColorMode failed to readStrongBinder: %d", result); |
| 1041 | return result; |
| 1042 | } |
| 1043 | int32_t colorModeInt = 0; |
| 1044 | result = data.readInt32(&colorModeInt); |
| 1045 | if (result != NO_ERROR) { |
| 1046 | ALOGE("setActiveColorMode failed to readInt32: %d", result); |
| 1047 | return result; |
| 1048 | } |
| 1049 | result = setActiveColorMode(display, |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 1050 | static_cast<ColorMode>(colorModeInt)); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1051 | result = reply->writeInt32(result); |
| 1052 | return result; |
| 1053 | } |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 1054 | case CLEAR_ANIMATION_FRAME_STATS: { |
| 1055 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1056 | status_t result = clearAnimationFrameStats(); |
| 1057 | reply->writeInt32(result); |
| 1058 | return NO_ERROR; |
| 1059 | } |
| 1060 | case GET_ANIMATION_FRAME_STATS: { |
| 1061 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1062 | FrameStats stats; |
| 1063 | status_t result = getAnimationFrameStats(&stats); |
| 1064 | reply->write(stats); |
| 1065 | reply->writeInt32(result); |
| 1066 | return NO_ERROR; |
| 1067 | } |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 1068 | case SET_POWER_MODE: { |
| 1069 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1070 | sp<IBinder> display = data.readStrongBinder(); |
| 1071 | int32_t mode = data.readInt32(); |
| 1072 | setPowerMode(display, mode); |
| 1073 | return NO_ERROR; |
| 1074 | } |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 1075 | case GET_HDR_CAPABILITIES: { |
| 1076 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1077 | sp<IBinder> display = nullptr; |
| 1078 | status_t result = data.readStrongBinder(&display); |
| 1079 | if (result != NO_ERROR) { |
| 1080 | ALOGE("getHdrCapabilities failed to readStrongBinder: %d", |
| 1081 | result); |
| 1082 | return result; |
| 1083 | } |
| 1084 | HdrCapabilities capabilities; |
| 1085 | result = getHdrCapabilities(display, &capabilities); |
| 1086 | reply->writeInt32(result); |
| 1087 | if (result == NO_ERROR) { |
Mathias Agopian | e1f5e6f | 2017-02-06 16:34:41 -0800 | [diff] [blame] | 1088 | reply->write(capabilities); |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 1089 | } |
| 1090 | return NO_ERROR; |
| 1091 | } |
Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 1092 | case ENABLE_VSYNC_INJECTIONS: { |
| 1093 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1094 | bool enable = false; |
| 1095 | status_t result = data.readBool(&enable); |
| 1096 | if (result != NO_ERROR) { |
| 1097 | ALOGE("enableVSyncInjections failed to readBool: %d", result); |
| 1098 | return result; |
| 1099 | } |
| 1100 | return enableVSyncInjections(enable); |
| 1101 | } |
| 1102 | case INJECT_VSYNC: { |
| 1103 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1104 | int64_t when = 0; |
| 1105 | status_t result = data.readInt64(&when); |
| 1106 | if (result != NO_ERROR) { |
| 1107 | ALOGE("enableVSyncInjections failed to readInt64: %d", result); |
| 1108 | return result; |
| 1109 | } |
| 1110 | return injectVSync(when); |
| 1111 | } |
Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 1112 | case GET_LAYER_DEBUG_INFO: { |
| 1113 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1114 | std::vector<LayerDebugInfo> outLayers; |
| 1115 | status_t result = getLayerDebugInfo(&outLayers); |
| 1116 | reply->writeInt32(result); |
| 1117 | if (result == NO_ERROR) |
| 1118 | { |
| 1119 | result = reply->writeParcelableVector(outLayers); |
| 1120 | } |
| 1121 | return result; |
| 1122 | } |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1123 | case GET_COMPOSITION_PREFERENCE: { |
| 1124 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 1125 | ui::Dataspace defaultDataspace; |
| 1126 | ui::PixelFormat defaultPixelFormat; |
| 1127 | ui::Dataspace wideColorGamutDataspace; |
| 1128 | ui::PixelFormat wideColorGamutPixelFormat; |
| 1129 | status_t error = |
| 1130 | getCompositionPreference(&defaultDataspace, &defaultPixelFormat, |
| 1131 | &wideColorGamutDataspace, &wideColorGamutPixelFormat); |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1132 | reply->writeInt32(error); |
| 1133 | if (error == NO_ERROR) { |
Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 1134 | reply->writeInt32(static_cast<int32_t>(defaultDataspace)); |
| 1135 | reply->writeInt32(static_cast<int32_t>(defaultPixelFormat)); |
| 1136 | reply->writeInt32(static_cast<int32_t>(wideColorGamutDataspace)); |
Peiyong Lin | aa3da6a | 2018-12-12 02:48:43 -0800 | [diff] [blame] | 1137 | reply->writeInt32(static_cast<int32_t>(wideColorGamutPixelFormat)); |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1138 | } |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 1139 | return error; |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1140 | } |
Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 1141 | case GET_COLOR_MANAGEMENT: { |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 1142 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 1143 | bool result; |
| 1144 | status_t error = getColorManagement(&result); |
| 1145 | if (error == NO_ERROR) { |
| 1146 | reply->writeBool(result); |
| 1147 | } |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 1148 | return error; |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 1149 | } |
Kevin DuBois | 9c0a176 | 2018-10-16 13:32:31 -0700 | [diff] [blame] | 1150 | case GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: { |
| 1151 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1152 | |
| 1153 | sp<IBinder> display = data.readStrongBinder(); |
| 1154 | ui::PixelFormat format; |
| 1155 | ui::Dataspace dataspace; |
| 1156 | uint8_t component = 0; |
| 1157 | auto result = |
| 1158 | getDisplayedContentSamplingAttributes(display, &format, &dataspace, &component); |
| 1159 | if (result == NO_ERROR) { |
| 1160 | reply->writeUint32(static_cast<uint32_t>(format)); |
| 1161 | reply->writeUint32(static_cast<uint32_t>(dataspace)); |
| 1162 | reply->writeUint32(static_cast<uint32_t>(component)); |
| 1163 | } |
| 1164 | return result; |
| 1165 | } |
Kevin DuBois | 74e5377 | 2018-11-19 10:52:38 -0800 | [diff] [blame] | 1166 | case SET_DISPLAY_CONTENT_SAMPLING_ENABLED: { |
| 1167 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1168 | |
| 1169 | sp<IBinder> display = nullptr; |
| 1170 | bool enable = false; |
| 1171 | int8_t componentMask = 0; |
| 1172 | uint64_t maxFrames = 0; |
| 1173 | status_t result = data.readStrongBinder(&display); |
| 1174 | if (result != NO_ERROR) { |
| 1175 | ALOGE("setDisplayContentSamplingEnabled failure in reading Display token: %d", |
| 1176 | result); |
| 1177 | return result; |
| 1178 | } |
| 1179 | |
| 1180 | result = data.readBool(&enable); |
| 1181 | if (result != NO_ERROR) { |
| 1182 | ALOGE("setDisplayContentSamplingEnabled failure in reading enable: %d", result); |
| 1183 | return result; |
| 1184 | } |
| 1185 | |
| 1186 | result = data.readByte(static_cast<int8_t*>(&componentMask)); |
| 1187 | if (result != NO_ERROR) { |
| 1188 | ALOGE("setDisplayContentSamplingEnabled failure in reading component mask: %d", |
| 1189 | result); |
| 1190 | return result; |
| 1191 | } |
| 1192 | |
| 1193 | result = data.readUint64(&maxFrames); |
| 1194 | if (result != NO_ERROR) { |
| 1195 | ALOGE("setDisplayContentSamplingEnabled failure in reading max frames: %d", result); |
| 1196 | return result; |
| 1197 | } |
| 1198 | |
| 1199 | return setDisplayContentSamplingEnabled(display, enable, |
| 1200 | static_cast<uint8_t>(componentMask), maxFrames); |
| 1201 | } |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 1202 | case GET_DISPLAYED_CONTENT_SAMPLE: { |
| 1203 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1204 | |
| 1205 | sp<IBinder> display = data.readStrongBinder(); |
| 1206 | uint64_t maxFrames = 0; |
| 1207 | uint64_t timestamp = 0; |
| 1208 | |
| 1209 | status_t result = data.readUint64(&maxFrames); |
| 1210 | if (result != NO_ERROR) { |
| 1211 | ALOGE("getDisplayedContentSample failure in reading max frames: %d", result); |
| 1212 | return result; |
| 1213 | } |
| 1214 | |
| 1215 | result = data.readUint64(×tamp); |
| 1216 | if (result != NO_ERROR) { |
| 1217 | ALOGE("getDisplayedContentSample failure in reading timestamp: %d", result); |
| 1218 | return result; |
| 1219 | } |
| 1220 | |
| 1221 | DisplayedFrameStats stats; |
| 1222 | result = getDisplayedContentSample(display, maxFrames, timestamp, &stats); |
| 1223 | if (result == NO_ERROR) { |
| 1224 | reply->writeUint64(stats.numFrames); |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 1225 | reply->writeUint64Vector(stats.component_0_sample); |
| 1226 | reply->writeUint64Vector(stats.component_1_sample); |
| 1227 | reply->writeUint64Vector(stats.component_2_sample); |
| 1228 | reply->writeUint64Vector(stats.component_3_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 1229 | } |
| 1230 | return result; |
| 1231 | } |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 1232 | case GET_PROTECTED_CONTENT_SUPPORT: { |
| 1233 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1234 | bool result; |
| 1235 | status_t error = getProtectedContentSupport(&result); |
| 1236 | if (error == NO_ERROR) { |
| 1237 | reply->writeBool(result); |
| 1238 | } |
| 1239 | return error; |
| 1240 | } |
Marissa Wall | ebc2c05 | 2019-01-16 19:16:55 -0800 | [diff] [blame] | 1241 | case CACHE_BUFFER: { |
| 1242 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1243 | sp<IBinder> token; |
| 1244 | status_t result = data.readStrongBinder(&token); |
| 1245 | if (result != NO_ERROR) { |
| 1246 | ALOGE("cache buffer failure in reading token: %d", result); |
| 1247 | return result; |
| 1248 | } |
| 1249 | |
| 1250 | sp<GraphicBuffer> buffer = new GraphicBuffer(); |
| 1251 | if (data.readBool()) { |
| 1252 | result = data.read(*buffer); |
| 1253 | if (result != NO_ERROR) { |
| 1254 | ALOGE("cache buffer failure in reading buffer: %d", result); |
| 1255 | return result; |
| 1256 | } |
| 1257 | } |
| 1258 | int32_t bufferId = -1; |
| 1259 | status_t error = cacheBuffer(token, buffer, &bufferId); |
| 1260 | if (error == NO_ERROR) { |
| 1261 | reply->writeInt32(bufferId); |
| 1262 | } |
| 1263 | return error; |
| 1264 | } |
| 1265 | case UNCACHE_BUFFER: { |
| 1266 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1267 | sp<IBinder> token; |
| 1268 | status_t result = data.readStrongBinder(&token); |
| 1269 | if (result != NO_ERROR) { |
| 1270 | ALOGE("uncache buffer failure in reading token: %d", result); |
| 1271 | return result; |
| 1272 | } |
| 1273 | |
| 1274 | int32_t bufferId = -1; |
| 1275 | result = data.readInt32(&bufferId); |
| 1276 | if (result != NO_ERROR) { |
| 1277 | ALOGE("uncache buffer failure in reading buffer id: %d", result); |
| 1278 | return result; |
| 1279 | } |
| 1280 | |
| 1281 | return uncacheBuffer(token, bufferId); |
| 1282 | } |
Peiyong Lin | 4f3fddf | 2019-01-24 17:21:24 -0800 | [diff] [blame] | 1283 | case IS_WIDE_COLOR_DISPLAY: { |
| 1284 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1285 | sp<IBinder> display = nullptr; |
| 1286 | status_t error = data.readStrongBinder(&display); |
| 1287 | if (error != NO_ERROR) { |
| 1288 | return error; |
| 1289 | } |
| 1290 | bool result; |
| 1291 | error = isWideColorDisplay(display, &result); |
| 1292 | if (error == NO_ERROR) { |
| 1293 | reply->writeBool(result); |
| 1294 | } |
| 1295 | return error; |
| 1296 | } |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1297 | default: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 1298 | return BBinder::onTransact(code, data, reply, flags); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1299 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1300 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1301 | } |
| 1302 | |
| 1303 | // ---------------------------------------------------------------------------- |
| 1304 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1305 | }; |