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 #include "history_info_mgr.h"
16
17 #include "string_util.h"
18
19 using namespace OHOS::IntellVoiceUtils;
20 #define LOG_TAG "HistoryInfoMgr"
21
22 namespace OHOS {
23 namespace IntellVoiceEngine {
24 constexpr int decimalNotation = 10;
25 const std::string KEY_ENROLL_ENGINE_UID = "EnrollEngineUid";
26 const std::string KEY_WAKEUP_ENGINE_BUNDLE_NAME = "WakeupEngineBundleName";
27 const std::string KEY_WAKEUP_ENGINE_ABILITY_NAME = "WakeupEngineAbilityName";
28
HistoryInfoMgr()29 HistoryInfoMgr::HistoryInfoMgr()
30 : ServiceDbHelper("intell_voice_service_manager", "local_intell_voice_history_mgr_storeId")
31 {
32 }
33
SetEnrollEngineUid(int32_t uid)34 void HistoryInfoMgr::SetEnrollEngineUid(int32_t uid)
35 {
36 SetValue(KEY_ENROLL_ENGINE_UID, StringUtil::Int2String(uid));
37 }
38
GetEnrollEngineUid()39 int32_t HistoryInfoMgr::GetEnrollEngineUid()
40 {
41 std::string value = GetValue(KEY_ENROLL_ENGINE_UID);
42 return static_cast<int32_t>(strtol(value.c_str(), nullptr, decimalNotation));
43 }
44
SetWakeupEngineBundleName(const std::string & bundleName)45 void HistoryInfoMgr::SetWakeupEngineBundleName(const std::string &bundleName)
46 {
47 SetValue(KEY_WAKEUP_ENGINE_BUNDLE_NAME, bundleName);
48 }
49
GetWakeupEngineBundleName()50 std::string HistoryInfoMgr::GetWakeupEngineBundleName()
51 {
52 return GetValue(KEY_WAKEUP_ENGINE_BUNDLE_NAME);
53 }
54
SetWakeupEngineAbilityName(const std::string & abilityName)55 void HistoryInfoMgr::SetWakeupEngineAbilityName(const std::string &abilityName)
56 {
57 SetValue(KEY_WAKEUP_ENGINE_ABILITY_NAME, abilityName);
58 }
59
GetWakeupEngineAbilityName()60 std::string HistoryInfoMgr::GetWakeupEngineAbilityName()
61 {
62 return GetValue(KEY_WAKEUP_ENGINE_ABILITY_NAME);
63 }
64 }
65 }