1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd. 2023-2023.
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 UPDATE_ENGINE_H
16 #define UPDATE_ENGINE_H
17 #include <memory>
18 #include <string>
19 #include "v1_0/iintell_voice_engine_callback.h"
20 #include "engine_base.h"
21 #include "engine_util.h"
22 #include "intell_voice_generic_factory.h"
23 #include "update_state.h"
24 
25 namespace OHOS {
26 namespace IntellVoiceEngine {
27 class UpdateEngine : public EngineBase, private EngineUtil {
28 public:
29     ~UpdateEngine();
30     bool Init(const std::string &param) override;
31     void SetCallback(sptr<IRemoteObject> object) override;
32     int32_t Attach(const IntellVoiceEngineInfo &info) override;
33     int32_t Detach(void) override;
34     int32_t Start(bool isLast) override;
35     int32_t Stop() override;
36     int32_t SetParameter(const std::string &keyValueList) override;
37     std::string GetParameter(const std::string &key) override;
38 
39 private:
40     UpdateEngine();
41     void OnUpdateEvent(int32_t msgId, int32_t result);
42     void OnCommitEnrollComplete(int32_t result);
43 
44 private:
45     std::string name_ = "update engine instance";
46     std::string param_;
47     UpdateState updateResult_ = UpdateState::UPDATE_STATE_DEFAULT;
48     sptr<OHOS::HDI::IntelligentVoice::Engine::V1_0::IIntellVoiceEngineCallback> callback_ = nullptr;
49     std::mutex mutex_;
50     friend class IntellVoiceUtils::SptrFactory<EngineBase, UpdateEngine>;
51 };
52 }
53 }
54 #endif
55