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 ENGINE_MANAGER_HOST_H 16 #define ENGINE_MANAGER_HOST_H 17 #include "v1_0/iintell_voice_engine_manager.h" 18 #include "v1_2/iintell_voice_engine_manager.h" 19 #include "intell_voice_death_recipient.h" 20 #include "i_adapter_host_manager.h" 21 22 namespace OHOS { 23 namespace IntellVoiceEngine { 24 using OHOS::HDI::IntelligentVoice::Engine::V1_0::IIntellVoiceEngineAdapter; 25 using OHOS::HDI::IntelligentVoice::Engine::V1_0::IntellVoiceEngineAdapterDescriptor; 26 using OHOS::HDI::IntelligentVoice::Engine::V1_1::IIntellVoiceDataOprCallback; 27 using OHOS::HDI::IntelligentVoice::Engine::V1_2::UploadHdiFile; 28 29 class EngineHostManager { 30 public: 31 EngineHostManager() = default; 32 ~EngineHostManager(); GetInstance()33 static EngineHostManager &GetInstance() 34 { 35 static EngineHostManager engineHostMgr; 36 return engineHostMgr; 37 } 38 39 bool Init(); 40 bool RegisterEngineHDIDeathRecipient(); 41 void DeregisterEngineHDIDeathRecipient(); 42 void SetDataOprCallback(); 43 std::shared_ptr<IAdapterHostManager> CreateEngineAdapter(const IntellVoiceEngineAdapterDescriptor &desc); 44 void ReleaseEngineAdapter(const IntellVoiceEngineAdapterDescriptor &desc); 45 int GetUploadFiles(int numMax, std::vector<UploadHdiFile> &files); 46 int32_t GetWakeupSourceFilesList(std::vector<std::string>& cloneFiles); 47 int32_t GetWakeupSourceFile(const std::string &filePath, std::vector<uint8_t> &buffer); 48 int32_t SendWakeupFile(const std::string &filePath, const std::vector<uint8_t> &buffer); 49 int32_t ClearUserWakeupData(const std::string &wakeupPhrase); GetEngineHostProxy1_0()50 const sptr<OHOS::HDI::IntelligentVoice::Engine::V1_0::IIntellVoiceEngineManager> &GetEngineHostProxy1_0() const 51 { 52 return engineHostProxy1_0_; 53 } GetEngineHostProxy1_1()54 const sptr<OHOS::HDI::IntelligentVoice::Engine::V1_1::IIntellVoiceEngineManager> &GetEngineHostProxy1_1() const 55 { 56 return engineHostProxy1_1_; 57 } GetEngineHostProxy1_2()58 const sptr<OHOS::HDI::IntelligentVoice::Engine::V1_2::IIntellVoiceEngineManager> &GetEngineHostProxy1_2() const 59 { 60 return engineHostProxy1_2_; 61 } 62 63 private: 64 static void OnEngineHDIDiedCallback(); 65 66 sptr<OHOS::HDI::IntelligentVoice::Engine::V1_0::IIntellVoiceEngineManager> engineHostProxy1_0_ = nullptr; 67 sptr<OHOS::HDI::IntelligentVoice::Engine::V1_1::IIntellVoiceEngineManager> engineHostProxy1_1_ = nullptr; 68 sptr<OHOS::HDI::IntelligentVoice::Engine::V1_2::IIntellVoiceEngineManager> engineHostProxy1_2_ = nullptr; 69 sptr<OHOS::IntellVoiceUtils::IntellVoiceDeathRecipient> engineHdiDeathRecipient_ = nullptr; 70 sptr<IIntellVoiceDataOprCallback> dataOprCb_ = nullptr; 71 }; 72 } 73 } 74 #endif 75