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 16 #ifndef INTELL_VOICE_MANAGER_H 17 #define INTELL_VOICE_MANAGER_H 18 19 #include <condition_variable> 20 #include "iremote_object.h" 21 #include "iremote_broker.h" 22 #include "i_intell_voice_engine.h" 23 #include "i_intell_voice_service.h" 24 #include "update_callback_inner.h" 25 #include "intell_voice_info.h" 26 27 namespace OHOS { 28 namespace IntellVoice { 29 using OHOS::IntellVoiceEngine::IntellVoiceEngineType; 30 using OHOS::IntellVoiceEngine::IIntellVoiceEngine; 31 using OHOS::HDI::IntelligentVoice::Engine::V1_2::UploadHdiFileType; 32 33 struct UploadFilesInfo { 34 UploadHdiFileType type; 35 std::string filesDescription; 36 std::vector<std::vector<uint8_t>> filesContent; 37 }; 38 39 class IntellVoiceManager { 40 public: 41 static IntellVoiceManager *GetInstance(); 42 43 int32_t CreateIntellVoiceEngine(IntellVoiceEngineType type, sptr<IIntellVoiceEngine> &inst); 44 int32_t ReleaseIntellVoiceEngine(IntellVoiceEngineType type); 45 bool Init(); 46 47 int32_t RegisterServiceDeathRecipient(sptr<OHOS::IRemoteObject::DeathRecipient> callback); 48 int32_t DeregisterServiceDeathRecipient(sptr<OHOS::IRemoteObject::DeathRecipient> callback); 49 int32_t GetUploadFiles(int numMax, std::vector<UploadFilesInfo> &reportedFilesInfo); 50 51 int32_t SetParameter(const std::string &key, const std::string &value); 52 std::string GetParameter(const std::string &key); 53 int32_t GetWakeupSourceFiles(std::vector<WakeupSourceFile> &cloneFileInfo); 54 int32_t EnrollWithWakeupFilesForResult(const std::vector<WakeupSourceFile> &cloneFileInfo, 55 const std::string &wakeupInfo, const std::shared_ptr<IIntellVoiceUpdateCallback> callback); 56 void ClearUserData(); 57 private: 58 IntellVoiceManager(); 59 ~IntellVoiceManager(); 60 int32_t GetFileDataFromAshmem(sptr<Ashmem> ashmem, std::vector<uint8_t> &fileData); 61 62 std::mutex mutex_; 63 std::condition_variable proxyConVar_; 64 sptr<OHOS::IntellVoiceEngine::IIntellVoiceService> g_sProxy; 65 sptr<UpdateCallbackInner> callback_ = nullptr; 66 }; 67 } // namespace IntellVoice 68 } // namespace OHOS 69 70 #endif 71