1 /* 2 * Copyright (c) 2024 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 #ifndef CLIENT_TYPE_MANAGER_H 17 #define CLIENT_TYPE_MANAGER_H 18 19 #include <mutex> 20 #include <string> 21 #include <unordered_map> 22 23 #include "client_type_manager.h" 24 #include "client_type_manager_handler.h" 25 26 namespace OHOS { 27 namespace AudioStandard { 28 using namespace std; 29 30 class ClientTypeManager : public ClientTypeListener { 31 public: 32 static ClientTypeManager *GetInstance(); 33 void GetAndSaveClientType(uint32_t uid, const std::string &bundleName); 34 ClientType GetClientTypeByUid(uint32_t uid); 35 36 void OnClientTypeQueryCompleted(uint32_t uid, ClientType clientType) override; 37 38 void SetQueryClientTypeCallback(const sptr<IStandardAudioPolicyManagerListener> &callback); 39 40 private: 41 std::mutex clientTypeMapMutex_; 42 std::unordered_map<uint32_t, ClientType> clientTypeMap_; 43 44 std::mutex handlerMutex_; 45 std::shared_ptr<ClientTypeManagerHandler> clientTypeManagerHandler_ = nullptr; 46 }; 47 } // namespace AudioStandard 48 } // namespace OHOS 49 #endif // CLIENT_TYPE_MANAGER_H 50