1 /* 2 * Copyright (c) 2023 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 #ifndef INTELL_VOICE_TRIGGER_MANAGER_H 16 #define INTELL_VOICE_TRIGGER_MANAGER_H 17 18 #include <map> 19 #include <memory> 20 #include "trigger_base_type.h" 21 #include "trigger_service.h" 22 #include "trigger_detector.h" 23 #include "i_intell_voice_trigger_detector_callback.h" 24 25 namespace OHOS { 26 namespace IntellVoiceTrigger { 27 class TriggerManager { 28 public: 29 ~TriggerManager(); 30 static std::shared_ptr<TriggerManager> GetInstance(); 31 32 void UpdateModel(std::shared_ptr<GenericTriggerModel> model); 33 void DeleteModel(int32_t uuid); 34 std::shared_ptr<GenericTriggerModel> GetModel(int32_t uuid); 35 std::shared_ptr<TriggerDetector> CreateTriggerDetector( 36 int32_t uuid, std::shared_ptr<IIntellVoiceTriggerDetectorCallback> callback); 37 void ReleaseTriggerDetector(int32_t uuid); 38 int32_t SetParameter(const std::string &key, const std::string &value); 39 std::string GetParameter(const std::string &key); 40 #ifdef SUPPORT_TELEPHONY_SERVICE 41 void AttachTelephonyObserver(); 42 void DetachTelephonyObserver(); 43 #endif 44 void AttachAudioCaptureListener(); 45 void DetachAudioCaptureListener(); 46 void AttachAudioRendererEventListener(); 47 void DetachAudioRendererEventListener(); 48 void AttachHibernateObserver(); 49 void DetachHibernateObserver(); 50 51 private: 52 explicit TriggerManager(); 53 54 private: 55 std::map<int32_t, std::shared_ptr<TriggerDetector>> detectors_; 56 std::shared_ptr<TriggerService> service_; 57 58 static std::mutex instanceMutex_; 59 static std::shared_ptr<TriggerManager> instance_; 60 }; 61 } // namespace IntellVoiceTrigger 62 } // namespace OHOS 63 #endif