1 /* 2 * Copyright (C) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @file avrcp_ct_connection.h 18 * 19 * @brief Declares the classes for saving the connection information, including attributes and methods. 20 */ 21 22 #ifndef AVRCP_CT_CONNECTION_H 23 #define AVRCP_CT_CONNECTION_H 24 25 #include "avrcp_ct_browse.h" 26 #include "avrcp_ct_internal.h" 27 #include "avrcp_ct_pass_through.h" 28 #include "avrcp_ct_sub_unit_info.h" 29 #include "avrcp_ct_unit_info.h" 30 #include "avrcp_ct_vendor.h" 31 32 namespace OHOS { 33 namespace bluetooth { 34 /** 35 * @brief This class provides a set of attributes for saving the connection information. 36 */ 37 class AvrcCtConnectInfo { 38 public: 39 /** 40 * @brief A constructor used to create an <b>AvrcTgConnectInfo</b> instance. 41 */ 42 AvrcCtConnectInfo(const std::string &btAddr, uint8_t connectId, uint8_t role, uint16_t controlMtu, 43 uint16_t browseMtu, uint32_t companyId, uint16_t uidCounter, bool absVolume, 44 AvctChannelEventCallback eventCallback, AvctMsgCallback msgCallback); 45 46 /** 47 * @brief A destructor used to delete the <b>AvrcCtConnectInfo</b> instance. 48 */ 49 ~AvrcCtConnectInfo(); 50 51 /** 52 * @brief A deleted default constructor. 53 */ 54 AvrcCtConnectInfo() = delete; 55 56 // The pointer to a callback function for receiving the events, which has been registered to the AVCTP. 57 AvctChannelEventCallback eventCallback_ {nullptr}; 58 // The pointer to a callback function for receiving the messages, which has been registered to the AVCTP. 59 AvctMsgCallback msgCallback_ {nullptr}; 60 61 uint8_t connectId_; // The id of the connection. 62 uint8_t role_; // The role of the connection.(Initiator or Acceptor) 63 uint16_t controlMtu_; // The the maximum transmission unit of the control channel. 64 uint16_t browseMtu_; // The the maximum transmission unit of the browse channel. 65 uint32_t companyId_; // The SIG company ID of the bluetooth device. 66 uint16_t uidCounter_; // The UID counter. 67 bool absVolume_; // Compatible device query interface of service layer. 68 bool brConnected_ = false; // The state of browsing channel. 69 std::string btAddr_; // The address of the bluetooth device. 70 std::map<uint8_t, bool> notes_ {}; // The notifications are enabled or not. 71 72 /** 73 * @brief This struct provides a set of attributes for saving the data of the <b>PASS THROUGH</b> command. 74 */ 75 struct PassInfo { 76 // The shared pointer to the instance of the <b>utility::Timer</b> 77 std::shared_ptr<utility::Timer> timer_ {nullptr}; 78 // The shared pointer to the instance of the <b>AvrcTgPassPacket</b> 79 std::shared_ptr<AvrcCtPassPacket> pkt_ {nullptr}; 80 // The queue of the <b>PASS THROUGH</b> command. 81 std::queue<std::shared_ptr<AvrcCtPassPacket>> cmdQue_ {}; 82 } ptInfo_ {}; 83 84 /** 85 * @brief This struct provides a set of attributes for saving the data of the <b>UNIT INFO</b> and <b>SUB UNIT 86 * INFO</b> command. 87 */ 88 struct UnitInfo { 89 // The shared pointer to the instance of the <b>utility::Timer</b>. 90 std::shared_ptr<utility::Timer> timer_ {nullptr}; 91 // The shared pointer to the instance of the <b>AvrcTgUnitPacket</b>. 92 std::shared_ptr<AvrcCtUnitPacket> pkt_ {nullptr}; 93 // The queue of the <b>UNIT INFO</b> and <b>SUB UNIT INFO</b> command. 94 std::queue<std::shared_ptr<AvrcCtUnitPacket>> cmdQue_ {}; 95 } unInfo_ {}; 96 97 /** 98 * @brief This struct provides the attributes for saving the data of the <b>VENDOR DEPENDENT</b> command. 99 */ 100 struct VendorInfo { 101 // The shared pointer to the instance of the <b>utility::Timer</b>. 102 std::shared_ptr<utility::Timer> timer_ {nullptr}; 103 // The shared pointer to the instance of the <b>AvrcTgVendorPacket</b>. 104 std::shared_ptr<AvrcCtVendorPacket> pkt_ {nullptr}; 105 // The shared pointer to the instance of the <b>AvrcTgVendorPacket</b>. 106 std::shared_ptr<AvrcCtVendorPacket> continuePkt_ {nullptr}; 107 // The queue of the <b>VENDOR DEPENDENT</b> command. 108 std::queue<std::shared_ptr<AvrcCtVendorPacket>> cmdQue_ {}; 109 } vdInfo_ {}; 110 111 /** 112 * @brief This struct provides the attributes for saving the data of the <b>BROWSING</b> command. 113 */ 114 struct BrowseInfo { 115 // The shared pointer to the instance of the <b>utility::Timer</b>. 116 std::shared_ptr<utility::Timer> timer_ {nullptr}; 117 // The shared pointer to the instance of the <b>AvrcTgBrowsePacket</b>. 118 std::shared_ptr<AvrcCtBrowsePacket> pkt_ {nullptr}; 119 // The queue of the <b>BROWSING</b> command. 120 std::queue<std::shared_ptr<AvrcCtBrowsePacket>> cmdQue_ {}; 121 } brInfo_ {}; 122 }; 123 124 /** 125 * @brief This class provides a set of methods for adding/deleting/getting/setting attributes of the connection 126 * information. 127 * 128 * @detail This class implements the singleton pattern. 129 */ 130 class AvrcCtConnectManager { 131 public: 132 /** 133 * @brief A destructor used to delete the <b>AvrcCtConnectManager</b> instance. 134 */ 135 ~AvrcCtConnectManager(); 136 137 /** 138 * @brief Gets the instance. 139 * 140 * @return The instance of the AvrcCtConnectManager. 141 */ 142 static AvrcCtConnectManager *GetInstance(void); 143 144 /** 145 * @brief Adds some properties of the connection information of the specified bluetooth address. 146 * 147 * @param[in] rawAddr The address of the bluetooth device. 148 * @param[in] connectId The ID of the connection. 149 * @param[in] role The role of the connection.(Initiator of the connection or Acceptor of the connection) 150 * @param[in] controlMtu The MTU size of the control channel. 151 * @param[in] browseMtu The MTU size of the browse channel. 152 * @param[in] companyId The SIG company ID of the bluetooth device. 153 * @param[in] uidCounter The uid counter. 154 * @param[in] eventCallback The callback function for receiving the channel event. 155 * @param[in] msgCallback The callback function for receiving the message. 156 * @return @c RET_NO_ERROR : The connection information was added successfully. 157 * @C RET_BAD_PARAM : The connection information already exists. 158 */ 159 int Add(const RawAddress &rawAddr, uint8_t connectId, uint8_t role, uint16_t controlMtu, uint16_t browseMtu, 160 uint32_t companyId, uint16_t uidCounter, bool absVolume, AvctChannelEventCallback eventCallback, 161 AvctMsgCallback msgCallback); 162 163 /** 164 * @brief Deletes the whole connection information of the specified bluetooth device. 165 * 166 * @param[in] rawAddr The address of the bluetooth device. 167 */ 168 void Delete(const RawAddress &rawAddr); 169 170 /** 171 * @brief Gets the whole connection information of the specified bluetooth device. 172 * 173 * @param[in] rawAddr The address of the bluetooth device. 174 * @return The read only pointer to the instance of the <b>AvrcTgConnectInfo</b> class. 175 */ 176 const AvrcCtConnectInfo *GetConnectInfo(const RawAddress &rawAddr) const; 177 178 /** 179 * @brief Gets the raw address of the specified connection id. 180 * 181 * @param[in] connectId The connection id. 182 * @return The raw address of the bluetooth device. 183 */ 184 RawAddress GetRawAddress(uint8_t connectId); 185 186 /** 187 * @brief Gets the address of the connected devices. 188 * 189 * @return The list of the address. 190 */ 191 std::list<std::string> GetDeviceAddresses(void); 192 193 /** 194 * @brief Adds the address of the disconnected bluetooth device. 195 * 196 * @param[in] rawAddr The address of the bluetooth device. 197 */ 198 void AddDisconnectedDevice(const std::string &addr); 199 200 /** 201 * @brief Deletes the address of the disconnected bluetooth device. 202 * 203 * @param[in] rawAddr The address of the bluetooth device. 204 */ 205 void DeleteDisconnectedDevice(const std::string &addr); 206 207 /** 208 * @brief Get all of the address of the disconnected bluetooth devices. 209 * 210 * @param[in] rawAddr The address of the bluetooth device. 211 */ 212 const std::list<std::string> &GetAllDisconnectedDevices(void); 213 214 /** 215 * @brief Checks the connection information of the specified bluetooth device is empty or not. 216 * 217 * @return The result of the method execution. 218 * @retval true The connection information is empty. 219 * @retval false The connection information is not empty. 220 */ 221 bool IsConnectInfoEmpty(void); 222 223 /** 224 * @brief Gets the connection id of the specified bluetooth device. 225 * 226 * @param[in] rawAddr The address of the bluetooth device. 227 * @return The connection id. 228 */ 229 uint8_t GetConnectId(const RawAddress &rawAddr); 230 231 /** 232 * @brief Sets the connection id of the specified bluetooth device. 233 * 234 * @param[in] rawAddr The address of the bluetooth device. 235 * @param[in] connectId The connection id. 236 */ 237 void SetConnectId(const RawAddress &rawAddr, uint8_t connectId); 238 239 /** 240 * @brief Enables the notification of the specified bluetooth device. 241 * 242 * @param[in] rawAddr The address of the bluetooth device. 243 * @param[in] notification The specified notify state. 244 */ 245 void EnableNotifyState(const RawAddress &rawAddr, uint8_t notification); 246 247 /** 248 * @brief Disables the notification of the specified bluetooth device. 249 * 250 * @param[in] rawAddr The address of the bluetooth device. 251 * @param[in] notification The specified notify state. 252 */ 253 void DisableNotifyState(const RawAddress &rawAddr, uint8_t notification); 254 255 /** 256 * @brief Checks the notification of the specified bluetooth device is enabled or not. 257 * 258 * @param[in] rawAddr The address of the bluetooth device. 259 * @param[in] notification The specified notify state. 260 * @return The result of the method execution. 261 * @retval true The notification is enabled. 262 * @retval false The notification is disabled. 263 */ 264 bool IsNotifyStateEnabled(const RawAddress &rawAddr, uint8_t notification); 265 266 /** 267 * @brief Disable the notification of the specified bluetooth device is enabled or not. 268 * 269 * @param[in] rawAddr The address of the bluetooth device. 270 * @param[in] events Disable the notification out of the events. 271 */ 272 void DisableExcludeEvents(const RawAddress &rawAddr, std::vector<uint8_t> events); 273 274 /** 275 * @brief Gets company id of the specified bluetooth device. 276 * 277 * @param[in] rawAddr The address of the bluetooth device. 278 * @return The company id. 279 */ 280 uint32_t GetCompanyId(const RawAddress &rawAddr); 281 282 /** 283 * @brief Gets the uid counter of the specified bluetooth device. 284 * 285 * @param[in] rawAddr The address of the bluetooth device. 286 * @return The uid counter. 287 */ 288 uint16_t GetUidCounter(const RawAddress &rawAddr); 289 290 /** 291 * @brief Sets the uid counter of the specified bluetooth device. 292 * 293 * @param[in] rawAddr The address of the bluetooth device. 294 * @param[in] UidCounter The uid counter. 295 */ 296 void SetUidCounter(const RawAddress &rawAddr, uint16_t uidCounter); 297 298 /****************************************************************** 299 * PASS THROUGH COMMAND * 300 ******************************************************************/ 301 302 /** 303 * @brief Gets the frame packet related to the <b>PASS THROUGH</b> command. 304 * 305 * @param[in] rawAddr The address of the bluetooth device. 306 * @return The shared pointer of the frame packet. 307 */ 308 std::shared_ptr<AvrcCtPassPacket> GetPassPacket(const RawAddress &rawAddr); 309 310 /** 311 * @brief Sets the frame packet related to the <b>PASS THROUGH</b> command. 312 * 313 * @param[in] rawAddr The address of the bluetooth device. 314 * @param[in] pkt The shared pointer of the frame packet. 315 */ 316 void SetPassPacket(const RawAddress &rawAddr, const std::shared_ptr<AvrcCtPassPacket> &pkt); 317 318 /** 319 * @brief Checks the frame packet related to the <b>PASS THROUGH</b> command is empty or not. 320 * 321 * @return The result of the method execution. 322 * @retval true The packet is empty. 323 * @retval false The packet is not empty. 324 */ 325 bool IsPassPacketEmpty(const RawAddress &rawAddr); 326 327 /** 328 * @brief Sets the timer related to the <b>PASS THROUGH</b> command. 329 * 330 * @param[in] rawAddr The address of the bluetooth device. 331 * @param[in] callback The callback for processing timeout. 332 * @param[in] ms The number of milliseconds used to count. 333 * @param[in] isPeriodic The timer is periodic or not. 334 */ 335 void SetPassTimer(const RawAddress &rawAddr, const std::function<void()> callback, int ms, bool isPeriodic = false); 336 337 /** 338 * @brief Clears the frame packet related to the <b>PASS THROUGH</b> command. 339 * 340 * @param[in] rawAddr The address of the bluetooth device. 341 */ 342 void ClearPassPacket(const RawAddress &rawAddr); 343 344 /** 345 * @brief Clears the timer related to the <b>PASS THROUGH</b> command. 346 * 347 * @param[in] rawAddr The address of the bluetooth device. 348 */ 349 void ClearPassTimer(const RawAddress &rawAddr); 350 351 /** 352 * @brief Clears all saved data related to the <b>PASS THROUGH</b> command. 353 * 354 * @param[in] rawAddr The address of the bluetooth device. 355 */ 356 void ClearPassInfo(const RawAddress &rawAddr); 357 358 /** 359 * @brief Pushes the packet of the <b>PASS THROUGH</b> command into the cache queue. 360 * 361 * @param[in] rawAddr The address of the bluetooth device. 362 * @param[in] pkt The shared pointer of the frame packet. 363 */ 364 void PushPassQueue(const RawAddress &rawAddr, const std::shared_ptr<AvrcCtPassPacket> &pkt); 365 366 /** 367 * @brief Popes the packet of the <b>PASS THROUGH</b> command from the cache queue. 368 * 369 * @param[in] rawAddr The address of the bluetooth device. 370 * @return The shared pointer of the frame packet. 371 */ 372 std::shared_ptr<AvrcCtPassPacket> PopPassQueue(const RawAddress &rawAddr); 373 374 /** 375 * @brief Gets the size of the cache queue of the <b>PASS THROUGH</b> command. 376 * 377 * @param[in] rawAddr The address of the bluetooth device. 378 * @return The size of the queue. 379 */ 380 uint8_t GetSizeOfPassQueue(const RawAddress &rawAddr); 381 382 /****************************************************************** 383 * UNIT INFO / SUB UNIT INFO COMMAND * 384 ******************************************************************/ 385 386 /** 387 * @brief Gets the frame packet related to the <b>UNIT INFO</b> and <b>SUB UNIT INFO</b> command. 388 * 389 * @param[in] rawAddr The address of the bluetooth device. 390 * @return The shared pointer of the frame packet. 391 */ 392 std::shared_ptr<AvrcCtUnitPacket> GetUnitPacket(const RawAddress &rawAddr); 393 394 /** 395 * @brief Sets the frame packet related to the <b>UNIT INFO</b> and <b>SUB UNIT INFO</b> command. 396 * 397 * @param[in] rawAddr The address of the bluetooth device. 398 * @param[in] pkt The frame packet. 399 */ 400 void SetUnitPacket(const RawAddress &rawAddr, const std::shared_ptr<AvrcCtUnitPacket> &pkt); 401 402 /** 403 * @brief Sets the timer related to the <b>PASS THROUGH</b> command. 404 * 405 * @param[in] rawAddr The address of the bluetooth device. 406 * @param[in] callback The callback for processing timeout. 407 * @param[in] ms The number of milliseconds used to count. 408 * @param[in] isPeriodic The timer is periodic or not. 409 */ 410 void SetUnitTimer(const RawAddress &rawAddr, std::function<void()> callback, int ms, bool isPeriodic = false); 411 412 /** 413 * @brief Clears the frame packet related to the <b>UNIT INFO</b> and <b>SUB UNIT INFO</b> command. 414 * 415 * @param[in] rawAddr The address of the bluetooth device. 416 */ 417 void ClearUnitPacket(const RawAddress &rawAddr); 418 419 /** 420 * @brief Clears the timer related to the <b>UNIT INFO</b> and <b>SUB UNIT INFO</b> command. 421 * 422 * @param[in] rawAddr The address of the bluetooth device. 423 */ 424 void ClearUnitTimer(const RawAddress &rawAddr); 425 426 /** 427 * @brief Clears all saved data related to the <b>UNIT INFO</b> and <b>SUB UNIT INFO</b> command. 428 * 429 * @param[in] rawAddr The address of the bluetooth device. 430 */ 431 void ClearUnitInfo(const RawAddress &rawAddr); 432 433 /** 434 * @brief Pushes the packet of the <b>UNIT INFO</b> and <b>SUB UNIT INFO</b> command into the cache queue. 435 * 436 * @param[in] rawAddr The address of the bluetooth device. 437 * @param[in] pkt The shared pointer of the frame packet. 438 */ 439 void PushUnitQueue(const RawAddress &rawAddr, const std::shared_ptr<AvrcCtUnitPacket> &pkt); 440 441 /** 442 * @brief Popes the packet of the <b>UNIT INFO</b> and <b>SUB UNIT INFO</b> command from the cache queue. 443 * 444 * @param[in] rawAddr The address of the bluetooth device. 445 * @return The shared pointer of the frame packet. 446 */ 447 std::shared_ptr<AvrcCtUnitPacket> PopUnitQueue(const RawAddress &rawAddr); 448 449 /** 450 * @brief Gets the size of the cache queue of the <b>UNIT INFO</b> and <b>SUB UNIT INFO</b> command. 451 * 452 * @param[in] rawAddr The address of the bluetooth device. 453 * @return The size of the queue. 454 */ 455 uint8_t GetSizeOfUnitQueue(const RawAddress &rawAddr); 456 457 /****************************************************************** 458 * VENDOR DEPENDENT COMMAND * 459 ******************************************************************/ 460 461 /** 462 * @brief Gets the frame packet related to the <b>VENDOR DEPENDENT</b> command. 463 * 464 * @param[in] rawAddr The address of the bluetooth device. 465 * @return The shared pointer of the frame packet. 466 */ 467 std::shared_ptr<AvrcCtVendorPacket> GetVendorPacket(const RawAddress &rawAddr); 468 469 /** 470 * @brief Sets the frame packet related to the <b>VENDOR DEPENDENT</b> command. 471 * 472 * @param[in] rawAddr The address of the bluetooth device. 473 * @param[in] pkt The frame packet. 474 */ 475 void SetVendorPacket(const RawAddress &rawAddr, const std::shared_ptr<AvrcCtVendorPacket> &pkt); 476 477 /** 478 * @brief Gets the frame packet related to the <b>VENDOR DEPENDENT</b> command. 479 * 480 * @param[in] rawAddr The address of the bluetooth device. 481 * @param[in] pkt The frame packet. 482 */ 483 std::shared_ptr<AvrcCtVendorPacket> GetVendorContinuePacket(const RawAddress &rawAddr); 484 485 /** 486 * @brief Sets the frame packet related to the <b>VENDOR DEPENDENT</b> command. 487 * 488 * @param[in] rawAddr The address of the bluetooth device. 489 * @param[in] pkt The frame packet. 490 */ 491 void SetVendorContinuePacket(const RawAddress &rawAddr, const std::shared_ptr<AvrcCtVendorPacket> &pkt); 492 493 /** 494 * @brief Clears the timer related to the <b>VENDOR DEPENDENT</b> command. 495 * 496 * @param[in] rawAddr The address of the bluetooth device. 497 * @param[in] callback The callback for processing timeout. 498 * @param[in] ms The number of milliseconds used to count. 499 * @param[in] isPeriodic The timer is periodic or not. 500 */ 501 void SetVendorTimer(const RawAddress &rawAddr, std::function<void()> callback, int ms, bool isPeriodic = false); 502 503 /** 504 * @brief Clears the frame packet related to the <b>VENDOR DEPENDENT</b> command. 505 * 506 * @param[in] rawAddr The address of the bluetooth device. 507 */ 508 void ClearVendorPacket(const RawAddress &rawAddr); 509 510 /** 511 * @brief Clears the frame packet related to the <b>VENDOR DEPENDENT</b> command. 512 * 513 * @param[in] rawAddr The address of the bluetooth device. 514 */ 515 void ClearVendorContinuePacket(const RawAddress &rawAddr); 516 517 /** 518 * @brief Clears the timer of the VENDOR DEPENDENT command associated with the specified bluetooth address. 519 * 520 * @param[in] rawAddr The address of the bluetooth device. 521 */ 522 void ClearVendorTimer(const RawAddress &rawAddr); 523 524 /** 525 * @brief Clears all saved data related to the <b>VENDOR DEPENDENT</b> command. 526 * 527 * @param[in] rawAddr The address of the bluetooth device. 528 */ 529 void ClearVendorInfo(const RawAddress &rawAddr); 530 531 /** 532 * @brief Pushes the packet of the <b>VENDOR DEPENDENT</b> command into the cache queue. 533 * 534 * @param[in] rawAddr The address of the bluetooth device. 535 * @param[in] pkt The shared pointer of the frame packet. 536 */ 537 void PushVendorQueue(const RawAddress &rawAddr, const std::shared_ptr<AvrcCtVendorPacket> &pkt); 538 539 /** 540 * @brief Popes the packet of the <b>VENDOR DEPENDENT</b> command from the cache queue. 541 * 542 * @param[in] rawAddr The address of the bluetooth device. 543 * @return The shared pointer of the frame packet. 544 */ 545 std::shared_ptr<AvrcCtVendorPacket> PopVendorQueue(const RawAddress &rawAddr); 546 547 /** 548 * @brief Gets the size of the cache queue of the <b>VENDOR DEPENDENT</b> command. 549 * 550 * @param[in] rawAddr The address of the bluetooth device. 551 * @return The size of the queue. 552 */ 553 uint8_t GetSizeOfVendorQueue(const RawAddress &rawAddr); 554 555 /****************************************************************** 556 * BROWSING COMMAND * 557 ******************************************************************/ 558 559 /** 560 * @brief Gets the frame packet related to the <b>BROWSING</b> command. 561 * 562 * @param[in] rawAddr The address of the bluetooth device. 563 * @return The shared pointer of the frame packet. 564 */ 565 std::shared_ptr<AvrcCtBrowsePacket> GetBrowsePacket(const RawAddress &rawAddr); 566 567 /** 568 * @brief Sets the frame packet related to the <b>BROWSING</b> command. 569 * 570 * @param[in] rawAddr The address of the bluetooth device. 571 * @param[in] pkt The frame packet. 572 */ 573 void SetBrowsePacket(const RawAddress &rawAddr, const std::shared_ptr<AvrcCtBrowsePacket> &pkt); 574 575 /** 576 * @brief Clears the timer related to the <b>BROWSING</b> command. 577 * 578 * @param[in] rawAddr The address of the bluetooth device. 579 * @param[in] callback The callback for processing timeout. 580 * @param[in] ms The number of milliseconds used to count. 581 * @param[in] isPeriodic The timer is periodic or not. 582 */ 583 void SetBrowseTimer(const RawAddress &rawAddr, std::function<void()> callback, int ms, bool isPeriodic = false); 584 585 /** 586 * @brief Clears the frame packet related to the <b>BROWSING</b> command. 587 * 588 * @param[in] rawAddr The address of the bluetooth device. 589 */ 590 void ClearBrowsePacket(const RawAddress &rawAddr); 591 592 /** 593 * @brief Clears the timer related to the <b>BROWSING</b> command. 594 * 595 * @param[in] rawAddr The address of the bluetooth device. 596 */ 597 void ClearBrowseTimer(const RawAddress &rawAddr); 598 599 /** 600 * @brief Clears all saved data related to the <b>BROWSING</b> command. 601 * 602 * @param[in] rawAddr The address of the bluetooth device. 603 */ 604 void ClearBrowseInfo(const RawAddress &rawAddr); 605 606 /** 607 * @brief Pushes the packet of the <b>BROWSING</b> command into the cache queue. 608 * 609 * @param[in] rawAddr The address of the bluetooth device. 610 * @param[in] pkt The shared pointer of the frame packet. 611 */ 612 void PushBrowseQueue(const RawAddress &rawAddr, const std::shared_ptr<AvrcCtBrowsePacket> &pkt); 613 614 /** 615 * @brief Popes the packet of the <b>BROWSING</b> command from the cache queue. 616 * 617 * @param[in] rawAddr The address of the bluetooth device. 618 * @return The shared pointer of the frame packet. 619 */ 620 std::shared_ptr<AvrcCtBrowsePacket> PopBrowseQueue(const RawAddress &rawAddr); 621 622 /** 623 * @brief Gets the size of the cache queue of the <b>BROWSING</b> command. 624 * 625 * @param[in] rawAddr The address of the bluetooth device. 626 * @return The size of the queue. 627 */ 628 uint8_t GetSizeOfBrowseQueue(const RawAddress &rawAddr); 629 630 /** 631 * @brief Whether peerAddr support absolute volume command. 632 * 633 * @param[in] rawAddr The address of the bluetooth device. 634 * @return The result of compatibility. 635 */ 636 bool IsDisableAbsoluteVolume(const RawAddress &rawAddr); 637 638 /** 639 * @brief Whether the browse channel connected. 640 * 641 * @param[in] rawAddr The address of the bluetooth device. 642 * @return The result. 643 */ 644 bool IsBrowsingConnected(const RawAddress &rawAddr); 645 646 /** 647 * @brief Set the browse channel connected flag. 648 * 649 * @param[in] rawAddr The address of the bluetooth device. 650 * @return The result. 651 */ 652 void SetBrowsingState(const RawAddress &rawAddr, bool state); 653 654 private: 655 // Locks the local variable in a multi-threaded environment. 656 std::recursive_mutex mutex_ {}; 657 // The disconnected address of the bluetooth devices. 658 std::list<std::string> disconnectedDevices_ {}; 659 // Saves the connection information according to the address of the bluetooth device. 660 std::map<std::string, AvrcCtConnectInfo> infos_ {}; 661 // The static pointer to the instance of the <b>AvrcCtConnectManager</b> class. 662 static AvrcCtConnectManager *g_instance; 663 664 /** 665 * @brief A constructor used to create an <b>AvrcCtConnectManager</b> instance. 666 */ 667 AvrcCtConnectManager() = default; 668 669 /** 670 * @brief Gets the connection information of the specified bluetooth address. 671 * 672 * @param[in] btAddr The address of the bluetooth device. 673 * @return The pointer to the instance of the <b>AvrcCtConnectInfo</b> class. 674 */ 675 AvrcCtConnectInfo *GetConnectInfo(const std::string &btAddr); 676 677 BT_DISALLOW_COPY_AND_ASSIGN(AvrcCtConnectManager); 678 }; 679 } // namespace bluetooth 680 } // namespace OHOS 681 682 #endif // !AVRCP_CT_CONNECTION_H 683