| 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, | 
| Robert Carr | 108b2c7 | 2019-04-02 16:32:58 -0700 | [diff] [blame] | 113 | bool& outCapturedSecureLayers, const ui::Dataspace reqDataspace, | 
| Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 114 | const ui::PixelFormat reqPixelFormat, Rect sourceCrop, | 
|  | 115 | uint32_t reqWidth, uint32_t reqHeight, bool useIdentityTransform, | 
| Robert Carr | fa8855f | 2019-02-19 10:05:00 -0800 | [diff] [blame] | 116 | ISurfaceComposer::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 |  | 
|  | 400 | virtual status_t setActiveConfig(const sp<IBinder>& display, int id) | 
|  | 401 | { | 
|  | 402 | Parcel data, reply; | 
| Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 403 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 404 | if (result != NO_ERROR) { | 
|  | 405 | ALOGE("setActiveConfig failed to writeInterfaceToken: %d", result); | 
|  | 406 | return result; | 
|  | 407 | } | 
|  | 408 | result = data.writeStrongBinder(display); | 
|  | 409 | if (result != NO_ERROR) { | 
|  | 410 | ALOGE("setActiveConfig failed to writeStrongBinder: %d", result); | 
|  | 411 | return result; | 
|  | 412 | } | 
|  | 413 | result = data.writeInt32(id); | 
|  | 414 | if (result != NO_ERROR) { | 
|  | 415 | ALOGE("setActiveConfig failed to writeInt32: %d", result); | 
|  | 416 | return result; | 
|  | 417 | } | 
|  | 418 | result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply); | 
|  | 419 | if (result != NO_ERROR) { | 
|  | 420 | ALOGE("setActiveConfig failed to transact: %d", result); | 
|  | 421 | return result; | 
|  | 422 | } | 
| Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 423 | return reply.readInt32(); | 
|  | 424 | } | 
| Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 425 |  | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 426 | virtual status_t getDisplayColorModes(const sp<IBinder>& display, | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 427 | Vector<ColorMode>* outColorModes) { | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 428 | Parcel data, reply; | 
|  | 429 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 430 | if (result != NO_ERROR) { | 
|  | 431 | ALOGE("getDisplayColorModes failed to writeInterfaceToken: %d", result); | 
|  | 432 | return result; | 
|  | 433 | } | 
|  | 434 | result = data.writeStrongBinder(display); | 
|  | 435 | if (result != NO_ERROR) { | 
|  | 436 | ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result); | 
|  | 437 | return result; | 
|  | 438 | } | 
|  | 439 | result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply); | 
|  | 440 | if (result != NO_ERROR) { | 
|  | 441 | ALOGE("getDisplayColorModes failed to transact: %d", result); | 
|  | 442 | return result; | 
|  | 443 | } | 
|  | 444 | result = static_cast<status_t>(reply.readInt32()); | 
|  | 445 | if (result == NO_ERROR) { | 
|  | 446 | size_t numModes = reply.readUint32(); | 
|  | 447 | outColorModes->clear(); | 
|  | 448 | outColorModes->resize(numModes); | 
|  | 449 | for (size_t i = 0; i < numModes; ++i) { | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 450 | outColorModes->replaceAt(static_cast<ColorMode>(reply.readInt32()), i); | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 451 | } | 
|  | 452 | } | 
|  | 453 | return result; | 
|  | 454 | } | 
|  | 455 |  | 
| Daniel Solomon | 42d0456 | 2019-01-20 21:03:19 -0800 | [diff] [blame] | 456 | virtual status_t getDisplayNativePrimaries(const sp<IBinder>& display, | 
|  | 457 | ui::DisplayPrimaries& primaries) { | 
|  | 458 | Parcel data, reply; | 
|  | 459 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 460 | if (result != NO_ERROR) { | 
|  | 461 | ALOGE("getDisplayNativePrimaries failed to writeInterfaceToken: %d", result); | 
|  | 462 | return result; | 
|  | 463 | } | 
|  | 464 | result = data.writeStrongBinder(display); | 
|  | 465 | if (result != NO_ERROR) { | 
|  | 466 | ALOGE("getDisplayNativePrimaries failed to writeStrongBinder: %d", result); | 
|  | 467 | return result; | 
|  | 468 | } | 
|  | 469 | result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_NATIVE_PRIMARIES, data, &reply); | 
|  | 470 | if (result != NO_ERROR) { | 
|  | 471 | ALOGE("getDisplayNativePrimaries failed to transact: %d", result); | 
|  | 472 | return result; | 
|  | 473 | } | 
|  | 474 | result = reply.readInt32(); | 
|  | 475 | if (result == NO_ERROR) { | 
|  | 476 | memcpy(&primaries, reply.readInplace(sizeof(ui::DisplayPrimaries)), | 
|  | 477 | sizeof(ui::DisplayPrimaries)); | 
|  | 478 | } | 
|  | 479 | return result; | 
|  | 480 | } | 
|  | 481 |  | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 482 | virtual ColorMode getActiveColorMode(const sp<IBinder>& display) { | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 483 | Parcel data, reply; | 
|  | 484 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 485 | if (result != NO_ERROR) { | 
|  | 486 | ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result); | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 487 | return static_cast<ColorMode>(result); | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 488 | } | 
|  | 489 | result = data.writeStrongBinder(display); | 
|  | 490 | if (result != NO_ERROR) { | 
|  | 491 | ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result); | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 492 | return static_cast<ColorMode>(result); | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 493 | } | 
|  | 494 | result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply); | 
|  | 495 | if (result != NO_ERROR) { | 
|  | 496 | ALOGE("getActiveColorMode failed to transact: %d", result); | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 497 | return static_cast<ColorMode>(result); | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 498 | } | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 499 | return static_cast<ColorMode>(reply.readInt32()); | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 500 | } | 
|  | 501 |  | 
|  | 502 | virtual status_t setActiveColorMode(const sp<IBinder>& display, | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 503 | ColorMode colorMode) { | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 504 | Parcel data, reply; | 
|  | 505 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 506 | if (result != NO_ERROR) { | 
|  | 507 | ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result); | 
|  | 508 | return result; | 
|  | 509 | } | 
|  | 510 | result = data.writeStrongBinder(display); | 
|  | 511 | if (result != NO_ERROR) { | 
|  | 512 | ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result); | 
|  | 513 | return result; | 
|  | 514 | } | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 515 | result = data.writeInt32(static_cast<int32_t>(colorMode)); | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 516 | if (result != NO_ERROR) { | 
|  | 517 | ALOGE("setActiveColorMode failed to writeInt32: %d", result); | 
|  | 518 | return result; | 
|  | 519 | } | 
|  | 520 | result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply); | 
|  | 521 | if (result != NO_ERROR) { | 
|  | 522 | ALOGE("setActiveColorMode failed to transact: %d", result); | 
|  | 523 | return result; | 
|  | 524 | } | 
|  | 525 | return static_cast<status_t>(reply.readInt32()); | 
|  | 526 | } | 
|  | 527 |  | 
| Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 528 | virtual status_t clearAnimationFrameStats() { | 
|  | 529 | Parcel data, reply; | 
| Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 530 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 531 | if (result != NO_ERROR) { | 
|  | 532 | ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result); | 
|  | 533 | return result; | 
|  | 534 | } | 
|  | 535 | result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply); | 
|  | 536 | if (result != NO_ERROR) { | 
|  | 537 | ALOGE("clearAnimationFrameStats failed to transact: %d", result); | 
|  | 538 | return result; | 
|  | 539 | } | 
| Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 540 | return reply.readInt32(); | 
|  | 541 | } | 
|  | 542 |  | 
|  | 543 | virtual status_t getAnimationFrameStats(FrameStats* outStats) const { | 
|  | 544 | Parcel data, reply; | 
|  | 545 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 546 | remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply); | 
|  | 547 | reply.read(*outStats); | 
|  | 548 | return reply.readInt32(); | 
|  | 549 | } | 
| Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 550 |  | 
|  | 551 | virtual status_t getHdrCapabilities(const sp<IBinder>& display, | 
|  | 552 | HdrCapabilities* outCapabilities) const { | 
|  | 553 | Parcel data, reply; | 
|  | 554 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 555 | status_t result = data.writeStrongBinder(display); | 
|  | 556 | if (result != NO_ERROR) { | 
|  | 557 | ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result); | 
|  | 558 | return result; | 
|  | 559 | } | 
|  | 560 | result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES, | 
|  | 561 | data, &reply); | 
|  | 562 | if (result != NO_ERROR) { | 
|  | 563 | ALOGE("getHdrCapabilities failed to transact: %d", result); | 
|  | 564 | return result; | 
|  | 565 | } | 
|  | 566 | result = reply.readInt32(); | 
|  | 567 | if (result == NO_ERROR) { | 
| Mathias Agopian | e1f5e6f | 2017-02-06 16:34:41 -0800 | [diff] [blame] | 568 | result = reply.read(*outCapabilities); | 
| Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 569 | } | 
|  | 570 | return result; | 
|  | 571 | } | 
| Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 572 |  | 
|  | 573 | virtual status_t enableVSyncInjections(bool enable) { | 
|  | 574 | Parcel data, reply; | 
|  | 575 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 576 | if (result != NO_ERROR) { | 
|  | 577 | ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result); | 
|  | 578 | return result; | 
|  | 579 | } | 
|  | 580 | result = data.writeBool(enable); | 
|  | 581 | if (result != NO_ERROR) { | 
|  | 582 | ALOGE("enableVSyncInjections failed to writeBool: %d", result); | 
|  | 583 | return result; | 
|  | 584 | } | 
| Steven Moreland | 366eb42 | 2019-04-01 19:22:32 -0700 | [diff] [blame] | 585 | result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS, data, &reply, | 
|  | 586 | IBinder::FLAG_ONEWAY); | 
| Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 587 | if (result != NO_ERROR) { | 
|  | 588 | ALOGE("enableVSyncInjections failed to transact: %d", result); | 
|  | 589 | return result; | 
|  | 590 | } | 
|  | 591 | return result; | 
|  | 592 | } | 
|  | 593 |  | 
|  | 594 | virtual status_t injectVSync(nsecs_t when) { | 
|  | 595 | Parcel data, reply; | 
|  | 596 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 597 | if (result != NO_ERROR) { | 
|  | 598 | ALOGE("injectVSync failed to writeInterfaceToken: %d", result); | 
|  | 599 | return result; | 
|  | 600 | } | 
|  | 601 | result = data.writeInt64(when); | 
|  | 602 | if (result != NO_ERROR) { | 
|  | 603 | ALOGE("injectVSync failed to writeInt64: %d", result); | 
|  | 604 | return result; | 
|  | 605 | } | 
| Steven Moreland | 366eb42 | 2019-04-01 19:22:32 -0700 | [diff] [blame] | 606 | result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply, | 
|  | 607 | IBinder::FLAG_ONEWAY); | 
| Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 608 | if (result != NO_ERROR) { | 
|  | 609 | ALOGE("injectVSync failed to transact: %d", result); | 
|  | 610 | return result; | 
|  | 611 | } | 
|  | 612 | return result; | 
|  | 613 | } | 
|  | 614 |  | 
| Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 615 | virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const | 
|  | 616 | { | 
|  | 617 | if (!outLayers) { | 
|  | 618 | return UNEXPECTED_NULL; | 
|  | 619 | } | 
|  | 620 |  | 
|  | 621 | Parcel data, reply; | 
|  | 622 |  | 
|  | 623 | status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 624 | if (err != NO_ERROR) { | 
|  | 625 | return err; | 
|  | 626 | } | 
|  | 627 |  | 
|  | 628 | err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply); | 
|  | 629 | if (err != NO_ERROR) { | 
|  | 630 | return err; | 
|  | 631 | } | 
|  | 632 |  | 
|  | 633 | int32_t result = 0; | 
|  | 634 | err = reply.readInt32(&result); | 
|  | 635 | if (err != NO_ERROR) { | 
|  | 636 | return err; | 
|  | 637 | } | 
|  | 638 | if (result != NO_ERROR) { | 
|  | 639 | return result; | 
|  | 640 | } | 
|  | 641 |  | 
|  | 642 | outLayers->clear(); | 
|  | 643 | return reply.readParcelableVector(outLayers); | 
|  | 644 | } | 
| Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 645 |  | 
| Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 646 | virtual status_t getCompositionPreference(ui::Dataspace* defaultDataspace, | 
|  | 647 | ui::PixelFormat* defaultPixelFormat, | 
|  | 648 | ui::Dataspace* wideColorGamutDataspace, | 
|  | 649 | ui::PixelFormat* wideColorGamutPixelFormat) const { | 
| Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 650 | Parcel data, reply; | 
|  | 651 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 652 | if (error != NO_ERROR) { | 
|  | 653 | return error; | 
|  | 654 | } | 
|  | 655 | error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply); | 
|  | 656 | if (error != NO_ERROR) { | 
|  | 657 | return error; | 
|  | 658 | } | 
|  | 659 | error = static_cast<status_t>(reply.readInt32()); | 
|  | 660 | if (error == NO_ERROR) { | 
| Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 661 | *defaultDataspace = static_cast<ui::Dataspace>(reply.readInt32()); | 
|  | 662 | *defaultPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32()); | 
|  | 663 | *wideColorGamutDataspace = static_cast<ui::Dataspace>(reply.readInt32()); | 
|  | 664 | *wideColorGamutPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32()); | 
| Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 665 | } | 
|  | 666 | return error; | 
|  | 667 | } | 
| Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 668 |  | 
| Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 669 | virtual status_t getColorManagement(bool* outGetColorManagement) const { | 
| Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 670 | Parcel data, reply; | 
|  | 671 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
| Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 672 | remote()->transact(BnSurfaceComposer::GET_COLOR_MANAGEMENT, data, &reply); | 
|  | 673 | bool result; | 
|  | 674 | status_t err = reply.readBool(&result); | 
|  | 675 | if (err == NO_ERROR) { | 
|  | 676 | *outGetColorManagement = result; | 
| Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 677 | } | 
| Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 678 | return err; | 
| Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 679 | } | 
| Kevin DuBois | 9c0a176 | 2018-10-16 13:32:31 -0700 | [diff] [blame] | 680 |  | 
|  | 681 | virtual status_t getDisplayedContentSamplingAttributes(const sp<IBinder>& display, | 
|  | 682 | ui::PixelFormat* outFormat, | 
|  | 683 | ui::Dataspace* outDataspace, | 
|  | 684 | uint8_t* outComponentMask) const { | 
|  | 685 | if (!outFormat || !outDataspace || !outComponentMask) return BAD_VALUE; | 
|  | 686 | Parcel data, reply; | 
|  | 687 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 688 | data.writeStrongBinder(display); | 
|  | 689 |  | 
|  | 690 | status_t error = | 
|  | 691 | remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES, | 
|  | 692 | data, &reply); | 
|  | 693 | if (error != NO_ERROR) { | 
|  | 694 | return error; | 
|  | 695 | } | 
|  | 696 |  | 
|  | 697 | uint32_t value = 0; | 
|  | 698 | error = reply.readUint32(&value); | 
|  | 699 | if (error != NO_ERROR) { | 
|  | 700 | return error; | 
|  | 701 | } | 
|  | 702 | *outFormat = static_cast<ui::PixelFormat>(value); | 
|  | 703 |  | 
|  | 704 | error = reply.readUint32(&value); | 
|  | 705 | if (error != NO_ERROR) { | 
|  | 706 | return error; | 
|  | 707 | } | 
|  | 708 | *outDataspace = static_cast<ui::Dataspace>(value); | 
|  | 709 |  | 
|  | 710 | error = reply.readUint32(&value); | 
|  | 711 | if (error != NO_ERROR) { | 
|  | 712 | return error; | 
|  | 713 | } | 
|  | 714 | *outComponentMask = static_cast<uint8_t>(value); | 
|  | 715 | return error; | 
|  | 716 | } | 
| Kevin DuBois | 74e5377 | 2018-11-19 10:52:38 -0800 | [diff] [blame] | 717 |  | 
|  | 718 | virtual status_t setDisplayContentSamplingEnabled(const sp<IBinder>& display, bool enable, | 
|  | 719 | uint8_t componentMask, | 
|  | 720 | uint64_t maxFrames) const { | 
|  | 721 | Parcel data, reply; | 
|  | 722 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 723 | data.writeStrongBinder(display); | 
|  | 724 | data.writeBool(enable); | 
|  | 725 | data.writeByte(static_cast<int8_t>(componentMask)); | 
|  | 726 | data.writeUint64(maxFrames); | 
|  | 727 | status_t result = | 
|  | 728 | remote()->transact(BnSurfaceComposer::SET_DISPLAY_CONTENT_SAMPLING_ENABLED, data, | 
|  | 729 | &reply); | 
|  | 730 | return result; | 
|  | 731 | } | 
| Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 732 |  | 
|  | 733 | virtual status_t getDisplayedContentSample(const sp<IBinder>& display, uint64_t maxFrames, | 
|  | 734 | uint64_t timestamp, | 
|  | 735 | DisplayedFrameStats* outStats) const { | 
|  | 736 | if (!outStats) return BAD_VALUE; | 
|  | 737 |  | 
|  | 738 | Parcel data, reply; | 
|  | 739 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 740 | data.writeStrongBinder(display); | 
|  | 741 | data.writeUint64(maxFrames); | 
|  | 742 | data.writeUint64(timestamp); | 
|  | 743 |  | 
|  | 744 | status_t result = | 
|  | 745 | remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLE, data, &reply); | 
|  | 746 |  | 
|  | 747 | if (result != NO_ERROR) { | 
|  | 748 | return result; | 
|  | 749 | } | 
|  | 750 |  | 
|  | 751 | result = reply.readUint64(&outStats->numFrames); | 
|  | 752 | if (result != NO_ERROR) { | 
|  | 753 | return result; | 
|  | 754 | } | 
|  | 755 |  | 
| Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 756 | result = reply.readUint64Vector(&outStats->component_0_sample); | 
| Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 757 | if (result != NO_ERROR) { | 
|  | 758 | return result; | 
|  | 759 | } | 
| Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 760 | result = reply.readUint64Vector(&outStats->component_1_sample); | 
| Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 761 | if (result != NO_ERROR) { | 
|  | 762 | return result; | 
|  | 763 | } | 
| Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 764 | result = reply.readUint64Vector(&outStats->component_2_sample); | 
| Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 765 | if (result != NO_ERROR) { | 
|  | 766 | return result; | 
|  | 767 | } | 
| Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 768 | result = reply.readUint64Vector(&outStats->component_3_sample); | 
| Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 769 | return result; | 
|  | 770 | } | 
| Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 771 |  | 
|  | 772 | virtual status_t getProtectedContentSupport(bool* outSupported) const { | 
|  | 773 | Parcel data, reply; | 
|  | 774 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
| Peiyong Lin | b6888fa | 2019-01-28 13:20:58 -0800 | [diff] [blame] | 775 | status_t error = | 
|  | 776 | remote()->transact(BnSurfaceComposer::GET_PROTECTED_CONTENT_SUPPORT, data, &reply); | 
|  | 777 | if (error != NO_ERROR) { | 
|  | 778 | return error; | 
| Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 779 | } | 
| Peiyong Lin | b6888fa | 2019-01-28 13:20:58 -0800 | [diff] [blame] | 780 | error = reply.readBool(outSupported); | 
|  | 781 | return error; | 
| Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 782 | } | 
| Marissa Wall | ebc2c05 | 2019-01-16 19:16:55 -0800 | [diff] [blame] | 783 |  | 
| Peiyong Lin | 4f3fddf | 2019-01-24 17:21:24 -0800 | [diff] [blame] | 784 | virtual status_t isWideColorDisplay(const sp<IBinder>& token, | 
|  | 785 | bool* outIsWideColorDisplay) const { | 
|  | 786 | Parcel data, reply; | 
|  | 787 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 788 | if (error != NO_ERROR) { | 
|  | 789 | return error; | 
|  | 790 | } | 
|  | 791 | error = data.writeStrongBinder(token); | 
|  | 792 | if (error != NO_ERROR) { | 
|  | 793 | return error; | 
|  | 794 | } | 
|  | 795 |  | 
|  | 796 | error = remote()->transact(BnSurfaceComposer::IS_WIDE_COLOR_DISPLAY, data, &reply); | 
|  | 797 | if (error != NO_ERROR) { | 
|  | 798 | return error; | 
|  | 799 | } | 
|  | 800 | error = reply.readBool(outIsWideColorDisplay); | 
|  | 801 | return error; | 
|  | 802 | } | 
| Dan Stoza | 84ab937 | 2018-12-17 15:27:57 -0800 | [diff] [blame] | 803 |  | 
|  | 804 | virtual status_t addRegionSamplingListener(const Rect& samplingArea, | 
|  | 805 | const sp<IBinder>& stopLayerHandle, | 
|  | 806 | const sp<IRegionSamplingListener>& listener) { | 
|  | 807 | Parcel data, reply; | 
|  | 808 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 809 | if (error != NO_ERROR) { | 
|  | 810 | ALOGE("addRegionSamplingListener: Failed to write interface token"); | 
|  | 811 | return error; | 
|  | 812 | } | 
|  | 813 | error = data.write(samplingArea); | 
|  | 814 | if (error != NO_ERROR) { | 
|  | 815 | ALOGE("addRegionSamplingListener: Failed to write sampling area"); | 
|  | 816 | return error; | 
|  | 817 | } | 
|  | 818 | error = data.writeStrongBinder(stopLayerHandle); | 
|  | 819 | if (error != NO_ERROR) { | 
|  | 820 | ALOGE("addRegionSamplingListener: Failed to write stop layer handle"); | 
|  | 821 | return error; | 
|  | 822 | } | 
|  | 823 | error = data.writeStrongBinder(IInterface::asBinder(listener)); | 
|  | 824 | if (error != NO_ERROR) { | 
|  | 825 | ALOGE("addRegionSamplingListener: Failed to write listener"); | 
|  | 826 | return error; | 
|  | 827 | } | 
|  | 828 | error = remote()->transact(BnSurfaceComposer::ADD_REGION_SAMPLING_LISTENER, data, &reply); | 
|  | 829 | if (error != NO_ERROR) { | 
|  | 830 | ALOGE("addRegionSamplingListener: Failed to transact"); | 
|  | 831 | } | 
|  | 832 | return error; | 
|  | 833 | } | 
|  | 834 |  | 
|  | 835 | virtual status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) { | 
|  | 836 | Parcel data, reply; | 
|  | 837 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 838 | if (error != NO_ERROR) { | 
| tangrobin | af45f01 | 2019-02-26 18:10:10 +0800 | [diff] [blame] | 839 | ALOGE("removeRegionSamplingListener: Failed to write interface token"); | 
| Dan Stoza | 84ab937 | 2018-12-17 15:27:57 -0800 | [diff] [blame] | 840 | return error; | 
|  | 841 | } | 
|  | 842 | error = data.writeStrongBinder(IInterface::asBinder(listener)); | 
|  | 843 | if (error != NO_ERROR) { | 
| tangrobin | af45f01 | 2019-02-26 18:10:10 +0800 | [diff] [blame] | 844 | ALOGE("removeRegionSamplingListener: Failed to write listener"); | 
| Dan Stoza | 84ab937 | 2018-12-17 15:27:57 -0800 | [diff] [blame] | 845 | return error; | 
|  | 846 | } | 
|  | 847 | error = remote()->transact(BnSurfaceComposer::REMOVE_REGION_SAMPLING_LISTENER, data, | 
|  | 848 | &reply); | 
|  | 849 | if (error != NO_ERROR) { | 
| tangrobin | af45f01 | 2019-02-26 18:10:10 +0800 | [diff] [blame] | 850 | ALOGE("removeRegionSamplingListener: Failed to transact"); | 
| Dan Stoza | 84ab937 | 2018-12-17 15:27:57 -0800 | [diff] [blame] | 851 | } | 
|  | 852 | return error; | 
|  | 853 | } | 
| Ady Abraham | 838de06 | 2019-02-04 10:24:03 -0800 | [diff] [blame] | 854 |  | 
|  | 855 | virtual status_t setAllowedDisplayConfigs(const sp<IBinder>& displayToken, | 
|  | 856 | const std::vector<int32_t>& allowedConfigs) { | 
|  | 857 | Parcel data, reply; | 
|  | 858 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 859 | if (result != NO_ERROR) { | 
|  | 860 | ALOGE("setAllowedDisplayConfigs failed to writeInterfaceToken: %d", result); | 
|  | 861 | return result; | 
|  | 862 | } | 
|  | 863 | result = data.writeStrongBinder(displayToken); | 
|  | 864 | if (result != NO_ERROR) { | 
|  | 865 | ALOGE("setAllowedDisplayConfigs failed to writeStrongBinder: %d", result); | 
|  | 866 | return result; | 
|  | 867 | } | 
|  | 868 | result = data.writeInt32Vector(allowedConfigs); | 
|  | 869 | if (result != NO_ERROR) { | 
|  | 870 | ALOGE("setAllowedDisplayConfigs failed to writeInt32Vector: %d", result); | 
|  | 871 | return result; | 
|  | 872 | } | 
|  | 873 | result = remote()->transact(BnSurfaceComposer::SET_ALLOWED_DISPLAY_CONFIGS, data, &reply); | 
|  | 874 | if (result != NO_ERROR) { | 
|  | 875 | ALOGE("setAllowedDisplayConfigs failed to transact: %d", result); | 
|  | 876 | return result; | 
|  | 877 | } | 
|  | 878 | return reply.readInt32(); | 
|  | 879 | } | 
| Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 880 |  | 
| Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 881 | virtual status_t getAllowedDisplayConfigs(const sp<IBinder>& displayToken, | 
|  | 882 | std::vector<int32_t>* outAllowedConfigs) { | 
|  | 883 | if (!outAllowedConfigs) return BAD_VALUE; | 
|  | 884 | Parcel data, reply; | 
|  | 885 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 886 | if (result != NO_ERROR) { | 
|  | 887 | ALOGE("getAllowedDisplayConfigs failed to writeInterfaceToken: %d", result); | 
|  | 888 | return result; | 
|  | 889 | } | 
|  | 890 | result = data.writeStrongBinder(displayToken); | 
|  | 891 | if (result != NO_ERROR) { | 
|  | 892 | ALOGE("getAllowedDisplayConfigs failed to writeStrongBinder: %d", result); | 
|  | 893 | return result; | 
|  | 894 | } | 
|  | 895 | result = remote()->transact(BnSurfaceComposer::GET_ALLOWED_DISPLAY_CONFIGS, data, &reply); | 
|  | 896 | if (result != NO_ERROR) { | 
|  | 897 | ALOGE("getAllowedDisplayConfigs failed to transact: %d", result); | 
|  | 898 | return result; | 
|  | 899 | } | 
|  | 900 | result = reply.readInt32Vector(outAllowedConfigs); | 
|  | 901 | if (result != NO_ERROR) { | 
|  | 902 | ALOGE("getAllowedDisplayConfigs failed to readInt32Vector: %d", result); | 
|  | 903 | return result; | 
|  | 904 | } | 
|  | 905 | return reply.readInt32(); | 
|  | 906 | } | 
|  | 907 |  | 
| Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 908 | virtual status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken, | 
|  | 909 | int32_t defaultModeId, float minRefreshRate, | 
|  | 910 | float maxRefreshRate) { | 
|  | 911 | Parcel data, reply; | 
|  | 912 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 913 | if (result != NO_ERROR) { | 
|  | 914 | ALOGE("setDesiredDisplayConfigSpecs: failed to writeInterfaceToken: %d", result); | 
|  | 915 | return result; | 
|  | 916 | } | 
|  | 917 | result = data.writeStrongBinder(displayToken); | 
|  | 918 | if (result != NO_ERROR) { | 
|  | 919 | ALOGE("setDesiredDisplayConfigSpecs: failed to write display token: %d", result); | 
|  | 920 | return result; | 
|  | 921 | } | 
|  | 922 | result = data.writeInt32(defaultModeId); | 
|  | 923 | if (result != NO_ERROR) { | 
|  | 924 | ALOGE("setDesiredDisplayConfigSpecs failed to write defaultModeId: %d", result); | 
|  | 925 | return result; | 
|  | 926 | } | 
|  | 927 | result = data.writeFloat(minRefreshRate); | 
|  | 928 | if (result != NO_ERROR) { | 
|  | 929 | ALOGE("setDesiredDisplayConfigSpecs failed to write minRefreshRate: %d", result); | 
|  | 930 | return result; | 
|  | 931 | } | 
|  | 932 | result = data.writeFloat(maxRefreshRate); | 
|  | 933 | if (result != NO_ERROR) { | 
|  | 934 | ALOGE("setDesiredDisplayConfigSpecs failed to write maxRefreshRate: %d", result); | 
|  | 935 | return result; | 
|  | 936 | } | 
|  | 937 |  | 
|  | 938 | result = remote()->transact(BnSurfaceComposer::SET_DESIRED_DISPLAY_CONFIG_SPECS, data, | 
|  | 939 | &reply); | 
|  | 940 | if (result != NO_ERROR) { | 
|  | 941 | ALOGE("setDesiredDisplayConfigSpecs failed to transact: %d", result); | 
|  | 942 | return result; | 
|  | 943 | } | 
|  | 944 | return reply.readInt32(); | 
|  | 945 | } | 
|  | 946 |  | 
| Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 947 | virtual status_t getDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken, | 
|  | 948 | int32_t* outDefaultModeId, | 
|  | 949 | float* outMinRefreshRate, | 
|  | 950 | float* outMaxRefreshRate) { | 
|  | 951 | if (!outDefaultModeId || !outMinRefreshRate || !outMaxRefreshRate) return BAD_VALUE; | 
| Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 952 | Parcel data, reply; | 
|  | 953 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 954 | if (result != NO_ERROR) { | 
| Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 955 | ALOGE("getDesiredDisplayConfigSpecs failed to writeInterfaceToken: %d", result); | 
| Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 956 | return result; | 
|  | 957 | } | 
|  | 958 | result = data.writeStrongBinder(displayToken); | 
|  | 959 | if (result != NO_ERROR) { | 
| Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 960 | ALOGE("getDesiredDisplayConfigSpecs failed to writeStrongBinder: %d", result); | 
| Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 961 | return result; | 
|  | 962 | } | 
| Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 963 | result = remote()->transact(BnSurfaceComposer::GET_DESIRED_DISPLAY_CONFIG_SPECS, data, | 
|  | 964 | &reply); | 
| Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 965 | if (result != NO_ERROR) { | 
| Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 966 | ALOGE("getDesiredDisplayConfigSpecs failed to transact: %d", result); | 
| Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 967 | return result; | 
|  | 968 | } | 
| Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 969 | result = reply.readInt32(outDefaultModeId); | 
| Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 970 | if (result != NO_ERROR) { | 
| Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 971 | ALOGE("getDesiredDisplayConfigSpecs failed to read defaultModeId: %d", result); | 
|  | 972 | return result; | 
|  | 973 | } | 
|  | 974 | result = reply.readFloat(outMinRefreshRate); | 
|  | 975 | if (result != NO_ERROR) { | 
|  | 976 | ALOGE("getDesiredDisplayConfigSpecs failed to read minRefreshRate: %d", result); | 
|  | 977 | return result; | 
|  | 978 | } | 
|  | 979 | result = reply.readFloat(outMaxRefreshRate); | 
|  | 980 | if (result != NO_ERROR) { | 
|  | 981 | ALOGE("getDesiredDisplayConfigSpecs failed to read maxRefreshRate: %d", result); | 
| Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 982 | return result; | 
|  | 983 | } | 
|  | 984 | return reply.readInt32(); | 
|  | 985 | } | 
| Dan Gittik | 57e63c5 | 2019-01-18 16:37:54 +0000 | [diff] [blame] | 986 |  | 
|  | 987 | virtual status_t getDisplayBrightnessSupport(const sp<IBinder>& displayToken, | 
|  | 988 | bool* outSupport) const { | 
|  | 989 | Parcel data, reply; | 
|  | 990 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 991 | if (error != NO_ERROR) { | 
|  | 992 | ALOGE("getDisplayBrightnessSupport: failed to write interface token: %d", error); | 
|  | 993 | return error; | 
|  | 994 | } | 
|  | 995 | error = data.writeStrongBinder(displayToken); | 
|  | 996 | if (error != NO_ERROR) { | 
|  | 997 | ALOGE("getDisplayBrightnessSupport: failed to write display token: %d", error); | 
|  | 998 | return error; | 
|  | 999 | } | 
|  | 1000 | error = remote()->transact(BnSurfaceComposer::GET_DISPLAY_BRIGHTNESS_SUPPORT, data, &reply); | 
|  | 1001 | if (error != NO_ERROR) { | 
|  | 1002 | ALOGE("getDisplayBrightnessSupport: failed to transact: %d", error); | 
|  | 1003 | return error; | 
|  | 1004 | } | 
|  | 1005 | bool support; | 
|  | 1006 | error = reply.readBool(&support); | 
|  | 1007 | if (error != NO_ERROR) { | 
|  | 1008 | ALOGE("getDisplayBrightnessSupport: failed to read support: %d", error); | 
|  | 1009 | return error; | 
|  | 1010 | } | 
|  | 1011 | *outSupport = support; | 
|  | 1012 | return NO_ERROR; | 
|  | 1013 | } | 
|  | 1014 |  | 
|  | 1015 | virtual status_t setDisplayBrightness(const sp<IBinder>& displayToken, float brightness) const { | 
|  | 1016 | Parcel data, reply; | 
|  | 1017 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 1018 | if (error != NO_ERROR) { | 
|  | 1019 | ALOGE("setDisplayBrightness: failed to write interface token: %d", error); | 
|  | 1020 | return error; | 
|  | 1021 | } | 
|  | 1022 | error = data.writeStrongBinder(displayToken); | 
|  | 1023 | if (error != NO_ERROR) { | 
|  | 1024 | ALOGE("setDisplayBrightness: failed to write display token: %d", error); | 
|  | 1025 | return error; | 
|  | 1026 | } | 
|  | 1027 | error = data.writeFloat(brightness); | 
|  | 1028 | if (error != NO_ERROR) { | 
|  | 1029 | ALOGE("setDisplayBrightness: failed to write brightness: %d", error); | 
|  | 1030 | return error; | 
|  | 1031 | } | 
|  | 1032 | error = remote()->transact(BnSurfaceComposer::SET_DISPLAY_BRIGHTNESS, data, &reply); | 
|  | 1033 | if (error != NO_ERROR) { | 
|  | 1034 | ALOGE("setDisplayBrightness: failed to transact: %d", error); | 
|  | 1035 | return error; | 
|  | 1036 | } | 
|  | 1037 | return NO_ERROR; | 
|  | 1038 | } | 
| Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 1039 |  | 
|  | 1040 | virtual status_t notifyPowerHint(int32_t hintId) { | 
|  | 1041 | Parcel data, reply; | 
|  | 1042 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 1043 | if (error != NO_ERROR) { | 
|  | 1044 | ALOGE("notifyPowerHint: failed to write interface token: %d", error); | 
|  | 1045 | return error; | 
|  | 1046 | } | 
|  | 1047 | error = data.writeInt32(hintId); | 
|  | 1048 | if (error != NO_ERROR) { | 
|  | 1049 | ALOGE("notifyPowerHint: failed to write hintId: %d", error); | 
|  | 1050 | return error; | 
|  | 1051 | } | 
|  | 1052 | error = remote()->transact(BnSurfaceComposer::NOTIFY_POWER_HINT, data, &reply, | 
|  | 1053 | IBinder::FLAG_ONEWAY); | 
|  | 1054 | if (error != NO_ERROR) { | 
|  | 1055 | ALOGE("notifyPowerHint: failed to transact: %d", error); | 
|  | 1056 | return error; | 
|  | 1057 | } | 
|  | 1058 | return NO_ERROR; | 
|  | 1059 | } | 
| Vishnu Nair | b13bb95 | 2019-11-15 10:24:08 -0800 | [diff] [blame] | 1060 |  | 
|  | 1061 | virtual status_t setGlobalShadowSettings(const half4& ambientColor, const half4& spotColor, | 
|  | 1062 | float lightPosY, float lightPosZ, float lightRadius) { | 
|  | 1063 | Parcel data, reply; | 
|  | 1064 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 1065 | if (error != NO_ERROR) { | 
|  | 1066 | ALOGE("setGlobalShadowSettings: failed to write interface token: %d", error); | 
|  | 1067 | return error; | 
|  | 1068 | } | 
|  | 1069 |  | 
|  | 1070 | std::vector<float> shadowConfig = {ambientColor.r, ambientColor.g, ambientColor.b, | 
|  | 1071 | ambientColor.a, spotColor.r,    spotColor.g, | 
|  | 1072 | spotColor.b,    spotColor.a,    lightPosY, | 
|  | 1073 | lightPosZ,      lightRadius}; | 
|  | 1074 |  | 
|  | 1075 | error = data.writeFloatVector(shadowConfig); | 
|  | 1076 | if (error != NO_ERROR) { | 
|  | 1077 | ALOGE("setGlobalShadowSettings: failed to write shadowConfig: %d", error); | 
|  | 1078 | return error; | 
|  | 1079 | } | 
|  | 1080 |  | 
|  | 1081 | error = remote()->transact(BnSurfaceComposer::SET_GLOBAL_SHADOW_SETTINGS, data, &reply, | 
|  | 1082 | IBinder::FLAG_ONEWAY); | 
|  | 1083 | if (error != NO_ERROR) { | 
|  | 1084 | ALOGE("setGlobalShadowSettings: failed to transact: %d", error); | 
|  | 1085 | return error; | 
|  | 1086 | } | 
|  | 1087 | return NO_ERROR; | 
|  | 1088 | } | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1089 | }; | 
|  | 1090 |  | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1091 | // Out-of-line virtual method definition to trigger vtable emission in this | 
|  | 1092 | // translation unit (see clang warning -Wweak-vtables) | 
|  | 1093 | BpSurfaceComposer::~BpSurfaceComposer() {} | 
|  | 1094 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1095 | IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer"); | 
|  | 1096 |  | 
|  | 1097 | // ---------------------------------------------------------------------- | 
|  | 1098 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1099 | status_t BnSurfaceComposer::onTransact( | 
|  | 1100 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) | 
|  | 1101 | { | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1102 | switch(code) { | 
|  | 1103 | case CREATE_CONNECTION: { | 
| Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 1104 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
| Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 1105 | sp<IBinder> b = IInterface::asBinder(createConnection()); | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1106 | reply->writeStrongBinder(b); | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1107 | return NO_ERROR; | 
|  | 1108 | } | 
| Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 1109 | case SET_TRANSACTION_STATE: { | 
| Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 1110 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1111 |  | 
|  | 1112 | size_t count = data.readUint32(); | 
| Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 1113 | if (count > data.dataSize()) { | 
|  | 1114 | return BAD_VALUE; | 
|  | 1115 | } | 
| Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 1116 | Vector<ComposerState> state; | 
|  | 1117 | state.setCapacity(count); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1118 | for (size_t i = 0; i < count; i++) { | 
| Marissa Wall | c837b5e | 2018-10-12 10:04:44 -0700 | [diff] [blame] | 1119 | ComposerState s; | 
| Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 1120 | if (s.read(data) == BAD_VALUE) { | 
|  | 1121 | return BAD_VALUE; | 
|  | 1122 | } | 
| Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 1123 | state.add(s); | 
|  | 1124 | } | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1125 |  | 
|  | 1126 | count = data.readUint32(); | 
| Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 1127 | if (count > data.dataSize()) { | 
|  | 1128 | return BAD_VALUE; | 
|  | 1129 | } | 
| Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 1130 | DisplayState d; | 
|  | 1131 | Vector<DisplayState> displays; | 
|  | 1132 | displays.setCapacity(count); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1133 | for (size_t i = 0; i < count; i++) { | 
| Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 1134 | if (d.read(data) == BAD_VALUE) { | 
|  | 1135 | return BAD_VALUE; | 
|  | 1136 | } | 
| Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 1137 | displays.add(d); | 
|  | 1138 | } | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1139 |  | 
|  | 1140 | uint32_t stateFlags = data.readUint32(); | 
| Marissa Wall | 713b63f | 2018-10-17 15:42:43 -0700 | [diff] [blame] | 1141 | sp<IBinder> applyToken = data.readStrongBinder(); | 
| chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 1142 | InputWindowCommands inputWindowCommands; | 
|  | 1143 | inputWindowCommands.read(data); | 
| Marissa Wall | 17b4e45 | 2018-12-26 16:32:34 -0800 | [diff] [blame] | 1144 |  | 
|  | 1145 | int64_t desiredPresentTime = data.readInt64(); | 
| Marissa Wall | 78b7220 | 2019-03-15 14:58:34 -0700 | [diff] [blame] | 1146 |  | 
| Marissa Wall | 947d34e | 2019-03-29 14:03:53 -0700 | [diff] [blame] | 1147 | client_cache_t uncachedBuffer; | 
| Steven Moreland | 9d4ce9b | 2019-07-17 15:23:38 -0700 | [diff] [blame] | 1148 | uncachedBuffer.token = data.readStrongBinder(); | 
| Marissa Wall | 947d34e | 2019-03-29 14:03:53 -0700 | [diff] [blame] | 1149 | uncachedBuffer.id = data.readUint64(); | 
| Marissa Wall | 78b7220 | 2019-03-15 14:58:34 -0700 | [diff] [blame] | 1150 |  | 
| Valerie Hau | 9dab973 | 2019-08-20 09:29:25 -0700 | [diff] [blame] | 1151 | bool hasListenerCallbacks = data.readBool(); | 
|  | 1152 |  | 
| Marissa Wall | 3dad52d | 2019-03-22 14:03:19 -0700 | [diff] [blame] | 1153 | std::vector<ListenerCallbacks> listenerCallbacks; | 
|  | 1154 | int32_t listenersSize = data.readInt32(); | 
|  | 1155 | for (int32_t i = 0; i < listenersSize; i++) { | 
| Valerie Hau | 5de3ad2 | 2019-08-20 07:47:43 -0700 | [diff] [blame] | 1156 | auto listener = data.readStrongBinder(); | 
| Marissa Wall | 3dad52d | 2019-03-22 14:03:19 -0700 | [diff] [blame] | 1157 | std::vector<CallbackId> callbackIds; | 
|  | 1158 | data.readInt64Vector(&callbackIds); | 
|  | 1159 | listenerCallbacks.emplace_back(listener, callbackIds); | 
|  | 1160 | } | 
| Marissa Wall | 17b4e45 | 2018-12-26 16:32:34 -0800 | [diff] [blame] | 1161 | setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands, | 
| Valerie Hau | 9dab973 | 2019-08-20 09:29:25 -0700 | [diff] [blame] | 1162 | desiredPresentTime, uncachedBuffer, hasListenerCallbacks, | 
|  | 1163 | listenerCallbacks); | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1164 | return NO_ERROR; | 
|  | 1165 | } | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1166 | case BOOT_FINISHED: { | 
| Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 1167 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1168 | bootFinished(); | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1169 | return NO_ERROR; | 
|  | 1170 | } | 
| Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 1171 | case CAPTURE_SCREEN: { | 
|  | 1172 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1173 | sp<IBinder> display = data.readStrongBinder(); | 
| Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 1174 | ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32()); | 
|  | 1175 | ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32()); | 
| Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 1176 | sp<GraphicBuffer> outBuffer; | 
| Pablo Ceballos | 60d6922 | 2015-08-07 14:47:20 -0700 | [diff] [blame] | 1177 | Rect sourceCrop(Rect::EMPTY_RECT); | 
| Dan Stoza | c187900 | 2014-05-22 15:59:05 -0700 | [diff] [blame] | 1178 | data.read(sourceCrop); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1179 | uint32_t reqWidth = data.readUint32(); | 
|  | 1180 | uint32_t reqHeight = data.readUint32(); | 
| Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 1181 | bool useIdentityTransform = static_cast<bool>(data.readInt32()); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1182 | int32_t rotation = data.readInt32(); | 
| Robert Carr | fa8855f | 2019-02-19 10:05:00 -0800 | [diff] [blame] | 1183 | bool captureSecureLayers = static_cast<bool>(data.readInt32()); | 
| Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 1184 |  | 
| Robert Carr | 108b2c7 | 2019-04-02 16:32:58 -0700 | [diff] [blame] | 1185 | bool capturedSecureLayers = false; | 
|  | 1186 | status_t res = captureScreen(display, &outBuffer, capturedSecureLayers, reqDataspace, | 
|  | 1187 | reqPixelFormat, sourceCrop, reqWidth, reqHeight, | 
|  | 1188 | useIdentityTransform, | 
|  | 1189 | static_cast<ISurfaceComposer::Rotation>(rotation), | 
|  | 1190 | captureSecureLayers); | 
|  | 1191 |  | 
| Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 1192 | reply->writeInt32(res); | 
| Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 1193 | if (res == NO_ERROR) { | 
|  | 1194 | reply->write(*outBuffer); | 
| Robert Carr | 108b2c7 | 2019-04-02 16:32:58 -0700 | [diff] [blame] | 1195 | reply->writeBool(capturedSecureLayers); | 
| Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 1196 | } | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1197 | return NO_ERROR; | 
|  | 1198 | } | 
| chaviw | 93df2ea | 2019-04-30 16:45:12 -0700 | [diff] [blame] | 1199 | case CAPTURE_SCREEN_BY_ID: { | 
|  | 1200 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1201 | uint64_t displayOrLayerStack = data.readUint64(); | 
|  | 1202 | ui::Dataspace outDataspace = ui::Dataspace::V0_SRGB; | 
|  | 1203 | sp<GraphicBuffer> outBuffer; | 
|  | 1204 | status_t res = captureScreen(displayOrLayerStack, &outDataspace, &outBuffer); | 
|  | 1205 | reply->writeInt32(res); | 
|  | 1206 | if (res == NO_ERROR) { | 
|  | 1207 | reply->writeInt32(static_cast<int32_t>(outDataspace)); | 
|  | 1208 | reply->write(*outBuffer); | 
|  | 1209 | } | 
|  | 1210 | return NO_ERROR; | 
|  | 1211 | } | 
| chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 1212 | case CAPTURE_LAYERS: { | 
|  | 1213 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1214 | sp<IBinder> layerHandleBinder = data.readStrongBinder(); | 
| Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 1215 | ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32()); | 
|  | 1216 | ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32()); | 
| Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 1217 | sp<GraphicBuffer> outBuffer; | 
| chaviw | 7206d49 | 2017-11-10 16:16:12 -0800 | [diff] [blame] | 1218 | Rect sourceCrop(Rect::EMPTY_RECT); | 
|  | 1219 | data.read(sourceCrop); | 
| Robert Carr | 866455f | 2019-04-02 16:28:26 -0700 | [diff] [blame] | 1220 |  | 
|  | 1221 | std::unordered_set<sp<IBinder>, SpHash<IBinder>> excludeHandles; | 
|  | 1222 | int numExcludeHandles = data.readInt32(); | 
|  | 1223 | excludeHandles.reserve(numExcludeHandles); | 
|  | 1224 | for (int i = 0; i < numExcludeHandles; i++) { | 
|  | 1225 | excludeHandles.emplace(data.readStrongBinder()); | 
|  | 1226 | } | 
|  | 1227 |  | 
| chaviw | 7206d49 | 2017-11-10 16:16:12 -0800 | [diff] [blame] | 1228 | float frameScale = data.readFloat(); | 
| Robert Carr | 578038f | 2018-03-09 12:25:24 -0800 | [diff] [blame] | 1229 | bool childrenOnly = data.readBool(); | 
| chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 1230 |  | 
| Robert Carr | 866455f | 2019-04-02 16:28:26 -0700 | [diff] [blame] | 1231 | status_t res = | 
|  | 1232 | captureLayers(layerHandleBinder, &outBuffer, reqDataspace, reqPixelFormat, | 
|  | 1233 | sourceCrop, excludeHandles, frameScale, childrenOnly); | 
| chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 1234 | reply->writeInt32(res); | 
| Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 1235 | if (res == NO_ERROR) { | 
|  | 1236 | reply->write(*outBuffer); | 
|  | 1237 | } | 
| chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 1238 | return NO_ERROR; | 
|  | 1239 | } | 
| Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 1240 | case AUTHENTICATE_SURFACE: { | 
|  | 1241 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 1242 | sp<IGraphicBufferProducer> bufferProducer = | 
|  | 1243 | interface_cast<IGraphicBufferProducer>(data.readStrongBinder()); | 
|  | 1244 | int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0; | 
| Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 1245 | reply->writeInt32(result); | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1246 | return NO_ERROR; | 
|  | 1247 | } | 
| Brian Anderson | 6b37671 | 2017-04-04 10:51:39 -0700 | [diff] [blame] | 1248 | case GET_SUPPORTED_FRAME_TIMESTAMPS: { | 
|  | 1249 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1250 | std::vector<FrameEvent> supportedTimestamps; | 
|  | 1251 | status_t result = getSupportedFrameTimestamps(&supportedTimestamps); | 
|  | 1252 | status_t err = reply->writeInt32(result); | 
|  | 1253 | if (err != NO_ERROR) { | 
|  | 1254 | return err; | 
|  | 1255 | } | 
|  | 1256 | if (result != NO_ERROR) { | 
|  | 1257 | return result; | 
|  | 1258 | } | 
|  | 1259 |  | 
|  | 1260 | std::vector<int32_t> supported; | 
|  | 1261 | supported.reserve(supportedTimestamps.size()); | 
|  | 1262 | for (FrameEvent s : supportedTimestamps) { | 
|  | 1263 | supported.push_back(static_cast<int32_t>(s)); | 
|  | 1264 | } | 
|  | 1265 | return reply->writeInt32Vector(supported); | 
|  | 1266 | } | 
| Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 1267 | case CREATE_DISPLAY_EVENT_CONNECTION: { | 
|  | 1268 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
| Ady Abraham | 0f4a1b1 | 2019-06-04 16:04:04 -0700 | [diff] [blame] | 1269 | auto vsyncSource = static_cast<ISurfaceComposer::VsyncSource>(data.readInt32()); | 
|  | 1270 | auto configChanged = static_cast<ISurfaceComposer::ConfigChanged>(data.readInt32()); | 
|  | 1271 |  | 
|  | 1272 | sp<IDisplayEventConnection> connection( | 
|  | 1273 | createDisplayEventConnection(vsyncSource, configChanged)); | 
| Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 1274 | reply->writeStrongBinder(IInterface::asBinder(connection)); | 
| Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 1275 | return NO_ERROR; | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1276 | } | 
| Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 1277 | case CREATE_DISPLAY: { | 
|  | 1278 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
| Andy McFadden | 8dfa92f | 2012-09-17 18:27:17 -0700 | [diff] [blame] | 1279 | String8 displayName = data.readString8(); | 
| Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 1280 | bool secure = bool(data.readInt32()); | 
|  | 1281 | sp<IBinder> display(createDisplay(displayName, secure)); | 
| Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 1282 | reply->writeStrongBinder(display); | 
|  | 1283 | return NO_ERROR; | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1284 | } | 
|  | 1285 | case DESTROY_DISPLAY: { | 
|  | 1286 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1287 | sp<IBinder> display = data.readStrongBinder(); | 
|  | 1288 | destroyDisplay(display); | 
|  | 1289 | return NO_ERROR; | 
|  | 1290 | } | 
| Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 1291 | case GET_PHYSICAL_DISPLAY_TOKEN: { | 
| Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 1292 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
| Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 1293 | PhysicalDisplayId displayId = data.readUint64(); | 
|  | 1294 | sp<IBinder> display = getPhysicalDisplayToken(displayId); | 
| Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 1295 | reply->writeStrongBinder(display); | 
|  | 1296 | return NO_ERROR; | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1297 | } | 
| Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 1298 | case GET_DISPLAY_CONFIGS: { | 
| Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 1299 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
| Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 1300 | Vector<DisplayInfo> configs; | 
| Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 1301 | sp<IBinder> display = data.readStrongBinder(); | 
| Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 1302 | status_t result = getDisplayConfigs(display, &configs); | 
|  | 1303 | reply->writeInt32(result); | 
|  | 1304 | if (result == NO_ERROR) { | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1305 | reply->writeUint32(static_cast<uint32_t>(configs.size())); | 
| Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 1306 | for (size_t c = 0; c < configs.size(); ++c) { | 
|  | 1307 | memcpy(reply->writeInplace(sizeof(DisplayInfo)), | 
|  | 1308 | &configs[c], sizeof(DisplayInfo)); | 
|  | 1309 | } | 
|  | 1310 | } | 
|  | 1311 | return NO_ERROR; | 
|  | 1312 | } | 
| Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 1313 | case GET_DISPLAY_STATS: { | 
|  | 1314 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1315 | DisplayStatInfo stats; | 
|  | 1316 | sp<IBinder> display = data.readStrongBinder(); | 
|  | 1317 | status_t result = getDisplayStats(display, &stats); | 
|  | 1318 | reply->writeInt32(result); | 
|  | 1319 | if (result == NO_ERROR) { | 
|  | 1320 | memcpy(reply->writeInplace(sizeof(DisplayStatInfo)), | 
|  | 1321 | &stats, sizeof(DisplayStatInfo)); | 
|  | 1322 | } | 
|  | 1323 | return NO_ERROR; | 
|  | 1324 | } | 
| Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 1325 | case GET_ACTIVE_CONFIG: { | 
|  | 1326 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1327 | sp<IBinder> display = data.readStrongBinder(); | 
|  | 1328 | int id = getActiveConfig(display); | 
|  | 1329 | reply->writeInt32(id); | 
|  | 1330 | return NO_ERROR; | 
|  | 1331 | } | 
|  | 1332 | case SET_ACTIVE_CONFIG: { | 
|  | 1333 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1334 | sp<IBinder> display = data.readStrongBinder(); | 
|  | 1335 | int id = data.readInt32(); | 
|  | 1336 | status_t result = setActiveConfig(display, id); | 
| Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 1337 | reply->writeInt32(result); | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1338 | return NO_ERROR; | 
|  | 1339 | } | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1340 | case GET_DISPLAY_COLOR_MODES: { | 
|  | 1341 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 1342 | Vector<ColorMode> colorModes; | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1343 | sp<IBinder> display = nullptr; | 
|  | 1344 | status_t result = data.readStrongBinder(&display); | 
|  | 1345 | if (result != NO_ERROR) { | 
|  | 1346 | ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result); | 
|  | 1347 | return result; | 
|  | 1348 | } | 
|  | 1349 | result = getDisplayColorModes(display, &colorModes); | 
|  | 1350 | reply->writeInt32(result); | 
|  | 1351 | if (result == NO_ERROR) { | 
|  | 1352 | reply->writeUint32(static_cast<uint32_t>(colorModes.size())); | 
|  | 1353 | for (size_t i = 0; i < colorModes.size(); ++i) { | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 1354 | reply->writeInt32(static_cast<int32_t>(colorModes[i])); | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1355 | } | 
|  | 1356 | } | 
|  | 1357 | return NO_ERROR; | 
|  | 1358 | } | 
| Daniel Solomon | 42d0456 | 2019-01-20 21:03:19 -0800 | [diff] [blame] | 1359 | case GET_DISPLAY_NATIVE_PRIMARIES: { | 
|  | 1360 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1361 | ui::DisplayPrimaries primaries; | 
|  | 1362 | sp<IBinder> display = nullptr; | 
|  | 1363 |  | 
|  | 1364 | status_t result = data.readStrongBinder(&display); | 
|  | 1365 | if (result != NO_ERROR) { | 
|  | 1366 | ALOGE("getDisplayNativePrimaries failed to readStrongBinder: %d", result); | 
|  | 1367 | return result; | 
|  | 1368 | } | 
|  | 1369 |  | 
|  | 1370 | result = getDisplayNativePrimaries(display, primaries); | 
|  | 1371 | reply->writeInt32(result); | 
|  | 1372 | if (result == NO_ERROR) { | 
|  | 1373 | memcpy(reply->writeInplace(sizeof(ui::DisplayPrimaries)), &primaries, | 
|  | 1374 | sizeof(ui::DisplayPrimaries)); | 
|  | 1375 | } | 
|  | 1376 |  | 
|  | 1377 | return NO_ERROR; | 
|  | 1378 | } | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1379 | case GET_ACTIVE_COLOR_MODE: { | 
|  | 1380 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1381 | sp<IBinder> display = nullptr; | 
|  | 1382 | status_t result = data.readStrongBinder(&display); | 
|  | 1383 | if (result != NO_ERROR) { | 
|  | 1384 | ALOGE("getActiveColorMode failed to readStrongBinder: %d", result); | 
|  | 1385 | return result; | 
|  | 1386 | } | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 1387 | ColorMode colorMode = getActiveColorMode(display); | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1388 | result = reply->writeInt32(static_cast<int32_t>(colorMode)); | 
|  | 1389 | return result; | 
|  | 1390 | } | 
|  | 1391 | case SET_ACTIVE_COLOR_MODE: { | 
|  | 1392 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1393 | sp<IBinder> display = nullptr; | 
|  | 1394 | status_t result = data.readStrongBinder(&display); | 
|  | 1395 | if (result != NO_ERROR) { | 
|  | 1396 | ALOGE("getActiveColorMode failed to readStrongBinder: %d", result); | 
|  | 1397 | return result; | 
|  | 1398 | } | 
|  | 1399 | int32_t colorModeInt = 0; | 
|  | 1400 | result = data.readInt32(&colorModeInt); | 
|  | 1401 | if (result != NO_ERROR) { | 
|  | 1402 | ALOGE("setActiveColorMode failed to readInt32: %d", result); | 
|  | 1403 | return result; | 
|  | 1404 | } | 
|  | 1405 | result = setActiveColorMode(display, | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 1406 | static_cast<ColorMode>(colorModeInt)); | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1407 | result = reply->writeInt32(result); | 
|  | 1408 | return result; | 
|  | 1409 | } | 
| Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 1410 | case CLEAR_ANIMATION_FRAME_STATS: { | 
|  | 1411 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1412 | status_t result = clearAnimationFrameStats(); | 
|  | 1413 | reply->writeInt32(result); | 
|  | 1414 | return NO_ERROR; | 
|  | 1415 | } | 
|  | 1416 | case GET_ANIMATION_FRAME_STATS: { | 
|  | 1417 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1418 | FrameStats stats; | 
|  | 1419 | status_t result = getAnimationFrameStats(&stats); | 
|  | 1420 | reply->write(stats); | 
|  | 1421 | reply->writeInt32(result); | 
|  | 1422 | return NO_ERROR; | 
|  | 1423 | } | 
| Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 1424 | case SET_POWER_MODE: { | 
|  | 1425 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1426 | sp<IBinder> display = data.readStrongBinder(); | 
|  | 1427 | int32_t mode = data.readInt32(); | 
|  | 1428 | setPowerMode(display, mode); | 
|  | 1429 | return NO_ERROR; | 
|  | 1430 | } | 
| Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 1431 | case GET_HDR_CAPABILITIES: { | 
|  | 1432 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1433 | sp<IBinder> display = nullptr; | 
|  | 1434 | status_t result = data.readStrongBinder(&display); | 
|  | 1435 | if (result != NO_ERROR) { | 
|  | 1436 | ALOGE("getHdrCapabilities failed to readStrongBinder: %d", | 
|  | 1437 | result); | 
|  | 1438 | return result; | 
|  | 1439 | } | 
|  | 1440 | HdrCapabilities capabilities; | 
|  | 1441 | result = getHdrCapabilities(display, &capabilities); | 
|  | 1442 | reply->writeInt32(result); | 
|  | 1443 | if (result == NO_ERROR) { | 
| Mathias Agopian | e1f5e6f | 2017-02-06 16:34:41 -0800 | [diff] [blame] | 1444 | reply->write(capabilities); | 
| Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 1445 | } | 
|  | 1446 | return NO_ERROR; | 
|  | 1447 | } | 
| Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 1448 | case ENABLE_VSYNC_INJECTIONS: { | 
|  | 1449 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1450 | bool enable = false; | 
|  | 1451 | status_t result = data.readBool(&enable); | 
|  | 1452 | if (result != NO_ERROR) { | 
|  | 1453 | ALOGE("enableVSyncInjections failed to readBool: %d", result); | 
|  | 1454 | return result; | 
|  | 1455 | } | 
|  | 1456 | return enableVSyncInjections(enable); | 
|  | 1457 | } | 
|  | 1458 | case INJECT_VSYNC: { | 
|  | 1459 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1460 | int64_t when = 0; | 
|  | 1461 | status_t result = data.readInt64(&when); | 
|  | 1462 | if (result != NO_ERROR) { | 
|  | 1463 | ALOGE("enableVSyncInjections failed to readInt64: %d", result); | 
|  | 1464 | return result; | 
|  | 1465 | } | 
|  | 1466 | return injectVSync(when); | 
|  | 1467 | } | 
| Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 1468 | case GET_LAYER_DEBUG_INFO: { | 
|  | 1469 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1470 | std::vector<LayerDebugInfo> outLayers; | 
|  | 1471 | status_t result = getLayerDebugInfo(&outLayers); | 
|  | 1472 | reply->writeInt32(result); | 
|  | 1473 | if (result == NO_ERROR) | 
|  | 1474 | { | 
|  | 1475 | result = reply->writeParcelableVector(outLayers); | 
|  | 1476 | } | 
|  | 1477 | return result; | 
|  | 1478 | } | 
| Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1479 | case GET_COMPOSITION_PREFERENCE: { | 
|  | 1480 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
| Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 1481 | ui::Dataspace defaultDataspace; | 
|  | 1482 | ui::PixelFormat defaultPixelFormat; | 
|  | 1483 | ui::Dataspace wideColorGamutDataspace; | 
|  | 1484 | ui::PixelFormat wideColorGamutPixelFormat; | 
|  | 1485 | status_t error = | 
|  | 1486 | getCompositionPreference(&defaultDataspace, &defaultPixelFormat, | 
|  | 1487 | &wideColorGamutDataspace, &wideColorGamutPixelFormat); | 
| Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1488 | reply->writeInt32(error); | 
|  | 1489 | if (error == NO_ERROR) { | 
| Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 1490 | reply->writeInt32(static_cast<int32_t>(defaultDataspace)); | 
|  | 1491 | reply->writeInt32(static_cast<int32_t>(defaultPixelFormat)); | 
|  | 1492 | reply->writeInt32(static_cast<int32_t>(wideColorGamutDataspace)); | 
| Peiyong Lin | aa3da6a | 2018-12-12 02:48:43 -0800 | [diff] [blame] | 1493 | reply->writeInt32(static_cast<int32_t>(wideColorGamutPixelFormat)); | 
| Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1494 | } | 
| Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 1495 | return error; | 
| Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1496 | } | 
| Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 1497 | case GET_COLOR_MANAGEMENT: { | 
| Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 1498 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
| Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 1499 | bool result; | 
|  | 1500 | status_t error = getColorManagement(&result); | 
|  | 1501 | if (error == NO_ERROR) { | 
|  | 1502 | reply->writeBool(result); | 
|  | 1503 | } | 
| Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 1504 | return error; | 
| Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 1505 | } | 
| Kevin DuBois | 9c0a176 | 2018-10-16 13:32:31 -0700 | [diff] [blame] | 1506 | case GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: { | 
|  | 1507 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1508 |  | 
|  | 1509 | sp<IBinder> display = data.readStrongBinder(); | 
|  | 1510 | ui::PixelFormat format; | 
|  | 1511 | ui::Dataspace dataspace; | 
|  | 1512 | uint8_t component = 0; | 
|  | 1513 | auto result = | 
|  | 1514 | getDisplayedContentSamplingAttributes(display, &format, &dataspace, &component); | 
|  | 1515 | if (result == NO_ERROR) { | 
|  | 1516 | reply->writeUint32(static_cast<uint32_t>(format)); | 
|  | 1517 | reply->writeUint32(static_cast<uint32_t>(dataspace)); | 
|  | 1518 | reply->writeUint32(static_cast<uint32_t>(component)); | 
|  | 1519 | } | 
|  | 1520 | return result; | 
|  | 1521 | } | 
| Kevin DuBois | 74e5377 | 2018-11-19 10:52:38 -0800 | [diff] [blame] | 1522 | case SET_DISPLAY_CONTENT_SAMPLING_ENABLED: { | 
|  | 1523 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1524 |  | 
|  | 1525 | sp<IBinder> display = nullptr; | 
|  | 1526 | bool enable = false; | 
|  | 1527 | int8_t componentMask = 0; | 
|  | 1528 | uint64_t maxFrames = 0; | 
|  | 1529 | status_t result = data.readStrongBinder(&display); | 
|  | 1530 | if (result != NO_ERROR) { | 
|  | 1531 | ALOGE("setDisplayContentSamplingEnabled failure in reading Display token: %d", | 
|  | 1532 | result); | 
|  | 1533 | return result; | 
|  | 1534 | } | 
|  | 1535 |  | 
|  | 1536 | result = data.readBool(&enable); | 
|  | 1537 | if (result != NO_ERROR) { | 
|  | 1538 | ALOGE("setDisplayContentSamplingEnabled failure in reading enable: %d", result); | 
|  | 1539 | return result; | 
|  | 1540 | } | 
|  | 1541 |  | 
|  | 1542 | result = data.readByte(static_cast<int8_t*>(&componentMask)); | 
|  | 1543 | if (result != NO_ERROR) { | 
|  | 1544 | ALOGE("setDisplayContentSamplingEnabled failure in reading component mask: %d", | 
|  | 1545 | result); | 
|  | 1546 | return result; | 
|  | 1547 | } | 
|  | 1548 |  | 
|  | 1549 | result = data.readUint64(&maxFrames); | 
|  | 1550 | if (result != NO_ERROR) { | 
|  | 1551 | ALOGE("setDisplayContentSamplingEnabled failure in reading max frames: %d", result); | 
|  | 1552 | return result; | 
|  | 1553 | } | 
|  | 1554 |  | 
|  | 1555 | return setDisplayContentSamplingEnabled(display, enable, | 
|  | 1556 | static_cast<uint8_t>(componentMask), maxFrames); | 
|  | 1557 | } | 
| Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 1558 | case GET_DISPLAYED_CONTENT_SAMPLE: { | 
|  | 1559 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1560 |  | 
|  | 1561 | sp<IBinder> display = data.readStrongBinder(); | 
|  | 1562 | uint64_t maxFrames = 0; | 
|  | 1563 | uint64_t timestamp = 0; | 
|  | 1564 |  | 
|  | 1565 | status_t result = data.readUint64(&maxFrames); | 
|  | 1566 | if (result != NO_ERROR) { | 
|  | 1567 | ALOGE("getDisplayedContentSample failure in reading max frames: %d", result); | 
|  | 1568 | return result; | 
|  | 1569 | } | 
|  | 1570 |  | 
|  | 1571 | result = data.readUint64(×tamp); | 
|  | 1572 | if (result != NO_ERROR) { | 
|  | 1573 | ALOGE("getDisplayedContentSample failure in reading timestamp: %d", result); | 
|  | 1574 | return result; | 
|  | 1575 | } | 
|  | 1576 |  | 
|  | 1577 | DisplayedFrameStats stats; | 
|  | 1578 | result = getDisplayedContentSample(display, maxFrames, timestamp, &stats); | 
|  | 1579 | if (result == NO_ERROR) { | 
|  | 1580 | reply->writeUint64(stats.numFrames); | 
| Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 1581 | reply->writeUint64Vector(stats.component_0_sample); | 
|  | 1582 | reply->writeUint64Vector(stats.component_1_sample); | 
|  | 1583 | reply->writeUint64Vector(stats.component_2_sample); | 
|  | 1584 | reply->writeUint64Vector(stats.component_3_sample); | 
| Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 1585 | } | 
|  | 1586 | return result; | 
|  | 1587 | } | 
| Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 1588 | case GET_PROTECTED_CONTENT_SUPPORT: { | 
|  | 1589 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1590 | bool result; | 
|  | 1591 | status_t error = getProtectedContentSupport(&result); | 
|  | 1592 | if (error == NO_ERROR) { | 
|  | 1593 | reply->writeBool(result); | 
|  | 1594 | } | 
|  | 1595 | return error; | 
|  | 1596 | } | 
| Peiyong Lin | 4f3fddf | 2019-01-24 17:21:24 -0800 | [diff] [blame] | 1597 | case IS_WIDE_COLOR_DISPLAY: { | 
|  | 1598 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1599 | sp<IBinder> display = nullptr; | 
|  | 1600 | status_t error = data.readStrongBinder(&display); | 
|  | 1601 | if (error != NO_ERROR) { | 
|  | 1602 | return error; | 
|  | 1603 | } | 
|  | 1604 | bool result; | 
|  | 1605 | error = isWideColorDisplay(display, &result); | 
|  | 1606 | if (error == NO_ERROR) { | 
|  | 1607 | reply->writeBool(result); | 
|  | 1608 | } | 
|  | 1609 | return error; | 
|  | 1610 | } | 
| Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 1611 | case GET_PHYSICAL_DISPLAY_IDS: { | 
|  | 1612 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1613 | return reply->writeUint64Vector(getPhysicalDisplayIds()); | 
|  | 1614 | } | 
| Dan Stoza | 84ab937 | 2018-12-17 15:27:57 -0800 | [diff] [blame] | 1615 | case ADD_REGION_SAMPLING_LISTENER: { | 
|  | 1616 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1617 | Rect samplingArea; | 
|  | 1618 | status_t result = data.read(samplingArea); | 
|  | 1619 | if (result != NO_ERROR) { | 
|  | 1620 | ALOGE("addRegionSamplingListener: Failed to read sampling area"); | 
|  | 1621 | return result; | 
|  | 1622 | } | 
|  | 1623 | sp<IBinder> stopLayerHandle; | 
|  | 1624 | result = data.readNullableStrongBinder(&stopLayerHandle); | 
|  | 1625 | if (result != NO_ERROR) { | 
|  | 1626 | ALOGE("addRegionSamplingListener: Failed to read stop layer handle"); | 
|  | 1627 | return result; | 
|  | 1628 | } | 
|  | 1629 | sp<IRegionSamplingListener> listener; | 
|  | 1630 | result = data.readNullableStrongBinder(&listener); | 
|  | 1631 | if (result != NO_ERROR) { | 
|  | 1632 | ALOGE("addRegionSamplingListener: Failed to read listener"); | 
|  | 1633 | return result; | 
|  | 1634 | } | 
|  | 1635 | return addRegionSamplingListener(samplingArea, stopLayerHandle, listener); | 
|  | 1636 | } | 
|  | 1637 | case REMOVE_REGION_SAMPLING_LISTENER: { | 
|  | 1638 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1639 | sp<IRegionSamplingListener> listener; | 
|  | 1640 | status_t result = data.readNullableStrongBinder(&listener); | 
|  | 1641 | if (result != NO_ERROR) { | 
|  | 1642 | ALOGE("removeRegionSamplingListener: Failed to read listener"); | 
|  | 1643 | return result; | 
|  | 1644 | } | 
|  | 1645 | return removeRegionSamplingListener(listener); | 
|  | 1646 | } | 
| Ady Abraham | 838de06 | 2019-02-04 10:24:03 -0800 | [diff] [blame] | 1647 | case SET_ALLOWED_DISPLAY_CONFIGS: { | 
|  | 1648 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1649 | sp<IBinder> displayToken = data.readStrongBinder(); | 
|  | 1650 | std::vector<int32_t> allowedConfigs; | 
|  | 1651 | data.readInt32Vector(&allowedConfigs); | 
|  | 1652 | status_t result = setAllowedDisplayConfigs(displayToken, allowedConfigs); | 
|  | 1653 | reply->writeInt32(result); | 
|  | 1654 | return result; | 
|  | 1655 | } | 
| Ady Abraham | d9b3ea6 | 2019-02-26 14:08:03 -0800 | [diff] [blame] | 1656 | case GET_ALLOWED_DISPLAY_CONFIGS: { | 
|  | 1657 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1658 | sp<IBinder> displayToken = data.readStrongBinder(); | 
|  | 1659 | std::vector<int32_t> allowedConfigs; | 
|  | 1660 | status_t result = getAllowedDisplayConfigs(displayToken, &allowedConfigs); | 
|  | 1661 | reply->writeInt32Vector(allowedConfigs); | 
|  | 1662 | reply->writeInt32(result); | 
|  | 1663 | return result; | 
|  | 1664 | } | 
| Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 1665 | case SET_DESIRED_DISPLAY_CONFIG_SPECS: { | 
|  | 1666 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1667 | sp<IBinder> displayToken = data.readStrongBinder(); | 
|  | 1668 | int32_t defaultModeId; | 
|  | 1669 | status_t result = data.readInt32(&defaultModeId); | 
|  | 1670 | if (result != NO_ERROR) { | 
|  | 1671 | ALOGE("setDesiredDisplayConfigSpecs: failed to read defaultModeId: %d", result); | 
|  | 1672 | return result; | 
|  | 1673 | } | 
|  | 1674 | float minRefreshRate; | 
|  | 1675 | result = data.readFloat(&minRefreshRate); | 
|  | 1676 | if (result != NO_ERROR) { | 
|  | 1677 | ALOGE("setDesiredDisplayConfigSpecs: failed to read minRefreshRate: %d", result); | 
|  | 1678 | return result; | 
|  | 1679 | } | 
|  | 1680 | float maxRefreshRate; | 
|  | 1681 | result = data.readFloat(&maxRefreshRate); | 
|  | 1682 | if (result != NO_ERROR) { | 
|  | 1683 | ALOGE("setDesiredDisplayConfigSpecs: failed to read maxRefreshRate: %d", result); | 
|  | 1684 | return result; | 
|  | 1685 | } | 
|  | 1686 | result = setDesiredDisplayConfigSpecs(displayToken, defaultModeId, minRefreshRate, | 
|  | 1687 | maxRefreshRate); | 
|  | 1688 | if (result != NO_ERROR) { | 
|  | 1689 | ALOGE("setDesiredDisplayConfigSpecs: failed to call setDesiredDisplayConfigSpecs: " | 
|  | 1690 | "%d", | 
|  | 1691 | result); | 
|  | 1692 | return result; | 
|  | 1693 | } | 
|  | 1694 | reply->writeInt32(result); | 
|  | 1695 | return result; | 
|  | 1696 | } | 
| Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 1697 | case GET_DESIRED_DISPLAY_CONFIG_SPECS: { | 
|  | 1698 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1699 | sp<IBinder> displayToken = data.readStrongBinder(); | 
|  | 1700 | int32_t defaultModeId; | 
|  | 1701 | float minRefreshRate; | 
|  | 1702 | float maxRefreshRate; | 
|  | 1703 |  | 
|  | 1704 | status_t result = getDesiredDisplayConfigSpecs(displayToken, &defaultModeId, | 
|  | 1705 | &minRefreshRate, &maxRefreshRate); | 
|  | 1706 | if (result != NO_ERROR) { | 
|  | 1707 | ALOGE("getDesiredDisplayConfigSpecs: failed to get getDesiredDisplayConfigSpecs: " | 
|  | 1708 | "%d", | 
|  | 1709 | result); | 
|  | 1710 | return result; | 
|  | 1711 | } | 
|  | 1712 |  | 
|  | 1713 | result = reply->writeInt32(defaultModeId); | 
|  | 1714 | if (result != NO_ERROR) { | 
|  | 1715 | ALOGE("getDesiredDisplayConfigSpecs: failed to write defaultModeId: %d", result); | 
|  | 1716 | return result; | 
|  | 1717 | } | 
|  | 1718 | result = reply->writeFloat(minRefreshRate); | 
|  | 1719 | if (result != NO_ERROR) { | 
|  | 1720 | ALOGE("getDesiredDisplayConfigSpecs: failed to write minRefreshRate: %d", result); | 
|  | 1721 | return result; | 
|  | 1722 | } | 
|  | 1723 | result = reply->writeFloat(maxRefreshRate); | 
|  | 1724 | if (result != NO_ERROR) { | 
|  | 1725 | ALOGE("getDesiredDisplayConfigSpecs: failed to write maxRefreshRate: %d", result); | 
|  | 1726 | return result; | 
|  | 1727 | } | 
|  | 1728 | reply->writeInt32(result); | 
|  | 1729 | return result; | 
|  | 1730 | } | 
| Dan Gittik | 57e63c5 | 2019-01-18 16:37:54 +0000 | [diff] [blame] | 1731 | case GET_DISPLAY_BRIGHTNESS_SUPPORT: { | 
|  | 1732 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1733 | sp<IBinder> displayToken; | 
|  | 1734 | status_t error = data.readNullableStrongBinder(&displayToken); | 
|  | 1735 | if (error != NO_ERROR) { | 
|  | 1736 | ALOGE("getDisplayBrightnessSupport: failed to read display token: %d", error); | 
|  | 1737 | return error; | 
|  | 1738 | } | 
|  | 1739 | bool support = false; | 
|  | 1740 | error = getDisplayBrightnessSupport(displayToken, &support); | 
|  | 1741 | reply->writeBool(support); | 
|  | 1742 | return error; | 
|  | 1743 | } | 
|  | 1744 | case SET_DISPLAY_BRIGHTNESS: { | 
|  | 1745 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1746 | sp<IBinder> displayToken; | 
|  | 1747 | status_t error = data.readNullableStrongBinder(&displayToken); | 
|  | 1748 | if (error != NO_ERROR) { | 
|  | 1749 | ALOGE("setDisplayBrightness: failed to read display token: %d", error); | 
|  | 1750 | return error; | 
|  | 1751 | } | 
|  | 1752 | float brightness = -1.0f; | 
|  | 1753 | error = data.readFloat(&brightness); | 
|  | 1754 | if (error != NO_ERROR) { | 
|  | 1755 | ALOGE("setDisplayBrightness: failed to read brightness: %d", error); | 
|  | 1756 | return error; | 
|  | 1757 | } | 
|  | 1758 | return setDisplayBrightness(displayToken, brightness); | 
|  | 1759 | } | 
| Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 1760 | case NOTIFY_POWER_HINT: { | 
|  | 1761 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1762 | int32_t hintId; | 
|  | 1763 | status_t error = data.readInt32(&hintId); | 
|  | 1764 | if (error != NO_ERROR) { | 
|  | 1765 | ALOGE("notifyPowerHint: failed to read hintId: %d", error); | 
|  | 1766 | return error; | 
|  | 1767 | } | 
|  | 1768 | return notifyPowerHint(hintId); | 
|  | 1769 | } | 
| Vishnu Nair | b13bb95 | 2019-11-15 10:24:08 -0800 | [diff] [blame] | 1770 | case SET_GLOBAL_SHADOW_SETTINGS: { | 
|  | 1771 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1772 |  | 
|  | 1773 | std::vector<float> shadowConfig; | 
|  | 1774 | status_t error = data.readFloatVector(&shadowConfig); | 
|  | 1775 | if (error != NO_ERROR || shadowConfig.size() != 11) { | 
|  | 1776 | ALOGE("setGlobalShadowSettings: failed to read shadowConfig: %d", error); | 
|  | 1777 | return error; | 
|  | 1778 | } | 
|  | 1779 |  | 
|  | 1780 | half4 ambientColor = {shadowConfig[0], shadowConfig[1], shadowConfig[2], | 
|  | 1781 | shadowConfig[3]}; | 
|  | 1782 | half4 spotColor = {shadowConfig[4], shadowConfig[5], shadowConfig[6], shadowConfig[7]}; | 
|  | 1783 | float lightPosY = shadowConfig[8]; | 
|  | 1784 | float lightPosZ = shadowConfig[9]; | 
|  | 1785 | float lightRadius = shadowConfig[10]; | 
|  | 1786 | return setGlobalShadowSettings(ambientColor, spotColor, lightPosY, lightPosZ, | 
|  | 1787 | lightRadius); | 
|  | 1788 | } | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1789 | default: { | 
| Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 1790 | return BBinder::onTransact(code, data, reply, flags); | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1791 | } | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1792 | } | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1793 | } | 
|  | 1794 |  | 
| Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 1795 | } // namespace android |