blob: 7a3472fa7e4e537b364cd2c30389fd5f93844fde [file] [log] [blame]
Jiwen 'Steve' Caid9f2abe2018-10-20 17:03:13 -07001/*
2 * Copyright (C) 2018 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
Fan Xu55b26a62018-12-19 11:03:14 -080017#include <array>
Fan Xufe097c72018-12-07 15:46:51 -080018#include <iomanip>
Fan Xu55b26a62018-12-19 11:03:14 -080019#include <random>
Fan Xufe097c72018-12-07 15:46:51 -080020#include <sstream>
21
Fan Xu93c94902018-11-01 12:22:05 -070022#include <android/hardware_buffer.h>
Jiwen 'Steve' Caid9f2abe2018-10-20 17:03:13 -070023#include <bufferhub/BufferHubService.h>
Fan Xu18d90ea2018-11-06 15:46:44 -080024#include <cutils/native_handle.h>
Fan Xu93c94902018-11-01 12:22:05 -070025#include <log/log.h>
Fan Xu55b26a62018-12-19 11:03:14 -080026#include <openssl/hmac.h>
Fan Xufe097c72018-12-07 15:46:51 -080027#include <system/graphics-base.h>
Fan Xuefce32e2018-12-12 14:34:16 -080028#include <ui/BufferHubDefs.h>
Fan Xufe097c72018-12-07 15:46:51 -080029
30using ::android::BufferHubDefs::MetadataHeader;
31using ::android::hardware::Void;
Jiwen 'Steve' Caid9f2abe2018-10-20 17:03:13 -070032
33namespace android {
34namespace frameworks {
35namespace bufferhub {
36namespace V1_0 {
37namespace implementation {
38
Fan Xu55b26a62018-12-19 11:03:14 -080039BufferHubService::BufferHubService() {
40 std::mt19937_64 randomEngine;
41 randomEngine.seed(time(nullptr));
42
43 mKey = randomEngine();
44}
45
Fan Xu93c94902018-11-01 12:22:05 -070046Return<void> BufferHubService::allocateBuffer(const HardwareBufferDescription& description,
47 const uint32_t userMetadataSize,
Fan Xuca70b7b2018-10-31 13:20:12 -070048 allocateBuffer_cb _hidl_cb) {
Fan Xu93c94902018-11-01 12:22:05 -070049 AHardwareBuffer_Desc desc;
50 memcpy(&desc, &description, sizeof(AHardwareBuffer_Desc));
51
52 std::shared_ptr<BufferNode> node =
53 std::make_shared<BufferNode>(desc.width, desc.height, desc.layers, desc.format,
Fan Xu1c16df52018-11-19 16:27:27 -080054 desc.usage, userMetadataSize,
55 BufferHubIdGenerator::getInstance().getId());
Tianyu Jiang727ede42019-02-01 11:44:51 -080056 if (node == nullptr || !node->isValid()) {
Fan Xu93c94902018-11-01 12:22:05 -070057 ALOGE("%s: creating BufferNode failed.", __FUNCTION__);
Fan Xuf8f4a452018-11-29 16:26:30 -080058 _hidl_cb(/*status=*/BufferHubStatus::ALLOCATION_FAILED, /*bufferClient=*/nullptr,
59 /*bufferTraits=*/{});
Fan Xu93c94902018-11-01 12:22:05 -070060 return Void();
61 }
62
Fan Xu18d90ea2018-11-06 15:46:44 -080063 sp<BufferClient> client = BufferClient::create(this, node);
Fan Xu93c94902018-11-01 12:22:05 -070064 // Add it to list for bookkeeping and dumpsys.
Fan Xucd74d782018-11-26 13:51:25 -080065 std::lock_guard<std::mutex> lock(mClientSetMutex);
66 mClientSet.emplace(client);
Fan Xu93c94902018-11-01 12:22:05 -070067
Tianyu Jiang8adb3192019-01-29 10:54:24 -080068 // Allocate memory for bufferInfo of type hidl_handle on the stack. See
69 // http://aosp/286282 for the usage of NATIVE_HANDLE_DECLARE_STORAGE.
70 NATIVE_HANDLE_DECLARE_STORAGE(bufferInfoStorage, BufferHubDefs::kBufferInfoNumFds,
71 BufferHubDefs::kBufferInfoNumInts);
72 hidl_handle bufferInfo =
Tianyu Jiang727ede42019-02-01 11:44:51 -080073 buildBufferInfo(bufferInfoStorage, node->id(), node->addNewActiveClientsBitToMask(),
74 node->userMetadataSize(), node->metadata().ashmemFd(),
Tianyu Jiang8adb3192019-01-29 10:54:24 -080075 node->eventFd().get());
Jiwen 'Steve' Caidfe0f4c2019-01-15 21:49:07 -080076 // During the gralloc allocation carried out by BufferNode, gralloc allocator will populate the
77 // fields of its HardwareBufferDescription (i.e. strides) according to the actual
78 // gralloc implementation. We need to read those fields back and send them to the client via
79 // BufferTraits.
80 HardwareBufferDescription allocatedBufferDesc;
81 memcpy(&allocatedBufferDesc, &node->bufferDesc(), sizeof(AHardwareBuffer_Desc));
82 BufferTraits bufferTraits = {/*bufferDesc=*/allocatedBufferDesc,
Tianyu Jiang727ede42019-02-01 11:44:51 -080083 /*bufferHandle=*/hidl_handle(node->bufferHandle()),
Tianyu Jiang8adb3192019-01-29 10:54:24 -080084 /*bufferInfo=*/std::move(bufferInfo)};
Fan Xuf8f4a452018-11-29 16:26:30 -080085
86 _hidl_cb(/*status=*/BufferHubStatus::NO_ERROR, /*bufferClient=*/client,
Tianyu Jiang8adb3192019-01-29 10:54:24 -080087 /*bufferTraits=*/std::move(bufferTraits));
Jiwen 'Steve' Caid9f2abe2018-10-20 17:03:13 -070088 return Void();
89}
90
Fan Xu467e08f2018-11-09 15:58:51 -080091Return<void> BufferHubService::importBuffer(const hidl_handle& tokenHandle,
Fan Xuca70b7b2018-10-31 13:20:12 -070092 importBuffer_cb _hidl_cb) {
Fan Xu55b26a62018-12-19 11:03:14 -080093 if (!tokenHandle.getNativeHandle() || tokenHandle->numFds != 0 || tokenHandle->numInts <= 1) {
Fan Xu467e08f2018-11-09 15:58:51 -080094 // nullptr handle or wrong format
Fan Xuf8f4a452018-11-29 16:26:30 -080095 _hidl_cb(/*status=*/BufferHubStatus::INVALID_TOKEN, /*bufferClient=*/nullptr,
96 /*bufferTraits=*/{});
Fan Xu467e08f2018-11-09 15:58:51 -080097 return Void();
98 }
99
Fan Xu55b26a62018-12-19 11:03:14 -0800100 int tokenId = tokenHandle->data[0];
Fan Xu467e08f2018-11-09 15:58:51 -0800101
102 wp<BufferClient> originClientWp;
103 {
Fan Xu55b26a62018-12-19 11:03:14 -0800104 std::lock_guard<std::mutex> lock(mTokenMutex);
105 auto iter = mTokenMap.find(tokenId);
Fan Xu467e08f2018-11-09 15:58:51 -0800106 if (iter == mTokenMap.end()) {
Fan Xu55b26a62018-12-19 11:03:14 -0800107 // Token Id not exist
108 ALOGD("%s: token #%d not found.", __FUNCTION__, tokenId);
Fan Xuf8f4a452018-11-29 16:26:30 -0800109 _hidl_cb(/*status=*/BufferHubStatus::INVALID_TOKEN, /*bufferClient=*/nullptr,
110 /*bufferTraits=*/{});
Fan Xu467e08f2018-11-09 15:58:51 -0800111 return Void();
112 }
113
Fan Xu55b26a62018-12-19 11:03:14 -0800114 const std::vector<uint8_t>& tokenHMAC = iter->second.first;
115
116 int numIntsForHMAC = (int)ceil(tokenHMAC.size() * sizeof(uint8_t) / (double)sizeof(int));
117 if (tokenHandle->numInts - 1 != numIntsForHMAC) {
118 // HMAC size not match
119 ALOGD("%s: token #%d HMAC size not match. Expected: %d Actual: %d", __FUNCTION__,
120 tokenId, numIntsForHMAC, tokenHandle->numInts - 1);
121 _hidl_cb(/*status=*/BufferHubStatus::INVALID_TOKEN, /*bufferClient=*/nullptr,
122 /*bufferTraits=*/{});
123 return Void();
124 }
125
126 size_t hmacSize = tokenHMAC.size() * sizeof(uint8_t);
127 if (memcmp(tokenHMAC.data(), &tokenHandle->data[1], hmacSize) != 0) {
128 // HMAC not match
129 ALOGD("%s: token #%d HMAC not match.", __FUNCTION__, tokenId);
130 _hidl_cb(/*status=*/BufferHubStatus::INVALID_TOKEN, /*bufferClient=*/nullptr,
131 /*bufferTraits=*/{});
132 return Void();
133 }
134
135 originClientWp = iter->second.second;
Fan Xu467e08f2018-11-09 15:58:51 -0800136 mTokenMap.erase(iter);
137 }
138
139 // Check if original client is dead
140 sp<BufferClient> originClient = originClientWp.promote();
141 if (!originClient) {
142 // Should not happen since token should be removed if already gone
143 ALOGE("%s: original client %p gone!", __FUNCTION__, originClientWp.unsafe_get());
Fan Xuf8f4a452018-11-29 16:26:30 -0800144 _hidl_cb(/*status=*/BufferHubStatus::BUFFER_FREED, /*bufferClient=*/nullptr,
145 /*bufferTraits=*/{});
Fan Xu467e08f2018-11-09 15:58:51 -0800146 return Void();
147 }
148
149 sp<BufferClient> client = new BufferClient(*originClient);
Tianyu Jiang727ede42019-02-01 11:44:51 -0800150 uint32_t clientStateMask = client->getBufferNode()->addNewActiveClientsBitToMask();
Fan Xuf8f4a452018-11-29 16:26:30 -0800151 if (clientStateMask == 0U) {
152 // Reach max client count
153 ALOGE("%s: import failed, BufferNode#%u reached maximum clients.", __FUNCTION__,
154 client->getBufferNode()->id());
155 _hidl_cb(/*status=*/BufferHubStatus::MAX_CLIENT, /*bufferClient=*/nullptr,
156 /*bufferTraits=*/{});
157 return Void();
158 }
Fan Xu467e08f2018-11-09 15:58:51 -0800159
Fan Xucd74d782018-11-26 13:51:25 -0800160 std::lock_guard<std::mutex> lock(mClientSetMutex);
161 mClientSet.emplace(client);
Fan Xuf8f4a452018-11-29 16:26:30 -0800162
163 std::shared_ptr<BufferNode> node = client->getBufferNode();
164
165 HardwareBufferDescription bufferDesc;
Tianyu Jiang727ede42019-02-01 11:44:51 -0800166 memcpy(&bufferDesc, &node->bufferDesc(), sizeof(HardwareBufferDescription));
Fan Xuf8f4a452018-11-29 16:26:30 -0800167
Tianyu Jiang8adb3192019-01-29 10:54:24 -0800168 // Allocate memory for bufferInfo of type hidl_handle on the stack. See
169 // http://aosp/286282 for the usage of NATIVE_HANDLE_DECLARE_STORAGE.
170 NATIVE_HANDLE_DECLARE_STORAGE(bufferInfoStorage, BufferHubDefs::kBufferInfoNumFds,
171 BufferHubDefs::kBufferInfoNumInts);
172 hidl_handle bufferInfo = buildBufferInfo(bufferInfoStorage, node->id(), clientStateMask,
Tianyu Jiang727ede42019-02-01 11:44:51 -0800173 node->userMetadataSize(), node->metadata().ashmemFd(),
174 node->eventFd().get());
Fan Xuf8f4a452018-11-29 16:26:30 -0800175 BufferTraits bufferTraits = {/*bufferDesc=*/bufferDesc,
Tianyu Jiang727ede42019-02-01 11:44:51 -0800176 /*bufferHandle=*/hidl_handle(node->bufferHandle()),
Tianyu Jiang8adb3192019-01-29 10:54:24 -0800177 /*bufferInfo=*/std::move(bufferInfo)};
Fan Xuf8f4a452018-11-29 16:26:30 -0800178
179 _hidl_cb(/*status=*/BufferHubStatus::NO_ERROR, /*bufferClient=*/client,
Tianyu Jiang8adb3192019-01-29 10:54:24 -0800180 /*bufferTraits=*/std::move(bufferTraits));
Fan Xuca70b7b2018-10-31 13:20:12 -0700181 return Void();
Jiwen 'Steve' Caid9f2abe2018-10-20 17:03:13 -0700182}
183
Fan Xufe097c72018-12-07 15:46:51 -0800184Return<void> BufferHubService::debug(const hidl_handle& fd, const hidl_vec<hidl_string>& args) {
185 if (fd.getNativeHandle() == nullptr || fd->numFds < 1) {
186 ALOGE("%s: missing fd for writing.", __FUNCTION__);
187 return Void();
188 }
189
190 FILE* out = fdopen(dup(fd->data[0]), "w");
191
192 if (args.size() != 0) {
193 fprintf(out,
194 "Note: lshal bufferhub currently does not support args. Input arguments are "
195 "ignored.\n");
196 }
197
198 std::ostringstream stream;
199
200 // Get the number of clients of each buffer.
201 // Map from bufferId to bufferNode_clientCount pair.
202 std::map<int, std::pair<const std::shared_ptr<BufferNode>, uint32_t>> clientCount;
203 {
204 std::lock_guard<std::mutex> lock(mClientSetMutex);
205 for (auto iter = mClientSet.begin(); iter != mClientSet.end(); ++iter) {
206 sp<BufferClient> client = iter->promote();
207 if (client != nullptr) {
208 const std::shared_ptr<BufferNode> node = client->getBufferNode();
209 auto mapIter = clientCount.find(node->id());
210 if (mapIter != clientCount.end()) {
211 ++mapIter->second.second;
212 } else {
213 clientCount.emplace(node->id(),
214 std::pair<std::shared_ptr<BufferNode>, uint32_t>(node, 1U));
215 }
216 }
217 }
218 }
219
220 stream << "Active Buffers:\n";
221 stream << std::right;
222 stream << std::setw(6) << "Id";
223 stream << " ";
Tianyu Jiang0f69e5e2019-01-23 17:17:59 -0800224 stream << std::setw(9) << "#Clients";
Fan Xufe097c72018-12-07 15:46:51 -0800225 stream << " ";
226 stream << std::setw(14) << "Geometry";
227 stream << " ";
228 stream << std::setw(6) << "Format";
229 stream << " ";
230 stream << std::setw(10) << "Usage";
231 stream << " ";
232 stream << std::setw(10) << "State";
233 stream << " ";
Jiwen 'Steve' Caif653d0b2019-01-15 10:52:20 -0800234 stream << std::setw(8) << "Index";
Fan Xufe097c72018-12-07 15:46:51 -0800235 stream << std::endl;
236
237 for (auto iter = clientCount.begin(); iter != clientCount.end(); ++iter) {
238 const std::shared_ptr<BufferNode> node = std::move(iter->second.first);
239 const uint32_t clientCount = iter->second.second;
Tianyu Jiang727ede42019-02-01 11:44:51 -0800240 AHardwareBuffer_Desc desc = node->bufferDesc();
Fan Xufe097c72018-12-07 15:46:51 -0800241
242 MetadataHeader* metadataHeader =
Tianyu Jiang727ede42019-02-01 11:44:51 -0800243 const_cast<BufferHubMetadata*>(&node->metadata())->metadataHeader();
Tianyu Jiangf377a762019-02-13 13:46:42 -0800244 const uint32_t state = metadataHeader->bufferState.load(std::memory_order_acquire);
245 const uint64_t index = metadataHeader->queueIndex;
Fan Xufe097c72018-12-07 15:46:51 -0800246
247 stream << std::right;
248 stream << std::setw(6) << /*Id=*/node->id();
249 stream << " ";
Tianyu Jiang0f69e5e2019-01-23 17:17:59 -0800250 stream << std::setw(9) << /*#Clients=*/clientCount;
Fan Xufe097c72018-12-07 15:46:51 -0800251 stream << " ";
252 if (desc.format == HAL_PIXEL_FORMAT_BLOB) {
253 std::string size = std::to_string(desc.width) + " B";
254 stream << std::setw(14) << /*Geometry=*/size;
255 } else {
256 std::string dimensions = std::to_string(desc.width) + "x" +
257 std::to_string(desc.height) + "x" + std::to_string(desc.layers);
258 stream << std::setw(14) << /*Geometry=*/dimensions;
259 }
260 stream << " ";
261 stream << std::setw(6) << /*Format=*/desc.format;
262 stream << " ";
263 stream << "0x" << std::hex << std::setfill('0');
264 stream << std::setw(8) << /*Usage=*/desc.usage;
265 stream << std::dec << std::setfill(' ');
266 stream << " ";
267 stream << "0x" << std::hex << std::setfill('0');
268 stream << std::setw(8) << /*State=*/state;
Jiwen 'Steve' Caif653d0b2019-01-15 10:52:20 -0800269 stream << std::dec << std::setfill(' ');
Fan Xufe097c72018-12-07 15:46:51 -0800270 stream << " ";
271 stream << std::setw(8) << /*Index=*/index;
272 stream << std::endl;
273 }
274
275 stream << std::endl;
276
277 // Get the number of tokens of each buffer.
278 // Map from bufferId to tokenCount
279 std::map<int, uint32_t> tokenCount;
280 {
Fan Xu55b26a62018-12-19 11:03:14 -0800281 std::lock_guard<std::mutex> lock(mTokenMutex);
Fan Xufe097c72018-12-07 15:46:51 -0800282 for (auto iter = mTokenMap.begin(); iter != mTokenMap.end(); ++iter) {
Fan Xu55b26a62018-12-19 11:03:14 -0800283 sp<BufferClient> client = iter->second.second.promote();
Fan Xufe097c72018-12-07 15:46:51 -0800284 if (client != nullptr) {
285 const std::shared_ptr<BufferNode> node = client->getBufferNode();
286 auto mapIter = tokenCount.find(node->id());
287 if (mapIter != tokenCount.end()) {
288 ++mapIter->second;
289 } else {
290 tokenCount.emplace(node->id(), 1U);
291 }
292 }
293 }
294 }
295
296 stream << "Unused Tokens:\n";
297 stream << std::right;
298 stream << std::setw(8) << "Buffer Id";
299 stream << " ";
Tianyu Jiang0f69e5e2019-01-23 17:17:59 -0800300 stream << std::setw(7) << "#Tokens";
Fan Xufe097c72018-12-07 15:46:51 -0800301 stream << std::endl;
302
303 for (auto iter = tokenCount.begin(); iter != tokenCount.end(); ++iter) {
304 stream << std::right;
305 stream << std::setw(8) << /*Buffer Id=*/iter->first;
306 stream << " ";
Tianyu Jiang0f69e5e2019-01-23 17:17:59 -0800307 stream << std::setw(7) << /*#Tokens=*/iter->second;
Fan Xufe097c72018-12-07 15:46:51 -0800308 stream << std::endl;
309 }
310
311 fprintf(out, "%s", stream.str().c_str());
312
313 fclose(out);
314 return Void();
315}
316
Fan Xud6cd6ba2018-11-15 16:46:55 -0800317hidl_handle BufferHubService::registerToken(const wp<BufferClient>& client) {
Fan Xu55b26a62018-12-19 11:03:14 -0800318 // Find next available token id
319 std::lock_guard<std::mutex> lock(mTokenMutex);
Fan Xu18d90ea2018-11-06 15:46:44 -0800320 do {
Fan Xu55b26a62018-12-19 11:03:14 -0800321 ++mLastTokenId;
322 } while (mTokenMap.find(mLastTokenId) != mTokenMap.end());
Fan Xu18d90ea2018-11-06 15:46:44 -0800323
Fan Xu55b26a62018-12-19 11:03:14 -0800324 std::array<uint8_t, EVP_MAX_MD_SIZE> hmac;
325 uint32_t hmacSize = 0U;
326
327 HMAC(/*evp_md=*/EVP_sha256(), /*key=*/&mKey, /*key_len=*/kKeyLen,
328 /*data=*/(uint8_t*)&mLastTokenId, /*data_len=*/mTokenIdSize,
329 /*out=*/hmac.data(), /*out_len=*/&hmacSize);
330
331 int numIntsForHMAC = (int)ceil(hmacSize / (double)sizeof(int));
332 native_handle_t* handle = native_handle_create(/*numFds=*/0, /*numInts=*/1 + numIntsForHMAC);
333 handle->data[0] = mLastTokenId;
334 // Set all the the bits of last int to 0 since it might not be fully overwritten
335 handle->data[numIntsForHMAC] = 0;
336 memcpy(&handle->data[1], hmac.data(), hmacSize);
Fan Xu18d90ea2018-11-06 15:46:44 -0800337
338 // returnToken owns the native_handle_t* thus doing lifecycle management
339 hidl_handle returnToken;
340 returnToken.setTo(handle, /*shoudOwn=*/true);
341
Fan Xu55b26a62018-12-19 11:03:14 -0800342 std::vector<uint8_t> hmacVec;
343 hmacVec.resize(hmacSize);
344 memcpy(hmacVec.data(), hmac.data(), hmacSize);
345 mTokenMap.emplace(mLastTokenId, std::pair(hmacVec, client));
346
Fan Xu18d90ea2018-11-06 15:46:44 -0800347 return returnToken;
348}
349
Fan Xua7422fe2018-11-19 15:21:32 -0800350void BufferHubService::onClientClosed(const BufferClient* client) {
351 removeTokenByClient(client);
352
Fan Xucd74d782018-11-26 13:51:25 -0800353 std::lock_guard<std::mutex> lock(mClientSetMutex);
354 auto iter = std::find(mClientSet.begin(), mClientSet.end(), client);
355 if (iter != mClientSet.end()) {
356 mClientSet.erase(iter);
Fan Xua7422fe2018-11-19 15:21:32 -0800357 }
358}
359
Fan Xuefce32e2018-12-12 14:34:16 -0800360// Implementation of this function should be consistent with the definition of bufferInfo handle in
361// ui/BufferHubDefs.h.
Tianyu Jiang8adb3192019-01-29 10:54:24 -0800362hidl_handle BufferHubService::buildBufferInfo(char* bufferInfoStorage, int bufferId,
363 uint32_t clientBitMask, uint32_t userMetadataSize,
364 int metadataFd, int eventFd) {
365 native_handle_t* infoHandle =
366 native_handle_init(bufferInfoStorage, BufferHubDefs::kBufferInfoNumFds,
367 BufferHubDefs::kBufferInfoNumInts);
Fan Xuefce32e2018-12-12 14:34:16 -0800368
Tianyu Jiang8adb3192019-01-29 10:54:24 -0800369 infoHandle->data[0] = metadataFd;
370 infoHandle->data[1] = eventFd;
Fan Xu5cf47bc2019-01-15 15:02:15 -0800371 infoHandle->data[2] = bufferId;
Fan Xuefce32e2018-12-12 14:34:16 -0800372 // Use memcpy to convert to int without missing digit.
373 // TOOD(b/121345852): use bit_cast to unpack bufferInfo when C++20 becomes available.
Fan Xu5cf47bc2019-01-15 15:02:15 -0800374 memcpy(&infoHandle->data[3], &clientBitMask, sizeof(clientBitMask));
375 memcpy(&infoHandle->data[4], &userMetadataSize, sizeof(userMetadataSize));
Fan Xuefce32e2018-12-12 14:34:16 -0800376
377 hidl_handle bufferInfo;
Tianyu Jiang8adb3192019-01-29 10:54:24 -0800378 bufferInfo.setTo(infoHandle, /*shouldOwn=*/false);
Fan Xuefce32e2018-12-12 14:34:16 -0800379
380 return bufferInfo;
381}
382
Fan Xua7422fe2018-11-19 15:21:32 -0800383void BufferHubService::removeTokenByClient(const BufferClient* client) {
Fan Xu55b26a62018-12-19 11:03:14 -0800384 std::lock_guard<std::mutex> lock(mTokenMutex);
Fan Xua7422fe2018-11-19 15:21:32 -0800385 auto iter = mTokenMap.begin();
386 while (iter != mTokenMap.end()) {
Fan Xu55b26a62018-12-19 11:03:14 -0800387 if (iter->second.second == client) {
Fan Xua7422fe2018-11-19 15:21:32 -0800388 auto oldIter = iter;
389 ++iter;
390 mTokenMap.erase(oldIter);
391 } else {
392 ++iter;
393 }
394 }
395}
396
Jiwen 'Steve' Caid9f2abe2018-10-20 17:03:13 -0700397} // namespace implementation
398} // namespace V1_0
399} // namespace bufferhub
400} // namespace frameworks
401} // namespace android