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 UPDATER_INTERFACE_H 17 #define UPDATER_INTERFACE_H 18 19 #include <memory> 20 #include "client_helper.h" 21 #include "iupdate_session.h" 22 #include "napi_util.h" 23 #include "session_manager.h" 24 25 namespace OHOS { 26 namespace UpdateEngine { 27 class IUpdater { 28 public: ~IUpdater()29 virtual ~IUpdater() {} 30 31 napi_value On(napi_env env, napi_callback_info info); 32 33 napi_value Off(napi_env env, napi_callback_info info); 34 35 virtual void GetUpdateResult(SessionType type, UpdateResult &result); 36 NotifyCheckVersionDone(const BusinessError & businessError,const CheckResult & checkResult)37 virtual void NotifyCheckVersionDone(const BusinessError &businessError, const CheckResult &checkResult) {}; 38 RemoveSession(uint32_t sessionId)39 void RemoveSession(uint32_t sessionId) 40 { 41 if (sessionsMgr_ == nullptr) { 42 return; 43 } 44 sessionsMgr_->RemoveSession(sessionId); 45 } 46 47 protected: 48 napi_value StartSession(napi_env env, napi_callback_info info, SessionParams &sessionParams, 49 IUpdateSession::DoWorkFunction function); 50 51 napi_value StartParamErrorSession(napi_env env, napi_callback_info info, CALLBACK_POSITION callbackPosition); 52 53 void NotifyEventInfo(const EventInfo &eventInfo); 54 55 std::shared_ptr<SessionManager> sessionsMgr_; 56 }; 57 } // namespace UpdateEngine 58 } // namespace OHOS 59 #endif // UPDATER_INTERFACE_H