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