• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 #include "quick_fix_switch_state.h"
17 
18 #include "app_log_wrapper.h"
19 #include "quick_fix_boot_scanner.h"
20 #include "quick_fix_delete_state.h"
21 #include "quick_fix_switcher.h"
22 
23 namespace OHOS {
24 namespace AppExecFwk {
QuickFixSwitchState(const std::string & bundleName,bool enable)25 QuickFixSwitchState::QuickFixSwitchState(const std::string &bundleName, bool enable)
26     : bundleName_(bundleName), enable_(enable)
27 {
28     APP_LOGI("create QuickFixSwitchState");
29 }
30 
Process()31 ErrCode QuickFixSwitchState::Process()
32 {
33     APP_LOGD("start to process switch-status bundle %{public}s", bundleName_.c_str());
34     std::unique_ptr<QuickFixSwitcher> switcher = std::make_unique<QuickFixSwitcher>(bundleName_, enable_);
35     auto res = switcher->Execute();
36     if (res != ERR_OK) {
37         APP_LOGE("switch quick fix info failed due to %{public}d", res);
38         return res;
39     }
40 
41     std::shared_ptr<QuickFixDeleteState> deleteState = std::make_shared<QuickFixDeleteState>(bundleName_);
42     auto scanner = DelayedSingleton<QuickFixBootScanner>::GetInstance();
43     if (scanner == nullptr) {
44         APP_LOGE("scanner is nullptr");
45         return ERR_BUNDLEMANAGER_QUICK_FIX_INTERNAL_ERROR;
46     }
47     scanner->SetQuickFixState(deleteState);
48     return scanner->ProcessState();
49 }
50 } // AppExecFwk
51 } // OHOS