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