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) { |
Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame^] | 330 | std::vector<uint64_t> rawIds; |
| 331 | if (reply.readUint64Vector(&rawIds) == NO_ERROR) { |
| 332 | std::vector<PhysicalDisplayId> displayIds(rawIds.size()); |
| 333 | std::transform(rawIds.begin(), rawIds.end(), displayIds.begin(), |
| 334 | [](uint64_t rawId) { return PhysicalDisplayId(rawId); }); |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 335 | return displayIds; |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | return {}; |
| 340 | } |
| 341 | |
| 342 | virtual sp<IBinder> getPhysicalDisplayToken(PhysicalDisplayId displayId) const { |
| 343 | Parcel data, reply; |
| 344 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame^] | 345 | data.writeUint64(displayId.value); |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 346 | remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_TOKEN, data, &reply); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 347 | return reply.readStrongBinder(); |
| 348 | } |
| 349 | |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 350 | virtual void setPowerMode(const sp<IBinder>& display, int mode) |
Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 351 | { |
| 352 | Parcel data, reply; |
| 353 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Andy McFadden | c01a79d | 2012-09-27 16:02:06 -0700 | [diff] [blame] | 354 | data.writeStrongBinder(display); |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 355 | data.writeInt32(mode); |
| 356 | remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply); |
Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 357 | } |
Mathias Agopian | 3094df3 | 2012-06-18 18:06:45 -0700 | [diff] [blame] | 358 | |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 359 | virtual status_t getDisplayState(const sp<IBinder>& display, ui::DisplayState* state) { |
| 360 | Parcel data, reply; |
| 361 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 362 | data.writeStrongBinder(display); |
| 363 | remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATE, data, &reply); |
| 364 | const status_t result = reply.readInt32(); |
| 365 | if (result == NO_ERROR) { |
| 366 | memcpy(state, reply.readInplace(sizeof(ui::DisplayState)), sizeof(ui::DisplayState)); |
| 367 | } |
| 368 | return result; |
| 369 | } |
| 370 | |
| 371 | virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) { |
| 372 | Parcel data, reply; |
| 373 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 374 | data.writeStrongBinder(display); |
| 375 | remote()->transact(BnSurfaceComposer::GET_DISPLAY_INFO, data, &reply); |
| 376 | const status_t result = reply.readInt32(); |
Marin Shalamanov | 359a7e7 | 2020-02-17 17:03:07 +0100 | [diff] [blame] | 377 | if (result != NO_ERROR) return result; |
| 378 | return reply.read(*info); |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | virtual status_t getDisplayConfigs(const sp<IBinder>& display, Vector<DisplayConfig>* configs) { |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 382 | Parcel data, reply; |
| 383 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 384 | data.writeStrongBinder(display); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 385 | remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply); |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 386 | const status_t result = reply.readInt32(); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 387 | if (result == NO_ERROR) { |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 388 | const size_t numConfigs = reply.readUint32(); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 389 | configs->clear(); |
| 390 | configs->resize(numConfigs); |
| 391 | for (size_t c = 0; c < numConfigs; ++c) { |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 392 | memcpy(&(configs->editItemAt(c)), reply.readInplace(sizeof(DisplayConfig)), |
| 393 | sizeof(DisplayConfig)); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 394 | } |
| 395 | } |
| 396 | return result; |
| 397 | } |
| 398 | |
Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 399 | virtual status_t getDisplayStats(const sp<IBinder>& display, |
| 400 | DisplayStatInfo* stats) |
| 401 | { |
| 402 | Parcel data, reply; |
| 403 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 404 | data.writeStrongBinder(display); |
| 405 | remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply); |
| 406 | status_t result = reply.readInt32(); |
| 407 | if (result == NO_ERROR) { |
| 408 | memcpy(stats, |
| 409 | reply.readInplace(sizeof(DisplayStatInfo)), |
| 410 | sizeof(DisplayStatInfo)); |
| 411 | } |
| 412 | return result; |
| 413 | } |
| 414 | |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 415 | virtual int getActiveConfig(const sp<IBinder>& display) |
| 416 | { |
| 417 | Parcel data, reply; |
| 418 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 419 | data.writeStrongBinder(display); |
| 420 | remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply); |
| 421 | return reply.readInt32(); |
| 422 | } |
| 423 | |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 424 | virtual status_t getDisplayColorModes(const sp<IBinder>& display, |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 425 | Vector<ColorMode>* outColorModes) { |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 426 | Parcel data, reply; |
| 427 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 428 | if (result != NO_ERROR) { |
| 429 | ALOGE("getDisplayColorModes failed to writeInterfaceToken: %d", result); |
| 430 | return result; |
| 431 | } |
| 432 | result = data.writeStrongBinder(display); |
| 433 | if (result != NO_ERROR) { |
| 434 | ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result); |
| 435 | return result; |
| 436 | } |
| 437 | result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply); |
| 438 | if (result != NO_ERROR) { |
| 439 | ALOGE("getDisplayColorModes failed to transact: %d", result); |
| 440 | return result; |
| 441 | } |
| 442 | result = static_cast<status_t>(reply.readInt32()); |
| 443 | if (result == NO_ERROR) { |
| 444 | size_t numModes = reply.readUint32(); |
| 445 | outColorModes->clear(); |
| 446 | outColorModes->resize(numModes); |
| 447 | for (size_t i = 0; i < numModes; ++i) { |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 448 | outColorModes->replaceAt(static_cast<ColorMode>(reply.readInt32()), i); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 449 | } |
| 450 | } |
| 451 | return result; |
| 452 | } |
| 453 | |
Daniel Solomon | 42d0456 | 2019-01-20 21:03:19 -0800 | [diff] [blame] | 454 | virtual status_t getDisplayNativePrimaries(const sp<IBinder>& display, |
| 455 | ui::DisplayPrimaries& primaries) { |
| 456 | Parcel data, reply; |
| 457 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 458 | if (result != NO_ERROR) { |
| 459 | ALOGE("getDisplayNativePrimaries failed to writeInterfaceToken: %d", result); |
| 460 | return result; |
| 461 | } |
| 462 | result = data.writeStrongBinder(display); |
| 463 | if (result != NO_ERROR) { |
| 464 | ALOGE("getDisplayNativePrimaries failed to writeStrongBinder: %d", result); |
| 465 | return result; |
| 466 | } |
| 467 | result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_NATIVE_PRIMARIES, data, &reply); |
| 468 | if (result != NO_ERROR) { |
| 469 | ALOGE("getDisplayNativePrimaries failed to transact: %d", result); |
| 470 | return result; |
| 471 | } |
| 472 | result = reply.readInt32(); |
| 473 | if (result == NO_ERROR) { |
| 474 | memcpy(&primaries, reply.readInplace(sizeof(ui::DisplayPrimaries)), |
| 475 | sizeof(ui::DisplayPrimaries)); |
| 476 | } |
| 477 | return result; |
| 478 | } |
| 479 | |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 480 | virtual ColorMode getActiveColorMode(const sp<IBinder>& display) { |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 481 | Parcel data, reply; |
| 482 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 483 | if (result != NO_ERROR) { |
| 484 | ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result); |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 485 | return static_cast<ColorMode>(result); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 486 | } |
| 487 | result = data.writeStrongBinder(display); |
| 488 | if (result != NO_ERROR) { |
| 489 | ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result); |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 490 | return static_cast<ColorMode>(result); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 491 | } |
| 492 | result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply); |
| 493 | if (result != NO_ERROR) { |
| 494 | ALOGE("getActiveColorMode failed to transact: %d", result); |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 495 | return static_cast<ColorMode>(result); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 496 | } |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 497 | return static_cast<ColorMode>(reply.readInt32()); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | virtual status_t setActiveColorMode(const sp<IBinder>& display, |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 501 | ColorMode colorMode) { |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 502 | Parcel data, reply; |
| 503 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 504 | if (result != NO_ERROR) { |
| 505 | ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result); |
| 506 | return result; |
| 507 | } |
| 508 | result = data.writeStrongBinder(display); |
| 509 | if (result != NO_ERROR) { |
| 510 | ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result); |
| 511 | return result; |
| 512 | } |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 513 | result = data.writeInt32(static_cast<int32_t>(colorMode)); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 514 | if (result != NO_ERROR) { |
| 515 | ALOGE("setActiveColorMode failed to writeInt32: %d", result); |
| 516 | return result; |
| 517 | } |
| 518 | result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply); |
| 519 | if (result != NO_ERROR) { |
| 520 | ALOGE("setActiveColorMode failed to transact: %d", result); |
| 521 | return result; |
| 522 | } |
| 523 | return static_cast<status_t>(reply.readInt32()); |
| 524 | } |
| 525 | |
Galia Peycheva | 5492cb5 | 2019-10-30 14:13:16 +0100 | [diff] [blame] | 526 | virtual status_t getAutoLowLatencyModeSupport(const sp<IBinder>& display, |
| 527 | bool* outSupport) const { |
| 528 | Parcel data, reply; |
| 529 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 530 | status_t result = data.writeStrongBinder(display); |
| 531 | if (result != NO_ERROR) { |
| 532 | ALOGE("getAutoLowLatencyModeSupport failed to writeStrongBinder: %d", result); |
| 533 | return result; |
| 534 | } |
| 535 | result = remote()->transact(BnSurfaceComposer::GET_AUTO_LOW_LATENCY_MODE_SUPPORT, data, |
| 536 | &reply); |
| 537 | if (result != NO_ERROR) { |
| 538 | ALOGE("getAutoLowLatencyModeSupport failed to transact: %d", result); |
| 539 | return result; |
| 540 | } |
| 541 | return reply.readBool(outSupport); |
| 542 | } |
| 543 | |
| 544 | virtual void setAutoLowLatencyMode(const sp<IBinder>& display, bool on) { |
| 545 | Parcel data, reply; |
| 546 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 547 | if (result != NO_ERROR) { |
| 548 | ALOGE("setAutoLowLatencyMode failed to writeInterfaceToken: %d", result); |
| 549 | return; |
| 550 | } |
| 551 | |
| 552 | result = data.writeStrongBinder(display); |
| 553 | if (result != NO_ERROR) { |
| 554 | ALOGE("setAutoLowLatencyMode failed to writeStrongBinder: %d", result); |
| 555 | return; |
| 556 | } |
| 557 | result = data.writeBool(on); |
| 558 | if (result != NO_ERROR) { |
| 559 | ALOGE("setAutoLowLatencyMode failed to writeBool: %d", result); |
| 560 | return; |
| 561 | } |
| 562 | result = remote()->transact(BnSurfaceComposer::SET_AUTO_LOW_LATENCY_MODE, data, &reply); |
| 563 | if (result != NO_ERROR) { |
| 564 | ALOGE("setAutoLowLatencyMode failed to transact: %d", result); |
| 565 | return; |
| 566 | } |
| 567 | } |
| 568 | |
| 569 | virtual status_t getGameContentTypeSupport(const sp<IBinder>& display, bool* outSupport) const { |
| 570 | Parcel data, reply; |
| 571 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 572 | status_t result = data.writeStrongBinder(display); |
| 573 | if (result != NO_ERROR) { |
| 574 | ALOGE("getGameContentTypeSupport failed to writeStrongBinder: %d", result); |
| 575 | return result; |
| 576 | } |
| 577 | result = remote()->transact(BnSurfaceComposer::GET_GAME_CONTENT_TYPE_SUPPORT, data, &reply); |
| 578 | if (result != NO_ERROR) { |
| 579 | ALOGE("getGameContentTypeSupport failed to transact: %d", result); |
| 580 | return result; |
| 581 | } |
| 582 | return reply.readBool(outSupport); |
| 583 | } |
| 584 | |
| 585 | virtual void setGameContentType(const sp<IBinder>& display, bool on) { |
| 586 | Parcel data, reply; |
| 587 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 588 | if (result != NO_ERROR) { |
| 589 | ALOGE("setGameContentType failed to writeInterfaceToken: %d", result); |
| 590 | return; |
| 591 | } |
| 592 | result = data.writeStrongBinder(display); |
| 593 | if (result != NO_ERROR) { |
| 594 | ALOGE("setGameContentType failed to writeStrongBinder: %d", result); |
| 595 | return; |
| 596 | } |
| 597 | result = data.writeBool(on); |
| 598 | if (result != NO_ERROR) { |
| 599 | ALOGE("setGameContentType failed to writeBool: %d", result); |
| 600 | return; |
| 601 | } |
| 602 | result = remote()->transact(BnSurfaceComposer::SET_GAME_CONTENT_TYPE, data, &reply); |
| 603 | if (result != NO_ERROR) { |
| 604 | ALOGE("setGameContentType failed to transact: %d", result); |
| 605 | } |
| 606 | } |
| 607 | |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 608 | virtual status_t clearAnimationFrameStats() { |
| 609 | Parcel data, reply; |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 610 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 611 | if (result != NO_ERROR) { |
| 612 | ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result); |
| 613 | return result; |
| 614 | } |
| 615 | result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply); |
| 616 | if (result != NO_ERROR) { |
| 617 | ALOGE("clearAnimationFrameStats failed to transact: %d", result); |
| 618 | return result; |
| 619 | } |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 620 | return reply.readInt32(); |
| 621 | } |
| 622 | |
| 623 | virtual status_t getAnimationFrameStats(FrameStats* outStats) const { |
| 624 | Parcel data, reply; |
| 625 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 626 | remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply); |
| 627 | reply.read(*outStats); |
| 628 | return reply.readInt32(); |
| 629 | } |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 630 | |
| 631 | virtual status_t getHdrCapabilities(const sp<IBinder>& display, |
| 632 | HdrCapabilities* outCapabilities) const { |
| 633 | Parcel data, reply; |
| 634 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 635 | status_t result = data.writeStrongBinder(display); |
| 636 | if (result != NO_ERROR) { |
| 637 | ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result); |
| 638 | return result; |
| 639 | } |
| 640 | result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES, |
| 641 | data, &reply); |
| 642 | if (result != NO_ERROR) { |
| 643 | ALOGE("getHdrCapabilities failed to transact: %d", result); |
| 644 | return result; |
| 645 | } |
| 646 | result = reply.readInt32(); |
| 647 | if (result == NO_ERROR) { |
Mathias Agopian | e1f5e6f | 2017-02-06 16:34:41 -0800 | [diff] [blame] | 648 | result = reply.read(*outCapabilities); |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 649 | } |
| 650 | return result; |
| 651 | } |
Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 652 | |
| 653 | virtual status_t enableVSyncInjections(bool enable) { |
| 654 | Parcel data, reply; |
| 655 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 656 | if (result != NO_ERROR) { |
| 657 | ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result); |
| 658 | return result; |
| 659 | } |
| 660 | result = data.writeBool(enable); |
| 661 | if (result != NO_ERROR) { |
| 662 | ALOGE("enableVSyncInjections failed to writeBool: %d", result); |
| 663 | return result; |
| 664 | } |
Steven Moreland | 366eb42 | 2019-04-01 19:22:32 -0700 | [diff] [blame] | 665 | result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS, data, &reply, |
| 666 | IBinder::FLAG_ONEWAY); |
Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 667 | if (result != NO_ERROR) { |
| 668 | ALOGE("enableVSyncInjections failed to transact: %d", result); |
| 669 | return result; |
| 670 | } |
| 671 | return result; |
| 672 | } |
| 673 | |
| 674 | virtual status_t injectVSync(nsecs_t when) { |
| 675 | Parcel data, reply; |
| 676 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 677 | if (result != NO_ERROR) { |
| 678 | ALOGE("injectVSync failed to writeInterfaceToken: %d", result); |
| 679 | return result; |
| 680 | } |
| 681 | result = data.writeInt64(when); |
| 682 | if (result != NO_ERROR) { |
| 683 | ALOGE("injectVSync failed to writeInt64: %d", result); |
| 684 | return result; |
| 685 | } |
Steven Moreland | 366eb42 | 2019-04-01 19:22:32 -0700 | [diff] [blame] | 686 | result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply, |
| 687 | IBinder::FLAG_ONEWAY); |
Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 688 | if (result != NO_ERROR) { |
| 689 | ALOGE("injectVSync failed to transact: %d", result); |
| 690 | return result; |
| 691 | } |
| 692 | return result; |
| 693 | } |
| 694 | |
Vishnu Nair | 43bccf8 | 2020-06-05 10:53:37 -0700 | [diff] [blame] | 695 | virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) { |
Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 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, |
Dominik Laskowski | 470df5f | 2020-04-02 22:27:42 -0700 | [diff] [blame] | 798 | uint8_t componentMask, uint64_t maxFrames) { |
Kevin DuBois | 74e5377 | 2018-11-19 10:52:38 -0800 | [diff] [blame] | 799 | Parcel data, reply; |
| 800 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 801 | data.writeStrongBinder(display); |
| 802 | data.writeBool(enable); |
| 803 | data.writeByte(static_cast<int8_t>(componentMask)); |
| 804 | data.writeUint64(maxFrames); |
| 805 | status_t result = |
| 806 | remote()->transact(BnSurfaceComposer::SET_DISPLAY_CONTENT_SAMPLING_ENABLED, data, |
| 807 | &reply); |
| 808 | return result; |
| 809 | } |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 810 | |
| 811 | virtual status_t getDisplayedContentSample(const sp<IBinder>& display, uint64_t maxFrames, |
| 812 | uint64_t timestamp, |
| 813 | DisplayedFrameStats* outStats) const { |
| 814 | if (!outStats) return BAD_VALUE; |
| 815 | |
| 816 | Parcel data, reply; |
| 817 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 818 | data.writeStrongBinder(display); |
| 819 | data.writeUint64(maxFrames); |
| 820 | data.writeUint64(timestamp); |
| 821 | |
| 822 | status_t result = |
| 823 | remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLE, data, &reply); |
| 824 | |
| 825 | if (result != NO_ERROR) { |
| 826 | return result; |
| 827 | } |
| 828 | |
| 829 | result = reply.readUint64(&outStats->numFrames); |
| 830 | if (result != NO_ERROR) { |
| 831 | return result; |
| 832 | } |
| 833 | |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 834 | result = reply.readUint64Vector(&outStats->component_0_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 835 | if (result != NO_ERROR) { |
| 836 | return result; |
| 837 | } |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 838 | result = reply.readUint64Vector(&outStats->component_1_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 839 | if (result != NO_ERROR) { |
| 840 | return result; |
| 841 | } |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 842 | result = reply.readUint64Vector(&outStats->component_2_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 843 | if (result != NO_ERROR) { |
| 844 | return result; |
| 845 | } |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 846 | result = reply.readUint64Vector(&outStats->component_3_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 847 | return result; |
| 848 | } |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 849 | |
| 850 | virtual status_t getProtectedContentSupport(bool* outSupported) const { |
| 851 | Parcel data, reply; |
| 852 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Peiyong Lin | b6888fa | 2019-01-28 13:20:58 -0800 | [diff] [blame] | 853 | status_t error = |
| 854 | remote()->transact(BnSurfaceComposer::GET_PROTECTED_CONTENT_SUPPORT, data, &reply); |
| 855 | if (error != NO_ERROR) { |
| 856 | return error; |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 857 | } |
Peiyong Lin | b6888fa | 2019-01-28 13:20:58 -0800 | [diff] [blame] | 858 | error = reply.readBool(outSupported); |
| 859 | return error; |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 860 | } |
Marissa Wall | ebc2c05 | 2019-01-16 19:16:55 -0800 | [diff] [blame] | 861 | |
Peiyong Lin | 4f3fddf | 2019-01-24 17:21:24 -0800 | [diff] [blame] | 862 | virtual status_t isWideColorDisplay(const sp<IBinder>& token, |
| 863 | bool* outIsWideColorDisplay) const { |
| 864 | Parcel data, reply; |
| 865 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 866 | if (error != NO_ERROR) { |
| 867 | return error; |
| 868 | } |
| 869 | error = data.writeStrongBinder(token); |
| 870 | if (error != NO_ERROR) { |
| 871 | return error; |
| 872 | } |
| 873 | |
| 874 | error = remote()->transact(BnSurfaceComposer::IS_WIDE_COLOR_DISPLAY, data, &reply); |
| 875 | if (error != NO_ERROR) { |
| 876 | return error; |
| 877 | } |
| 878 | error = reply.readBool(outIsWideColorDisplay); |
| 879 | return error; |
| 880 | } |
Dan Stoza | 84ab937 | 2018-12-17 15:27:57 -0800 | [diff] [blame] | 881 | |
| 882 | virtual status_t addRegionSamplingListener(const Rect& samplingArea, |
| 883 | const sp<IBinder>& stopLayerHandle, |
| 884 | const sp<IRegionSamplingListener>& listener) { |
| 885 | Parcel data, reply; |
| 886 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 887 | if (error != NO_ERROR) { |
| 888 | ALOGE("addRegionSamplingListener: Failed to write interface token"); |
| 889 | return error; |
| 890 | } |
| 891 | error = data.write(samplingArea); |
| 892 | if (error != NO_ERROR) { |
| 893 | ALOGE("addRegionSamplingListener: Failed to write sampling area"); |
| 894 | return error; |
| 895 | } |
| 896 | error = data.writeStrongBinder(stopLayerHandle); |
| 897 | if (error != NO_ERROR) { |
| 898 | ALOGE("addRegionSamplingListener: Failed to write stop layer handle"); |
| 899 | return error; |
| 900 | } |
| 901 | error = data.writeStrongBinder(IInterface::asBinder(listener)); |
| 902 | if (error != NO_ERROR) { |
| 903 | ALOGE("addRegionSamplingListener: Failed to write listener"); |
| 904 | return error; |
| 905 | } |
| 906 | error = remote()->transact(BnSurfaceComposer::ADD_REGION_SAMPLING_LISTENER, data, &reply); |
| 907 | if (error != NO_ERROR) { |
| 908 | ALOGE("addRegionSamplingListener: Failed to transact"); |
| 909 | } |
| 910 | return error; |
| 911 | } |
| 912 | |
| 913 | virtual status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) { |
| 914 | Parcel data, reply; |
| 915 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 916 | if (error != NO_ERROR) { |
tangrobin | af45f01 | 2019-02-26 18:10:10 +0800 | [diff] [blame] | 917 | ALOGE("removeRegionSamplingListener: Failed to write interface token"); |
Dan Stoza | 84ab937 | 2018-12-17 15:27:57 -0800 | [diff] [blame] | 918 | return error; |
| 919 | } |
| 920 | error = data.writeStrongBinder(IInterface::asBinder(listener)); |
| 921 | if (error != NO_ERROR) { |
tangrobin | af45f01 | 2019-02-26 18:10:10 +0800 | [diff] [blame] | 922 | ALOGE("removeRegionSamplingListener: Failed to write listener"); |
Dan Stoza | 84ab937 | 2018-12-17 15:27:57 -0800 | [diff] [blame] | 923 | return error; |
| 924 | } |
| 925 | error = remote()->transact(BnSurfaceComposer::REMOVE_REGION_SAMPLING_LISTENER, data, |
| 926 | &reply); |
| 927 | if (error != NO_ERROR) { |
tangrobin | af45f01 | 2019-02-26 18:10:10 +0800 | [diff] [blame] | 928 | ALOGE("removeRegionSamplingListener: Failed to transact"); |
Dan Stoza | 84ab937 | 2018-12-17 15:27:57 -0800 | [diff] [blame] | 929 | } |
| 930 | return error; |
| 931 | } |
Ady Abraham | 838de06 | 2019-02-04 10:24:03 -0800 | [diff] [blame] | 932 | |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 933 | virtual status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken, |
Steven Thomas | f734df4 | 2020-04-13 21:09:28 -0700 | [diff] [blame] | 934 | int32_t defaultConfig, |
| 935 | float primaryRefreshRateMin, |
| 936 | float primaryRefreshRateMax, |
| 937 | float appRequestRefreshRateMin, |
| 938 | float appRequestRefreshRateMax) { |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 939 | Parcel data, reply; |
| 940 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 941 | if (result != NO_ERROR) { |
| 942 | ALOGE("setDesiredDisplayConfigSpecs: failed to writeInterfaceToken: %d", result); |
| 943 | return result; |
| 944 | } |
| 945 | result = data.writeStrongBinder(displayToken); |
| 946 | if (result != NO_ERROR) { |
| 947 | ALOGE("setDesiredDisplayConfigSpecs: failed to write display token: %d", result); |
| 948 | return result; |
| 949 | } |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 950 | result = data.writeInt32(defaultConfig); |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 951 | if (result != NO_ERROR) { |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 952 | ALOGE("setDesiredDisplayConfigSpecs failed to write defaultConfig: %d", result); |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 953 | return result; |
| 954 | } |
Steven Thomas | f734df4 | 2020-04-13 21:09:28 -0700 | [diff] [blame] | 955 | result = data.writeFloat(primaryRefreshRateMin); |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 956 | if (result != NO_ERROR) { |
Steven Thomas | f734df4 | 2020-04-13 21:09:28 -0700 | [diff] [blame] | 957 | ALOGE("setDesiredDisplayConfigSpecs failed to write primaryRefreshRateMin: %d", result); |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 958 | return result; |
| 959 | } |
Steven Thomas | f734df4 | 2020-04-13 21:09:28 -0700 | [diff] [blame] | 960 | result = data.writeFloat(primaryRefreshRateMax); |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 961 | if (result != NO_ERROR) { |
Steven Thomas | f734df4 | 2020-04-13 21:09:28 -0700 | [diff] [blame] | 962 | ALOGE("setDesiredDisplayConfigSpecs failed to write primaryRefreshRateMax: %d", result); |
| 963 | return result; |
| 964 | } |
| 965 | result = data.writeFloat(appRequestRefreshRateMin); |
| 966 | if (result != NO_ERROR) { |
| 967 | ALOGE("setDesiredDisplayConfigSpecs failed to write appRequestRefreshRateMin: %d", |
| 968 | result); |
| 969 | return result; |
| 970 | } |
| 971 | result = data.writeFloat(appRequestRefreshRateMax); |
| 972 | if (result != NO_ERROR) { |
| 973 | ALOGE("setDesiredDisplayConfigSpecs failed to write appRequestRefreshRateMax: %d", |
| 974 | result); |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 975 | return result; |
| 976 | } |
| 977 | |
| 978 | result = remote()->transact(BnSurfaceComposer::SET_DESIRED_DISPLAY_CONFIG_SPECS, data, |
| 979 | &reply); |
| 980 | if (result != NO_ERROR) { |
| 981 | ALOGE("setDesiredDisplayConfigSpecs failed to transact: %d", result); |
| 982 | return result; |
| 983 | } |
| 984 | return reply.readInt32(); |
| 985 | } |
| 986 | |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 987 | virtual status_t getDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken, |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 988 | int32_t* outDefaultConfig, |
Steven Thomas | f734df4 | 2020-04-13 21:09:28 -0700 | [diff] [blame] | 989 | float* outPrimaryRefreshRateMin, |
| 990 | float* outPrimaryRefreshRateMax, |
| 991 | float* outAppRequestRefreshRateMin, |
| 992 | float* outAppRequestRefreshRateMax) { |
| 993 | if (!outDefaultConfig || !outPrimaryRefreshRateMin || !outPrimaryRefreshRateMax || |
| 994 | !outAppRequestRefreshRateMin || !outAppRequestRefreshRateMax) { |
| 995 | return BAD_VALUE; |
| 996 | } |
Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 997 | Parcel data, reply; |
| 998 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 999 | if (result != NO_ERROR) { |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1000 | ALOGE("getDesiredDisplayConfigSpecs failed to writeInterfaceToken: %d", result); |
Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 1001 | return result; |
| 1002 | } |
| 1003 | result = data.writeStrongBinder(displayToken); |
| 1004 | if (result != NO_ERROR) { |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1005 | ALOGE("getDesiredDisplayConfigSpecs failed to writeStrongBinder: %d", result); |
Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 1006 | return result; |
| 1007 | } |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1008 | result = remote()->transact(BnSurfaceComposer::GET_DESIRED_DISPLAY_CONFIG_SPECS, data, |
| 1009 | &reply); |
Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 1010 | if (result != NO_ERROR) { |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1011 | ALOGE("getDesiredDisplayConfigSpecs failed to transact: %d", result); |
Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 1012 | return result; |
| 1013 | } |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 1014 | result = reply.readInt32(outDefaultConfig); |
Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 1015 | if (result != NO_ERROR) { |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 1016 | ALOGE("getDesiredDisplayConfigSpecs failed to read defaultConfig: %d", result); |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1017 | return result; |
| 1018 | } |
Steven Thomas | f734df4 | 2020-04-13 21:09:28 -0700 | [diff] [blame] | 1019 | result = reply.readFloat(outPrimaryRefreshRateMin); |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1020 | if (result != NO_ERROR) { |
Steven Thomas | f734df4 | 2020-04-13 21:09:28 -0700 | [diff] [blame] | 1021 | ALOGE("getDesiredDisplayConfigSpecs failed to read primaryRefreshRateMin: %d", result); |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1022 | return result; |
| 1023 | } |
Steven Thomas | f734df4 | 2020-04-13 21:09:28 -0700 | [diff] [blame] | 1024 | result = reply.readFloat(outPrimaryRefreshRateMax); |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1025 | if (result != NO_ERROR) { |
Steven Thomas | f734df4 | 2020-04-13 21:09:28 -0700 | [diff] [blame] | 1026 | ALOGE("getDesiredDisplayConfigSpecs failed to read primaryRefreshRateMax: %d", result); |
| 1027 | return result; |
| 1028 | } |
| 1029 | result = reply.readFloat(outAppRequestRefreshRateMin); |
| 1030 | if (result != NO_ERROR) { |
| 1031 | ALOGE("getDesiredDisplayConfigSpecs failed to read appRequestRefreshRateMin: %d", |
| 1032 | result); |
| 1033 | return result; |
| 1034 | } |
| 1035 | result = reply.readFloat(outAppRequestRefreshRateMax); |
| 1036 | if (result != NO_ERROR) { |
| 1037 | ALOGE("getDesiredDisplayConfigSpecs failed to read appRequestRefreshRateMax: %d", |
| 1038 | result); |
Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 1039 | return result; |
| 1040 | } |
| 1041 | return reply.readInt32(); |
| 1042 | } |
Dan Gittik | 57e63c5 | 2019-01-18 16:37:54 +0000 | [diff] [blame] | 1043 | |
| 1044 | virtual status_t getDisplayBrightnessSupport(const sp<IBinder>& displayToken, |
| 1045 | bool* outSupport) const { |
| 1046 | Parcel data, reply; |
| 1047 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 1048 | if (error != NO_ERROR) { |
| 1049 | ALOGE("getDisplayBrightnessSupport: failed to write interface token: %d", error); |
| 1050 | return error; |
| 1051 | } |
| 1052 | error = data.writeStrongBinder(displayToken); |
| 1053 | if (error != NO_ERROR) { |
| 1054 | ALOGE("getDisplayBrightnessSupport: failed to write display token: %d", error); |
| 1055 | return error; |
| 1056 | } |
| 1057 | error = remote()->transact(BnSurfaceComposer::GET_DISPLAY_BRIGHTNESS_SUPPORT, data, &reply); |
| 1058 | if (error != NO_ERROR) { |
| 1059 | ALOGE("getDisplayBrightnessSupport: failed to transact: %d", error); |
| 1060 | return error; |
| 1061 | } |
| 1062 | bool support; |
| 1063 | error = reply.readBool(&support); |
| 1064 | if (error != NO_ERROR) { |
| 1065 | ALOGE("getDisplayBrightnessSupport: failed to read support: %d", error); |
| 1066 | return error; |
| 1067 | } |
| 1068 | *outSupport = support; |
| 1069 | return NO_ERROR; |
| 1070 | } |
| 1071 | |
Dominik Laskowski | 470df5f | 2020-04-02 22:27:42 -0700 | [diff] [blame] | 1072 | virtual status_t setDisplayBrightness(const sp<IBinder>& displayToken, float brightness) { |
Dan Gittik | 57e63c5 | 2019-01-18 16:37:54 +0000 | [diff] [blame] | 1073 | Parcel data, reply; |
| 1074 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 1075 | if (error != NO_ERROR) { |
| 1076 | ALOGE("setDisplayBrightness: failed to write interface token: %d", error); |
| 1077 | return error; |
| 1078 | } |
| 1079 | error = data.writeStrongBinder(displayToken); |
| 1080 | if (error != NO_ERROR) { |
| 1081 | ALOGE("setDisplayBrightness: failed to write display token: %d", error); |
| 1082 | return error; |
| 1083 | } |
| 1084 | error = data.writeFloat(brightness); |
| 1085 | if (error != NO_ERROR) { |
| 1086 | ALOGE("setDisplayBrightness: failed to write brightness: %d", error); |
| 1087 | return error; |
| 1088 | } |
| 1089 | error = remote()->transact(BnSurfaceComposer::SET_DISPLAY_BRIGHTNESS, data, &reply); |
| 1090 | if (error != NO_ERROR) { |
| 1091 | ALOGE("setDisplayBrightness: failed to transact: %d", error); |
| 1092 | return error; |
| 1093 | } |
| 1094 | return NO_ERROR; |
| 1095 | } |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 1096 | |
Lais Andrade | 3a6e47d | 2020-04-02 11:20:16 +0100 | [diff] [blame] | 1097 | virtual status_t notifyPowerBoost(int32_t boostId) { |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 1098 | Parcel data, reply; |
| 1099 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 1100 | if (error != NO_ERROR) { |
Lais Andrade | 3a6e47d | 2020-04-02 11:20:16 +0100 | [diff] [blame] | 1101 | ALOGE("notifyPowerBoost: failed to write interface token: %d", error); |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 1102 | return error; |
| 1103 | } |
Lais Andrade | 3a6e47d | 2020-04-02 11:20:16 +0100 | [diff] [blame] | 1104 | error = data.writeInt32(boostId); |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 1105 | if (error != NO_ERROR) { |
Lais Andrade | 3a6e47d | 2020-04-02 11:20:16 +0100 | [diff] [blame] | 1106 | ALOGE("notifyPowerBoost: failed to write boostId: %d", error); |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 1107 | return error; |
| 1108 | } |
Lais Andrade | 3a6e47d | 2020-04-02 11:20:16 +0100 | [diff] [blame] | 1109 | error = remote()->transact(BnSurfaceComposer::NOTIFY_POWER_BOOST, data, &reply, |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 1110 | IBinder::FLAG_ONEWAY); |
| 1111 | if (error != NO_ERROR) { |
Lais Andrade | 3a6e47d | 2020-04-02 11:20:16 +0100 | [diff] [blame] | 1112 | ALOGE("notifyPowerBoost: failed to transact: %d", error); |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 1113 | return error; |
| 1114 | } |
| 1115 | return NO_ERROR; |
| 1116 | } |
Vishnu Nair | b13bb95 | 2019-11-15 10:24:08 -0800 | [diff] [blame] | 1117 | |
| 1118 | virtual status_t setGlobalShadowSettings(const half4& ambientColor, const half4& spotColor, |
| 1119 | float lightPosY, float lightPosZ, float lightRadius) { |
| 1120 | Parcel data, reply; |
| 1121 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 1122 | if (error != NO_ERROR) { |
| 1123 | ALOGE("setGlobalShadowSettings: failed to write interface token: %d", error); |
| 1124 | return error; |
| 1125 | } |
| 1126 | |
| 1127 | std::vector<float> shadowConfig = {ambientColor.r, ambientColor.g, ambientColor.b, |
| 1128 | ambientColor.a, spotColor.r, spotColor.g, |
| 1129 | spotColor.b, spotColor.a, lightPosY, |
| 1130 | lightPosZ, lightRadius}; |
| 1131 | |
| 1132 | error = data.writeFloatVector(shadowConfig); |
| 1133 | if (error != NO_ERROR) { |
| 1134 | ALOGE("setGlobalShadowSettings: failed to write shadowConfig: %d", error); |
| 1135 | return error; |
| 1136 | } |
| 1137 | |
| 1138 | error = remote()->transact(BnSurfaceComposer::SET_GLOBAL_SHADOW_SETTINGS, data, &reply, |
| 1139 | IBinder::FLAG_ONEWAY); |
| 1140 | if (error != NO_ERROR) { |
| 1141 | ALOGE("setGlobalShadowSettings: failed to transact: %d", error); |
| 1142 | return error; |
| 1143 | } |
| 1144 | return NO_ERROR; |
| 1145 | } |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 1146 | |
| 1147 | virtual status_t setFrameRate(const sp<IGraphicBufferProducer>& surface, float frameRate, |
| 1148 | int8_t compatibility) { |
| 1149 | Parcel data, reply; |
| 1150 | status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 1151 | if (err != NO_ERROR) { |
| 1152 | ALOGE("setFrameRate: failed writing interface token: %s (%d)", strerror(-err), -err); |
| 1153 | return err; |
| 1154 | } |
| 1155 | |
| 1156 | err = data.writeStrongBinder(IInterface::asBinder(surface)); |
| 1157 | if (err != NO_ERROR) { |
| 1158 | ALOGE("setFrameRate: failed writing strong binder: %s (%d)", strerror(-err), -err); |
| 1159 | return err; |
| 1160 | } |
| 1161 | |
| 1162 | err = data.writeFloat(frameRate); |
| 1163 | if (err != NO_ERROR) { |
| 1164 | ALOGE("setFrameRate: failed writing float: %s (%d)", strerror(-err), -err); |
| 1165 | return err; |
| 1166 | } |
| 1167 | |
| 1168 | err = data.writeByte(compatibility); |
| 1169 | if (err != NO_ERROR) { |
| 1170 | ALOGE("setFrameRate: failed writing byte: %s (%d)", strerror(-err), -err); |
| 1171 | return err; |
| 1172 | } |
| 1173 | |
Ady Abraham | 60e42ea | 2020-03-09 19:17:31 -0700 | [diff] [blame] | 1174 | err = remote()->transact(BnSurfaceComposer::SET_FRAME_RATE, data, &reply); |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 1175 | if (err != NO_ERROR) { |
| 1176 | ALOGE("setFrameRate: failed to transact: %s (%d)", strerror(-err), err); |
| 1177 | return err; |
| 1178 | } |
Steven Thomas | d407190 | 2020-03-24 16:02:53 -0700 | [diff] [blame] | 1179 | |
| 1180 | return reply.readInt32(); |
| 1181 | } |
| 1182 | |
| 1183 | virtual status_t acquireFrameRateFlexibilityToken(sp<IBinder>* outToken) { |
| 1184 | if (!outToken) return BAD_VALUE; |
| 1185 | |
| 1186 | Parcel data, reply; |
| 1187 | status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 1188 | if (err != NO_ERROR) { |
| 1189 | ALOGE("acquireFrameRateFlexibilityToken: failed writing interface token: %s (%d)", |
| 1190 | strerror(-err), -err); |
| 1191 | return err; |
| 1192 | } |
| 1193 | |
| 1194 | err = remote()->transact(BnSurfaceComposer::ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN, data, |
| 1195 | &reply); |
| 1196 | if (err != NO_ERROR) { |
| 1197 | ALOGE("acquireFrameRateFlexibilityToken: failed to transact: %s (%d)", strerror(-err), |
| 1198 | err); |
| 1199 | return err; |
| 1200 | } |
| 1201 | |
| 1202 | err = reply.readInt32(); |
| 1203 | if (err != NO_ERROR) { |
| 1204 | ALOGE("acquireFrameRateFlexibilityToken: call failed: %s (%d)", strerror(-err), err); |
| 1205 | return err; |
| 1206 | } |
| 1207 | |
| 1208 | err = reply.readStrongBinder(outToken); |
| 1209 | if (err != NO_ERROR) { |
| 1210 | ALOGE("acquireFrameRateFlexibilityToken: failed reading binder token: %s (%d)", |
| 1211 | strerror(-err), err); |
| 1212 | return err; |
| 1213 | } |
| 1214 | |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 1215 | return NO_ERROR; |
| 1216 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1217 | }; |
| 1218 | |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1219 | // Out-of-line virtual method definition to trigger vtable emission in this |
| 1220 | // translation unit (see clang warning -Wweak-vtables) |
| 1221 | BpSurfaceComposer::~BpSurfaceComposer() {} |
| 1222 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1223 | IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer"); |
| 1224 | |
| 1225 | // ---------------------------------------------------------------------- |
| 1226 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1227 | status_t BnSurfaceComposer::onTransact( |
| 1228 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 1229 | { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1230 | switch(code) { |
| 1231 | case CREATE_CONNECTION: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 1232 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 1233 | sp<IBinder> b = IInterface::asBinder(createConnection()); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1234 | reply->writeStrongBinder(b); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1235 | return NO_ERROR; |
| 1236 | } |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 1237 | case SET_TRANSACTION_STATE: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 1238 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1239 | |
| 1240 | size_t count = data.readUint32(); |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 1241 | if (count > data.dataSize()) { |
| 1242 | return BAD_VALUE; |
| 1243 | } |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 1244 | Vector<ComposerState> state; |
| 1245 | state.setCapacity(count); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1246 | for (size_t i = 0; i < count; i++) { |
Marissa Wall | c837b5e | 2018-10-12 10:04:44 -0700 | [diff] [blame] | 1247 | ComposerState s; |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 1248 | if (s.read(data) == BAD_VALUE) { |
| 1249 | return BAD_VALUE; |
| 1250 | } |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 1251 | state.add(s); |
| 1252 | } |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1253 | |
| 1254 | count = data.readUint32(); |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 1255 | if (count > data.dataSize()) { |
| 1256 | return BAD_VALUE; |
| 1257 | } |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 1258 | DisplayState d; |
| 1259 | Vector<DisplayState> displays; |
| 1260 | displays.setCapacity(count); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1261 | for (size_t i = 0; i < count; i++) { |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 1262 | if (d.read(data) == BAD_VALUE) { |
| 1263 | return BAD_VALUE; |
| 1264 | } |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 1265 | displays.add(d); |
| 1266 | } |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1267 | |
| 1268 | uint32_t stateFlags = data.readUint32(); |
Marissa Wall | 713b63f | 2018-10-17 15:42:43 -0700 | [diff] [blame] | 1269 | sp<IBinder> applyToken = data.readStrongBinder(); |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 1270 | InputWindowCommands inputWindowCommands; |
| 1271 | inputWindowCommands.read(data); |
Marissa Wall | 17b4e45 | 2018-12-26 16:32:34 -0800 | [diff] [blame] | 1272 | |
| 1273 | int64_t desiredPresentTime = data.readInt64(); |
Marissa Wall | 78b7220 | 2019-03-15 14:58:34 -0700 | [diff] [blame] | 1274 | |
Marissa Wall | 947d34e | 2019-03-29 14:03:53 -0700 | [diff] [blame] | 1275 | client_cache_t uncachedBuffer; |
Steven Moreland | 9d4ce9b | 2019-07-17 15:23:38 -0700 | [diff] [blame] | 1276 | uncachedBuffer.token = data.readStrongBinder(); |
Marissa Wall | 947d34e | 2019-03-29 14:03:53 -0700 | [diff] [blame] | 1277 | uncachedBuffer.id = data.readUint64(); |
Marissa Wall | 78b7220 | 2019-03-15 14:58:34 -0700 | [diff] [blame] | 1278 | |
Valerie Hau | 9dab973 | 2019-08-20 09:29:25 -0700 | [diff] [blame] | 1279 | bool hasListenerCallbacks = data.readBool(); |
| 1280 | |
Marissa Wall | 3dad52d | 2019-03-22 14:03:19 -0700 | [diff] [blame] | 1281 | std::vector<ListenerCallbacks> listenerCallbacks; |
| 1282 | int32_t listenersSize = data.readInt32(); |
| 1283 | for (int32_t i = 0; i < listenersSize; i++) { |
Valerie Hau | 5de3ad2 | 2019-08-20 07:47:43 -0700 | [diff] [blame] | 1284 | auto listener = data.readStrongBinder(); |
Marissa Wall | 3dad52d | 2019-03-22 14:03:19 -0700 | [diff] [blame] | 1285 | std::vector<CallbackId> callbackIds; |
| 1286 | data.readInt64Vector(&callbackIds); |
| 1287 | listenerCallbacks.emplace_back(listener, callbackIds); |
| 1288 | } |
Marissa Wall | 17b4e45 | 2018-12-26 16:32:34 -0800 | [diff] [blame] | 1289 | setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands, |
Valerie Hau | 9dab973 | 2019-08-20 09:29:25 -0700 | [diff] [blame] | 1290 | desiredPresentTime, uncachedBuffer, hasListenerCallbacks, |
| 1291 | listenerCallbacks); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1292 | return NO_ERROR; |
| 1293 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1294 | case BOOT_FINISHED: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 1295 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1296 | bootFinished(); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1297 | return NO_ERROR; |
| 1298 | } |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 1299 | case CAPTURE_SCREEN: { |
| 1300 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1301 | sp<IBinder> display = data.readStrongBinder(); |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 1302 | ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32()); |
| 1303 | ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32()); |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 1304 | sp<GraphicBuffer> outBuffer; |
Pablo Ceballos | 60d6922 | 2015-08-07 14:47:20 -0700 | [diff] [blame] | 1305 | Rect sourceCrop(Rect::EMPTY_RECT); |
Dan Stoza | c187900 | 2014-05-22 15:59:05 -0700 | [diff] [blame] | 1306 | data.read(sourceCrop); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1307 | uint32_t reqWidth = data.readUint32(); |
| 1308 | uint32_t reqHeight = data.readUint32(); |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 1309 | bool useIdentityTransform = static_cast<bool>(data.readInt32()); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1310 | int32_t rotation = data.readInt32(); |
Robert Carr | fa8855f | 2019-02-19 10:05:00 -0800 | [diff] [blame] | 1311 | bool captureSecureLayers = static_cast<bool>(data.readInt32()); |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 1312 | |
Robert Carr | 108b2c7 | 2019-04-02 16:32:58 -0700 | [diff] [blame] | 1313 | bool capturedSecureLayers = false; |
| 1314 | status_t res = captureScreen(display, &outBuffer, capturedSecureLayers, reqDataspace, |
| 1315 | reqPixelFormat, sourceCrop, reqWidth, reqHeight, |
Dominik Laskowski | 718f960 | 2019-11-09 20:01:35 -0800 | [diff] [blame] | 1316 | useIdentityTransform, ui::toRotation(rotation), |
Robert Carr | 108b2c7 | 2019-04-02 16:32:58 -0700 | [diff] [blame] | 1317 | captureSecureLayers); |
| 1318 | |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 1319 | reply->writeInt32(res); |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 1320 | if (res == NO_ERROR) { |
| 1321 | reply->write(*outBuffer); |
Robert Carr | 108b2c7 | 2019-04-02 16:32:58 -0700 | [diff] [blame] | 1322 | reply->writeBool(capturedSecureLayers); |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 1323 | } |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1324 | return NO_ERROR; |
| 1325 | } |
chaviw | 93df2ea | 2019-04-30 16:45:12 -0700 | [diff] [blame] | 1326 | case CAPTURE_SCREEN_BY_ID: { |
| 1327 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1328 | uint64_t displayOrLayerStack = data.readUint64(); |
| 1329 | ui::Dataspace outDataspace = ui::Dataspace::V0_SRGB; |
| 1330 | sp<GraphicBuffer> outBuffer; |
| 1331 | status_t res = captureScreen(displayOrLayerStack, &outDataspace, &outBuffer); |
| 1332 | reply->writeInt32(res); |
| 1333 | if (res == NO_ERROR) { |
| 1334 | reply->writeInt32(static_cast<int32_t>(outDataspace)); |
| 1335 | reply->write(*outBuffer); |
| 1336 | } |
| 1337 | return NO_ERROR; |
| 1338 | } |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 1339 | case CAPTURE_LAYERS: { |
| 1340 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1341 | sp<IBinder> layerHandleBinder = data.readStrongBinder(); |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 1342 | ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32()); |
| 1343 | ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32()); |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 1344 | sp<GraphicBuffer> outBuffer; |
chaviw | 7206d49 | 2017-11-10 16:16:12 -0800 | [diff] [blame] | 1345 | Rect sourceCrop(Rect::EMPTY_RECT); |
| 1346 | data.read(sourceCrop); |
Robert Carr | 866455f | 2019-04-02 16:28:26 -0700 | [diff] [blame] | 1347 | |
| 1348 | std::unordered_set<sp<IBinder>, SpHash<IBinder>> excludeHandles; |
| 1349 | int numExcludeHandles = data.readInt32(); |
Ady Abraham | 0a52509 | 2020-03-03 12:51:24 -0800 | [diff] [blame] | 1350 | if (numExcludeHandles >= static_cast<int>(MAX_LAYERS)) { |
| 1351 | return BAD_VALUE; |
| 1352 | } |
Robert Carr | 866455f | 2019-04-02 16:28:26 -0700 | [diff] [blame] | 1353 | excludeHandles.reserve(numExcludeHandles); |
| 1354 | for (int i = 0; i < numExcludeHandles; i++) { |
| 1355 | excludeHandles.emplace(data.readStrongBinder()); |
| 1356 | } |
| 1357 | |
chaviw | 7206d49 | 2017-11-10 16:16:12 -0800 | [diff] [blame] | 1358 | float frameScale = data.readFloat(); |
Robert Carr | 578038f | 2018-03-09 12:25:24 -0800 | [diff] [blame] | 1359 | bool childrenOnly = data.readBool(); |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 1360 | |
Robert Carr | 866455f | 2019-04-02 16:28:26 -0700 | [diff] [blame] | 1361 | status_t res = |
| 1362 | captureLayers(layerHandleBinder, &outBuffer, reqDataspace, reqPixelFormat, |
| 1363 | sourceCrop, excludeHandles, frameScale, childrenOnly); |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 1364 | reply->writeInt32(res); |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 1365 | if (res == NO_ERROR) { |
| 1366 | reply->write(*outBuffer); |
| 1367 | } |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 1368 | return NO_ERROR; |
| 1369 | } |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 1370 | case AUTHENTICATE_SURFACE: { |
| 1371 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 1372 | sp<IGraphicBufferProducer> bufferProducer = |
| 1373 | interface_cast<IGraphicBufferProducer>(data.readStrongBinder()); |
| 1374 | int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0; |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 1375 | reply->writeInt32(result); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1376 | return NO_ERROR; |
| 1377 | } |
Brian Anderson | 6b37671 | 2017-04-04 10:51:39 -0700 | [diff] [blame] | 1378 | case GET_SUPPORTED_FRAME_TIMESTAMPS: { |
| 1379 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1380 | std::vector<FrameEvent> supportedTimestamps; |
| 1381 | status_t result = getSupportedFrameTimestamps(&supportedTimestamps); |
| 1382 | status_t err = reply->writeInt32(result); |
| 1383 | if (err != NO_ERROR) { |
| 1384 | return err; |
| 1385 | } |
| 1386 | if (result != NO_ERROR) { |
| 1387 | return result; |
| 1388 | } |
| 1389 | |
| 1390 | std::vector<int32_t> supported; |
| 1391 | supported.reserve(supportedTimestamps.size()); |
| 1392 | for (FrameEvent s : supportedTimestamps) { |
| 1393 | supported.push_back(static_cast<int32_t>(s)); |
| 1394 | } |
| 1395 | return reply->writeInt32Vector(supported); |
| 1396 | } |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 1397 | case CREATE_DISPLAY_EVENT_CONNECTION: { |
| 1398 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Ady Abraham | 0f4a1b1 | 2019-06-04 16:04:04 -0700 | [diff] [blame] | 1399 | auto vsyncSource = static_cast<ISurfaceComposer::VsyncSource>(data.readInt32()); |
| 1400 | auto configChanged = static_cast<ISurfaceComposer::ConfigChanged>(data.readInt32()); |
| 1401 | |
| 1402 | sp<IDisplayEventConnection> connection( |
| 1403 | createDisplayEventConnection(vsyncSource, configChanged)); |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 1404 | reply->writeStrongBinder(IInterface::asBinder(connection)); |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 1405 | return NO_ERROR; |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1406 | } |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 1407 | case CREATE_DISPLAY: { |
| 1408 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Andy McFadden | 8dfa92f | 2012-09-17 18:27:17 -0700 | [diff] [blame] | 1409 | String8 displayName = data.readString8(); |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 1410 | bool secure = bool(data.readInt32()); |
| 1411 | sp<IBinder> display(createDisplay(displayName, secure)); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 1412 | reply->writeStrongBinder(display); |
| 1413 | return NO_ERROR; |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1414 | } |
| 1415 | case DESTROY_DISPLAY: { |
| 1416 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1417 | sp<IBinder> display = data.readStrongBinder(); |
| 1418 | destroyDisplay(display); |
| 1419 | return NO_ERROR; |
| 1420 | } |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 1421 | case GET_PHYSICAL_DISPLAY_TOKEN: { |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 1422 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame^] | 1423 | PhysicalDisplayId displayId(data.readUint64()); |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 1424 | sp<IBinder> display = getPhysicalDisplayToken(displayId); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 1425 | reply->writeStrongBinder(display); |
| 1426 | return NO_ERROR; |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1427 | } |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 1428 | case GET_DISPLAY_STATE: { |
| 1429 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1430 | ui::DisplayState state; |
| 1431 | const sp<IBinder> display = data.readStrongBinder(); |
| 1432 | const status_t result = getDisplayState(display, &state); |
| 1433 | reply->writeInt32(result); |
| 1434 | if (result == NO_ERROR) { |
| 1435 | memcpy(reply->writeInplace(sizeof(ui::DisplayState)), &state, |
| 1436 | sizeof(ui::DisplayState)); |
| 1437 | } |
| 1438 | return NO_ERROR; |
| 1439 | } |
| 1440 | case GET_DISPLAY_INFO: { |
| 1441 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1442 | DisplayInfo info; |
| 1443 | const sp<IBinder> display = data.readStrongBinder(); |
| 1444 | const status_t result = getDisplayInfo(display, &info); |
| 1445 | reply->writeInt32(result); |
Marin Shalamanov | 359a7e7 | 2020-02-17 17:03:07 +0100 | [diff] [blame] | 1446 | if (result != NO_ERROR) return result; |
| 1447 | return reply->write(info); |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 1448 | } |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 1449 | case GET_DISPLAY_CONFIGS: { |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 1450 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 1451 | Vector<DisplayConfig> configs; |
| 1452 | const sp<IBinder> display = data.readStrongBinder(); |
| 1453 | const status_t result = getDisplayConfigs(display, &configs); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 1454 | reply->writeInt32(result); |
| 1455 | if (result == NO_ERROR) { |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1456 | reply->writeUint32(static_cast<uint32_t>(configs.size())); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 1457 | for (size_t c = 0; c < configs.size(); ++c) { |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 1458 | memcpy(reply->writeInplace(sizeof(DisplayConfig)), &configs[c], |
| 1459 | sizeof(DisplayConfig)); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 1460 | } |
| 1461 | } |
| 1462 | return NO_ERROR; |
| 1463 | } |
Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 1464 | case GET_DISPLAY_STATS: { |
| 1465 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1466 | DisplayStatInfo stats; |
| 1467 | sp<IBinder> display = data.readStrongBinder(); |
| 1468 | status_t result = getDisplayStats(display, &stats); |
| 1469 | reply->writeInt32(result); |
| 1470 | if (result == NO_ERROR) { |
| 1471 | memcpy(reply->writeInplace(sizeof(DisplayStatInfo)), |
| 1472 | &stats, sizeof(DisplayStatInfo)); |
| 1473 | } |
| 1474 | return NO_ERROR; |
| 1475 | } |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 1476 | case GET_ACTIVE_CONFIG: { |
| 1477 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1478 | sp<IBinder> display = data.readStrongBinder(); |
| 1479 | int id = getActiveConfig(display); |
| 1480 | reply->writeInt32(id); |
| 1481 | return NO_ERROR; |
| 1482 | } |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1483 | case GET_DISPLAY_COLOR_MODES: { |
| 1484 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 1485 | Vector<ColorMode> colorModes; |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1486 | sp<IBinder> display = nullptr; |
| 1487 | status_t result = data.readStrongBinder(&display); |
| 1488 | if (result != NO_ERROR) { |
| 1489 | ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result); |
| 1490 | return result; |
| 1491 | } |
| 1492 | result = getDisplayColorModes(display, &colorModes); |
| 1493 | reply->writeInt32(result); |
| 1494 | if (result == NO_ERROR) { |
| 1495 | reply->writeUint32(static_cast<uint32_t>(colorModes.size())); |
| 1496 | for (size_t i = 0; i < colorModes.size(); ++i) { |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 1497 | reply->writeInt32(static_cast<int32_t>(colorModes[i])); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1498 | } |
| 1499 | } |
| 1500 | return NO_ERROR; |
| 1501 | } |
Daniel Solomon | 42d0456 | 2019-01-20 21:03:19 -0800 | [diff] [blame] | 1502 | case GET_DISPLAY_NATIVE_PRIMARIES: { |
| 1503 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1504 | ui::DisplayPrimaries primaries; |
| 1505 | sp<IBinder> display = nullptr; |
| 1506 | |
| 1507 | status_t result = data.readStrongBinder(&display); |
| 1508 | if (result != NO_ERROR) { |
| 1509 | ALOGE("getDisplayNativePrimaries failed to readStrongBinder: %d", result); |
| 1510 | return result; |
| 1511 | } |
| 1512 | |
| 1513 | result = getDisplayNativePrimaries(display, primaries); |
| 1514 | reply->writeInt32(result); |
| 1515 | if (result == NO_ERROR) { |
| 1516 | memcpy(reply->writeInplace(sizeof(ui::DisplayPrimaries)), &primaries, |
| 1517 | sizeof(ui::DisplayPrimaries)); |
| 1518 | } |
| 1519 | |
| 1520 | return NO_ERROR; |
| 1521 | } |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1522 | case GET_ACTIVE_COLOR_MODE: { |
| 1523 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1524 | sp<IBinder> display = nullptr; |
| 1525 | status_t result = data.readStrongBinder(&display); |
| 1526 | if (result != NO_ERROR) { |
| 1527 | ALOGE("getActiveColorMode failed to readStrongBinder: %d", result); |
| 1528 | return result; |
| 1529 | } |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 1530 | ColorMode colorMode = getActiveColorMode(display); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1531 | result = reply->writeInt32(static_cast<int32_t>(colorMode)); |
| 1532 | return result; |
| 1533 | } |
| 1534 | case SET_ACTIVE_COLOR_MODE: { |
| 1535 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1536 | sp<IBinder> display = nullptr; |
| 1537 | status_t result = data.readStrongBinder(&display); |
| 1538 | if (result != NO_ERROR) { |
| 1539 | ALOGE("getActiveColorMode failed to readStrongBinder: %d", result); |
| 1540 | return result; |
| 1541 | } |
| 1542 | int32_t colorModeInt = 0; |
| 1543 | result = data.readInt32(&colorModeInt); |
| 1544 | if (result != NO_ERROR) { |
| 1545 | ALOGE("setActiveColorMode failed to readInt32: %d", result); |
| 1546 | return result; |
| 1547 | } |
| 1548 | result = setActiveColorMode(display, |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 1549 | static_cast<ColorMode>(colorModeInt)); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1550 | result = reply->writeInt32(result); |
| 1551 | return result; |
| 1552 | } |
Galia Peycheva | 5492cb5 | 2019-10-30 14:13:16 +0100 | [diff] [blame] | 1553 | |
| 1554 | case GET_AUTO_LOW_LATENCY_MODE_SUPPORT: { |
| 1555 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1556 | sp<IBinder> display = nullptr; |
| 1557 | status_t result = data.readStrongBinder(&display); |
| 1558 | if (result != NO_ERROR) { |
| 1559 | ALOGE("getAutoLowLatencyModeSupport failed to readStrongBinder: %d", result); |
| 1560 | return result; |
| 1561 | } |
| 1562 | bool supported = false; |
| 1563 | result = getAutoLowLatencyModeSupport(display, &supported); |
| 1564 | if (result == NO_ERROR) { |
| 1565 | result = reply->writeBool(supported); |
| 1566 | } |
| 1567 | return result; |
| 1568 | } |
| 1569 | |
| 1570 | case SET_AUTO_LOW_LATENCY_MODE: { |
| 1571 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1572 | sp<IBinder> display = nullptr; |
| 1573 | status_t result = data.readStrongBinder(&display); |
| 1574 | if (result != NO_ERROR) { |
| 1575 | ALOGE("setAutoLowLatencyMode failed to readStrongBinder: %d", result); |
| 1576 | return result; |
| 1577 | } |
| 1578 | bool setAllm = false; |
| 1579 | result = data.readBool(&setAllm); |
| 1580 | if (result != NO_ERROR) { |
| 1581 | ALOGE("setAutoLowLatencyMode failed to readBool: %d", result); |
| 1582 | return result; |
| 1583 | } |
| 1584 | setAutoLowLatencyMode(display, setAllm); |
| 1585 | return result; |
| 1586 | } |
| 1587 | |
| 1588 | case GET_GAME_CONTENT_TYPE_SUPPORT: { |
| 1589 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1590 | sp<IBinder> display = nullptr; |
| 1591 | status_t result = data.readStrongBinder(&display); |
| 1592 | if (result != NO_ERROR) { |
| 1593 | ALOGE("getGameContentTypeSupport failed to readStrongBinder: %d", result); |
| 1594 | return result; |
| 1595 | } |
| 1596 | bool supported = false; |
| 1597 | result = getGameContentTypeSupport(display, &supported); |
| 1598 | if (result == NO_ERROR) { |
| 1599 | result = reply->writeBool(supported); |
| 1600 | } |
| 1601 | return result; |
| 1602 | } |
| 1603 | |
| 1604 | case SET_GAME_CONTENT_TYPE: { |
| 1605 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1606 | sp<IBinder> display = nullptr; |
| 1607 | status_t result = data.readStrongBinder(&display); |
| 1608 | if (result != NO_ERROR) { |
| 1609 | ALOGE("setGameContentType failed to readStrongBinder: %d", result); |
| 1610 | return result; |
| 1611 | } |
| 1612 | bool setGameContentTypeOn = false; |
| 1613 | result = data.readBool(&setGameContentTypeOn); |
| 1614 | if (result != NO_ERROR) { |
| 1615 | ALOGE("setGameContentType failed to readBool: %d", result); |
| 1616 | return result; |
| 1617 | } |
| 1618 | setGameContentType(display, setGameContentTypeOn); |
| 1619 | return result; |
| 1620 | } |
| 1621 | |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 1622 | case CLEAR_ANIMATION_FRAME_STATS: { |
| 1623 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1624 | status_t result = clearAnimationFrameStats(); |
| 1625 | reply->writeInt32(result); |
| 1626 | return NO_ERROR; |
| 1627 | } |
| 1628 | case GET_ANIMATION_FRAME_STATS: { |
| 1629 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1630 | FrameStats stats; |
| 1631 | status_t result = getAnimationFrameStats(&stats); |
| 1632 | reply->write(stats); |
| 1633 | reply->writeInt32(result); |
| 1634 | return NO_ERROR; |
| 1635 | } |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 1636 | case SET_POWER_MODE: { |
| 1637 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1638 | sp<IBinder> display = data.readStrongBinder(); |
| 1639 | int32_t mode = data.readInt32(); |
| 1640 | setPowerMode(display, mode); |
| 1641 | return NO_ERROR; |
| 1642 | } |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 1643 | case GET_HDR_CAPABILITIES: { |
| 1644 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1645 | sp<IBinder> display = nullptr; |
| 1646 | status_t result = data.readStrongBinder(&display); |
| 1647 | if (result != NO_ERROR) { |
| 1648 | ALOGE("getHdrCapabilities failed to readStrongBinder: %d", |
| 1649 | result); |
| 1650 | return result; |
| 1651 | } |
| 1652 | HdrCapabilities capabilities; |
| 1653 | result = getHdrCapabilities(display, &capabilities); |
| 1654 | reply->writeInt32(result); |
| 1655 | if (result == NO_ERROR) { |
Mathias Agopian | e1f5e6f | 2017-02-06 16:34:41 -0800 | [diff] [blame] | 1656 | reply->write(capabilities); |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 1657 | } |
| 1658 | return NO_ERROR; |
| 1659 | } |
Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 1660 | case ENABLE_VSYNC_INJECTIONS: { |
| 1661 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1662 | bool enable = false; |
| 1663 | status_t result = data.readBool(&enable); |
| 1664 | if (result != NO_ERROR) { |
| 1665 | ALOGE("enableVSyncInjections failed to readBool: %d", result); |
| 1666 | return result; |
| 1667 | } |
| 1668 | return enableVSyncInjections(enable); |
| 1669 | } |
| 1670 | case INJECT_VSYNC: { |
| 1671 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1672 | int64_t when = 0; |
| 1673 | status_t result = data.readInt64(&when); |
| 1674 | if (result != NO_ERROR) { |
| 1675 | ALOGE("enableVSyncInjections failed to readInt64: %d", result); |
| 1676 | return result; |
| 1677 | } |
| 1678 | return injectVSync(when); |
| 1679 | } |
Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 1680 | case GET_LAYER_DEBUG_INFO: { |
| 1681 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1682 | std::vector<LayerDebugInfo> outLayers; |
| 1683 | status_t result = getLayerDebugInfo(&outLayers); |
| 1684 | reply->writeInt32(result); |
| 1685 | if (result == NO_ERROR) |
| 1686 | { |
| 1687 | result = reply->writeParcelableVector(outLayers); |
| 1688 | } |
| 1689 | return result; |
| 1690 | } |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1691 | case GET_COMPOSITION_PREFERENCE: { |
| 1692 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 1693 | ui::Dataspace defaultDataspace; |
| 1694 | ui::PixelFormat defaultPixelFormat; |
| 1695 | ui::Dataspace wideColorGamutDataspace; |
| 1696 | ui::PixelFormat wideColorGamutPixelFormat; |
| 1697 | status_t error = |
| 1698 | getCompositionPreference(&defaultDataspace, &defaultPixelFormat, |
| 1699 | &wideColorGamutDataspace, &wideColorGamutPixelFormat); |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1700 | reply->writeInt32(error); |
| 1701 | if (error == NO_ERROR) { |
Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 1702 | reply->writeInt32(static_cast<int32_t>(defaultDataspace)); |
| 1703 | reply->writeInt32(static_cast<int32_t>(defaultPixelFormat)); |
| 1704 | reply->writeInt32(static_cast<int32_t>(wideColorGamutDataspace)); |
Peiyong Lin | aa3da6a | 2018-12-12 02:48:43 -0800 | [diff] [blame] | 1705 | reply->writeInt32(static_cast<int32_t>(wideColorGamutPixelFormat)); |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1706 | } |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 1707 | return error; |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1708 | } |
Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 1709 | case GET_COLOR_MANAGEMENT: { |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 1710 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 1711 | bool result; |
| 1712 | status_t error = getColorManagement(&result); |
| 1713 | if (error == NO_ERROR) { |
| 1714 | reply->writeBool(result); |
| 1715 | } |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 1716 | return error; |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 1717 | } |
Kevin DuBois | 9c0a176 | 2018-10-16 13:32:31 -0700 | [diff] [blame] | 1718 | case GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: { |
| 1719 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1720 | |
| 1721 | sp<IBinder> display = data.readStrongBinder(); |
| 1722 | ui::PixelFormat format; |
| 1723 | ui::Dataspace dataspace; |
| 1724 | uint8_t component = 0; |
| 1725 | auto result = |
| 1726 | getDisplayedContentSamplingAttributes(display, &format, &dataspace, &component); |
| 1727 | if (result == NO_ERROR) { |
| 1728 | reply->writeUint32(static_cast<uint32_t>(format)); |
| 1729 | reply->writeUint32(static_cast<uint32_t>(dataspace)); |
| 1730 | reply->writeUint32(static_cast<uint32_t>(component)); |
| 1731 | } |
| 1732 | return result; |
| 1733 | } |
Kevin DuBois | 74e5377 | 2018-11-19 10:52:38 -0800 | [diff] [blame] | 1734 | case SET_DISPLAY_CONTENT_SAMPLING_ENABLED: { |
| 1735 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1736 | |
| 1737 | sp<IBinder> display = nullptr; |
| 1738 | bool enable = false; |
| 1739 | int8_t componentMask = 0; |
| 1740 | uint64_t maxFrames = 0; |
| 1741 | status_t result = data.readStrongBinder(&display); |
| 1742 | if (result != NO_ERROR) { |
| 1743 | ALOGE("setDisplayContentSamplingEnabled failure in reading Display token: %d", |
| 1744 | result); |
| 1745 | return result; |
| 1746 | } |
| 1747 | |
| 1748 | result = data.readBool(&enable); |
| 1749 | if (result != NO_ERROR) { |
| 1750 | ALOGE("setDisplayContentSamplingEnabled failure in reading enable: %d", result); |
| 1751 | return result; |
| 1752 | } |
| 1753 | |
| 1754 | result = data.readByte(static_cast<int8_t*>(&componentMask)); |
| 1755 | if (result != NO_ERROR) { |
| 1756 | ALOGE("setDisplayContentSamplingEnabled failure in reading component mask: %d", |
| 1757 | result); |
| 1758 | return result; |
| 1759 | } |
| 1760 | |
| 1761 | result = data.readUint64(&maxFrames); |
| 1762 | if (result != NO_ERROR) { |
| 1763 | ALOGE("setDisplayContentSamplingEnabled failure in reading max frames: %d", result); |
| 1764 | return result; |
| 1765 | } |
| 1766 | |
| 1767 | return setDisplayContentSamplingEnabled(display, enable, |
| 1768 | static_cast<uint8_t>(componentMask), maxFrames); |
| 1769 | } |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 1770 | case GET_DISPLAYED_CONTENT_SAMPLE: { |
| 1771 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1772 | |
| 1773 | sp<IBinder> display = data.readStrongBinder(); |
| 1774 | uint64_t maxFrames = 0; |
| 1775 | uint64_t timestamp = 0; |
| 1776 | |
| 1777 | status_t result = data.readUint64(&maxFrames); |
| 1778 | if (result != NO_ERROR) { |
| 1779 | ALOGE("getDisplayedContentSample failure in reading max frames: %d", result); |
| 1780 | return result; |
| 1781 | } |
| 1782 | |
| 1783 | result = data.readUint64(×tamp); |
| 1784 | if (result != NO_ERROR) { |
| 1785 | ALOGE("getDisplayedContentSample failure in reading timestamp: %d", result); |
| 1786 | return result; |
| 1787 | } |
| 1788 | |
| 1789 | DisplayedFrameStats stats; |
| 1790 | result = getDisplayedContentSample(display, maxFrames, timestamp, &stats); |
| 1791 | if (result == NO_ERROR) { |
| 1792 | reply->writeUint64(stats.numFrames); |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 1793 | reply->writeUint64Vector(stats.component_0_sample); |
| 1794 | reply->writeUint64Vector(stats.component_1_sample); |
| 1795 | reply->writeUint64Vector(stats.component_2_sample); |
| 1796 | reply->writeUint64Vector(stats.component_3_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 1797 | } |
| 1798 | return result; |
| 1799 | } |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 1800 | case GET_PROTECTED_CONTENT_SUPPORT: { |
| 1801 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1802 | bool result; |
| 1803 | status_t error = getProtectedContentSupport(&result); |
| 1804 | if (error == NO_ERROR) { |
| 1805 | reply->writeBool(result); |
| 1806 | } |
| 1807 | return error; |
| 1808 | } |
Peiyong Lin | 4f3fddf | 2019-01-24 17:21:24 -0800 | [diff] [blame] | 1809 | case IS_WIDE_COLOR_DISPLAY: { |
| 1810 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1811 | sp<IBinder> display = nullptr; |
| 1812 | status_t error = data.readStrongBinder(&display); |
| 1813 | if (error != NO_ERROR) { |
| 1814 | return error; |
| 1815 | } |
| 1816 | bool result; |
| 1817 | error = isWideColorDisplay(display, &result); |
| 1818 | if (error == NO_ERROR) { |
| 1819 | reply->writeBool(result); |
| 1820 | } |
| 1821 | return error; |
| 1822 | } |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 1823 | case GET_PHYSICAL_DISPLAY_IDS: { |
| 1824 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame^] | 1825 | std::vector<PhysicalDisplayId> ids = getPhysicalDisplayIds(); |
| 1826 | std::vector<uint64_t> rawIds(ids.size()); |
| 1827 | std::transform(ids.begin(), ids.end(), rawIds.begin(), |
| 1828 | [](PhysicalDisplayId id) { return id.value; }); |
| 1829 | return reply->writeUint64Vector(rawIds); |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 1830 | } |
Dan Stoza | 84ab937 | 2018-12-17 15:27:57 -0800 | [diff] [blame] | 1831 | case ADD_REGION_SAMPLING_LISTENER: { |
| 1832 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1833 | Rect samplingArea; |
| 1834 | status_t result = data.read(samplingArea); |
| 1835 | if (result != NO_ERROR) { |
| 1836 | ALOGE("addRegionSamplingListener: Failed to read sampling area"); |
| 1837 | return result; |
| 1838 | } |
| 1839 | sp<IBinder> stopLayerHandle; |
| 1840 | result = data.readNullableStrongBinder(&stopLayerHandle); |
| 1841 | if (result != NO_ERROR) { |
| 1842 | ALOGE("addRegionSamplingListener: Failed to read stop layer handle"); |
| 1843 | return result; |
| 1844 | } |
| 1845 | sp<IRegionSamplingListener> listener; |
| 1846 | result = data.readNullableStrongBinder(&listener); |
| 1847 | if (result != NO_ERROR) { |
| 1848 | ALOGE("addRegionSamplingListener: Failed to read listener"); |
| 1849 | return result; |
| 1850 | } |
| 1851 | return addRegionSamplingListener(samplingArea, stopLayerHandle, listener); |
| 1852 | } |
| 1853 | case REMOVE_REGION_SAMPLING_LISTENER: { |
| 1854 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1855 | sp<IRegionSamplingListener> listener; |
| 1856 | status_t result = data.readNullableStrongBinder(&listener); |
| 1857 | if (result != NO_ERROR) { |
| 1858 | ALOGE("removeRegionSamplingListener: Failed to read listener"); |
| 1859 | return result; |
| 1860 | } |
| 1861 | return removeRegionSamplingListener(listener); |
| 1862 | } |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 1863 | case SET_DESIRED_DISPLAY_CONFIG_SPECS: { |
| 1864 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1865 | sp<IBinder> displayToken = data.readStrongBinder(); |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 1866 | int32_t defaultConfig; |
| 1867 | status_t result = data.readInt32(&defaultConfig); |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 1868 | if (result != NO_ERROR) { |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 1869 | ALOGE("setDesiredDisplayConfigSpecs: failed to read defaultConfig: %d", result); |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 1870 | return result; |
| 1871 | } |
Steven Thomas | f734df4 | 2020-04-13 21:09:28 -0700 | [diff] [blame] | 1872 | float primaryRefreshRateMin; |
| 1873 | result = data.readFloat(&primaryRefreshRateMin); |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 1874 | if (result != NO_ERROR) { |
Steven Thomas | f734df4 | 2020-04-13 21:09:28 -0700 | [diff] [blame] | 1875 | ALOGE("setDesiredDisplayConfigSpecs: failed to read primaryRefreshRateMin: %d", |
| 1876 | result); |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 1877 | return result; |
| 1878 | } |
Steven Thomas | f734df4 | 2020-04-13 21:09:28 -0700 | [diff] [blame] | 1879 | float primaryRefreshRateMax; |
| 1880 | result = data.readFloat(&primaryRefreshRateMax); |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 1881 | if (result != NO_ERROR) { |
Steven Thomas | f734df4 | 2020-04-13 21:09:28 -0700 | [diff] [blame] | 1882 | ALOGE("setDesiredDisplayConfigSpecs: failed to read primaryRefreshRateMax: %d", |
| 1883 | result); |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 1884 | return result; |
| 1885 | } |
Steven Thomas | f734df4 | 2020-04-13 21:09:28 -0700 | [diff] [blame] | 1886 | float appRequestRefreshRateMin; |
| 1887 | result = data.readFloat(&appRequestRefreshRateMin); |
| 1888 | if (result != NO_ERROR) { |
| 1889 | ALOGE("setDesiredDisplayConfigSpecs: failed to read appRequestRefreshRateMin: %d", |
| 1890 | result); |
| 1891 | return result; |
| 1892 | } |
| 1893 | float appRequestRefreshRateMax; |
| 1894 | result = data.readFloat(&appRequestRefreshRateMax); |
| 1895 | if (result != NO_ERROR) { |
| 1896 | ALOGE("setDesiredDisplayConfigSpecs: failed to read appRequestRefreshRateMax: %d", |
| 1897 | result); |
| 1898 | return result; |
| 1899 | } |
| 1900 | result = |
| 1901 | setDesiredDisplayConfigSpecs(displayToken, defaultConfig, primaryRefreshRateMin, |
| 1902 | primaryRefreshRateMax, appRequestRefreshRateMin, |
| 1903 | appRequestRefreshRateMax); |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 1904 | if (result != NO_ERROR) { |
| 1905 | ALOGE("setDesiredDisplayConfigSpecs: failed to call setDesiredDisplayConfigSpecs: " |
| 1906 | "%d", |
| 1907 | result); |
| 1908 | return result; |
| 1909 | } |
| 1910 | reply->writeInt32(result); |
| 1911 | return result; |
| 1912 | } |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1913 | case GET_DESIRED_DISPLAY_CONFIG_SPECS: { |
| 1914 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1915 | sp<IBinder> displayToken = data.readStrongBinder(); |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 1916 | int32_t defaultConfig; |
Steven Thomas | f734df4 | 2020-04-13 21:09:28 -0700 | [diff] [blame] | 1917 | float primaryRefreshRateMin; |
| 1918 | float primaryRefreshRateMax; |
| 1919 | float appRequestRefreshRateMin; |
| 1920 | float appRequestRefreshRateMax; |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1921 | |
Steven Thomas | f734df4 | 2020-04-13 21:09:28 -0700 | [diff] [blame] | 1922 | status_t result = |
| 1923 | getDesiredDisplayConfigSpecs(displayToken, &defaultConfig, |
| 1924 | &primaryRefreshRateMin, &primaryRefreshRateMax, |
| 1925 | &appRequestRefreshRateMin, |
| 1926 | &appRequestRefreshRateMax); |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1927 | if (result != NO_ERROR) { |
| 1928 | ALOGE("getDesiredDisplayConfigSpecs: failed to get getDesiredDisplayConfigSpecs: " |
| 1929 | "%d", |
| 1930 | result); |
| 1931 | return result; |
| 1932 | } |
| 1933 | |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 1934 | result = reply->writeInt32(defaultConfig); |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1935 | if (result != NO_ERROR) { |
Ana Krulec | ed3a8cc | 2019-11-14 00:55:07 +0100 | [diff] [blame] | 1936 | ALOGE("getDesiredDisplayConfigSpecs: failed to write defaultConfig: %d", result); |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1937 | return result; |
| 1938 | } |
Steven Thomas | f734df4 | 2020-04-13 21:09:28 -0700 | [diff] [blame] | 1939 | result = reply->writeFloat(primaryRefreshRateMin); |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1940 | if (result != NO_ERROR) { |
Steven Thomas | f734df4 | 2020-04-13 21:09:28 -0700 | [diff] [blame] | 1941 | ALOGE("getDesiredDisplayConfigSpecs: failed to write primaryRefreshRateMin: %d", |
| 1942 | result); |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1943 | return result; |
| 1944 | } |
Steven Thomas | f734df4 | 2020-04-13 21:09:28 -0700 | [diff] [blame] | 1945 | result = reply->writeFloat(primaryRefreshRateMax); |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1946 | if (result != NO_ERROR) { |
Steven Thomas | f734df4 | 2020-04-13 21:09:28 -0700 | [diff] [blame] | 1947 | ALOGE("getDesiredDisplayConfigSpecs: failed to write primaryRefreshRateMax: %d", |
| 1948 | result); |
| 1949 | return result; |
| 1950 | } |
| 1951 | result = reply->writeFloat(appRequestRefreshRateMin); |
| 1952 | if (result != NO_ERROR) { |
| 1953 | ALOGE("getDesiredDisplayConfigSpecs: failed to write appRequestRefreshRateMin: %d", |
| 1954 | result); |
| 1955 | return result; |
| 1956 | } |
| 1957 | result = reply->writeFloat(appRequestRefreshRateMax); |
| 1958 | if (result != NO_ERROR) { |
| 1959 | ALOGE("getDesiredDisplayConfigSpecs: failed to write appRequestRefreshRateMax: %d", |
| 1960 | result); |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1961 | return result; |
| 1962 | } |
| 1963 | reply->writeInt32(result); |
| 1964 | return result; |
| 1965 | } |
Dan Gittik | 57e63c5 | 2019-01-18 16:37:54 +0000 | [diff] [blame] | 1966 | case GET_DISPLAY_BRIGHTNESS_SUPPORT: { |
| 1967 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1968 | sp<IBinder> displayToken; |
| 1969 | status_t error = data.readNullableStrongBinder(&displayToken); |
| 1970 | if (error != NO_ERROR) { |
| 1971 | ALOGE("getDisplayBrightnessSupport: failed to read display token: %d", error); |
| 1972 | return error; |
| 1973 | } |
| 1974 | bool support = false; |
| 1975 | error = getDisplayBrightnessSupport(displayToken, &support); |
| 1976 | reply->writeBool(support); |
| 1977 | return error; |
| 1978 | } |
| 1979 | case SET_DISPLAY_BRIGHTNESS: { |
| 1980 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1981 | sp<IBinder> displayToken; |
| 1982 | status_t error = data.readNullableStrongBinder(&displayToken); |
| 1983 | if (error != NO_ERROR) { |
| 1984 | ALOGE("setDisplayBrightness: failed to read display token: %d", error); |
| 1985 | return error; |
| 1986 | } |
| 1987 | float brightness = -1.0f; |
| 1988 | error = data.readFloat(&brightness); |
| 1989 | if (error != NO_ERROR) { |
| 1990 | ALOGE("setDisplayBrightness: failed to read brightness: %d", error); |
| 1991 | return error; |
| 1992 | } |
| 1993 | return setDisplayBrightness(displayToken, brightness); |
| 1994 | } |
Lais Andrade | 3a6e47d | 2020-04-02 11:20:16 +0100 | [diff] [blame] | 1995 | case NOTIFY_POWER_BOOST: { |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 1996 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Lais Andrade | 3a6e47d | 2020-04-02 11:20:16 +0100 | [diff] [blame] | 1997 | int32_t boostId; |
| 1998 | status_t error = data.readInt32(&boostId); |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 1999 | if (error != NO_ERROR) { |
Lais Andrade | 3a6e47d | 2020-04-02 11:20:16 +0100 | [diff] [blame] | 2000 | ALOGE("notifyPowerBoost: failed to read boostId: %d", error); |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 2001 | return error; |
| 2002 | } |
Lais Andrade | 3a6e47d | 2020-04-02 11:20:16 +0100 | [diff] [blame] | 2003 | return notifyPowerBoost(boostId); |
Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 2004 | } |
Vishnu Nair | b13bb95 | 2019-11-15 10:24:08 -0800 | [diff] [blame] | 2005 | case SET_GLOBAL_SHADOW_SETTINGS: { |
| 2006 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 2007 | |
| 2008 | std::vector<float> shadowConfig; |
| 2009 | status_t error = data.readFloatVector(&shadowConfig); |
| 2010 | if (error != NO_ERROR || shadowConfig.size() != 11) { |
| 2011 | ALOGE("setGlobalShadowSettings: failed to read shadowConfig: %d", error); |
| 2012 | return error; |
| 2013 | } |
| 2014 | |
| 2015 | half4 ambientColor = {shadowConfig[0], shadowConfig[1], shadowConfig[2], |
| 2016 | shadowConfig[3]}; |
| 2017 | half4 spotColor = {shadowConfig[4], shadowConfig[5], shadowConfig[6], shadowConfig[7]}; |
| 2018 | float lightPosY = shadowConfig[8]; |
| 2019 | float lightPosZ = shadowConfig[9]; |
| 2020 | float lightRadius = shadowConfig[10]; |
| 2021 | return setGlobalShadowSettings(ambientColor, spotColor, lightPosY, lightPosZ, |
| 2022 | lightRadius); |
| 2023 | } |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 2024 | case SET_FRAME_RATE: { |
| 2025 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 2026 | sp<IBinder> binder; |
| 2027 | status_t err = data.readStrongBinder(&binder); |
| 2028 | if (err != NO_ERROR) { |
| 2029 | ALOGE("setFrameRate: failed to read strong binder: %s (%d)", strerror(-err), -err); |
| 2030 | return err; |
| 2031 | } |
| 2032 | sp<IGraphicBufferProducer> surface = interface_cast<IGraphicBufferProducer>(binder); |
| 2033 | if (!surface) { |
| 2034 | ALOGE("setFrameRate: failed to cast to IGraphicBufferProducer: %s (%d)", |
| 2035 | strerror(-err), -err); |
| 2036 | return err; |
| 2037 | } |
| 2038 | float frameRate; |
| 2039 | err = data.readFloat(&frameRate); |
| 2040 | if (err != NO_ERROR) { |
| 2041 | ALOGE("setFrameRate: failed to read float: %s (%d)", strerror(-err), -err); |
| 2042 | return err; |
| 2043 | } |
| 2044 | int8_t compatibility; |
| 2045 | err = data.readByte(&compatibility); |
| 2046 | if (err != NO_ERROR) { |
| 2047 | ALOGE("setFrameRate: failed to read byte: %s (%d)", strerror(-err), -err); |
| 2048 | return err; |
| 2049 | } |
| 2050 | status_t result = setFrameRate(surface, frameRate, compatibility); |
| 2051 | reply->writeInt32(result); |
| 2052 | return NO_ERROR; |
| 2053 | } |
Steven Thomas | d407190 | 2020-03-24 16:02:53 -0700 | [diff] [blame] | 2054 | case ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN: { |
| 2055 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 2056 | sp<IBinder> token; |
| 2057 | status_t result = acquireFrameRateFlexibilityToken(&token); |
| 2058 | reply->writeInt32(result); |
| 2059 | if (result == NO_ERROR) { |
| 2060 | reply->writeStrongBinder(token); |
| 2061 | } |
| 2062 | return NO_ERROR; |
| 2063 | } |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 2064 | default: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 2065 | return BBinder::onTransact(code, data, reply, flags); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 2066 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2067 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2068 | } |
| 2069 | |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 2070 | } // namespace android |