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