• 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 #include "silence_update_strategy.h"
16 #include <fstream>
17 #include "securec.h"
18 #include "intell_voice_log.h"
19 #include "scope_guard.h"
20 #include "update_engine_utils.h"
21 #include "intell_voice_util.h"
22 
23 #define LOG_TAG "SilenceUpdateStrategy"
24 
25 using namespace OHOS::IntellVoiceUtils;
26 
27 namespace OHOS {
28 namespace IntellVoiceEngine {
29 static constexpr int32_t SILENCE_UPDATE_RETRY_TIMES = 5;
30 
SilenceUpdateStrategy(const std::string & param)31 SilenceUpdateStrategy::SilenceUpdateStrategy(const std::string &param): IUpdateStrategy(param)
32 {
33 }
34 
~SilenceUpdateStrategy()35 SilenceUpdateStrategy::~SilenceUpdateStrategy()
36 {
37 }
38 
UpdateRestrain()39 bool SilenceUpdateStrategy::UpdateRestrain()
40 {
41     return !UpdateEngineUtils::IsVersionUpdate();
42 }
43 
GetUpdatePriority()44 UpdatePriority SilenceUpdateStrategy::GetUpdatePriority()
45 {
46     return SILENCE_UPDATE_PRIORITY;
47 }
48 
GetRetryTimes()49 int SilenceUpdateStrategy::GetRetryTimes()
50 {
51     return SILENCE_UPDATE_RETRY_TIMES;
52 }
53 
OnUpdateCompleteCallback(const int result,bool isLast)54 int SilenceUpdateStrategy::OnUpdateCompleteCallback(const int result, bool isLast)
55 {
56     if (!isLast || result == 0) {
57         return 0;
58     }
59 
60     INTELL_VOICE_LOG_INFO("notify silence update fail");
61     IntellVoiceUtil::StartAbility("update_event");
62     return  0;
63 }
64 }
65 }