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 | |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 37 | #include <ui/DisplayConfig.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | #include <ui/DisplayInfo.h> |
Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 39 | #include <ui/DisplayStatInfo.h> |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 40 | #include <ui/DisplayState.h> |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 41 | #include <ui/HdrCapabilities.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 42 | |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 43 | #include <utils/Log.h> |
Mathias Agopian | 9cce325 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 44 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 45 | // --------------------------------------------------------------------------- |
| 46 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | namespace android { |
| 48 | |
Peiyong Lin | 9f03447 | 2018-03-28 15:29:00 -0700 | [diff] [blame] | 49 | using ui::ColorMode; |
| 50 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | class BpSurfaceComposer : public BpInterface<ISurfaceComposer> |
| 52 | { |
| 53 | public: |
Chih-Hung Hsieh | e2347b7 | 2016-04-25 15:41:05 -0700 | [diff] [blame] | 54 | explicit BpSurfaceComposer(const sp<IBinder>& impl) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | : BpInterface<ISurfaceComposer>(impl) |
| 56 | { |
| 57 | } |
| 58 | |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 59 | virtual ~BpSurfaceComposer(); |
| 60 | |
Mathias Agopian | 7e27f05 | 2010-05-28 14:22:23 -0700 | [diff] [blame] | 61 | virtual sp<ISurfaceComposerClient> createConnection() |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 62 | { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 63 | Parcel data, reply; |
| 64 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 65 | remote()->transact(BnSurfaceComposer::CREATE_CONNECTION, data, &reply); |
Mathias Agopian | 7e27f05 | 2010-05-28 14:22:23 -0700 | [diff] [blame] | 66 | return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder()); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 67 | } |
| 68 | |
Marissa Wall | 713b63f | 2018-10-17 15:42:43 -0700 | [diff] [blame] | 69 | virtual void setTransactionState(const Vector<ComposerState>& state, |
| 70 | const Vector<DisplayState>& displays, uint32_t flags, |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 71 | const sp<IBinder>& applyToken, |
Marissa Wall | 17b4e45 | 2018-12-26 16:32:34 -0800 | [diff] [blame] | 72 | const InputWindowCommands& commands, |
Marissa Wall | 78b7220 | 2019-03-15 14:58:34 -0700 | [diff] [blame] | 73 | int64_t desiredPresentTime, |
Valerie Hau | 9dab973 | 2019-08-20 09:29:25 -0700 | [diff] [blame] | 74 | const client_cache_t& uncacheBuffer, bool hasListenerCallbacks, |
Marissa Wall | 3dad52d | 2019-03-22 14:03:19 -0700 | [diff] [blame] | 75 | const std::vector<ListenerCallbacks>& listenerCallbacks) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 76 | Parcel data, reply; |
| 77 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 78 | |
| 79 | data.writeUint32(static_cast<uint32_t>(state.size())); |
| 80 | for (const auto& s : state) { |
| 81 | s.write(data); |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 82 | } |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 83 | |
| 84 | data.writeUint32(static_cast<uint32_t>(displays.size())); |
| 85 | for (const auto& d : displays) { |
| 86 | d.write(data); |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 87 | } |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 88 | |
| 89 | data.writeUint32(flags); |
Marissa Wall | 713b63f | 2018-10-17 15:42:43 -0700 | [diff] [blame] | 90 | data.writeStrongBinder(applyToken); |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 91 | commands.write(data); |
Marissa Wall | 17b4e45 | 2018-12-26 16:32:34 -0800 | [diff] [blame] | 92 | data.writeInt64(desiredPresentTime); |
Steven Moreland | 9d4ce9b | 2019-07-17 15:23:38 -0700 | [diff] [blame] | 93 | data.writeStrongBinder(uncacheBuffer.token.promote()); |
Marissa Wall | 947d34e | 2019-03-29 14:03:53 -0700 | [diff] [blame] | 94 | data.writeUint64(uncacheBuffer.id); |
Valerie Hau | 9dab973 | 2019-08-20 09:29:25 -0700 | [diff] [blame] | 95 | data.writeBool(hasListenerCallbacks); |
Marissa Wall | 3dad52d | 2019-03-22 14:03:19 -0700 | [diff] [blame] | 96 | |
| 97 | if (data.writeVectorSize(listenerCallbacks) == NO_ERROR) { |
| 98 | for (const auto& [listener, callbackIds] : listenerCallbacks) { |
Valerie Hau | 5de3ad2 | 2019-08-20 07:47:43 -0700 | [diff] [blame] | 99 | data.writeStrongBinder(listener); |
Marissa Wall | 3dad52d | 2019-03-22 14:03:19 -0700 | [diff] [blame] | 100 | data.writeInt64Vector(callbackIds); |
| 101 | } |
| 102 | } |
| 103 | |
Jamie Gennis | b8d69a5 | 2011-10-10 15:48:06 -0700 | [diff] [blame] | 104 | remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | virtual void bootFinished() |
| 108 | { |
| 109 | Parcel data, reply; |
| 110 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 111 | remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply); |
| 112 | } |
| 113 | |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 114 | virtual status_t captureScreen(const sp<IBinder>& display, sp<GraphicBuffer>* outBuffer, |
Dominik Laskowski | 718f960 | 2019-11-09 20:01:35 -0800 | [diff] [blame] | 115 | bool& outCapturedSecureLayers, ui::Dataspace reqDataspace, |
| 116 | ui::PixelFormat reqPixelFormat, const Rect& sourceCrop, |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 117 | uint32_t reqWidth, uint32_t reqHeight, bool useIdentityTransform, |
Dominik Laskowski | 718f960 | 2019-11-09 20:01:35 -0800 | [diff] [blame] | 118 | ui::Rotation rotation, bool captureSecureLayers) { |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 119 | Parcel data, reply; |
| 120 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 121 | data.writeStrongBinder(display); |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 122 | data.writeInt32(static_cast<int32_t>(reqDataspace)); |
| 123 | data.writeInt32(static_cast<int32_t>(reqPixelFormat)); |
Dan Stoza | c187900 | 2014-05-22 15:59:05 -0700 | [diff] [blame] | 124 | data.write(sourceCrop); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 125 | data.writeUint32(reqWidth); |
| 126 | data.writeUint32(reqHeight); |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 127 | data.writeInt32(static_cast<int32_t>(useIdentityTransform)); |
Riley Andrews | c3ebe66 | 2014-09-04 16:20:31 -0700 | [diff] [blame] | 128 | data.writeInt32(static_cast<int32_t>(rotation)); |
Robert Carr | fa8855f | 2019-02-19 10:05:00 -0800 | [diff] [blame] | 129 | data.writeInt32(static_cast<int32_t>(captureSecureLayers)); |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 130 | status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply); |
| 131 | if (result != NO_ERROR) { |
| 132 | ALOGE("captureScreen failed to transact: %d", result); |
| 133 | return result; |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 134 | } |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 135 | result = reply.readInt32(); |
| 136 | if (result != NO_ERROR) { |
| 137 | ALOGE("captureScreen failed to readInt32: %d", result); |
| 138 | return result; |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | *outBuffer = new GraphicBuffer(); |
| 142 | reply.read(**outBuffer); |
Robert Carr | 108b2c7 | 2019-04-02 16:32:58 -0700 | [diff] [blame] | 143 | outCapturedSecureLayers = reply.readBool(); |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 144 | |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 145 | return result; |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 146 | } |
| 147 | |
chaviw | 93df2ea | 2019-04-30 16:45:12 -0700 | [diff] [blame] | 148 | virtual status_t captureScreen(uint64_t displayOrLayerStack, ui::Dataspace* outDataspace, |
| 149 | sp<GraphicBuffer>* outBuffer) { |
| 150 | Parcel data, reply; |
| 151 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 152 | data.writeUint64(displayOrLayerStack); |
| 153 | status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN_BY_ID, data, &reply); |
| 154 | if (result != NO_ERROR) { |
| 155 | ALOGE("captureScreen failed to transact: %d", result); |
| 156 | return result; |
| 157 | } |
| 158 | result = reply.readInt32(); |
| 159 | if (result != NO_ERROR) { |
| 160 | ALOGE("captureScreen failed to readInt32: %d", result); |
| 161 | return result; |
| 162 | } |
| 163 | |
| 164 | *outDataspace = static_cast<ui::Dataspace>(reply.readInt32()); |
| 165 | *outBuffer = new GraphicBuffer(); |
| 166 | reply.read(**outBuffer); |
| 167 | return result; |
| 168 | } |
| 169 | |
Robert Carr | 866455f | 2019-04-02 16:28:26 -0700 | [diff] [blame] | 170 | virtual status_t captureLayers( |
| 171 | const sp<IBinder>& layerHandleBinder, sp<GraphicBuffer>* outBuffer, |
| 172 | const ui::Dataspace reqDataspace, const ui::PixelFormat reqPixelFormat, |
| 173 | const Rect& sourceCrop, |
| 174 | const std::unordered_set<sp<IBinder>, SpHash<IBinder>>& excludeLayers, float frameScale, |
| 175 | bool childrenOnly) { |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 176 | Parcel data, reply; |
| 177 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 178 | data.writeStrongBinder(layerHandleBinder); |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 179 | data.writeInt32(static_cast<int32_t>(reqDataspace)); |
| 180 | data.writeInt32(static_cast<int32_t>(reqPixelFormat)); |
chaviw | 7206d49 | 2017-11-10 16:16:12 -0800 | [diff] [blame] | 181 | data.write(sourceCrop); |
Robert Carr | 866455f | 2019-04-02 16:28:26 -0700 | [diff] [blame] | 182 | data.writeInt32(excludeLayers.size()); |
| 183 | for (auto el : excludeLayers) { |
| 184 | data.writeStrongBinder(el); |
| 185 | } |
chaviw | 7206d49 | 2017-11-10 16:16:12 -0800 | [diff] [blame] | 186 | data.writeFloat(frameScale); |
Robert Carr | 578038f | 2018-03-09 12:25:24 -0800 | [diff] [blame] | 187 | data.writeBool(childrenOnly); |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 188 | status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_LAYERS, data, &reply); |
| 189 | if (result != NO_ERROR) { |
| 190 | ALOGE("captureLayers failed to transact: %d", result); |
| 191 | return result; |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 192 | } |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 193 | result = reply.readInt32(); |
| 194 | if (result != NO_ERROR) { |
| 195 | ALOGE("captureLayers failed to readInt32: %d", result); |
| 196 | return result; |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 197 | } |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 198 | |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 199 | *outBuffer = new GraphicBuffer(); |
| 200 | reply.read(**outBuffer); |
| 201 | |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 202 | return result; |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 203 | } |
| 204 | |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 205 | virtual bool authenticateSurfaceTexture( |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 206 | const sp<IGraphicBufferProducer>& bufferProducer) const |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 207 | { |
| 208 | Parcel data, reply; |
| 209 | int err = NO_ERROR; |
| 210 | err = data.writeInterfaceToken( |
| 211 | ISurfaceComposer::getInterfaceDescriptor()); |
| 212 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 213 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing " |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 214 | "interface descriptor: %s (%d)", strerror(-err), -err); |
| 215 | return false; |
| 216 | } |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 217 | err = data.writeStrongBinder(IInterface::asBinder(bufferProducer)); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 218 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 219 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing " |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 220 | "strong binder to parcel: %s (%d)", strerror(-err), -err); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 221 | return false; |
| 222 | } |
| 223 | err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data, |
| 224 | &reply); |
| 225 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 226 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error " |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 227 | "performing transaction: %s (%d)", strerror(-err), -err); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 228 | return false; |
| 229 | } |
| 230 | int32_t result = 0; |
| 231 | err = reply.readInt32(&result); |
| 232 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 233 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error " |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 234 | "retrieving result: %s (%d)", strerror(-err), -err); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 235 | return false; |
| 236 | } |
| 237 | return result != 0; |
| 238 | } |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 239 | |
Brian Anderson | 6b37671 | 2017-04-04 10:51:39 -0700 | [diff] [blame] | 240 | virtual status_t getSupportedFrameTimestamps( |
| 241 | std::vector<FrameEvent>* outSupported) const { |
| 242 | if (!outSupported) { |
| 243 | return UNEXPECTED_NULL; |
| 244 | } |
| 245 | outSupported->clear(); |
| 246 | |
| 247 | Parcel data, reply; |
| 248 | |
| 249 | status_t err = data.writeInterfaceToken( |
| 250 | ISurfaceComposer::getInterfaceDescriptor()); |
| 251 | if (err != NO_ERROR) { |
| 252 | return err; |
| 253 | } |
| 254 | |
| 255 | err = remote()->transact( |
| 256 | BnSurfaceComposer::GET_SUPPORTED_FRAME_TIMESTAMPS, |
| 257 | data, &reply); |
| 258 | if (err != NO_ERROR) { |
| 259 | return err; |
| 260 | } |
| 261 | |
| 262 | int32_t result = 0; |
| 263 | err = reply.readInt32(&result); |
| 264 | if (err != NO_ERROR) { |
| 265 | return err; |
| 266 | } |
| 267 | if (result != NO_ERROR) { |
| 268 | return result; |
| 269 | } |
| 270 | |
| 271 | std::vector<int32_t> supported; |
| 272 | err = reply.readInt32Vector(&supported); |
| 273 | if (err != NO_ERROR) { |
| 274 | return err; |
| 275 | } |
| 276 | |
| 277 | outSupported->reserve(supported.size()); |
| 278 | for (int32_t s : supported) { |
| 279 | outSupported->push_back(static_cast<FrameEvent>(s)); |
| 280 | } |
| 281 | return NO_ERROR; |
| 282 | } |
| 283 | |
Ady Abraham | 0f4a1b1 | 2019-06-04 16:04:04 -0700 | [diff] [blame] | 284 | virtual sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource, |
| 285 | ConfigChanged configChanged) { |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 286 | Parcel data, reply; |
| 287 | sp<IDisplayEventConnection> result; |
| 288 | int err = data.writeInterfaceToken( |
| 289 | ISurfaceComposer::getInterfaceDescriptor()); |
| 290 | if (err != NO_ERROR) { |
| 291 | return result; |
| 292 | } |
Jorim Jaggi | b1e2f8d | 2017-06-08 15:43:59 -0700 | [diff] [blame] | 293 | data.writeInt32(static_cast<int32_t>(vsyncSource)); |
Ady Abraham | 0f4a1b1 | 2019-06-04 16:04:04 -0700 | [diff] [blame] | 294 | data.writeInt32(static_cast<int32_t>(configChanged)); |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 295 | err = remote()->transact( |
| 296 | BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION, |
| 297 | data, &reply); |
| 298 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 299 | ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing " |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 300 | "transaction: %s (%d)", strerror(-err), -err); |
| 301 | return result; |
| 302 | } |
| 303 | result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder()); |
| 304 | return result; |
| 305 | } |
Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 306 | |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 307 | virtual sp<IBinder> createDisplay(const String8& displayName, bool secure) |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 308 | { |
| 309 | Parcel data, reply; |
| 310 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Andy McFadden | 8dfa92f | 2012-09-17 18:27:17 -0700 | [diff] [blame] | 311 | data.writeString8(displayName); |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 312 | data.writeInt32(secure ? 1 : 0); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 313 | remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply); |
| 314 | return reply.readStrongBinder(); |
| 315 | } |
| 316 | |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 317 | virtual void destroyDisplay(const sp<IBinder>& display) |
| 318 | { |
| 319 | Parcel data, reply; |
| 320 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 321 | data.writeStrongBinder(display); |
| 322 | remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply); |
| 323 | } |
| 324 | |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 325 | virtual std::vector<PhysicalDisplayId> getPhysicalDisplayIds() const { |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 326 | Parcel data, reply; |
| 327 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 328 | if (remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_IDS, data, &reply) == |
| 329 | NO_ERROR) { |
| 330 | std::vector<PhysicalDisplayId> displayIds; |
| 331 | if (reply.readUint64Vector(&displayIds) == NO_ERROR) { |
| 332 | return displayIds; |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | return {}; |
| 337 | } |
| 338 | |
| 339 | virtual sp<IBinder> getPhysicalDisplayToken(PhysicalDisplayId displayId) const { |
| 340 | Parcel data, reply; |
| 341 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 342 | data.writeUint64(displayId); |
| 343 | remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_TOKEN, data, &reply); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 344 | return reply.readStrongBinder(); |
| 345 | } |
| 346 | |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 347 | virtual void setPowerMode(const sp<IBinder>& display, int mode) |
Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 348 | { |
| 349 | Parcel data, reply; |
| 350 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Andy McFadden | c01a79d | 2012-09-27 16:02:06 -0700 | [diff] [blame] | 351 | data.writeStrongBinder(display); |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 352 | data.writeInt32(mode); |
| 353 | remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply); |
Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 354 | } |
Mathias Agopian | 3094df3 | 2012-06-18 18:06:45 -0700 | [diff] [blame] | 355 | |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 356 | virtual status_t getDisplayState(const sp<IBinder>& display, ui::DisplayState* state) { |
| 357 | Parcel data, reply; |
| 358 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 359 | data.writeStrongBinder(display); |
| 360 | remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATE, data, &reply); |
| 361 | const status_t result = reply.readInt32(); |
| 362 | if (result == NO_ERROR) { |
| 363 | memcpy(state, reply.readInplace(sizeof(ui::DisplayState)), sizeof(ui::DisplayState)); |
| 364 | } |
| 365 | return result; |
| 366 | } |
| 367 | |
| 368 | virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) { |
| 369 | Parcel data, reply; |
| 370 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 371 | data.writeStrongBinder(display); |
| 372 | remote()->transact(BnSurfaceComposer::GET_DISPLAY_INFO, data, &reply); |
| 373 | const status_t result = reply.readInt32(); |
| 374 | if (result == NO_ERROR) { |
| 375 | memcpy(info, reply.readInplace(sizeof(DisplayInfo)), sizeof(DisplayInfo)); |
| 376 | } |
| 377 | return result; |
| 378 | } |
| 379 | |
| 380 | virtual status_t getDisplayConfigs(const sp<IBinder>& display, Vector<DisplayConfig>* configs) { |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 381 | Parcel data, reply; |
| 382 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 383 | data.writeStrongBinder(display); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 384 | remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply); |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 385 | const status_t result = reply.readInt32(); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 386 | if (result == NO_ERROR) { |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 387 | const size_t numConfigs = reply.readUint32(); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 388 | configs->clear(); |
| 389 | configs->resize(numConfigs); |
| 390 | for (size_t c = 0; c < numConfigs; ++c) { |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 391 | memcpy(&(configs->editItemAt(c)), reply.readInplace(sizeof(DisplayConfig)), |
| 392 | sizeof(DisplayConfig)); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 393 | } |
| 394 | } |
| 395 | return result; |
| 396 | } |
| 397 | |
Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 398 | virtual status_t getDisplayStats(const sp<IBinder>& display, |
| 399 | DisplayStatInfo* stats) |
| 400 | { |
| 401 | Parcel data, reply; |
| 402 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 403 | data.writeStrongBinder(display); |
| 404 | remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply); |
| 405 | status_t result = reply.readInt32(); |
| 406 | if (result == NO_ERROR) { |
| 407 | memcpy(stats, |
| 408 | reply.readInplace(sizeof(DisplayStatInfo)), |
| 409 | sizeof(DisplayStatInfo)); |
| 410 | } |
| 411 | return result; |
| 412 | } |
| 413 | |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 414 | virtual int getActiveConfig(const sp<IBinder>& display) |
| 415 | { |
| 416 | Parcel data, reply; |
| 417 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 418 | data.writeStrongBinder(display); |
| 419 | remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply); |
| 420 | return reply.readInt32(); |
| 421 | } |
| 422 | |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 423 | virtual status_t getDisplayColorModes(const sp<IBinder>& display, |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 424 | Vector<ColorMode>* outColorModes) { |
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("getDisplayColorModes failed to writeInterfaceToken: %d", result); |
| 429 | return result; |
| 430 | } |
| 431 | result = data.writeStrongBinder(display); |
| 432 | if (result != NO_ERROR) { |
| 433 | ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result); |
| 434 | return result; |
| 435 | } |
| 436 | result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply); |
| 437 | if (result != NO_ERROR) { |
| 438 | ALOGE("getDisplayColorModes failed to transact: %d", result); |
| 439 | return result; |
| 440 | } |
| 441 | result = static_cast<status_t>(reply.readInt32()); |
| 442 | if (result == NO_ERROR) { |
| 443 | size_t numModes = reply.readUint32(); |
| 444 | outColorModes->clear(); |
| 445 | outColorModes->resize(numModes); |
| 446 | for (size_t i = 0; i < numModes; ++i) { |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 447 | outColorModes->replaceAt(static_cast<ColorMode>(reply.readInt32()), i); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 448 | } |
| 449 | } |
| 450 | return result; |
| 451 | } |
| 452 | |
Daniel Solomon | 42d0456 | 2019-01-20 21:03:19 -0800 | [diff] [blame] | 453 | virtual status_t getDisplayNativePrimaries(const sp<IBinder>& display, |
| 454 | ui::DisplayPrimaries& primaries) { |
| 455 | Parcel data, reply; |
| 456 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 457 | if (result != NO_ERROR) { |
| 458 | ALOGE("getDisplayNativePrimaries failed to writeInterfaceToken: %d", result); |
| 459 | return result; |
| 460 | } |
| 461 | result = data.writeStrongBinder(display); |
| 462 | if (result != NO_ERROR) { |
| 463 | ALOGE("getDisplayNativePrimaries failed to writeStrongBinder: %d", result); |
| 464 | return result; |
| 465 | } |
| 466 | result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_NATIVE_PRIMARIES, data, &reply); |
| 467 | if (result != NO_ERROR) { |
| 468 | ALOGE("getDisplayNativePrimaries failed to transact: %d", result); |
| 469 | return result; |
| 470 | } |
| 471 | result = reply.readInt32(); |
| 472 | if (result == NO_ERROR) { |
| 473 | memcpy(&primaries, reply.readInplace(sizeof(ui::DisplayPrimaries)), |
| 474 | sizeof(ui::DisplayPrimaries)); |
| 475 | } |
| 476 | return result; |
| 477 | } |
| 478 | |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 479 | virtual ColorMode getActiveColorMode(const sp<IBinder>& display) { |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 480 | Parcel data, reply; |
| 481 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 482 | if (result != NO_ERROR) { |
| 483 | ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result); |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 484 | return static_cast<ColorMode>(result); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 485 | } |
| 486 | result = data.writeStrongBinder(display); |
| 487 | if (result != NO_ERROR) { |
| 488 | ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result); |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 489 | return static_cast<ColorMode>(result); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 490 | } |
| 491 | result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply); |
| 492 | if (result != NO_ERROR) { |
| 493 | ALOGE("getActiveColorMode failed to transact: %d", result); |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 494 | return static_cast<ColorMode>(result); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 495 | } |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 496 | return static_cast<ColorMode>(reply.readInt32()); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 497 | } |
| 498 | |
| 499 | virtual status_t setActiveColorMode(const sp<IBinder>& display, |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 500 | ColorMode colorMode) { |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 501 | Parcel data, reply; |
| 502 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 503 | if (result != NO_ERROR) { |
| 504 | ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result); |
| 505 | return result; |
| 506 | } |
| 507 | result = data.writeStrongBinder(display); |
| 508 | if (result != NO_ERROR) { |
| 509 | ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result); |
| 510 | return result; |
| 511 | } |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 512 | result = data.writeInt32(static_cast<int32_t>(colorMode)); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 513 | if (result != NO_ERROR) { |
| 514 | ALOGE("setActiveColorMode failed to writeInt32: %d", result); |
| 515 | return result; |
| 516 | } |
| 517 | result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply); |
| 518 | if (result != NO_ERROR) { |
| 519 | ALOGE("setActiveColorMode failed to transact: %d", result); |
| 520 | return result; |
| 521 | } |
| 522 | return static_cast<status_t>(reply.readInt32()); |
| 523 | } |
| 524 | |
Galia Peycheva | 5492cb5 | 2019-10-30 14:13:16 +0100 | [diff] [blame] | 525 | virtual status_t getAutoLowLatencyModeSupport(const sp<IBinder>& display, |
| 526 | bool* outSupport) const { |
| 527 | Parcel data, reply; |
| 528 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 529 | status_t result = data.writeStrongBinder(display); |
| 530 | if (result != NO_ERROR) { |
| 531 | ALOGE("getAutoLowLatencyModeSupport failed to writeStrongBinder: %d", result); |
| 532 | return result; |
| 533 | } |
| 534 | result = remote()->transact(BnSurfaceComposer::GET_AUTO_LOW_LATENCY_MODE_SUPPORT, data, |
| 535 | &reply); |
| 536 | if (result != NO_ERROR) { |
| 537 | ALOGE("getAutoLowLatencyModeSupport failed to transact: %d", result); |
| 538 | return result; |
| 539 | } |
| 540 | return reply.readBool(outSupport); |
| 541 | } |
| 542 | |
| 543 | virtual void setAutoLowLatencyMode(const sp<IBinder>& display, bool on) { |
| 544 | Parcel data, reply; |
| 545 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 546 | if (result != NO_ERROR) { |
| 547 | ALOGE("setAutoLowLatencyMode failed to writeInterfaceToken: %d", result); |
| 548 | return; |
| 549 | } |
| 550 | |
| 551 | result = data.writeStrongBinder(display); |
| 552 | if (result != NO_ERROR) { |
| 553 | ALOGE("setAutoLowLatencyMode failed to writeStrongBinder: %d", result); |
| 554 | return; |
| 555 | } |
| 556 | result = data.writeBool(on); |
| 557 | if (result != NO_ERROR) { |
| 558 | ALOGE("setAutoLowLatencyMode failed to writeBool: %d", result); |
| 559 | return; |
| 560 | } |
| 561 | result = remote()->transact(BnSurfaceComposer::SET_AUTO_LOW_LATENCY_MODE, data, &reply); |
| 562 | if (result != NO_ERROR) { |
| 563 | ALOGE("setAutoLowLatencyMode failed to transact: %d", result); |
| 564 | return; |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | virtual status_t getGameContentTypeSupport(const sp<IBinder>& display, bool* outSupport) const { |
| 569 | Parcel data, reply; |
| 570 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 571 | status_t result = data.writeStrongBinder(display); |
| 572 | if (result != NO_ERROR) { |
| 573 | ALOGE("getGameContentTypeSupport failed to writeStrongBinder: %d", result); |
| 574 | return result; |
| 575 | } |
| 576 | result = remote()->transact(BnSurfaceComposer::GET_GAME_CONTENT_TYPE_SUPPORT, data, &reply); |
| 577 | if (result != NO_ERROR) { |
| 578 | ALOGE("getGameContentTypeSupport failed to transact: %d", result); |
| 579 | return result; |
| 580 | } |
| 581 | return reply.readBool(outSupport); |
| 582 | } |
| 583 | |
| 584 | virtual void setGameContentType(const sp<IBinder>& display, bool on) { |
| 585 | Parcel data, reply; |
| 586 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 587 | if (result != NO_ERROR) { |
| 588 | ALOGE("setGameContentType failed to writeInterfaceToken: %d", result); |
| 589 | return; |
| 590 | } |
| 591 | result = data.writeStrongBinder(display); |
| 592 | if (result != NO_ERROR) { |
| 593 | ALOGE("setGameContentType failed to writeStrongBinder: %d", result); |
| 594 | return; |
| 595 | } |
| 596 | result = data.writeBool(on); |
| 597 | if (result != NO_ERROR) { |
| 598 | ALOGE("setGameContentType failed to writeBool: %d", result); |
| 599 | return; |
| 600 | } |
| 601 | result = remote()->transact(BnSurfaceComposer::SET_GAME_CONTENT_TYPE, data, &reply); |
| 602 | if (result != NO_ERROR) { |
| 603 | ALOGE("setGameContentType failed to transact: %d", result); |
| 604 | } |
| 605 | } |
| 606 | |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 607 | virtual status_t clearAnimationFrameStats() { |
| 608 | Parcel data, reply; |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 609 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 610 | if (result != NO_ERROR) { |
| 611 | ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result); |
| 612 | return result; |
| 613 | } |
| 614 | result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply); |
| 615 | if (result != NO_ERROR) { |
| 616 | ALOGE("clearAnimationFrameStats failed to transact: %d", result); |
| 617 | return result; |
| 618 | } |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 619 | return reply.readInt32(); |
| 620 | } |
| 621 | |
| 622 | virtual status_t getAnimationFrameStats(FrameStats* outStats) const { |
| 623 | Parcel data, reply; |
| 624 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 625 | remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply); |
| 626 | reply.read(*outStats); |
| 627 | return reply.readInt32(); |
| 628 | } |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 629 | |
| 630 | virtual status_t getHdrCapabilities(const sp<IBinder>& display, |
| 631 | HdrCapabilities* outCapabilities) const { |
| 632 | Parcel data, reply; |
| 633 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 634 | status_t result = data.writeStrongBinder(display); |
| 635 | if (result != NO_ERROR) { |
| 636 | ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result); |
| 637 | return result; |
| 638 | } |
| 639 | result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES, |
| 640 | data, &reply); |
| 641 | if (result != NO_ERROR) { |
| 642 | ALOGE("getHdrCapabilities failed to transact: %d", result); |
| 643 | return result; |
| 644 | } |
| 645 | result = reply.readInt32(); |
| 646 | if (result == NO_ERROR) { |
Mathias Agopian | e1f5e6f | 2017-02-06 16:34:41 -0800 | [diff] [blame] | 647 | result = reply.read(*outCapabilities); |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 648 | } |
| 649 | return result; |
| 650 | } |
Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 651 | |
| 652 | virtual status_t enableVSyncInjections(bool enable) { |
| 653 | Parcel data, reply; |
| 654 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 655 | if (result != NO_ERROR) { |
| 656 | ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result); |
| 657 | return result; |
| 658 | } |
| 659 | result = data.writeBool(enable); |
| 660 | if (result != NO_ERROR) { |
| 661 | ALOGE("enableVSyncInjections failed to writeBool: %d", result); |
| 662 | return result; |
| 663 | } |
Steven Moreland | 366eb42 | 2019-04-01 19:22:32 -0700 | [diff] [blame] | 664 | result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS, data, &reply, |
| 665 | IBinder::FLAG_ONEWAY); |
Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 666 | if (result != NO_ERROR) { |
| 667 | ALOGE("enableVSyncInjections failed to transact: %d", result); |
| 668 | return result; |
| 669 | } |
| 670 | return result; |
| 671 | } |
| 672 | |
| 673 | virtual status_t injectVSync(nsecs_t when) { |
| 674 | Parcel data, reply; |
| 675 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 676 | if (result != NO_ERROR) { |
| 677 | ALOGE("injectVSync failed to writeInterfaceToken: %d", result); |
| 678 | return result; |
| 679 | } |
| 680 | result = data.writeInt64(when); |
| 681 | if (result != NO_ERROR) { |
| 682 | ALOGE("injectVSync failed to writeInt64: %d", result); |
| 683 | return result; |
| 684 | } |
Steven Moreland | 366eb42 | 2019-04-01 19:22:32 -0700 | [diff] [blame] | 685 | result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply, |
| 686 | IBinder::FLAG_ONEWAY); |
Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 687 | if (result != NO_ERROR) { |
| 688 | ALOGE("injectVSync failed to transact: %d", result); |
| 689 | return result; |
| 690 | } |
| 691 | return result; |
| 692 | } |
| 693 | |
Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 694 | virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const |
| 695 | { |
| 696 | if (!outLayers) { |
| 697 | return UNEXPECTED_NULL; |
| 698 | } |
| 699 | |
| 700 | Parcel data, reply; |
| 701 | |
| 702 | status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 703 | if (err != NO_ERROR) { |
| 704 | return err; |
| 705 | } |
| 706 | |
| 707 | err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply); |
| 708 | if (err != NO_ERROR) { |
| 709 | return err; |
| 710 | } |
| 711 | |
| 712 | int32_t result = 0; |
| 713 | err = reply.readInt32(&result); |
| 714 | if (err != NO_ERROR) { |
| 715 | return err; |
| 716 | } |
| 717 | if (result != NO_ERROR) { |
| 718 | return result; |
| 719 | } |
| 720 | |
| 721 | outLayers->clear(); |
| 722 | return reply.readParcelableVector(outLayers); |
| 723 | } |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 724 | |
Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 725 | virtual status_t getCompositionPreference(ui::Dataspace* defaultDataspace, |
| 726 | ui::PixelFormat* defaultPixelFormat, |
| 727 | ui::Dataspace* wideColorGamutDataspace, |
| 728 | ui::PixelFormat* wideColorGamutPixelFormat) const { |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 729 | Parcel data, reply; |
| 730 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 731 | if (error != NO_ERROR) { |
| 732 | return error; |
| 733 | } |
| 734 | error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply); |
| 735 | if (error != NO_ERROR) { |
| 736 | return error; |
| 737 | } |
| 738 | error = static_cast<status_t>(reply.readInt32()); |
| 739 | if (error == NO_ERROR) { |
Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 740 | *defaultDataspace = static_cast<ui::Dataspace>(reply.readInt32()); |
| 741 | *defaultPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32()); |
| 742 | *wideColorGamutDataspace = static_cast<ui::Dataspace>(reply.readInt32()); |
| 743 | *wideColorGamutPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32()); |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 744 | } |
| 745 | return error; |
| 746 | } |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 747 | |
Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 748 | virtual status_t getColorManagement(bool* outGetColorManagement) const { |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 749 | Parcel data, reply; |
| 750 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 751 | remote()->transact(BnSurfaceComposer::GET_COLOR_MANAGEMENT, data, &reply); |
| 752 | bool result; |
| 753 | status_t err = reply.readBool(&result); |
| 754 | if (err == NO_ERROR) { |
| 755 | *outGetColorManagement = result; |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 756 | } |
Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 757 | return err; |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 758 | } |
Kevin DuBois | 9c0a176 | 2018-10-16 13:32:31 -0700 | [diff] [blame] | 759 | |
| 760 | virtual status_t getDisplayedContentSamplingAttributes(const sp<IBinder>& display, |
| 761 | ui::PixelFormat* outFormat, |
| 762 | ui::Dataspace* outDataspace, |
| 763 | uint8_t* outComponentMask) const { |
| 764 | if (!outFormat || !outDataspace || !outComponentMask) return BAD_VALUE; |
| 765 | Parcel data, reply; |
| 766 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 767 | data.writeStrongBinder(display); |
| 768 | |
| 769 | status_t error = |
| 770 | remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES, |
| 771 | data, &reply); |
| 772 | if (error != NO_ERROR) { |
| 773 | return error; |
| 774 | } |
| 775 | |
| 776 | uint32_t value = 0; |
| 777 | error = reply.readUint32(&value); |
| 778 | if (error != NO_ERROR) { |
| 779 | return error; |
| 780 | } |
| 781 | *outFormat = static_cast<ui::PixelFormat>(value); |
| 782 | |
| 783 | error = reply.readUint32(&value); |
| 784 | if (error != NO_ERROR) { |
| 785 | return error; |
| 786 | } |
| 787 | *outDataspace = static_cast<ui::Dataspace>(value); |
| 788 | |
| 789 | error = reply.readUint32(&value); |
| 790 | if (error != NO_ERROR) { |
| 791 | return error; |
| 792 | } |
| 793 | *outComponentMask = static_cast<uint8_t>(value); |
| 794 | return error; |
| 795 | } |
Kevin DuBois | 74e5377 | 2018-11-19 10:52:38 -0800 | [diff] [blame] | 796 | |
| 797 | virtual status_t setDisplayContentSamplingEnabled(const sp<IBinder>& display, bool enable, |
| 798 | uint8_t componentMask, |
| 799 | uint64_t maxFrames) const { |
| 800 | Parcel data, reply; |
| 801 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 802 | data.writeStrongBinder(display); |
| 803 | data.writeBool(enable); |
| 804 | data.writeByte(static_cast<int8_t>(componentMask)); |
| 805 | data.writeUint64(maxFrames); |
| 806 | status_t result = |
| 807 | remote()->transact(BnSurfaceComposer::SET_DISPLAY_CONTENT_SAMPLING_ENABLED, data, |
| 808 | &reply); |
| 809 | return result; |
| 810 | } |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 811 | |
| 812 | virtual status_t getDisplayedContentSample(const sp<IBinder>& display, uint64_t maxFrames, |
| 813 | uint64_t timestamp, |
| 814 | DisplayedFrameStats* outStats) const { |
| 815 | if (!outStats) return BAD_VALUE; |
| 816 | |
| 817 | Parcel data, reply; |
| 818 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 819 | data.writeStrongBinder(display); |
| 820 | data.writeUint64(maxFrames); |
| 821 | data.writeUint64(timestamp); |
| 822 | |
| 823 | status_t result = |
| 824 | remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLE, data, &reply); |
| 825 | |
| 826 | if (result != NO_ERROR) { |
| 827 | return result; |
| 828 | } |
| 829 | |
| 830 | result = reply.readUint64(&outStats->numFrames); |
| 831 | if (result != NO_ERROR) { |
| 832 | return result; |
| 833 | } |
| 834 | |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 835 | result = reply.readUint64Vector(&outStats->component_0_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 836 | if (result != NO_ERROR) { |
| 837 | return result; |
| 838 | } |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 839 | result = reply.readUint64Vector(&outStats->component_1_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 840 | if (result != NO_ERROR) { |
| 841 | return result; |
| 842 | } |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 843 | result = reply.readUint64Vector(&outStats->component_2_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 844 | if (result != NO_ERROR) { |
| 845 | return result; |
| 846 | } |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 847 | result = reply.readUint64Vector(&outStats->component_3_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 848 | return result; |
| 849 | } |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 850 | |
| 851 | virtual status_t getProtectedContentSupport(bool* outSupported) const { |
| 852 | Parcel data, reply; |
| 853 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Peiyong Lin | b6888fa | 2019-01-28 13:20:58 -0800 | [diff] [blame] | 854 | status_t error = |
| 855 | remote()->transact(BnSurfaceComposer::GET_PROTECTED_CONTENT_SUPPORT, data, &reply); |
| 856 | if (error != NO_ERROR) { |
| 857 | return error; |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 858 | } |
Peiyong Lin | b6888fa | 2019-01-28 13:20:58 -0800 | [diff] [blame] | 859 | error = reply.readBool(outSupported); |
| 860 | return error; |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 861 | } |
Marissa Wall | ebc2c05 | 2019-01-16 19:16:55 -0800 | [diff] [blame] | 862 | |
Peiyong Lin | 4f3fddf | 2019-01-24 17:21:24 -0800 | [diff] [blame] | 863 | virtual status_t isWideColorDisplay(const sp<IBinder>& token, |
| 864 | bool* outIsWideColorDisplay) const { |
| 865 | Parcel data, reply; |
| 866 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 867 | if (error != NO_ERROR) { |
| 868 | return error; |
| 869 | } |
| 870 | error = data.writeStrongBinder(token); |
| 871 | if (error != NO_ERROR) { |
| 872 | return error; |
| 873 | } |
| 874 | |
| 875 | error = remote()->transact(BnSurfaceComposer::IS_WIDE_COLOR_DISPLAY, data, &reply); |
| 876 | if (error != NO_ERROR) { |
| 877 | return error; |
| 878 | } |
| 879 | error = reply.readBool(outIsWideColorDisplay); |
| 880 | return error; |
| 881 | } |
Dan Stoza | 84ab937 | 2018-12-17 15:27:57 -0800 | [diff] [blame] | 882 | |
| 883 | virtual status_t addRegionSamplingListener(const Rect& samplingArea, |
| 884 | const sp<IBinder>& stopLayerHandle, |
| 885 | const sp<IRegionSamplingListener>& listener) { |
| 886 | Parcel data, reply; |
| 887 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 888 | if (error != NO_ERROR) { |
| 889 | ALOGE("addRegionSamplingListener: Failed to write interface token"); |
| 890 | return error; |
| 891 | } |
| 892 | error = data.write(samplingArea); |
| 893 | if (error != NO_ERROR) { |
| 894 | ALOGE("addRegionSamplingListener: Failed to write sampling area"); |
| 895 | return error; |
| 896 | } |
| 897 | error = data.writeStrongBinder(stopLayerHandle); |
| 898 | if (error != NO_ERROR) { |
| 899 | ALOGE("addRegionSamplingListener: Failed to write stop layer handle"); |
| 900 | return error; |
| 901 | } |
| 902 | error = data.writeStrongBinder(IInterface::asBinder(listener)); |
| 903 | if (error != NO_ERROR) { |
| 904 | ALOGE("addRegionSamplingListener: Failed to write listener"); |
| 905 | return error; |
| 906 | } |
| 907 | error = remote()->transact(BnSurfaceComposer::ADD_REGION_SAMPLING_LISTENER, data, &reply); |
| 908 | if (error != NO_ERROR) { |
| 909 | ALOGE("addRegionSamplingListener: Failed to transact"); |
| 910 | } |
| 911 | return error; |
| 912 | } |
| 913 | |
| 914 | virtual status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) { |
| 915 | Parcel data, reply; |
| 916 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 917 | if (error != NO_ERROR) { |
tangrobin | af45f01 | 2019-02-26 18:10:10 +0800 | [diff] [blame] | 918 | ALOGE("removeRegionSamplingListener: Failed to write interface token"); |
Dan Stoza | 84ab937 | 2018-12-17 15:27:57 -0800 | [diff] [blame] | 919 | return error; |
| 920 | } |
| 921 | error = data.writeStrongBinder(IInterface::asBinder(listener)); |
| 922 | if (error != NO_ERROR) { |
tangrobin | af45f01 | 2019-02-26 18:10:10 +0800 | [diff] [blame] | 923 | ALOGE("removeRegionSamplingListener: Failed to write listener"); |
Dan Stoza | 84ab937 | 2018-12-17 15:27:57 -0800 | [diff] [blame] | 924 | return error; |
| 925 | } |
| 926 | error = remote()->transact(BnSurfaceComposer::REMOVE_REGION_SAMPLING_LISTENER, data, |
| 927 | &reply); |
| 928 | if (error != NO_ERROR) { |
tangrobin | af45f01 | 2019-02-26 18:10:10 +0800 | [diff] [blame] | 929 | ALOGE("removeRegionSamplingListener: Failed to transact"); |
Dan Stoza | 84ab937 | 2018-12-17 15:27:57 -0800 | [diff] [blame] | 930 | } |
| 931 | return error; |
| 932 | } |
Ady Abraham | 838de06 | 2019-02-04 10:24:03 -0800 | [diff] [blame] | 933 | |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 934 | virtual status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken, |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 935 | int32_t defaultConfig, float minRefreshRate, |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 936 | float maxRefreshRate) { |
| 937 | Parcel data, reply; |
| 938 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 939 | if (result != NO_ERROR) { |
| 940 | ALOGE("setDesiredDisplayConfigSpecs: failed to writeInterfaceToken: %d", result); |
| 941 | return result; |
| 942 | } |
| 943 | result = data.writeStrongBinder(displayToken); |
| 944 | if (result != NO_ERROR) { |
| 945 | ALOGE("setDesiredDisplayConfigSpecs: failed to write display token: %d", result); |
| 946 | return result; |
| 947 | } |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 948 | result = data.writeInt32(defaultConfig); |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 949 | if (result != NO_ERROR) { |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 950 | ALOGE("setDesiredDisplayConfigSpecs failed to write defaultConfig: %d", result); |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 951 | return result; |
| 952 | } |
| 953 | result = data.writeFloat(minRefreshRate); |
| 954 | if (result != NO_ERROR) { |
| 955 | ALOGE("setDesiredDisplayConfigSpecs failed to write minRefreshRate: %d", result); |
| 956 | return result; |
| 957 | } |
| 958 | result = data.writeFloat(maxRefreshRate); |
| 959 | if (result != NO_ERROR) { |
| 960 | ALOGE("setDesiredDisplayConfigSpecs failed to write maxRefreshRate: %d", result); |
| 961 | return result; |
| 962 | } |
| 963 | |
| 964 | result = remote()->transact(BnSurfaceComposer::SET_DESIRED_DISPLAY_CONFIG_SPECS, data, |
| 965 | &reply); |
| 966 | if (result != NO_ERROR) { |
| 967 | ALOGE("setDesiredDisplayConfigSpecs failed to transact: %d", result); |
| 968 | return result; |
| 969 | } |
| 970 | return reply.readInt32(); |
| 971 | } |
| 972 | |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 973 | virtual status_t getDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken, |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 974 | int32_t* outDefaultConfig, |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 975 | float* outMinRefreshRate, |
| 976 | float* outMaxRefreshRate) { |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 977 | if (!outDefaultConfig || !outMinRefreshRate || !outMaxRefreshRate) return BAD_VALUE; |
Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 978 | Parcel data, reply; |
| 979 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 980 | if (result != NO_ERROR) { |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 981 | ALOGE("getDesiredDisplayConfigSpecs failed to writeInterfaceToken: %d", result); |
Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 982 | return result; |
| 983 | } |
| 984 | result = data.writeStrongBinder(displayToken); |
| 985 | if (result != NO_ERROR) { |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 986 | ALOGE("getDesiredDisplayConfigSpecs failed to writeStrongBinder: %d", result); |
Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 987 | return result; |
| 988 | } |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 989 | result = remote()->transact(BnSurfaceComposer::GET_DESIRED_DISPLAY_CONFIG_SPECS, data, |
| 990 | &reply); |
Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 991 | if (result != NO_ERROR) { |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 992 | ALOGE("getDesiredDisplayConfigSpecs failed to transact: %d", result); |
Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 993 | return result; |
| 994 | } |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 995 | result = reply.readInt32(outDefaultConfig); |
Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 996 | if (result != NO_ERROR) { |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 997 | ALOGE("getDesiredDisplayConfigSpecs failed to read defaultConfig: %d", result); |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 998 | return result; |
| 999 | } |
| 1000 | result = reply.readFloat(outMinRefreshRate); |
| 1001 | if (result != NO_ERROR) { |
| 1002 | ALOGE("getDesiredDisplayConfigSpecs failed to read minRefreshRate: %d", result); |
| 1003 | return result; |
| 1004 | } |
| 1005 | result = reply.readFloat(outMaxRefreshRate); |
| 1006 | if (result != NO_ERROR) { |
| 1007 | ALOGE("getDesiredDisplayConfigSpecs failed to read maxRefreshRate: %d", result); |
Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 1008 | return result; |
| 1009 | } |
| 1010 | return reply.readInt32(); |
| 1011 | } |
Dan Gittik | 57e63c5 | 2019-01-18 16:37:54 +0000 | [diff] [blame] | 1012 | |
| 1013 | virtual status_t getDisplayBrightnessSupport(const sp<IBinder>& displayToken, |
| 1014 | bool* outSupport) const { |
| 1015 | Parcel data, reply; |
| 1016 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 1017 | if (error != NO_ERROR) { |
| 1018 | ALOGE("getDisplayBrightnessSupport: failed to write interface token: %d", error); |
| 1019 | return error; |
| 1020 | } |
| 1021 | error = data.writeStrongBinder(displayToken); |
| 1022 | if (error != NO_ERROR) { |
| 1023 | ALOGE("getDisplayBrightnessSupport: failed to write display token: %d", error); |
| 1024 | return error; |
| 1025 | } |
| 1026 | error = remote()->transact(BnSurfaceComposer::GET_DISPLAY_BRIGHTNESS_SUPPORT, data, &reply); |
| 1027 | if (error != NO_ERROR) { |
| 1028 | ALOGE("getDisplayBrightnessSupport: failed to transact: %d", error); |
| 1029 | return error; |
| 1030 | } |
| 1031 | bool support; |
| 1032 | error = reply.readBool(&support); |
| 1033 | if (error != NO_ERROR) { |
| 1034 | ALOGE("getDisplayBrightnessSupport: failed to read support: %d", error); |
| 1035 | return error; |
| 1036 | } |
| 1037 | *outSupport = support; |
| 1038 | return NO_ERROR; |
| 1039 | } |
| 1040 | |
| 1041 | virtual status_t setDisplayBrightness(const sp<IBinder>& displayToken, float brightness) const { |
| 1042 | Parcel data, reply; |
| 1043 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 1044 | if (error != NO_ERROR) { |
| 1045 | ALOGE("setDisplayBrightness: failed to write interface token: %d", error); |
| 1046 | return error; |
| 1047 | } |
| 1048 | error = data.writeStrongBinder(displayToken); |
| 1049 | if (error != NO_ERROR) { |
| 1050 | ALOGE("setDisplayBrightness: failed to write display token: %d", error); |
| 1051 | return error; |
| 1052 | } |
| 1053 | error = data.writeFloat(brightness); |
| 1054 | if (error != NO_ERROR) { |
| 1055 | ALOGE("setDisplayBrightness: failed to write brightness: %d", error); |
| 1056 | return error; |
| 1057 | } |
| 1058 | error = remote()->transact(BnSurfaceComposer::SET_DISPLAY_BRIGHTNESS, data, &reply); |
| 1059 | if (error != NO_ERROR) { |
| 1060 | ALOGE("setDisplayBrightness: failed to transact: %d", error); |
| 1061 | return error; |
| 1062 | } |
| 1063 | return NO_ERROR; |
| 1064 | } |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 1065 | |
| 1066 | virtual status_t notifyPowerHint(int32_t hintId) { |
| 1067 | Parcel data, reply; |
| 1068 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 1069 | if (error != NO_ERROR) { |
| 1070 | ALOGE("notifyPowerHint: failed to write interface token: %d", error); |
| 1071 | return error; |
| 1072 | } |
| 1073 | error = data.writeInt32(hintId); |
| 1074 | if (error != NO_ERROR) { |
| 1075 | ALOGE("notifyPowerHint: failed to write hintId: %d", error); |
| 1076 | return error; |
| 1077 | } |
| 1078 | error = remote()->transact(BnSurfaceComposer::NOTIFY_POWER_HINT, data, &reply, |
| 1079 | IBinder::FLAG_ONEWAY); |
| 1080 | if (error != NO_ERROR) { |
| 1081 | ALOGE("notifyPowerHint: failed to transact: %d", error); |
| 1082 | return error; |
| 1083 | } |
| 1084 | return NO_ERROR; |
| 1085 | } |
Vishnu Nair | b13bb95 | 2019-11-15 10:24:08 -0800 | [diff] [blame] | 1086 | |
| 1087 | virtual status_t setGlobalShadowSettings(const half4& ambientColor, const half4& spotColor, |
| 1088 | float lightPosY, float lightPosZ, float lightRadius) { |
| 1089 | Parcel data, reply; |
| 1090 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 1091 | if (error != NO_ERROR) { |
| 1092 | ALOGE("setGlobalShadowSettings: failed to write interface token: %d", error); |
| 1093 | return error; |
| 1094 | } |
| 1095 | |
| 1096 | std::vector<float> shadowConfig = {ambientColor.r, ambientColor.g, ambientColor.b, |
| 1097 | ambientColor.a, spotColor.r, spotColor.g, |
| 1098 | spotColor.b, spotColor.a, lightPosY, |
| 1099 | lightPosZ, lightRadius}; |
| 1100 | |
| 1101 | error = data.writeFloatVector(shadowConfig); |
| 1102 | if (error != NO_ERROR) { |
| 1103 | ALOGE("setGlobalShadowSettings: failed to write shadowConfig: %d", error); |
| 1104 | return error; |
| 1105 | } |
| 1106 | |
| 1107 | error = remote()->transact(BnSurfaceComposer::SET_GLOBAL_SHADOW_SETTINGS, data, &reply, |
| 1108 | IBinder::FLAG_ONEWAY); |
| 1109 | if (error != NO_ERROR) { |
| 1110 | ALOGE("setGlobalShadowSettings: failed to transact: %d", error); |
| 1111 | return error; |
| 1112 | } |
| 1113 | return NO_ERROR; |
| 1114 | } |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 1115 | |
| 1116 | virtual status_t setFrameRate(const sp<IGraphicBufferProducer>& surface, float frameRate, |
| 1117 | int8_t compatibility) { |
| 1118 | Parcel data, reply; |
| 1119 | status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 1120 | if (err != NO_ERROR) { |
| 1121 | ALOGE("setFrameRate: failed writing interface token: %s (%d)", strerror(-err), -err); |
| 1122 | return err; |
| 1123 | } |
| 1124 | |
| 1125 | err = data.writeStrongBinder(IInterface::asBinder(surface)); |
| 1126 | if (err != NO_ERROR) { |
| 1127 | ALOGE("setFrameRate: failed writing strong binder: %s (%d)", strerror(-err), -err); |
| 1128 | return err; |
| 1129 | } |
| 1130 | |
| 1131 | err = data.writeFloat(frameRate); |
| 1132 | if (err != NO_ERROR) { |
| 1133 | ALOGE("setFrameRate: failed writing float: %s (%d)", strerror(-err), -err); |
| 1134 | return err; |
| 1135 | } |
| 1136 | |
| 1137 | err = data.writeByte(compatibility); |
| 1138 | if (err != NO_ERROR) { |
| 1139 | ALOGE("setFrameRate: failed writing byte: %s (%d)", strerror(-err), -err); |
| 1140 | return err; |
| 1141 | } |
| 1142 | |
Ady Abraham | 60e42ea | 2020-03-09 19:17:31 -0700 | [diff] [blame^] | 1143 | err = remote()->transact(BnSurfaceComposer::SET_FRAME_RATE, data, &reply); |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 1144 | if (err != NO_ERROR) { |
| 1145 | ALOGE("setFrameRate: failed to transact: %s (%d)", strerror(-err), err); |
| 1146 | return err; |
| 1147 | } |
| 1148 | return NO_ERROR; |
| 1149 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1150 | }; |
| 1151 | |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1152 | // Out-of-line virtual method definition to trigger vtable emission in this |
| 1153 | // translation unit (see clang warning -Wweak-vtables) |
| 1154 | BpSurfaceComposer::~BpSurfaceComposer() {} |
| 1155 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1156 | IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer"); |
| 1157 | |
| 1158 | // ---------------------------------------------------------------------- |
| 1159 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1160 | status_t BnSurfaceComposer::onTransact( |
| 1161 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 1162 | { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1163 | switch(code) { |
| 1164 | case CREATE_CONNECTION: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 1165 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 1166 | sp<IBinder> b = IInterface::asBinder(createConnection()); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1167 | reply->writeStrongBinder(b); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1168 | return NO_ERROR; |
| 1169 | } |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 1170 | case SET_TRANSACTION_STATE: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 1171 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1172 | |
| 1173 | size_t count = data.readUint32(); |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 1174 | if (count > data.dataSize()) { |
| 1175 | return BAD_VALUE; |
| 1176 | } |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 1177 | Vector<ComposerState> state; |
| 1178 | state.setCapacity(count); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1179 | for (size_t i = 0; i < count; i++) { |
Marissa Wall | c837b5e | 2018-10-12 10:04:44 -0700 | [diff] [blame] | 1180 | ComposerState s; |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 1181 | if (s.read(data) == BAD_VALUE) { |
| 1182 | return BAD_VALUE; |
| 1183 | } |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 1184 | state.add(s); |
| 1185 | } |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1186 | |
| 1187 | count = data.readUint32(); |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 1188 | if (count > data.dataSize()) { |
| 1189 | return BAD_VALUE; |
| 1190 | } |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 1191 | DisplayState d; |
| 1192 | Vector<DisplayState> displays; |
| 1193 | displays.setCapacity(count); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1194 | for (size_t i = 0; i < count; i++) { |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 1195 | if (d.read(data) == BAD_VALUE) { |
| 1196 | return BAD_VALUE; |
| 1197 | } |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 1198 | displays.add(d); |
| 1199 | } |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1200 | |
| 1201 | uint32_t stateFlags = data.readUint32(); |
Marissa Wall | 713b63f | 2018-10-17 15:42:43 -0700 | [diff] [blame] | 1202 | sp<IBinder> applyToken = data.readStrongBinder(); |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 1203 | InputWindowCommands inputWindowCommands; |
| 1204 | inputWindowCommands.read(data); |
Marissa Wall | 17b4e45 | 2018-12-26 16:32:34 -0800 | [diff] [blame] | 1205 | |
| 1206 | int64_t desiredPresentTime = data.readInt64(); |
Marissa Wall | 78b7220 | 2019-03-15 14:58:34 -0700 | [diff] [blame] | 1207 | |
Marissa Wall | 947d34e | 2019-03-29 14:03:53 -0700 | [diff] [blame] | 1208 | client_cache_t uncachedBuffer; |
Steven Moreland | 9d4ce9b | 2019-07-17 15:23:38 -0700 | [diff] [blame] | 1209 | uncachedBuffer.token = data.readStrongBinder(); |
Marissa Wall | 947d34e | 2019-03-29 14:03:53 -0700 | [diff] [blame] | 1210 | uncachedBuffer.id = data.readUint64(); |
Marissa Wall | 78b7220 | 2019-03-15 14:58:34 -0700 | [diff] [blame] | 1211 | |
Valerie Hau | 9dab973 | 2019-08-20 09:29:25 -0700 | [diff] [blame] | 1212 | bool hasListenerCallbacks = data.readBool(); |
| 1213 | |
Marissa Wall | 3dad52d | 2019-03-22 14:03:19 -0700 | [diff] [blame] | 1214 | std::vector<ListenerCallbacks> listenerCallbacks; |
| 1215 | int32_t listenersSize = data.readInt32(); |
| 1216 | for (int32_t i = 0; i < listenersSize; i++) { |
Valerie Hau | 5de3ad2 | 2019-08-20 07:47:43 -0700 | [diff] [blame] | 1217 | auto listener = data.readStrongBinder(); |
Marissa Wall | 3dad52d | 2019-03-22 14:03:19 -0700 | [diff] [blame] | 1218 | std::vector<CallbackId> callbackIds; |
| 1219 | data.readInt64Vector(&callbackIds); |
| 1220 | listenerCallbacks.emplace_back(listener, callbackIds); |
| 1221 | } |
Marissa Wall | 17b4e45 | 2018-12-26 16:32:34 -0800 | [diff] [blame] | 1222 | setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands, |
Valerie Hau | 9dab973 | 2019-08-20 09:29:25 -0700 | [diff] [blame] | 1223 | desiredPresentTime, uncachedBuffer, hasListenerCallbacks, |
| 1224 | listenerCallbacks); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1225 | return NO_ERROR; |
| 1226 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1227 | case BOOT_FINISHED: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 1228 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1229 | bootFinished(); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1230 | return NO_ERROR; |
| 1231 | } |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 1232 | case CAPTURE_SCREEN: { |
| 1233 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1234 | sp<IBinder> display = data.readStrongBinder(); |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 1235 | ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32()); |
| 1236 | ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32()); |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 1237 | sp<GraphicBuffer> outBuffer; |
Pablo Ceballos | 60d6922 | 2015-08-07 14:47:20 -0700 | [diff] [blame] | 1238 | Rect sourceCrop(Rect::EMPTY_RECT); |
Dan Stoza | c187900 | 2014-05-22 15:59:05 -0700 | [diff] [blame] | 1239 | data.read(sourceCrop); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1240 | uint32_t reqWidth = data.readUint32(); |
| 1241 | uint32_t reqHeight = data.readUint32(); |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 1242 | bool useIdentityTransform = static_cast<bool>(data.readInt32()); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1243 | int32_t rotation = data.readInt32(); |
Robert Carr | fa8855f | 2019-02-19 10:05:00 -0800 | [diff] [blame] | 1244 | bool captureSecureLayers = static_cast<bool>(data.readInt32()); |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 1245 | |
Robert Carr | 108b2c7 | 2019-04-02 16:32:58 -0700 | [diff] [blame] | 1246 | bool capturedSecureLayers = false; |
| 1247 | status_t res = captureScreen(display, &outBuffer, capturedSecureLayers, reqDataspace, |
| 1248 | reqPixelFormat, sourceCrop, reqWidth, reqHeight, |
Dominik Laskowski | 718f960 | 2019-11-09 20:01:35 -0800 | [diff] [blame] | 1249 | useIdentityTransform, ui::toRotation(rotation), |
Robert Carr | 108b2c7 | 2019-04-02 16:32:58 -0700 | [diff] [blame] | 1250 | captureSecureLayers); |
| 1251 | |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 1252 | reply->writeInt32(res); |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 1253 | if (res == NO_ERROR) { |
| 1254 | reply->write(*outBuffer); |
Robert Carr | 108b2c7 | 2019-04-02 16:32:58 -0700 | [diff] [blame] | 1255 | reply->writeBool(capturedSecureLayers); |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 1256 | } |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1257 | return NO_ERROR; |
| 1258 | } |
chaviw | 93df2ea | 2019-04-30 16:45:12 -0700 | [diff] [blame] | 1259 | case CAPTURE_SCREEN_BY_ID: { |
| 1260 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1261 | uint64_t displayOrLayerStack = data.readUint64(); |
| 1262 | ui::Dataspace outDataspace = ui::Dataspace::V0_SRGB; |
| 1263 | sp<GraphicBuffer> outBuffer; |
| 1264 | status_t res = captureScreen(displayOrLayerStack, &outDataspace, &outBuffer); |
| 1265 | reply->writeInt32(res); |
| 1266 | if (res == NO_ERROR) { |
| 1267 | reply->writeInt32(static_cast<int32_t>(outDataspace)); |
| 1268 | reply->write(*outBuffer); |
| 1269 | } |
| 1270 | return NO_ERROR; |
| 1271 | } |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 1272 | case CAPTURE_LAYERS: { |
| 1273 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1274 | sp<IBinder> layerHandleBinder = data.readStrongBinder(); |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 1275 | ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32()); |
| 1276 | ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32()); |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 1277 | sp<GraphicBuffer> outBuffer; |
chaviw | 7206d49 | 2017-11-10 16:16:12 -0800 | [diff] [blame] | 1278 | Rect sourceCrop(Rect::EMPTY_RECT); |
| 1279 | data.read(sourceCrop); |
Robert Carr | 866455f | 2019-04-02 16:28:26 -0700 | [diff] [blame] | 1280 | |
| 1281 | std::unordered_set<sp<IBinder>, SpHash<IBinder>> excludeHandles; |
| 1282 | int numExcludeHandles = data.readInt32(); |
| 1283 | excludeHandles.reserve(numExcludeHandles); |
| 1284 | for (int i = 0; i < numExcludeHandles; i++) { |
| 1285 | excludeHandles.emplace(data.readStrongBinder()); |
| 1286 | } |
| 1287 | |
chaviw | 7206d49 | 2017-11-10 16:16:12 -0800 | [diff] [blame] | 1288 | float frameScale = data.readFloat(); |
Robert Carr | 578038f | 2018-03-09 12:25:24 -0800 | [diff] [blame] | 1289 | bool childrenOnly = data.readBool(); |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 1290 | |
Robert Carr | 866455f | 2019-04-02 16:28:26 -0700 | [diff] [blame] | 1291 | status_t res = |
| 1292 | captureLayers(layerHandleBinder, &outBuffer, reqDataspace, reqPixelFormat, |
| 1293 | sourceCrop, excludeHandles, frameScale, childrenOnly); |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 1294 | reply->writeInt32(res); |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 1295 | if (res == NO_ERROR) { |
| 1296 | reply->write(*outBuffer); |
| 1297 | } |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 1298 | return NO_ERROR; |
| 1299 | } |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 1300 | case AUTHENTICATE_SURFACE: { |
| 1301 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 1302 | sp<IGraphicBufferProducer> bufferProducer = |
| 1303 | interface_cast<IGraphicBufferProducer>(data.readStrongBinder()); |
| 1304 | int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0; |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 1305 | reply->writeInt32(result); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1306 | return NO_ERROR; |
| 1307 | } |
Brian Anderson | 6b37671 | 2017-04-04 10:51:39 -0700 | [diff] [blame] | 1308 | case GET_SUPPORTED_FRAME_TIMESTAMPS: { |
| 1309 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1310 | std::vector<FrameEvent> supportedTimestamps; |
| 1311 | status_t result = getSupportedFrameTimestamps(&supportedTimestamps); |
| 1312 | status_t err = reply->writeInt32(result); |
| 1313 | if (err != NO_ERROR) { |
| 1314 | return err; |
| 1315 | } |
| 1316 | if (result != NO_ERROR) { |
| 1317 | return result; |
| 1318 | } |
| 1319 | |
| 1320 | std::vector<int32_t> supported; |
| 1321 | supported.reserve(supportedTimestamps.size()); |
| 1322 | for (FrameEvent s : supportedTimestamps) { |
| 1323 | supported.push_back(static_cast<int32_t>(s)); |
| 1324 | } |
| 1325 | return reply->writeInt32Vector(supported); |
| 1326 | } |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 1327 | case CREATE_DISPLAY_EVENT_CONNECTION: { |
| 1328 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Ady Abraham | 0f4a1b1 | 2019-06-04 16:04:04 -0700 | [diff] [blame] | 1329 | auto vsyncSource = static_cast<ISurfaceComposer::VsyncSource>(data.readInt32()); |
| 1330 | auto configChanged = static_cast<ISurfaceComposer::ConfigChanged>(data.readInt32()); |
| 1331 | |
| 1332 | sp<IDisplayEventConnection> connection( |
| 1333 | createDisplayEventConnection(vsyncSource, configChanged)); |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 1334 | reply->writeStrongBinder(IInterface::asBinder(connection)); |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 1335 | return NO_ERROR; |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1336 | } |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 1337 | case CREATE_DISPLAY: { |
| 1338 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Andy McFadden | 8dfa92f | 2012-09-17 18:27:17 -0700 | [diff] [blame] | 1339 | String8 displayName = data.readString8(); |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 1340 | bool secure = bool(data.readInt32()); |
| 1341 | sp<IBinder> display(createDisplay(displayName, secure)); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 1342 | reply->writeStrongBinder(display); |
| 1343 | return NO_ERROR; |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1344 | } |
| 1345 | case DESTROY_DISPLAY: { |
| 1346 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1347 | sp<IBinder> display = data.readStrongBinder(); |
| 1348 | destroyDisplay(display); |
| 1349 | return NO_ERROR; |
| 1350 | } |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 1351 | case GET_PHYSICAL_DISPLAY_TOKEN: { |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 1352 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 1353 | PhysicalDisplayId displayId = data.readUint64(); |
| 1354 | sp<IBinder> display = getPhysicalDisplayToken(displayId); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 1355 | reply->writeStrongBinder(display); |
| 1356 | return NO_ERROR; |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1357 | } |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 1358 | case GET_DISPLAY_STATE: { |
| 1359 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1360 | ui::DisplayState state; |
| 1361 | const sp<IBinder> display = data.readStrongBinder(); |
| 1362 | const status_t result = getDisplayState(display, &state); |
| 1363 | reply->writeInt32(result); |
| 1364 | if (result == NO_ERROR) { |
| 1365 | memcpy(reply->writeInplace(sizeof(ui::DisplayState)), &state, |
| 1366 | sizeof(ui::DisplayState)); |
| 1367 | } |
| 1368 | return NO_ERROR; |
| 1369 | } |
| 1370 | case GET_DISPLAY_INFO: { |
| 1371 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1372 | DisplayInfo info; |
| 1373 | const sp<IBinder> display = data.readStrongBinder(); |
| 1374 | const status_t result = getDisplayInfo(display, &info); |
| 1375 | reply->writeInt32(result); |
| 1376 | if (result == NO_ERROR) { |
| 1377 | memcpy(reply->writeInplace(sizeof(DisplayInfo)), &info, sizeof(DisplayInfo)); |
| 1378 | } |
| 1379 | return NO_ERROR; |
| 1380 | } |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 1381 | case GET_DISPLAY_CONFIGS: { |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 1382 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 1383 | Vector<DisplayConfig> configs; |
| 1384 | const sp<IBinder> display = data.readStrongBinder(); |
| 1385 | const status_t result = getDisplayConfigs(display, &configs); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 1386 | reply->writeInt32(result); |
| 1387 | if (result == NO_ERROR) { |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1388 | reply->writeUint32(static_cast<uint32_t>(configs.size())); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 1389 | for (size_t c = 0; c < configs.size(); ++c) { |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 1390 | memcpy(reply->writeInplace(sizeof(DisplayConfig)), &configs[c], |
| 1391 | sizeof(DisplayConfig)); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 1392 | } |
| 1393 | } |
| 1394 | return NO_ERROR; |
| 1395 | } |
Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 1396 | case GET_DISPLAY_STATS: { |
| 1397 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1398 | DisplayStatInfo stats; |
| 1399 | sp<IBinder> display = data.readStrongBinder(); |
| 1400 | status_t result = getDisplayStats(display, &stats); |
| 1401 | reply->writeInt32(result); |
| 1402 | if (result == NO_ERROR) { |
| 1403 | memcpy(reply->writeInplace(sizeof(DisplayStatInfo)), |
| 1404 | &stats, sizeof(DisplayStatInfo)); |
| 1405 | } |
| 1406 | return NO_ERROR; |
| 1407 | } |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 1408 | case GET_ACTIVE_CONFIG: { |
| 1409 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1410 | sp<IBinder> display = data.readStrongBinder(); |
| 1411 | int id = getActiveConfig(display); |
| 1412 | reply->writeInt32(id); |
| 1413 | return NO_ERROR; |
| 1414 | } |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1415 | case GET_DISPLAY_COLOR_MODES: { |
| 1416 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 1417 | Vector<ColorMode> colorModes; |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1418 | sp<IBinder> display = nullptr; |
| 1419 | status_t result = data.readStrongBinder(&display); |
| 1420 | if (result != NO_ERROR) { |
| 1421 | ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result); |
| 1422 | return result; |
| 1423 | } |
| 1424 | result = getDisplayColorModes(display, &colorModes); |
| 1425 | reply->writeInt32(result); |
| 1426 | if (result == NO_ERROR) { |
| 1427 | reply->writeUint32(static_cast<uint32_t>(colorModes.size())); |
| 1428 | for (size_t i = 0; i < colorModes.size(); ++i) { |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 1429 | reply->writeInt32(static_cast<int32_t>(colorModes[i])); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1430 | } |
| 1431 | } |
| 1432 | return NO_ERROR; |
| 1433 | } |
Daniel Solomon | 42d0456 | 2019-01-20 21:03:19 -0800 | [diff] [blame] | 1434 | case GET_DISPLAY_NATIVE_PRIMARIES: { |
| 1435 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1436 | ui::DisplayPrimaries primaries; |
| 1437 | sp<IBinder> display = nullptr; |
| 1438 | |
| 1439 | status_t result = data.readStrongBinder(&display); |
| 1440 | if (result != NO_ERROR) { |
| 1441 | ALOGE("getDisplayNativePrimaries failed to readStrongBinder: %d", result); |
| 1442 | return result; |
| 1443 | } |
| 1444 | |
| 1445 | result = getDisplayNativePrimaries(display, primaries); |
| 1446 | reply->writeInt32(result); |
| 1447 | if (result == NO_ERROR) { |
| 1448 | memcpy(reply->writeInplace(sizeof(ui::DisplayPrimaries)), &primaries, |
| 1449 | sizeof(ui::DisplayPrimaries)); |
| 1450 | } |
| 1451 | |
| 1452 | return NO_ERROR; |
| 1453 | } |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1454 | case GET_ACTIVE_COLOR_MODE: { |
| 1455 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1456 | sp<IBinder> display = nullptr; |
| 1457 | status_t result = data.readStrongBinder(&display); |
| 1458 | if (result != NO_ERROR) { |
| 1459 | ALOGE("getActiveColorMode failed to readStrongBinder: %d", result); |
| 1460 | return result; |
| 1461 | } |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 1462 | ColorMode colorMode = getActiveColorMode(display); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1463 | result = reply->writeInt32(static_cast<int32_t>(colorMode)); |
| 1464 | return result; |
| 1465 | } |
| 1466 | case SET_ACTIVE_COLOR_MODE: { |
| 1467 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1468 | sp<IBinder> display = nullptr; |
| 1469 | status_t result = data.readStrongBinder(&display); |
| 1470 | if (result != NO_ERROR) { |
| 1471 | ALOGE("getActiveColorMode failed to readStrongBinder: %d", result); |
| 1472 | return result; |
| 1473 | } |
| 1474 | int32_t colorModeInt = 0; |
| 1475 | result = data.readInt32(&colorModeInt); |
| 1476 | if (result != NO_ERROR) { |
| 1477 | ALOGE("setActiveColorMode failed to readInt32: %d", result); |
| 1478 | return result; |
| 1479 | } |
| 1480 | result = setActiveColorMode(display, |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 1481 | static_cast<ColorMode>(colorModeInt)); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1482 | result = reply->writeInt32(result); |
| 1483 | return result; |
| 1484 | } |
Galia Peycheva | 5492cb5 | 2019-10-30 14:13:16 +0100 | [diff] [blame] | 1485 | |
| 1486 | case GET_AUTO_LOW_LATENCY_MODE_SUPPORT: { |
| 1487 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1488 | sp<IBinder> display = nullptr; |
| 1489 | status_t result = data.readStrongBinder(&display); |
| 1490 | if (result != NO_ERROR) { |
| 1491 | ALOGE("getAutoLowLatencyModeSupport failed to readStrongBinder: %d", result); |
| 1492 | return result; |
| 1493 | } |
| 1494 | bool supported = false; |
| 1495 | result = getAutoLowLatencyModeSupport(display, &supported); |
| 1496 | if (result == NO_ERROR) { |
| 1497 | result = reply->writeBool(supported); |
| 1498 | } |
| 1499 | return result; |
| 1500 | } |
| 1501 | |
| 1502 | case SET_AUTO_LOW_LATENCY_MODE: { |
| 1503 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1504 | sp<IBinder> display = nullptr; |
| 1505 | status_t result = data.readStrongBinder(&display); |
| 1506 | if (result != NO_ERROR) { |
| 1507 | ALOGE("setAutoLowLatencyMode failed to readStrongBinder: %d", result); |
| 1508 | return result; |
| 1509 | } |
| 1510 | bool setAllm = false; |
| 1511 | result = data.readBool(&setAllm); |
| 1512 | if (result != NO_ERROR) { |
| 1513 | ALOGE("setAutoLowLatencyMode failed to readBool: %d", result); |
| 1514 | return result; |
| 1515 | } |
| 1516 | setAutoLowLatencyMode(display, setAllm); |
| 1517 | return result; |
| 1518 | } |
| 1519 | |
| 1520 | case GET_GAME_CONTENT_TYPE_SUPPORT: { |
| 1521 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1522 | sp<IBinder> display = nullptr; |
| 1523 | status_t result = data.readStrongBinder(&display); |
| 1524 | if (result != NO_ERROR) { |
| 1525 | ALOGE("getGameContentTypeSupport failed to readStrongBinder: %d", result); |
| 1526 | return result; |
| 1527 | } |
| 1528 | bool supported = false; |
| 1529 | result = getGameContentTypeSupport(display, &supported); |
| 1530 | if (result == NO_ERROR) { |
| 1531 | result = reply->writeBool(supported); |
| 1532 | } |
| 1533 | return result; |
| 1534 | } |
| 1535 | |
| 1536 | case SET_GAME_CONTENT_TYPE: { |
| 1537 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1538 | sp<IBinder> display = nullptr; |
| 1539 | status_t result = data.readStrongBinder(&display); |
| 1540 | if (result != NO_ERROR) { |
| 1541 | ALOGE("setGameContentType failed to readStrongBinder: %d", result); |
| 1542 | return result; |
| 1543 | } |
| 1544 | bool setGameContentTypeOn = false; |
| 1545 | result = data.readBool(&setGameContentTypeOn); |
| 1546 | if (result != NO_ERROR) { |
| 1547 | ALOGE("setGameContentType failed to readBool: %d", result); |
| 1548 | return result; |
| 1549 | } |
| 1550 | setGameContentType(display, setGameContentTypeOn); |
| 1551 | return result; |
| 1552 | } |
| 1553 | |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 1554 | case CLEAR_ANIMATION_FRAME_STATS: { |
| 1555 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1556 | status_t result = clearAnimationFrameStats(); |
| 1557 | reply->writeInt32(result); |
| 1558 | return NO_ERROR; |
| 1559 | } |
| 1560 | case GET_ANIMATION_FRAME_STATS: { |
| 1561 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1562 | FrameStats stats; |
| 1563 | status_t result = getAnimationFrameStats(&stats); |
| 1564 | reply->write(stats); |
| 1565 | reply->writeInt32(result); |
| 1566 | return NO_ERROR; |
| 1567 | } |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 1568 | case SET_POWER_MODE: { |
| 1569 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1570 | sp<IBinder> display = data.readStrongBinder(); |
| 1571 | int32_t mode = data.readInt32(); |
| 1572 | setPowerMode(display, mode); |
| 1573 | return NO_ERROR; |
| 1574 | } |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 1575 | case GET_HDR_CAPABILITIES: { |
| 1576 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1577 | sp<IBinder> display = nullptr; |
| 1578 | status_t result = data.readStrongBinder(&display); |
| 1579 | if (result != NO_ERROR) { |
| 1580 | ALOGE("getHdrCapabilities failed to readStrongBinder: %d", |
| 1581 | result); |
| 1582 | return result; |
| 1583 | } |
| 1584 | HdrCapabilities capabilities; |
| 1585 | result = getHdrCapabilities(display, &capabilities); |
| 1586 | reply->writeInt32(result); |
| 1587 | if (result == NO_ERROR) { |
Mathias Agopian | e1f5e6f | 2017-02-06 16:34:41 -0800 | [diff] [blame] | 1588 | reply->write(capabilities); |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 1589 | } |
| 1590 | return NO_ERROR; |
| 1591 | } |
Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 1592 | case ENABLE_VSYNC_INJECTIONS: { |
| 1593 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1594 | bool enable = false; |
| 1595 | status_t result = data.readBool(&enable); |
| 1596 | if (result != NO_ERROR) { |
| 1597 | ALOGE("enableVSyncInjections failed to readBool: %d", result); |
| 1598 | return result; |
| 1599 | } |
| 1600 | return enableVSyncInjections(enable); |
| 1601 | } |
| 1602 | case INJECT_VSYNC: { |
| 1603 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1604 | int64_t when = 0; |
| 1605 | status_t result = data.readInt64(&when); |
| 1606 | if (result != NO_ERROR) { |
| 1607 | ALOGE("enableVSyncInjections failed to readInt64: %d", result); |
| 1608 | return result; |
| 1609 | } |
| 1610 | return injectVSync(when); |
| 1611 | } |
Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 1612 | case GET_LAYER_DEBUG_INFO: { |
| 1613 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1614 | std::vector<LayerDebugInfo> outLayers; |
| 1615 | status_t result = getLayerDebugInfo(&outLayers); |
| 1616 | reply->writeInt32(result); |
| 1617 | if (result == NO_ERROR) |
| 1618 | { |
| 1619 | result = reply->writeParcelableVector(outLayers); |
| 1620 | } |
| 1621 | return result; |
| 1622 | } |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1623 | case GET_COMPOSITION_PREFERENCE: { |
| 1624 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 1625 | ui::Dataspace defaultDataspace; |
| 1626 | ui::PixelFormat defaultPixelFormat; |
| 1627 | ui::Dataspace wideColorGamutDataspace; |
| 1628 | ui::PixelFormat wideColorGamutPixelFormat; |
| 1629 | status_t error = |
| 1630 | getCompositionPreference(&defaultDataspace, &defaultPixelFormat, |
| 1631 | &wideColorGamutDataspace, &wideColorGamutPixelFormat); |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1632 | reply->writeInt32(error); |
| 1633 | if (error == NO_ERROR) { |
Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 1634 | reply->writeInt32(static_cast<int32_t>(defaultDataspace)); |
| 1635 | reply->writeInt32(static_cast<int32_t>(defaultPixelFormat)); |
| 1636 | reply->writeInt32(static_cast<int32_t>(wideColorGamutDataspace)); |
Peiyong Lin | aa3da6a | 2018-12-12 02:48:43 -0800 | [diff] [blame] | 1637 | reply->writeInt32(static_cast<int32_t>(wideColorGamutPixelFormat)); |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1638 | } |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 1639 | return error; |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1640 | } |
Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 1641 | case GET_COLOR_MANAGEMENT: { |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 1642 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 1643 | bool result; |
| 1644 | status_t error = getColorManagement(&result); |
| 1645 | if (error == NO_ERROR) { |
| 1646 | reply->writeBool(result); |
| 1647 | } |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 1648 | return error; |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 1649 | } |
Kevin DuBois | 9c0a176 | 2018-10-16 13:32:31 -0700 | [diff] [blame] | 1650 | case GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: { |
| 1651 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1652 | |
| 1653 | sp<IBinder> display = data.readStrongBinder(); |
| 1654 | ui::PixelFormat format; |
| 1655 | ui::Dataspace dataspace; |
| 1656 | uint8_t component = 0; |
| 1657 | auto result = |
| 1658 | getDisplayedContentSamplingAttributes(display, &format, &dataspace, &component); |
| 1659 | if (result == NO_ERROR) { |
| 1660 | reply->writeUint32(static_cast<uint32_t>(format)); |
| 1661 | reply->writeUint32(static_cast<uint32_t>(dataspace)); |
| 1662 | reply->writeUint32(static_cast<uint32_t>(component)); |
| 1663 | } |
| 1664 | return result; |
| 1665 | } |
Kevin DuBois | 74e5377 | 2018-11-19 10:52:38 -0800 | [diff] [blame] | 1666 | case SET_DISPLAY_CONTENT_SAMPLING_ENABLED: { |
| 1667 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1668 | |
| 1669 | sp<IBinder> display = nullptr; |
| 1670 | bool enable = false; |
| 1671 | int8_t componentMask = 0; |
| 1672 | uint64_t maxFrames = 0; |
| 1673 | status_t result = data.readStrongBinder(&display); |
| 1674 | if (result != NO_ERROR) { |
| 1675 | ALOGE("setDisplayContentSamplingEnabled failure in reading Display token: %d", |
| 1676 | result); |
| 1677 | return result; |
| 1678 | } |
| 1679 | |
| 1680 | result = data.readBool(&enable); |
| 1681 | if (result != NO_ERROR) { |
| 1682 | ALOGE("setDisplayContentSamplingEnabled failure in reading enable: %d", result); |
| 1683 | return result; |
| 1684 | } |
| 1685 | |
| 1686 | result = data.readByte(static_cast<int8_t*>(&componentMask)); |
| 1687 | if (result != NO_ERROR) { |
| 1688 | ALOGE("setDisplayContentSamplingEnabled failure in reading component mask: %d", |
| 1689 | result); |
| 1690 | return result; |
| 1691 | } |
| 1692 | |
| 1693 | result = data.readUint64(&maxFrames); |
| 1694 | if (result != NO_ERROR) { |
| 1695 | ALOGE("setDisplayContentSamplingEnabled failure in reading max frames: %d", result); |
| 1696 | return result; |
| 1697 | } |
| 1698 | |
| 1699 | return setDisplayContentSamplingEnabled(display, enable, |
| 1700 | static_cast<uint8_t>(componentMask), maxFrames); |
| 1701 | } |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 1702 | case GET_DISPLAYED_CONTENT_SAMPLE: { |
| 1703 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1704 | |
| 1705 | sp<IBinder> display = data.readStrongBinder(); |
| 1706 | uint64_t maxFrames = 0; |
| 1707 | uint64_t timestamp = 0; |
| 1708 | |
| 1709 | status_t result = data.readUint64(&maxFrames); |
| 1710 | if (result != NO_ERROR) { |
| 1711 | ALOGE("getDisplayedContentSample failure in reading max frames: %d", result); |
| 1712 | return result; |
| 1713 | } |
| 1714 | |
| 1715 | result = data.readUint64(×tamp); |
| 1716 | if (result != NO_ERROR) { |
| 1717 | ALOGE("getDisplayedContentSample failure in reading timestamp: %d", result); |
| 1718 | return result; |
| 1719 | } |
| 1720 | |
| 1721 | DisplayedFrameStats stats; |
| 1722 | result = getDisplayedContentSample(display, maxFrames, timestamp, &stats); |
| 1723 | if (result == NO_ERROR) { |
| 1724 | reply->writeUint64(stats.numFrames); |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 1725 | reply->writeUint64Vector(stats.component_0_sample); |
| 1726 | reply->writeUint64Vector(stats.component_1_sample); |
| 1727 | reply->writeUint64Vector(stats.component_2_sample); |
| 1728 | reply->writeUint64Vector(stats.component_3_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 1729 | } |
| 1730 | return result; |
| 1731 | } |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 1732 | case GET_PROTECTED_CONTENT_SUPPORT: { |
| 1733 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1734 | bool result; |
| 1735 | status_t error = getProtectedContentSupport(&result); |
| 1736 | if (error == NO_ERROR) { |
| 1737 | reply->writeBool(result); |
| 1738 | } |
| 1739 | return error; |
| 1740 | } |
Peiyong Lin | 4f3fddf | 2019-01-24 17:21:24 -0800 | [diff] [blame] | 1741 | case IS_WIDE_COLOR_DISPLAY: { |
| 1742 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1743 | sp<IBinder> display = nullptr; |
| 1744 | status_t error = data.readStrongBinder(&display); |
| 1745 | if (error != NO_ERROR) { |
| 1746 | return error; |
| 1747 | } |
| 1748 | bool result; |
| 1749 | error = isWideColorDisplay(display, &result); |
| 1750 | if (error == NO_ERROR) { |
| 1751 | reply->writeBool(result); |
| 1752 | } |
| 1753 | return error; |
| 1754 | } |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 1755 | case GET_PHYSICAL_DISPLAY_IDS: { |
| 1756 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1757 | return reply->writeUint64Vector(getPhysicalDisplayIds()); |
| 1758 | } |
Dan Stoza | 84ab937 | 2018-12-17 15:27:57 -0800 | [diff] [blame] | 1759 | case ADD_REGION_SAMPLING_LISTENER: { |
| 1760 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1761 | Rect samplingArea; |
| 1762 | status_t result = data.read(samplingArea); |
| 1763 | if (result != NO_ERROR) { |
| 1764 | ALOGE("addRegionSamplingListener: Failed to read sampling area"); |
| 1765 | return result; |
| 1766 | } |
| 1767 | sp<IBinder> stopLayerHandle; |
| 1768 | result = data.readNullableStrongBinder(&stopLayerHandle); |
| 1769 | if (result != NO_ERROR) { |
| 1770 | ALOGE("addRegionSamplingListener: Failed to read stop layer handle"); |
| 1771 | return result; |
| 1772 | } |
| 1773 | sp<IRegionSamplingListener> listener; |
| 1774 | result = data.readNullableStrongBinder(&listener); |
| 1775 | if (result != NO_ERROR) { |
| 1776 | ALOGE("addRegionSamplingListener: Failed to read listener"); |
| 1777 | return result; |
| 1778 | } |
| 1779 | return addRegionSamplingListener(samplingArea, stopLayerHandle, listener); |
| 1780 | } |
| 1781 | case REMOVE_REGION_SAMPLING_LISTENER: { |
| 1782 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1783 | sp<IRegionSamplingListener> listener; |
| 1784 | status_t result = data.readNullableStrongBinder(&listener); |
| 1785 | if (result != NO_ERROR) { |
| 1786 | ALOGE("removeRegionSamplingListener: Failed to read listener"); |
| 1787 | return result; |
| 1788 | } |
| 1789 | return removeRegionSamplingListener(listener); |
| 1790 | } |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 1791 | case SET_DESIRED_DISPLAY_CONFIG_SPECS: { |
| 1792 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1793 | sp<IBinder> displayToken = data.readStrongBinder(); |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 1794 | int32_t defaultConfig; |
| 1795 | status_t result = data.readInt32(&defaultConfig); |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 1796 | if (result != NO_ERROR) { |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 1797 | ALOGE("setDesiredDisplayConfigSpecs: failed to read defaultConfig: %d", result); |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 1798 | return result; |
| 1799 | } |
| 1800 | float minRefreshRate; |
| 1801 | result = data.readFloat(&minRefreshRate); |
| 1802 | if (result != NO_ERROR) { |
| 1803 | ALOGE("setDesiredDisplayConfigSpecs: failed to read minRefreshRate: %d", result); |
| 1804 | return result; |
| 1805 | } |
| 1806 | float maxRefreshRate; |
| 1807 | result = data.readFloat(&maxRefreshRate); |
| 1808 | if (result != NO_ERROR) { |
| 1809 | ALOGE("setDesiredDisplayConfigSpecs: failed to read maxRefreshRate: %d", result); |
| 1810 | return result; |
| 1811 | } |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 1812 | result = setDesiredDisplayConfigSpecs(displayToken, defaultConfig, minRefreshRate, |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 1813 | maxRefreshRate); |
| 1814 | if (result != NO_ERROR) { |
| 1815 | ALOGE("setDesiredDisplayConfigSpecs: failed to call setDesiredDisplayConfigSpecs: " |
| 1816 | "%d", |
| 1817 | result); |
| 1818 | return result; |
| 1819 | } |
| 1820 | reply->writeInt32(result); |
| 1821 | return result; |
| 1822 | } |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1823 | case GET_DESIRED_DISPLAY_CONFIG_SPECS: { |
| 1824 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1825 | sp<IBinder> displayToken = data.readStrongBinder(); |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 1826 | int32_t defaultConfig; |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1827 | float minRefreshRate; |
| 1828 | float maxRefreshRate; |
| 1829 | |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 1830 | status_t result = getDesiredDisplayConfigSpecs(displayToken, &defaultConfig, |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1831 | &minRefreshRate, &maxRefreshRate); |
| 1832 | if (result != NO_ERROR) { |
| 1833 | ALOGE("getDesiredDisplayConfigSpecs: failed to get getDesiredDisplayConfigSpecs: " |
| 1834 | "%d", |
| 1835 | result); |
| 1836 | return result; |
| 1837 | } |
| 1838 | |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 1839 | result = reply->writeInt32(defaultConfig); |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1840 | if (result != NO_ERROR) { |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 1841 | ALOGE("getDesiredDisplayConfigSpecs: failed to write defaultConfig: %d", result); |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1842 | return result; |
| 1843 | } |
| 1844 | result = reply->writeFloat(minRefreshRate); |
| 1845 | if (result != NO_ERROR) { |
| 1846 | ALOGE("getDesiredDisplayConfigSpecs: failed to write minRefreshRate: %d", result); |
| 1847 | return result; |
| 1848 | } |
| 1849 | result = reply->writeFloat(maxRefreshRate); |
| 1850 | if (result != NO_ERROR) { |
| 1851 | ALOGE("getDesiredDisplayConfigSpecs: failed to write maxRefreshRate: %d", result); |
| 1852 | return result; |
| 1853 | } |
| 1854 | reply->writeInt32(result); |
| 1855 | return result; |
| 1856 | } |
Dan Gittik | 57e63c5 | 2019-01-18 16:37:54 +0000 | [diff] [blame] | 1857 | case GET_DISPLAY_BRIGHTNESS_SUPPORT: { |
| 1858 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1859 | sp<IBinder> displayToken; |
| 1860 | status_t error = data.readNullableStrongBinder(&displayToken); |
| 1861 | if (error != NO_ERROR) { |
| 1862 | ALOGE("getDisplayBrightnessSupport: failed to read display token: %d", error); |
| 1863 | return error; |
| 1864 | } |
| 1865 | bool support = false; |
| 1866 | error = getDisplayBrightnessSupport(displayToken, &support); |
| 1867 | reply->writeBool(support); |
| 1868 | return error; |
| 1869 | } |
| 1870 | case SET_DISPLAY_BRIGHTNESS: { |
| 1871 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1872 | sp<IBinder> displayToken; |
| 1873 | status_t error = data.readNullableStrongBinder(&displayToken); |
| 1874 | if (error != NO_ERROR) { |
| 1875 | ALOGE("setDisplayBrightness: failed to read display token: %d", error); |
| 1876 | return error; |
| 1877 | } |
| 1878 | float brightness = -1.0f; |
| 1879 | error = data.readFloat(&brightness); |
| 1880 | if (error != NO_ERROR) { |
| 1881 | ALOGE("setDisplayBrightness: failed to read brightness: %d", error); |
| 1882 | return error; |
| 1883 | } |
| 1884 | return setDisplayBrightness(displayToken, brightness); |
| 1885 | } |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 1886 | case NOTIFY_POWER_HINT: { |
| 1887 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1888 | int32_t hintId; |
| 1889 | status_t error = data.readInt32(&hintId); |
| 1890 | if (error != NO_ERROR) { |
| 1891 | ALOGE("notifyPowerHint: failed to read hintId: %d", error); |
| 1892 | return error; |
| 1893 | } |
| 1894 | return notifyPowerHint(hintId); |
| 1895 | } |
Vishnu Nair | b13bb95 | 2019-11-15 10:24:08 -0800 | [diff] [blame] | 1896 | case SET_GLOBAL_SHADOW_SETTINGS: { |
| 1897 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1898 | |
| 1899 | std::vector<float> shadowConfig; |
| 1900 | status_t error = data.readFloatVector(&shadowConfig); |
| 1901 | if (error != NO_ERROR || shadowConfig.size() != 11) { |
| 1902 | ALOGE("setGlobalShadowSettings: failed to read shadowConfig: %d", error); |
| 1903 | return error; |
| 1904 | } |
| 1905 | |
| 1906 | half4 ambientColor = {shadowConfig[0], shadowConfig[1], shadowConfig[2], |
| 1907 | shadowConfig[3]}; |
| 1908 | half4 spotColor = {shadowConfig[4], shadowConfig[5], shadowConfig[6], shadowConfig[7]}; |
| 1909 | float lightPosY = shadowConfig[8]; |
| 1910 | float lightPosZ = shadowConfig[9]; |
| 1911 | float lightRadius = shadowConfig[10]; |
| 1912 | return setGlobalShadowSettings(ambientColor, spotColor, lightPosY, lightPosZ, |
| 1913 | lightRadius); |
| 1914 | } |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 1915 | case SET_FRAME_RATE: { |
| 1916 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1917 | sp<IBinder> binder; |
| 1918 | status_t err = data.readStrongBinder(&binder); |
| 1919 | if (err != NO_ERROR) { |
| 1920 | ALOGE("setFrameRate: failed to read strong binder: %s (%d)", strerror(-err), -err); |
| 1921 | return err; |
| 1922 | } |
| 1923 | sp<IGraphicBufferProducer> surface = interface_cast<IGraphicBufferProducer>(binder); |
| 1924 | if (!surface) { |
| 1925 | ALOGE("setFrameRate: failed to cast to IGraphicBufferProducer: %s (%d)", |
| 1926 | strerror(-err), -err); |
| 1927 | return err; |
| 1928 | } |
| 1929 | float frameRate; |
| 1930 | err = data.readFloat(&frameRate); |
| 1931 | if (err != NO_ERROR) { |
| 1932 | ALOGE("setFrameRate: failed to read float: %s (%d)", strerror(-err), -err); |
| 1933 | return err; |
| 1934 | } |
| 1935 | int8_t compatibility; |
| 1936 | err = data.readByte(&compatibility); |
| 1937 | if (err != NO_ERROR) { |
| 1938 | ALOGE("setFrameRate: failed to read byte: %s (%d)", strerror(-err), -err); |
| 1939 | return err; |
| 1940 | } |
| 1941 | status_t result = setFrameRate(surface, frameRate, compatibility); |
| 1942 | reply->writeInt32(result); |
| 1943 | return NO_ERROR; |
| 1944 | } |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1945 | default: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 1946 | return BBinder::onTransact(code, data, reply, flags); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1947 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1948 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1949 | } |
| 1950 | |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 1951 | } // namespace android |