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 SYS_INSTALLER_I_ACTION_H 17 #define SYS_INSTALLER_I_ACTION_H 18 19 #include <cstdio> 20 #include "error_code.h" 21 #include "sys_installer_common.h" 22 23 namespace OHOS { 24 namespace SysInstaller { 25 using ActionCallbackFun = std::function<void (InstallerErrCode, const std::string &)>; 26 27 class IAction { 28 public: 29 IAction() = default; 30 virtual ~IAction() = default; 31 SetCallback(ActionCallbackFun actionCallBack)32 virtual void SetCallback(ActionCallbackFun actionCallBack) 33 { 34 actionCallBack_ = actionCallBack; 35 } 36 virtual void PerformAction() = 0; 37 virtual std::string GetActionName() = 0; TerminateAction()38 virtual void TerminateAction() {}; SuspendAction()39 virtual void SuspendAction() {} ResumeAction()40 virtual void ResumeAction() {} GetErrorStr()41 virtual std::string GetErrorStr() 42 { 43 return ""; 44 } 45 46 protected: 47 ActionCallbackFun actionCallBack_; 48 }; 49 } // SysInstaller 50 } // namespace OHOS 51 #endif // SYS_INSTALLER_I_ACTION_H 52