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