• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 WAKEUP_ADAPTER_LISTENER_H
16 #define WAKEUP_ADAPTER_LISTENER_H
17 
18 #include <functional>
19 #include <memory>
20 #include <mutex>
21 #include "intell_voice_adapter_listener.h"
22 #include "i_intell_voice_engine_callback.h"
23 
24 namespace OHOS {
25 namespace IntellVoiceEngine {
26 using OnWakeupEventCb = std::function<void(
27     const OHOS::HDI::IntelligentVoice::Engine::V1_0::IntellVoiceEngineCallBackEvent &)>;
28 
29 class WakeupAdapterListener : public IntellVoiceAdapterListener {
30 public:
31     explicit WakeupAdapterListener(OnWakeupEventCb wakeupEventCb);
32     ~WakeupAdapterListener();
33 
34     void SetCallback(const sptr<IIntelligentVoiceEngineCallback> &cb);
35     void OnIntellVoiceHdiEvent(
36         const OHOS::HDI::IntelligentVoice::Engine::V1_0::IntellVoiceEngineCallBackEvent &event) override;
37     void Notify(const OHOS::HDI::IntelligentVoice::Engine::V1_0::IntellVoiceEngineCallBackEvent &event);
38 
39 private:
40     void BackupCallBackEvent(const OHOS::HDI::IntelligentVoice::Engine::V1_0::IntellVoiceEngineCallBackEvent &event);
41 
42 private:
43     std::mutex mutex_;
44     std::shared_ptr<OHOS::HDI::IntelligentVoice::Engine::V1_0::IntellVoiceEngineCallBackEvent> historyEvent_ = nullptr;
45     sptr<IIntelligentVoiceEngineCallback> cb_ = nullptr;
46     OnWakeupEventCb wakeupEventCb_ = nullptr;
47 };
48 }  // namespace IntellVoice
49 }  // namespace OHOS
50 #endif