| 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> | 
| Mathias Agopian | 2b5dd40 | 2017-02-07 17:36:19 -0800 | [diff] [blame] | 29 | #include <gui/ISurfaceComposer.h> | 
|  | 30 | #include <gui/ISurfaceComposerClient.h> | 
| Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 31 | #include <gui/LayerDebugInfo.h> | 
| Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 32 | #include <gui/LayerState.h> | 
| Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 33 |  | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 34 | #include <system/graphics.h> | 
|  | 35 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | #include <ui/DisplayInfo.h> | 
| Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 37 | #include <ui/DisplayStatInfo.h> | 
| Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 38 | #include <ui/HdrCapabilities.h> | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 |  | 
| Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 40 | #include <utils/Log.h> | 
| Mathias Agopian | 9cce325 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 41 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 42 | // --------------------------------------------------------------------------- | 
|  | 43 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | namespace android { | 
|  | 45 |  | 
| Peiyong Lin | 9f03447 | 2018-03-28 15:29:00 -0700 | [diff] [blame] | 46 | using ui::ColorMode; | 
|  | 47 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | class BpSurfaceComposer : public BpInterface<ISurfaceComposer> | 
|  | 49 | { | 
|  | 50 | public: | 
| Chih-Hung Hsieh | e2347b7 | 2016-04-25 15:41:05 -0700 | [diff] [blame] | 51 | explicit BpSurfaceComposer(const sp<IBinder>& impl) | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | : BpInterface<ISurfaceComposer>(impl) | 
|  | 53 | { | 
|  | 54 | } | 
|  | 55 |  | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 56 | virtual ~BpSurfaceComposer(); | 
|  | 57 |  | 
| Mathias Agopian | 7e27f05 | 2010-05-28 14:22:23 -0700 | [diff] [blame] | 58 | virtual sp<ISurfaceComposerClient> createConnection() | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | { | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | Parcel data, reply; | 
|  | 61 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 62 | remote()->transact(BnSurfaceComposer::CREATE_CONNECTION, data, &reply); | 
| Mathias Agopian | 7e27f05 | 2010-05-28 14:22:23 -0700 | [diff] [blame] | 63 | return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder()); | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 64 | } | 
|  | 65 |  | 
| Marissa Wall | 713b63f | 2018-10-17 15:42:43 -0700 | [diff] [blame] | 66 | virtual void setTransactionState(const Vector<ComposerState>& state, | 
|  | 67 | const Vector<DisplayState>& displays, uint32_t flags, | 
| chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 68 | const sp<IBinder>& applyToken, | 
|  | 69 | const InputWindowCommands& commands) { | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 70 | Parcel data, reply; | 
|  | 71 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 72 |  | 
|  | 73 | data.writeUint32(static_cast<uint32_t>(state.size())); | 
|  | 74 | for (const auto& s : state) { | 
|  | 75 | s.write(data); | 
| Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 76 | } | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 77 |  | 
|  | 78 | data.writeUint32(static_cast<uint32_t>(displays.size())); | 
|  | 79 | for (const auto& d : displays) { | 
|  | 80 | d.write(data); | 
| Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 81 | } | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 82 |  | 
|  | 83 | data.writeUint32(flags); | 
| Marissa Wall | 713b63f | 2018-10-17 15:42:43 -0700 | [diff] [blame] | 84 | data.writeStrongBinder(applyToken); | 
| chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 85 | commands.write(data); | 
| Jamie Gennis | b8d69a5 | 2011-10-10 15:48:06 -0700 | [diff] [blame] | 86 | remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply); | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 87 | } | 
|  | 88 |  | 
|  | 89 | virtual void bootFinished() | 
|  | 90 | { | 
|  | 91 | Parcel data, reply; | 
|  | 92 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 93 | remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply); | 
|  | 94 | } | 
|  | 95 |  | 
| Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 96 | virtual status_t captureScreen(const sp<IBinder>& display, sp<GraphicBuffer>* outBuffer, | 
| Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 97 | const ui::Dataspace reqDataspace, | 
|  | 98 | const ui::PixelFormat reqPixelFormat, Rect sourceCrop, | 
|  | 99 | uint32_t reqWidth, uint32_t reqHeight, bool useIdentityTransform, | 
|  | 100 | ISurfaceComposer::Rotation rotation) { | 
| Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 101 | Parcel data, reply; | 
|  | 102 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 103 | data.writeStrongBinder(display); | 
| Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 104 | data.writeInt32(static_cast<int32_t>(reqDataspace)); | 
|  | 105 | data.writeInt32(static_cast<int32_t>(reqPixelFormat)); | 
| Dan Stoza | c187900 | 2014-05-22 15:59:05 -0700 | [diff] [blame] | 106 | data.write(sourceCrop); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 107 | data.writeUint32(reqWidth); | 
|  | 108 | data.writeUint32(reqHeight); | 
| Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 109 | data.writeInt32(static_cast<int32_t>(useIdentityTransform)); | 
| Riley Andrews | c3ebe66 | 2014-09-04 16:20:31 -0700 | [diff] [blame] | 110 | data.writeInt32(static_cast<int32_t>(rotation)); | 
| Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 111 | status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply); | 
|  | 112 | if (result != NO_ERROR) { | 
|  | 113 | ALOGE("captureScreen failed to transact: %d", result); | 
|  | 114 | return result; | 
| Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 115 | } | 
| Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 116 | result = reply.readInt32(); | 
|  | 117 | if (result != NO_ERROR) { | 
|  | 118 | ALOGE("captureScreen failed to readInt32: %d", result); | 
|  | 119 | return result; | 
| Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 120 | } | 
|  | 121 |  | 
|  | 122 | *outBuffer = new GraphicBuffer(); | 
|  | 123 | reply.read(**outBuffer); | 
| Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 124 |  | 
| Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 125 | return result; | 
| Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 126 | } | 
|  | 127 |  | 
| chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 128 | virtual status_t captureLayers(const sp<IBinder>& layerHandleBinder, | 
| Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 129 | sp<GraphicBuffer>* outBuffer, const ui::Dataspace reqDataspace, | 
|  | 130 | const ui::PixelFormat reqPixelFormat, const Rect& sourceCrop, | 
| Robert Carr | 578038f | 2018-03-09 12:25:24 -0800 | [diff] [blame] | 131 | float frameScale, bool childrenOnly) { | 
| chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 132 | Parcel data, reply; | 
|  | 133 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 134 | data.writeStrongBinder(layerHandleBinder); | 
| Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 135 | data.writeInt32(static_cast<int32_t>(reqDataspace)); | 
|  | 136 | data.writeInt32(static_cast<int32_t>(reqPixelFormat)); | 
| chaviw | 7206d49 | 2017-11-10 16:16:12 -0800 | [diff] [blame] | 137 | data.write(sourceCrop); | 
|  | 138 | data.writeFloat(frameScale); | 
| Robert Carr | 578038f | 2018-03-09 12:25:24 -0800 | [diff] [blame] | 139 | data.writeBool(childrenOnly); | 
| Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 140 | status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_LAYERS, data, &reply); | 
|  | 141 | if (result != NO_ERROR) { | 
|  | 142 | ALOGE("captureLayers failed to transact: %d", result); | 
|  | 143 | return result; | 
| Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 144 | } | 
| Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 145 | result = reply.readInt32(); | 
|  | 146 | if (result != NO_ERROR) { | 
|  | 147 | ALOGE("captureLayers failed to readInt32: %d", result); | 
|  | 148 | return result; | 
| Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 149 | } | 
| Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 150 |  | 
| Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 151 | *outBuffer = new GraphicBuffer(); | 
|  | 152 | reply.read(**outBuffer); | 
|  | 153 |  | 
| Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 154 | return result; | 
| chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 155 | } | 
|  | 156 |  | 
| Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 157 | virtual bool authenticateSurfaceTexture( | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 158 | const sp<IGraphicBufferProducer>& bufferProducer) const | 
| Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 159 | { | 
|  | 160 | Parcel data, reply; | 
|  | 161 | int err = NO_ERROR; | 
|  | 162 | err = data.writeInterfaceToken( | 
|  | 163 | ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 164 | if (err != NO_ERROR) { | 
| Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 165 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing " | 
| Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 166 | "interface descriptor: %s (%d)", strerror(-err), -err); | 
|  | 167 | return false; | 
|  | 168 | } | 
| Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 169 | err = data.writeStrongBinder(IInterface::asBinder(bufferProducer)); | 
| Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 170 | if (err != NO_ERROR) { | 
| Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 171 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing " | 
| Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 172 | "strong binder to parcel: %s (%d)", strerror(-err), -err); | 
| Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 173 | return false; | 
|  | 174 | } | 
|  | 175 | err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data, | 
|  | 176 | &reply); | 
|  | 177 | if (err != NO_ERROR) { | 
| Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 178 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error " | 
| Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 179 | "performing transaction: %s (%d)", strerror(-err), -err); | 
| Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 180 | return false; | 
|  | 181 | } | 
|  | 182 | int32_t result = 0; | 
|  | 183 | err = reply.readInt32(&result); | 
|  | 184 | if (err != NO_ERROR) { | 
| Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 185 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error " | 
| Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 186 | "retrieving result: %s (%d)", strerror(-err), -err); | 
| Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 187 | return false; | 
|  | 188 | } | 
|  | 189 | return result != 0; | 
|  | 190 | } | 
| Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 191 |  | 
| Brian Anderson | 6b37671 | 2017-04-04 10:51:39 -0700 | [diff] [blame] | 192 | virtual status_t getSupportedFrameTimestamps( | 
|  | 193 | std::vector<FrameEvent>* outSupported) const { | 
|  | 194 | if (!outSupported) { | 
|  | 195 | return UNEXPECTED_NULL; | 
|  | 196 | } | 
|  | 197 | outSupported->clear(); | 
|  | 198 |  | 
|  | 199 | Parcel data, reply; | 
|  | 200 |  | 
|  | 201 | status_t err = data.writeInterfaceToken( | 
|  | 202 | ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 203 | if (err != NO_ERROR) { | 
|  | 204 | return err; | 
|  | 205 | } | 
|  | 206 |  | 
|  | 207 | err = remote()->transact( | 
|  | 208 | BnSurfaceComposer::GET_SUPPORTED_FRAME_TIMESTAMPS, | 
|  | 209 | data, &reply); | 
|  | 210 | if (err != NO_ERROR) { | 
|  | 211 | return err; | 
|  | 212 | } | 
|  | 213 |  | 
|  | 214 | int32_t result = 0; | 
|  | 215 | err = reply.readInt32(&result); | 
|  | 216 | if (err != NO_ERROR) { | 
|  | 217 | return err; | 
|  | 218 | } | 
|  | 219 | if (result != NO_ERROR) { | 
|  | 220 | return result; | 
|  | 221 | } | 
|  | 222 |  | 
|  | 223 | std::vector<int32_t> supported; | 
|  | 224 | err = reply.readInt32Vector(&supported); | 
|  | 225 | if (err != NO_ERROR) { | 
|  | 226 | return err; | 
|  | 227 | } | 
|  | 228 |  | 
|  | 229 | outSupported->reserve(supported.size()); | 
|  | 230 | for (int32_t s : supported) { | 
|  | 231 | outSupported->push_back(static_cast<FrameEvent>(s)); | 
|  | 232 | } | 
|  | 233 | return NO_ERROR; | 
|  | 234 | } | 
|  | 235 |  | 
| Jorim Jaggi | b1e2f8d | 2017-06-08 15:43:59 -0700 | [diff] [blame] | 236 | virtual sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource) | 
| Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 237 | { | 
|  | 238 | Parcel data, reply; | 
|  | 239 | sp<IDisplayEventConnection> result; | 
|  | 240 | int err = data.writeInterfaceToken( | 
|  | 241 | ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 242 | if (err != NO_ERROR) { | 
|  | 243 | return result; | 
|  | 244 | } | 
| Jorim Jaggi | b1e2f8d | 2017-06-08 15:43:59 -0700 | [diff] [blame] | 245 | data.writeInt32(static_cast<int32_t>(vsyncSource)); | 
| Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 246 | err = remote()->transact( | 
|  | 247 | BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION, | 
|  | 248 | data, &reply); | 
|  | 249 | if (err != NO_ERROR) { | 
| Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 250 | ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing " | 
| Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 251 | "transaction: %s (%d)", strerror(-err), -err); | 
|  | 252 | return result; | 
|  | 253 | } | 
|  | 254 | result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder()); | 
|  | 255 | return result; | 
|  | 256 | } | 
| Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 257 |  | 
| Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 258 | virtual sp<IBinder> createDisplay(const String8& displayName, bool secure) | 
| Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 259 | { | 
|  | 260 | Parcel data, reply; | 
|  | 261 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
| Andy McFadden | 8dfa92f | 2012-09-17 18:27:17 -0700 | [diff] [blame] | 262 | data.writeString8(displayName); | 
| Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 263 | data.writeInt32(secure ? 1 : 0); | 
| Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 264 | remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply); | 
|  | 265 | return reply.readStrongBinder(); | 
|  | 266 | } | 
|  | 267 |  | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 268 | virtual void destroyDisplay(const sp<IBinder>& display) | 
|  | 269 | { | 
|  | 270 | Parcel data, reply; | 
|  | 271 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 272 | data.writeStrongBinder(display); | 
|  | 273 | remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply); | 
|  | 274 | } | 
|  | 275 |  | 
| Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 276 | virtual sp<IBinder> getBuiltInDisplay(int32_t id) | 
|  | 277 | { | 
|  | 278 | Parcel data, reply; | 
|  | 279 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 280 | data.writeInt32(id); | 
|  | 281 | remote()->transact(BnSurfaceComposer::GET_BUILT_IN_DISPLAY, data, &reply); | 
|  | 282 | return reply.readStrongBinder(); | 
|  | 283 | } | 
|  | 284 |  | 
| Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 285 | virtual void setPowerMode(const sp<IBinder>& display, int mode) | 
| Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 286 | { | 
|  | 287 | Parcel data, reply; | 
|  | 288 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
| Andy McFadden | c01a79d | 2012-09-27 16:02:06 -0700 | [diff] [blame] | 289 | data.writeStrongBinder(display); | 
| Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 290 | data.writeInt32(mode); | 
|  | 291 | remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply); | 
| Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 292 | } | 
| Mathias Agopian | 3094df3 | 2012-06-18 18:06:45 -0700 | [diff] [blame] | 293 |  | 
| Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 294 | virtual status_t getDisplayConfigs(const sp<IBinder>& display, | 
|  | 295 | Vector<DisplayInfo>* configs) | 
| Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 296 | { | 
|  | 297 | Parcel data, reply; | 
|  | 298 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
| Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 299 | data.writeStrongBinder(display); | 
| Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 300 | remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply); | 
|  | 301 | status_t result = reply.readInt32(); | 
|  | 302 | if (result == NO_ERROR) { | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 303 | size_t numConfigs = reply.readUint32(); | 
| Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 304 | configs->clear(); | 
|  | 305 | configs->resize(numConfigs); | 
|  | 306 | for (size_t c = 0; c < numConfigs; ++c) { | 
|  | 307 | memcpy(&(configs->editItemAt(c)), | 
|  | 308 | reply.readInplace(sizeof(DisplayInfo)), | 
|  | 309 | sizeof(DisplayInfo)); | 
|  | 310 | } | 
|  | 311 | } | 
|  | 312 | return result; | 
|  | 313 | } | 
|  | 314 |  | 
| Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 315 | virtual status_t getDisplayStats(const sp<IBinder>& display, | 
|  | 316 | DisplayStatInfo* stats) | 
|  | 317 | { | 
|  | 318 | Parcel data, reply; | 
|  | 319 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 320 | data.writeStrongBinder(display); | 
|  | 321 | remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply); | 
|  | 322 | status_t result = reply.readInt32(); | 
|  | 323 | if (result == NO_ERROR) { | 
|  | 324 | memcpy(stats, | 
|  | 325 | reply.readInplace(sizeof(DisplayStatInfo)), | 
|  | 326 | sizeof(DisplayStatInfo)); | 
|  | 327 | } | 
|  | 328 | return result; | 
|  | 329 | } | 
|  | 330 |  | 
| Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 331 | virtual int getActiveConfig(const sp<IBinder>& display) | 
|  | 332 | { | 
|  | 333 | Parcel data, reply; | 
|  | 334 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 335 | data.writeStrongBinder(display); | 
|  | 336 | remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply); | 
|  | 337 | return reply.readInt32(); | 
|  | 338 | } | 
|  | 339 |  | 
|  | 340 | virtual status_t setActiveConfig(const sp<IBinder>& display, int id) | 
|  | 341 | { | 
|  | 342 | Parcel data, reply; | 
| Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 343 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 344 | if (result != NO_ERROR) { | 
|  | 345 | ALOGE("setActiveConfig failed to writeInterfaceToken: %d", result); | 
|  | 346 | return result; | 
|  | 347 | } | 
|  | 348 | result = data.writeStrongBinder(display); | 
|  | 349 | if (result != NO_ERROR) { | 
|  | 350 | ALOGE("setActiveConfig failed to writeStrongBinder: %d", result); | 
|  | 351 | return result; | 
|  | 352 | } | 
|  | 353 | result = data.writeInt32(id); | 
|  | 354 | if (result != NO_ERROR) { | 
|  | 355 | ALOGE("setActiveConfig failed to writeInt32: %d", result); | 
|  | 356 | return result; | 
|  | 357 | } | 
|  | 358 | result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply); | 
|  | 359 | if (result != NO_ERROR) { | 
|  | 360 | ALOGE("setActiveConfig failed to transact: %d", result); | 
|  | 361 | return result; | 
|  | 362 | } | 
| Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 363 | return reply.readInt32(); | 
|  | 364 | } | 
| Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 365 |  | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 366 | virtual status_t getDisplayColorModes(const sp<IBinder>& display, | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 367 | Vector<ColorMode>* outColorModes) { | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 368 | Parcel data, reply; | 
|  | 369 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 370 | if (result != NO_ERROR) { | 
|  | 371 | ALOGE("getDisplayColorModes failed to writeInterfaceToken: %d", result); | 
|  | 372 | return result; | 
|  | 373 | } | 
|  | 374 | result = data.writeStrongBinder(display); | 
|  | 375 | if (result != NO_ERROR) { | 
|  | 376 | ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result); | 
|  | 377 | return result; | 
|  | 378 | } | 
|  | 379 | result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply); | 
|  | 380 | if (result != NO_ERROR) { | 
|  | 381 | ALOGE("getDisplayColorModes failed to transact: %d", result); | 
|  | 382 | return result; | 
|  | 383 | } | 
|  | 384 | result = static_cast<status_t>(reply.readInt32()); | 
|  | 385 | if (result == NO_ERROR) { | 
|  | 386 | size_t numModes = reply.readUint32(); | 
|  | 387 | outColorModes->clear(); | 
|  | 388 | outColorModes->resize(numModes); | 
|  | 389 | for (size_t i = 0; i < numModes; ++i) { | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 390 | outColorModes->replaceAt(static_cast<ColorMode>(reply.readInt32()), i); | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 391 | } | 
|  | 392 | } | 
|  | 393 | return result; | 
|  | 394 | } | 
|  | 395 |  | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 396 | virtual ColorMode getActiveColorMode(const sp<IBinder>& display) { | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 397 | Parcel data, reply; | 
|  | 398 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 399 | if (result != NO_ERROR) { | 
|  | 400 | ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result); | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 401 | return static_cast<ColorMode>(result); | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 402 | } | 
|  | 403 | result = data.writeStrongBinder(display); | 
|  | 404 | if (result != NO_ERROR) { | 
|  | 405 | ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result); | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 406 | return static_cast<ColorMode>(result); | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 407 | } | 
|  | 408 | result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply); | 
|  | 409 | if (result != NO_ERROR) { | 
|  | 410 | ALOGE("getActiveColorMode failed to transact: %d", result); | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 411 | return static_cast<ColorMode>(result); | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 412 | } | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 413 | return static_cast<ColorMode>(reply.readInt32()); | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 414 | } | 
|  | 415 |  | 
|  | 416 | virtual status_t setActiveColorMode(const sp<IBinder>& display, | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 417 | ColorMode colorMode) { | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 418 | Parcel data, reply; | 
|  | 419 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 420 | if (result != NO_ERROR) { | 
|  | 421 | ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result); | 
|  | 422 | return result; | 
|  | 423 | } | 
|  | 424 | result = data.writeStrongBinder(display); | 
|  | 425 | if (result != NO_ERROR) { | 
|  | 426 | ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result); | 
|  | 427 | return result; | 
|  | 428 | } | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 429 | result = data.writeInt32(static_cast<int32_t>(colorMode)); | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 430 | if (result != NO_ERROR) { | 
|  | 431 | ALOGE("setActiveColorMode failed to writeInt32: %d", result); | 
|  | 432 | return result; | 
|  | 433 | } | 
|  | 434 | result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply); | 
|  | 435 | if (result != NO_ERROR) { | 
|  | 436 | ALOGE("setActiveColorMode failed to transact: %d", result); | 
|  | 437 | return result; | 
|  | 438 | } | 
|  | 439 | return static_cast<status_t>(reply.readInt32()); | 
|  | 440 | } | 
|  | 441 |  | 
| Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 442 | virtual status_t clearAnimationFrameStats() { | 
|  | 443 | Parcel data, reply; | 
| Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 444 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 445 | if (result != NO_ERROR) { | 
|  | 446 | ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result); | 
|  | 447 | return result; | 
|  | 448 | } | 
|  | 449 | result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply); | 
|  | 450 | if (result != NO_ERROR) { | 
|  | 451 | ALOGE("clearAnimationFrameStats failed to transact: %d", result); | 
|  | 452 | return result; | 
|  | 453 | } | 
| Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 454 | return reply.readInt32(); | 
|  | 455 | } | 
|  | 456 |  | 
|  | 457 | virtual status_t getAnimationFrameStats(FrameStats* outStats) const { | 
|  | 458 | Parcel data, reply; | 
|  | 459 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 460 | remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply); | 
|  | 461 | reply.read(*outStats); | 
|  | 462 | return reply.readInt32(); | 
|  | 463 | } | 
| Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 464 |  | 
|  | 465 | virtual status_t getHdrCapabilities(const sp<IBinder>& display, | 
|  | 466 | HdrCapabilities* outCapabilities) const { | 
|  | 467 | Parcel data, reply; | 
|  | 468 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 469 | status_t result = data.writeStrongBinder(display); | 
|  | 470 | if (result != NO_ERROR) { | 
|  | 471 | ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result); | 
|  | 472 | return result; | 
|  | 473 | } | 
|  | 474 | result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES, | 
|  | 475 | data, &reply); | 
|  | 476 | if (result != NO_ERROR) { | 
|  | 477 | ALOGE("getHdrCapabilities failed to transact: %d", result); | 
|  | 478 | return result; | 
|  | 479 | } | 
|  | 480 | result = reply.readInt32(); | 
|  | 481 | if (result == NO_ERROR) { | 
| Mathias Agopian | e1f5e6f | 2017-02-06 16:34:41 -0800 | [diff] [blame] | 482 | result = reply.read(*outCapabilities); | 
| Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 483 | } | 
|  | 484 | return result; | 
|  | 485 | } | 
| Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 486 |  | 
|  | 487 | virtual status_t enableVSyncInjections(bool enable) { | 
|  | 488 | Parcel data, reply; | 
|  | 489 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 490 | if (result != NO_ERROR) { | 
|  | 491 | ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result); | 
|  | 492 | return result; | 
|  | 493 | } | 
|  | 494 | result = data.writeBool(enable); | 
|  | 495 | if (result != NO_ERROR) { | 
|  | 496 | ALOGE("enableVSyncInjections failed to writeBool: %d", result); | 
|  | 497 | return result; | 
|  | 498 | } | 
|  | 499 | result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS, | 
|  | 500 | data, &reply, TF_ONE_WAY); | 
|  | 501 | if (result != NO_ERROR) { | 
|  | 502 | ALOGE("enableVSyncInjections failed to transact: %d", result); | 
|  | 503 | return result; | 
|  | 504 | } | 
|  | 505 | return result; | 
|  | 506 | } | 
|  | 507 |  | 
|  | 508 | virtual status_t injectVSync(nsecs_t when) { | 
|  | 509 | Parcel data, reply; | 
|  | 510 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 511 | if (result != NO_ERROR) { | 
|  | 512 | ALOGE("injectVSync failed to writeInterfaceToken: %d", result); | 
|  | 513 | return result; | 
|  | 514 | } | 
|  | 515 | result = data.writeInt64(when); | 
|  | 516 | if (result != NO_ERROR) { | 
|  | 517 | ALOGE("injectVSync failed to writeInt64: %d", result); | 
|  | 518 | return result; | 
|  | 519 | } | 
|  | 520 | result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply, TF_ONE_WAY); | 
|  | 521 | if (result != NO_ERROR) { | 
|  | 522 | ALOGE("injectVSync failed to transact: %d", result); | 
|  | 523 | return result; | 
|  | 524 | } | 
|  | 525 | return result; | 
|  | 526 | } | 
|  | 527 |  | 
| Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 528 | virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const | 
|  | 529 | { | 
|  | 530 | if (!outLayers) { | 
|  | 531 | return UNEXPECTED_NULL; | 
|  | 532 | } | 
|  | 533 |  | 
|  | 534 | Parcel data, reply; | 
|  | 535 |  | 
|  | 536 | status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 537 | if (err != NO_ERROR) { | 
|  | 538 | return err; | 
|  | 539 | } | 
|  | 540 |  | 
|  | 541 | err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply); | 
|  | 542 | if (err != NO_ERROR) { | 
|  | 543 | return err; | 
|  | 544 | } | 
|  | 545 |  | 
|  | 546 | int32_t result = 0; | 
|  | 547 | err = reply.readInt32(&result); | 
|  | 548 | if (err != NO_ERROR) { | 
|  | 549 | return err; | 
|  | 550 | } | 
|  | 551 | if (result != NO_ERROR) { | 
|  | 552 | return result; | 
|  | 553 | } | 
|  | 554 |  | 
|  | 555 | outLayers->clear(); | 
|  | 556 | return reply.readParcelableVector(outLayers); | 
|  | 557 | } | 
| Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 558 |  | 
| Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 559 | virtual status_t getCompositionPreference(ui::Dataspace* defaultDataspace, | 
|  | 560 | ui::PixelFormat* defaultPixelFormat, | 
|  | 561 | ui::Dataspace* wideColorGamutDataspace, | 
|  | 562 | ui::PixelFormat* wideColorGamutPixelFormat) const { | 
| Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 563 | Parcel data, reply; | 
|  | 564 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 565 | if (error != NO_ERROR) { | 
|  | 566 | return error; | 
|  | 567 | } | 
|  | 568 | error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply); | 
|  | 569 | if (error != NO_ERROR) { | 
|  | 570 | return error; | 
|  | 571 | } | 
|  | 572 | error = static_cast<status_t>(reply.readInt32()); | 
|  | 573 | if (error == NO_ERROR) { | 
| Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 574 | *defaultDataspace = static_cast<ui::Dataspace>(reply.readInt32()); | 
|  | 575 | *defaultPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32()); | 
|  | 576 | *wideColorGamutDataspace = static_cast<ui::Dataspace>(reply.readInt32()); | 
|  | 577 | *wideColorGamutPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32()); | 
| Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 578 | } | 
|  | 579 | return error; | 
|  | 580 | } | 
| Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 581 |  | 
| Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 582 | virtual status_t getColorManagement(bool* outGetColorManagement) const { | 
| Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 583 | Parcel data, reply; | 
|  | 584 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
| Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 585 | remote()->transact(BnSurfaceComposer::GET_COLOR_MANAGEMENT, data, &reply); | 
|  | 586 | bool result; | 
|  | 587 | status_t err = reply.readBool(&result); | 
|  | 588 | if (err == NO_ERROR) { | 
|  | 589 | *outGetColorManagement = result; | 
| Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 590 | } | 
| Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 591 | return err; | 
| Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 592 | } | 
| Kevin DuBois | 9c0a176 | 2018-10-16 13:32:31 -0700 | [diff] [blame] | 593 |  | 
|  | 594 | virtual status_t getDisplayedContentSamplingAttributes(const sp<IBinder>& display, | 
|  | 595 | ui::PixelFormat* outFormat, | 
|  | 596 | ui::Dataspace* outDataspace, | 
|  | 597 | uint8_t* outComponentMask) const { | 
|  | 598 | if (!outFormat || !outDataspace || !outComponentMask) return BAD_VALUE; | 
|  | 599 | Parcel data, reply; | 
|  | 600 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 601 | data.writeStrongBinder(display); | 
|  | 602 |  | 
|  | 603 | status_t error = | 
|  | 604 | remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES, | 
|  | 605 | data, &reply); | 
|  | 606 | if (error != NO_ERROR) { | 
|  | 607 | return error; | 
|  | 608 | } | 
|  | 609 |  | 
|  | 610 | uint32_t value = 0; | 
|  | 611 | error = reply.readUint32(&value); | 
|  | 612 | if (error != NO_ERROR) { | 
|  | 613 | return error; | 
|  | 614 | } | 
|  | 615 | *outFormat = static_cast<ui::PixelFormat>(value); | 
|  | 616 |  | 
|  | 617 | error = reply.readUint32(&value); | 
|  | 618 | if (error != NO_ERROR) { | 
|  | 619 | return error; | 
|  | 620 | } | 
|  | 621 | *outDataspace = static_cast<ui::Dataspace>(value); | 
|  | 622 |  | 
|  | 623 | error = reply.readUint32(&value); | 
|  | 624 | if (error != NO_ERROR) { | 
|  | 625 | return error; | 
|  | 626 | } | 
|  | 627 | *outComponentMask = static_cast<uint8_t>(value); | 
|  | 628 | return error; | 
|  | 629 | } | 
| Kevin DuBois | 74e5377 | 2018-11-19 10:52:38 -0800 | [diff] [blame] | 630 |  | 
|  | 631 | virtual status_t setDisplayContentSamplingEnabled(const sp<IBinder>& display, bool enable, | 
|  | 632 | uint8_t componentMask, | 
|  | 633 | uint64_t maxFrames) const { | 
|  | 634 | Parcel data, reply; | 
|  | 635 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 636 | data.writeStrongBinder(display); | 
|  | 637 | data.writeBool(enable); | 
|  | 638 | data.writeByte(static_cast<int8_t>(componentMask)); | 
|  | 639 | data.writeUint64(maxFrames); | 
|  | 640 | status_t result = | 
|  | 641 | remote()->transact(BnSurfaceComposer::SET_DISPLAY_CONTENT_SAMPLING_ENABLED, data, | 
|  | 642 | &reply); | 
|  | 643 | return result; | 
|  | 644 | } | 
| Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 645 |  | 
|  | 646 | virtual status_t getDisplayedContentSample(const sp<IBinder>& display, uint64_t maxFrames, | 
|  | 647 | uint64_t timestamp, | 
|  | 648 | DisplayedFrameStats* outStats) const { | 
|  | 649 | if (!outStats) return BAD_VALUE; | 
|  | 650 |  | 
|  | 651 | Parcel data, reply; | 
|  | 652 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); | 
|  | 653 | data.writeStrongBinder(display); | 
|  | 654 | data.writeUint64(maxFrames); | 
|  | 655 | data.writeUint64(timestamp); | 
|  | 656 |  | 
|  | 657 | status_t result = | 
|  | 658 | remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLE, data, &reply); | 
|  | 659 |  | 
|  | 660 | if (result != NO_ERROR) { | 
|  | 661 | return result; | 
|  | 662 | } | 
|  | 663 |  | 
|  | 664 | result = reply.readUint64(&outStats->numFrames); | 
|  | 665 | if (result != NO_ERROR) { | 
|  | 666 | return result; | 
|  | 667 | } | 
|  | 668 |  | 
| Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 669 | result = reply.readUint64Vector(&outStats->component_0_sample); | 
| Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 670 | if (result != NO_ERROR) { | 
|  | 671 | return result; | 
|  | 672 | } | 
| Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 673 | result = reply.readUint64Vector(&outStats->component_1_sample); | 
| Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 674 | if (result != NO_ERROR) { | 
|  | 675 | return result; | 
|  | 676 | } | 
| Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 677 | result = reply.readUint64Vector(&outStats->component_2_sample); | 
| Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 678 | if (result != NO_ERROR) { | 
|  | 679 | return result; | 
|  | 680 | } | 
| Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 681 | result = reply.readUint64Vector(&outStats->component_3_sample); | 
| Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 682 | return result; | 
|  | 683 | } | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 684 | }; | 
|  | 685 |  | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 686 | // Out-of-line virtual method definition to trigger vtable emission in this | 
|  | 687 | // translation unit (see clang warning -Wweak-vtables) | 
|  | 688 | BpSurfaceComposer::~BpSurfaceComposer() {} | 
|  | 689 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 690 | IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer"); | 
|  | 691 |  | 
|  | 692 | // ---------------------------------------------------------------------- | 
|  | 693 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 694 | status_t BnSurfaceComposer::onTransact( | 
|  | 695 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) | 
|  | 696 | { | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 697 | switch(code) { | 
|  | 698 | case CREATE_CONNECTION: { | 
| Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 699 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
| Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 700 | sp<IBinder> b = IInterface::asBinder(createConnection()); | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 701 | reply->writeStrongBinder(b); | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 702 | return NO_ERROR; | 
|  | 703 | } | 
| Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 704 | case SET_TRANSACTION_STATE: { | 
| Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 705 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 706 |  | 
|  | 707 | size_t count = data.readUint32(); | 
| Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 708 | if (count > data.dataSize()) { | 
|  | 709 | return BAD_VALUE; | 
|  | 710 | } | 
| Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 711 | Vector<ComposerState> state; | 
|  | 712 | state.setCapacity(count); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 713 | for (size_t i = 0; i < count; i++) { | 
| Marissa Wall | c837b5e | 2018-10-12 10:04:44 -0700 | [diff] [blame] | 714 | ComposerState s; | 
| Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 715 | if (s.read(data) == BAD_VALUE) { | 
|  | 716 | return BAD_VALUE; | 
|  | 717 | } | 
| Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 718 | state.add(s); | 
|  | 719 | } | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 720 |  | 
|  | 721 | count = data.readUint32(); | 
| Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 722 | if (count > data.dataSize()) { | 
|  | 723 | return BAD_VALUE; | 
|  | 724 | } | 
| Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 725 | DisplayState d; | 
|  | 726 | Vector<DisplayState> displays; | 
|  | 727 | displays.setCapacity(count); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 728 | for (size_t i = 0; i < count; i++) { | 
| Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 729 | if (d.read(data) == BAD_VALUE) { | 
|  | 730 | return BAD_VALUE; | 
|  | 731 | } | 
| Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 732 | displays.add(d); | 
|  | 733 | } | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 734 |  | 
|  | 735 | uint32_t stateFlags = data.readUint32(); | 
| Marissa Wall | 713b63f | 2018-10-17 15:42:43 -0700 | [diff] [blame] | 736 | sp<IBinder> applyToken = data.readStrongBinder(); | 
| chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 737 | InputWindowCommands inputWindowCommands; | 
|  | 738 | inputWindowCommands.read(data); | 
|  | 739 | setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands); | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 740 | return NO_ERROR; | 
|  | 741 | } | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 742 | case BOOT_FINISHED: { | 
| Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 743 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 744 | bootFinished(); | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 745 | return NO_ERROR; | 
|  | 746 | } | 
| Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 747 | case CAPTURE_SCREEN: { | 
|  | 748 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 749 | sp<IBinder> display = data.readStrongBinder(); | 
| Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 750 | ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32()); | 
|  | 751 | ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32()); | 
| Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 752 | sp<GraphicBuffer> outBuffer; | 
| Pablo Ceballos | 60d6922 | 2015-08-07 14:47:20 -0700 | [diff] [blame] | 753 | Rect sourceCrop(Rect::EMPTY_RECT); | 
| Dan Stoza | c187900 | 2014-05-22 15:59:05 -0700 | [diff] [blame] | 754 | data.read(sourceCrop); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 755 | uint32_t reqWidth = data.readUint32(); | 
|  | 756 | uint32_t reqHeight = data.readUint32(); | 
| Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 757 | bool useIdentityTransform = static_cast<bool>(data.readInt32()); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 758 | int32_t rotation = data.readInt32(); | 
| Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 759 |  | 
| Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 760 | status_t res = captureScreen(display, &outBuffer, reqDataspace, reqPixelFormat, | 
|  | 761 | sourceCrop, reqWidth, reqHeight, useIdentityTransform, | 
| Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 762 | static_cast<ISurfaceComposer::Rotation>(rotation)); | 
| Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 763 | reply->writeInt32(res); | 
| Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 764 | if (res == NO_ERROR) { | 
|  | 765 | reply->write(*outBuffer); | 
|  | 766 | } | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 767 | return NO_ERROR; | 
|  | 768 | } | 
| chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 769 | case CAPTURE_LAYERS: { | 
|  | 770 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 771 | sp<IBinder> layerHandleBinder = data.readStrongBinder(); | 
| Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 772 | ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32()); | 
|  | 773 | ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32()); | 
| Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 774 | sp<GraphicBuffer> outBuffer; | 
| chaviw | 7206d49 | 2017-11-10 16:16:12 -0800 | [diff] [blame] | 775 | Rect sourceCrop(Rect::EMPTY_RECT); | 
|  | 776 | data.read(sourceCrop); | 
|  | 777 | float frameScale = data.readFloat(); | 
| Robert Carr | 578038f | 2018-03-09 12:25:24 -0800 | [diff] [blame] | 778 | bool childrenOnly = data.readBool(); | 
| chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 779 |  | 
| Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 780 | status_t res = captureLayers(layerHandleBinder, &outBuffer, reqDataspace, | 
|  | 781 | reqPixelFormat, sourceCrop, frameScale, childrenOnly); | 
| chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 782 | reply->writeInt32(res); | 
| Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 783 | if (res == NO_ERROR) { | 
|  | 784 | reply->write(*outBuffer); | 
|  | 785 | } | 
| chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 786 | return NO_ERROR; | 
|  | 787 | } | 
| Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 788 | case AUTHENTICATE_SURFACE: { | 
|  | 789 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 790 | sp<IGraphicBufferProducer> bufferProducer = | 
|  | 791 | interface_cast<IGraphicBufferProducer>(data.readStrongBinder()); | 
|  | 792 | int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0; | 
| Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 793 | reply->writeInt32(result); | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 794 | return NO_ERROR; | 
|  | 795 | } | 
| Brian Anderson | 6b37671 | 2017-04-04 10:51:39 -0700 | [diff] [blame] | 796 | case GET_SUPPORTED_FRAME_TIMESTAMPS: { | 
|  | 797 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 798 | std::vector<FrameEvent> supportedTimestamps; | 
|  | 799 | status_t result = getSupportedFrameTimestamps(&supportedTimestamps); | 
|  | 800 | status_t err = reply->writeInt32(result); | 
|  | 801 | if (err != NO_ERROR) { | 
|  | 802 | return err; | 
|  | 803 | } | 
|  | 804 | if (result != NO_ERROR) { | 
|  | 805 | return result; | 
|  | 806 | } | 
|  | 807 |  | 
|  | 808 | std::vector<int32_t> supported; | 
|  | 809 | supported.reserve(supportedTimestamps.size()); | 
|  | 810 | for (FrameEvent s : supportedTimestamps) { | 
|  | 811 | supported.push_back(static_cast<int32_t>(s)); | 
|  | 812 | } | 
|  | 813 | return reply->writeInt32Vector(supported); | 
|  | 814 | } | 
| Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 815 | case CREATE_DISPLAY_EVENT_CONNECTION: { | 
|  | 816 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
| Jorim Jaggi | b1e2f8d | 2017-06-08 15:43:59 -0700 | [diff] [blame] | 817 | sp<IDisplayEventConnection> connection(createDisplayEventConnection( | 
|  | 818 | static_cast<ISurfaceComposer::VsyncSource>(data.readInt32()))); | 
| Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 819 | reply->writeStrongBinder(IInterface::asBinder(connection)); | 
| Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 820 | return NO_ERROR; | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 821 | } | 
| Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 822 | case CREATE_DISPLAY: { | 
|  | 823 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
| Andy McFadden | 8dfa92f | 2012-09-17 18:27:17 -0700 | [diff] [blame] | 824 | String8 displayName = data.readString8(); | 
| Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 825 | bool secure = bool(data.readInt32()); | 
|  | 826 | sp<IBinder> display(createDisplay(displayName, secure)); | 
| Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 827 | reply->writeStrongBinder(display); | 
|  | 828 | return NO_ERROR; | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 829 | } | 
|  | 830 | case DESTROY_DISPLAY: { | 
|  | 831 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 832 | sp<IBinder> display = data.readStrongBinder(); | 
|  | 833 | destroyDisplay(display); | 
|  | 834 | return NO_ERROR; | 
|  | 835 | } | 
| Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 836 | case GET_BUILT_IN_DISPLAY: { | 
|  | 837 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 838 | int32_t id = data.readInt32(); | 
|  | 839 | sp<IBinder> display(getBuiltInDisplay(id)); | 
|  | 840 | reply->writeStrongBinder(display); | 
|  | 841 | return NO_ERROR; | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 842 | } | 
| Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 843 | case GET_DISPLAY_CONFIGS: { | 
| Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 844 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
| Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 845 | Vector<DisplayInfo> configs; | 
| Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 846 | sp<IBinder> display = data.readStrongBinder(); | 
| Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 847 | status_t result = getDisplayConfigs(display, &configs); | 
|  | 848 | reply->writeInt32(result); | 
|  | 849 | if (result == NO_ERROR) { | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 850 | reply->writeUint32(static_cast<uint32_t>(configs.size())); | 
| Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 851 | for (size_t c = 0; c < configs.size(); ++c) { | 
|  | 852 | memcpy(reply->writeInplace(sizeof(DisplayInfo)), | 
|  | 853 | &configs[c], sizeof(DisplayInfo)); | 
|  | 854 | } | 
|  | 855 | } | 
|  | 856 | return NO_ERROR; | 
|  | 857 | } | 
| Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 858 | case GET_DISPLAY_STATS: { | 
|  | 859 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 860 | DisplayStatInfo stats; | 
|  | 861 | sp<IBinder> display = data.readStrongBinder(); | 
|  | 862 | status_t result = getDisplayStats(display, &stats); | 
|  | 863 | reply->writeInt32(result); | 
|  | 864 | if (result == NO_ERROR) { | 
|  | 865 | memcpy(reply->writeInplace(sizeof(DisplayStatInfo)), | 
|  | 866 | &stats, sizeof(DisplayStatInfo)); | 
|  | 867 | } | 
|  | 868 | return NO_ERROR; | 
|  | 869 | } | 
| Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 870 | case GET_ACTIVE_CONFIG: { | 
|  | 871 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 872 | sp<IBinder> display = data.readStrongBinder(); | 
|  | 873 | int id = getActiveConfig(display); | 
|  | 874 | reply->writeInt32(id); | 
|  | 875 | return NO_ERROR; | 
|  | 876 | } | 
|  | 877 | case SET_ACTIVE_CONFIG: { | 
|  | 878 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 879 | sp<IBinder> display = data.readStrongBinder(); | 
|  | 880 | int id = data.readInt32(); | 
|  | 881 | status_t result = setActiveConfig(display, id); | 
| Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 882 | reply->writeInt32(result); | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 883 | return NO_ERROR; | 
|  | 884 | } | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 885 | case GET_DISPLAY_COLOR_MODES: { | 
|  | 886 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 887 | Vector<ColorMode> colorModes; | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 888 | sp<IBinder> display = nullptr; | 
|  | 889 | status_t result = data.readStrongBinder(&display); | 
|  | 890 | if (result != NO_ERROR) { | 
|  | 891 | ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result); | 
|  | 892 | return result; | 
|  | 893 | } | 
|  | 894 | result = getDisplayColorModes(display, &colorModes); | 
|  | 895 | reply->writeInt32(result); | 
|  | 896 | if (result == NO_ERROR) { | 
|  | 897 | reply->writeUint32(static_cast<uint32_t>(colorModes.size())); | 
|  | 898 | for (size_t i = 0; i < colorModes.size(); ++i) { | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 899 | reply->writeInt32(static_cast<int32_t>(colorModes[i])); | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 900 | } | 
|  | 901 | } | 
|  | 902 | return NO_ERROR; | 
|  | 903 | } | 
|  | 904 | case GET_ACTIVE_COLOR_MODE: { | 
|  | 905 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 906 | sp<IBinder> display = nullptr; | 
|  | 907 | status_t result = data.readStrongBinder(&display); | 
|  | 908 | if (result != NO_ERROR) { | 
|  | 909 | ALOGE("getActiveColorMode failed to readStrongBinder: %d", result); | 
|  | 910 | return result; | 
|  | 911 | } | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 912 | ColorMode colorMode = getActiveColorMode(display); | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 913 | result = reply->writeInt32(static_cast<int32_t>(colorMode)); | 
|  | 914 | return result; | 
|  | 915 | } | 
|  | 916 | case SET_ACTIVE_COLOR_MODE: { | 
|  | 917 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 918 | sp<IBinder> display = nullptr; | 
|  | 919 | status_t result = data.readStrongBinder(&display); | 
|  | 920 | if (result != NO_ERROR) { | 
|  | 921 | ALOGE("getActiveColorMode failed to readStrongBinder: %d", result); | 
|  | 922 | return result; | 
|  | 923 | } | 
|  | 924 | int32_t colorModeInt = 0; | 
|  | 925 | result = data.readInt32(&colorModeInt); | 
|  | 926 | if (result != NO_ERROR) { | 
|  | 927 | ALOGE("setActiveColorMode failed to readInt32: %d", result); | 
|  | 928 | return result; | 
|  | 929 | } | 
|  | 930 | result = setActiveColorMode(display, | 
| Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 931 | static_cast<ColorMode>(colorModeInt)); | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 932 | result = reply->writeInt32(result); | 
|  | 933 | return result; | 
|  | 934 | } | 
| Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 935 | case CLEAR_ANIMATION_FRAME_STATS: { | 
|  | 936 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 937 | status_t result = clearAnimationFrameStats(); | 
|  | 938 | reply->writeInt32(result); | 
|  | 939 | return NO_ERROR; | 
|  | 940 | } | 
|  | 941 | case GET_ANIMATION_FRAME_STATS: { | 
|  | 942 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 943 | FrameStats stats; | 
|  | 944 | status_t result = getAnimationFrameStats(&stats); | 
|  | 945 | reply->write(stats); | 
|  | 946 | reply->writeInt32(result); | 
|  | 947 | return NO_ERROR; | 
|  | 948 | } | 
| Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 949 | case SET_POWER_MODE: { | 
|  | 950 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 951 | sp<IBinder> display = data.readStrongBinder(); | 
|  | 952 | int32_t mode = data.readInt32(); | 
|  | 953 | setPowerMode(display, mode); | 
|  | 954 | return NO_ERROR; | 
|  | 955 | } | 
| Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 956 | case GET_HDR_CAPABILITIES: { | 
|  | 957 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 958 | sp<IBinder> display = nullptr; | 
|  | 959 | status_t result = data.readStrongBinder(&display); | 
|  | 960 | if (result != NO_ERROR) { | 
|  | 961 | ALOGE("getHdrCapabilities failed to readStrongBinder: %d", | 
|  | 962 | result); | 
|  | 963 | return result; | 
|  | 964 | } | 
|  | 965 | HdrCapabilities capabilities; | 
|  | 966 | result = getHdrCapabilities(display, &capabilities); | 
|  | 967 | reply->writeInt32(result); | 
|  | 968 | if (result == NO_ERROR) { | 
| Mathias Agopian | e1f5e6f | 2017-02-06 16:34:41 -0800 | [diff] [blame] | 969 | reply->write(capabilities); | 
| Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 970 | } | 
|  | 971 | return NO_ERROR; | 
|  | 972 | } | 
| Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 973 | case ENABLE_VSYNC_INJECTIONS: { | 
|  | 974 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 975 | bool enable = false; | 
|  | 976 | status_t result = data.readBool(&enable); | 
|  | 977 | if (result != NO_ERROR) { | 
|  | 978 | ALOGE("enableVSyncInjections failed to readBool: %d", result); | 
|  | 979 | return result; | 
|  | 980 | } | 
|  | 981 | return enableVSyncInjections(enable); | 
|  | 982 | } | 
|  | 983 | case INJECT_VSYNC: { | 
|  | 984 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 985 | int64_t when = 0; | 
|  | 986 | status_t result = data.readInt64(&when); | 
|  | 987 | if (result != NO_ERROR) { | 
|  | 988 | ALOGE("enableVSyncInjections failed to readInt64: %d", result); | 
|  | 989 | return result; | 
|  | 990 | } | 
|  | 991 | return injectVSync(when); | 
|  | 992 | } | 
| Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 993 | case GET_LAYER_DEBUG_INFO: { | 
|  | 994 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 995 | std::vector<LayerDebugInfo> outLayers; | 
|  | 996 | status_t result = getLayerDebugInfo(&outLayers); | 
|  | 997 | reply->writeInt32(result); | 
|  | 998 | if (result == NO_ERROR) | 
|  | 999 | { | 
|  | 1000 | result = reply->writeParcelableVector(outLayers); | 
|  | 1001 | } | 
|  | 1002 | return result; | 
|  | 1003 | } | 
| Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1004 | case GET_COMPOSITION_PREFERENCE: { | 
|  | 1005 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
| Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 1006 | ui::Dataspace defaultDataspace; | 
|  | 1007 | ui::PixelFormat defaultPixelFormat; | 
|  | 1008 | ui::Dataspace wideColorGamutDataspace; | 
|  | 1009 | ui::PixelFormat wideColorGamutPixelFormat; | 
|  | 1010 | status_t error = | 
|  | 1011 | getCompositionPreference(&defaultDataspace, &defaultPixelFormat, | 
|  | 1012 | &wideColorGamutDataspace, &wideColorGamutPixelFormat); | 
| Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1013 | reply->writeInt32(error); | 
|  | 1014 | if (error == NO_ERROR) { | 
| Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 1015 | reply->writeInt32(static_cast<int32_t>(defaultDataspace)); | 
|  | 1016 | reply->writeInt32(static_cast<int32_t>(defaultPixelFormat)); | 
|  | 1017 | reply->writeInt32(static_cast<int32_t>(wideColorGamutDataspace)); | 
| Peiyong Lin | aa3da6a | 2018-12-12 02:48:43 -0800 | [diff] [blame] | 1018 | reply->writeInt32(static_cast<int32_t>(wideColorGamutPixelFormat)); | 
| Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1019 | } | 
|  | 1020 | return NO_ERROR; | 
|  | 1021 | } | 
| Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 1022 | case GET_COLOR_MANAGEMENT: { | 
| Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 1023 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
| Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 1024 | bool result; | 
|  | 1025 | status_t error = getColorManagement(&result); | 
|  | 1026 | if (error == NO_ERROR) { | 
|  | 1027 | reply->writeBool(result); | 
|  | 1028 | } | 
|  | 1029 | return result; | 
| Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 1030 | } | 
| Kevin DuBois | 9c0a176 | 2018-10-16 13:32:31 -0700 | [diff] [blame] | 1031 | case GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: { | 
|  | 1032 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1033 |  | 
|  | 1034 | sp<IBinder> display = data.readStrongBinder(); | 
|  | 1035 | ui::PixelFormat format; | 
|  | 1036 | ui::Dataspace dataspace; | 
|  | 1037 | uint8_t component = 0; | 
|  | 1038 | auto result = | 
|  | 1039 | getDisplayedContentSamplingAttributes(display, &format, &dataspace, &component); | 
|  | 1040 | if (result == NO_ERROR) { | 
|  | 1041 | reply->writeUint32(static_cast<uint32_t>(format)); | 
|  | 1042 | reply->writeUint32(static_cast<uint32_t>(dataspace)); | 
|  | 1043 | reply->writeUint32(static_cast<uint32_t>(component)); | 
|  | 1044 | } | 
|  | 1045 | return result; | 
|  | 1046 | } | 
| Kevin DuBois | 74e5377 | 2018-11-19 10:52:38 -0800 | [diff] [blame] | 1047 | case SET_DISPLAY_CONTENT_SAMPLING_ENABLED: { | 
|  | 1048 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1049 |  | 
|  | 1050 | sp<IBinder> display = nullptr; | 
|  | 1051 | bool enable = false; | 
|  | 1052 | int8_t componentMask = 0; | 
|  | 1053 | uint64_t maxFrames = 0; | 
|  | 1054 | status_t result = data.readStrongBinder(&display); | 
|  | 1055 | if (result != NO_ERROR) { | 
|  | 1056 | ALOGE("setDisplayContentSamplingEnabled failure in reading Display token: %d", | 
|  | 1057 | result); | 
|  | 1058 | return result; | 
|  | 1059 | } | 
|  | 1060 |  | 
|  | 1061 | result = data.readBool(&enable); | 
|  | 1062 | if (result != NO_ERROR) { | 
|  | 1063 | ALOGE("setDisplayContentSamplingEnabled failure in reading enable: %d", result); | 
|  | 1064 | return result; | 
|  | 1065 | } | 
|  | 1066 |  | 
|  | 1067 | result = data.readByte(static_cast<int8_t*>(&componentMask)); | 
|  | 1068 | if (result != NO_ERROR) { | 
|  | 1069 | ALOGE("setDisplayContentSamplingEnabled failure in reading component mask: %d", | 
|  | 1070 | result); | 
|  | 1071 | return result; | 
|  | 1072 | } | 
|  | 1073 |  | 
|  | 1074 | result = data.readUint64(&maxFrames); | 
|  | 1075 | if (result != NO_ERROR) { | 
|  | 1076 | ALOGE("setDisplayContentSamplingEnabled failure in reading max frames: %d", result); | 
|  | 1077 | return result; | 
|  | 1078 | } | 
|  | 1079 |  | 
|  | 1080 | return setDisplayContentSamplingEnabled(display, enable, | 
|  | 1081 | static_cast<uint8_t>(componentMask), maxFrames); | 
|  | 1082 | } | 
| Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 1083 | case GET_DISPLAYED_CONTENT_SAMPLE: { | 
|  | 1084 | CHECK_INTERFACE(ISurfaceComposer, data, reply); | 
|  | 1085 |  | 
|  | 1086 | sp<IBinder> display = data.readStrongBinder(); | 
|  | 1087 | uint64_t maxFrames = 0; | 
|  | 1088 | uint64_t timestamp = 0; | 
|  | 1089 |  | 
|  | 1090 | status_t result = data.readUint64(&maxFrames); | 
|  | 1091 | if (result != NO_ERROR) { | 
|  | 1092 | ALOGE("getDisplayedContentSample failure in reading max frames: %d", result); | 
|  | 1093 | return result; | 
|  | 1094 | } | 
|  | 1095 |  | 
|  | 1096 | result = data.readUint64(×tamp); | 
|  | 1097 | if (result != NO_ERROR) { | 
|  | 1098 | ALOGE("getDisplayedContentSample failure in reading timestamp: %d", result); | 
|  | 1099 | return result; | 
|  | 1100 | } | 
|  | 1101 |  | 
|  | 1102 | DisplayedFrameStats stats; | 
|  | 1103 | result = getDisplayedContentSample(display, maxFrames, timestamp, &stats); | 
|  | 1104 | if (result == NO_ERROR) { | 
|  | 1105 | reply->writeUint64(stats.numFrames); | 
| Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 1106 | reply->writeUint64Vector(stats.component_0_sample); | 
|  | 1107 | reply->writeUint64Vector(stats.component_1_sample); | 
|  | 1108 | reply->writeUint64Vector(stats.component_2_sample); | 
|  | 1109 | reply->writeUint64Vector(stats.component_3_sample); | 
| Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 1110 | } | 
|  | 1111 | return result; | 
|  | 1112 | } | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1113 | default: { | 
| Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 1114 | return BBinder::onTransact(code, data, reply, flags); | 
| Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1115 | } | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1116 | } | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1117 | } | 
|  | 1118 |  | 
|  | 1119 | // ---------------------------------------------------------------------------- | 
|  | 1120 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1121 | }; |