• 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 #ifndef OHOS_ABILITY_RUNTIME_QUICK_FIX_MANAGER_APPLY_TASK_H
17 #define OHOS_ABILITY_RUNTIME_QUICK_FIX_MANAGER_APPLY_TASK_H
18 
19 #include "app_mgr_interface.h"
20 #include "event_handler.h"
21 #include "quick_fix_result_info.h"
22 #include "quick_fix/quick_fix_manager_interface.h"
23 
24 namespace OHOS {
25 namespace AAFwk {
26 class QuickFixManagerService;
27 class QuickFixManagerApplyTask : public std::enable_shared_from_this<QuickFixManagerApplyTask> {
28 public:
QuickFixManagerApplyTask(sptr<AppExecFwk::IQuickFixManager> bundleQfMgr,sptr<AppExecFwk::IAppMgr> appMgr,std::shared_ptr<AppExecFwk::EventHandler> handler,wptr<QuickFixManagerService> service)29     QuickFixManagerApplyTask(sptr<AppExecFwk::IQuickFixManager> bundleQfMgr, sptr<AppExecFwk::IAppMgr> appMgr,
30         std::shared_ptr<AppExecFwk::EventHandler> handler, wptr<QuickFixManagerService> service)
31         : bundleQfMgr_(bundleQfMgr), appMgr_(appMgr), eventHandler_(handler), quickFixMgrService_(service)
32     {}
33 
34     virtual ~QuickFixManagerApplyTask();
35 
36     void Run(const std::vector<std::string> &quickFixFiles);
37     void HandlePatchDeployed();
38     void HandlePatchSwitched();
39     void HandlePatchDeleted();
40 
41     bool SetQuickFixInfo(const std::shared_ptr<AppExecFwk::QuickFixResult> &result);
42     bool GetRunningState();
43 
44     void RemoveTimeoutTask();
45     void NotifyApplyStatus(int32_t applyResult);
46     void RemoveSelf();
47 
48     void PostSwitchQuickFixTask();
49     void PostDeleteQuickFixTask();
50 
51     void UnregAppStateObserver();
52 
53 private:
54     void PostDeployQuickFixTask(const std::vector<std::string> &quickFixFiles);
55     void PostTimeOutTask();
56     void PostNotifyLoadRepairPatchTask();
57     void PostNotifyUnloadRepairPatchTask();
58     void PostNotifyHotReloadPageTask();
59     void RegAppStateObserver();
60 
61     sptr<AppExecFwk::IQuickFixManager> bundleQfMgr_ = nullptr;
62     sptr<AppExecFwk::IAppMgr> appMgr_ = nullptr;
63     sptr<AppExecFwk::IApplicationStateObserver> appStateCallback_ = nullptr;
64     std::shared_ptr<AppExecFwk::EventHandler> eventHandler_ = nullptr;
65     wptr<QuickFixManagerService> quickFixMgrService_ = nullptr;
66     std::string bundleName_;
67     int bundleVersionCode_ = 0;
68     int patchVersionCode_ = 0;
69     bool isRunning_ = false;
70     bool isSoContained_ = false;
71     AppExecFwk::QuickFixType type_ = AppExecFwk::QuickFixType::UNKNOWN;
72     std::vector<std::string> moduleNames_;
73 };
74 } // namespace AAFwk
75 } // namespace OHOS
76 #endif // OHOS_ABILITY_RUNTIME_QUICK_FIX_MANAGER_APPLY_TASK_H
77