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 RemoveSession(uint32_t sessionId)37 void RemoveSession(uint32_t sessionId) 38 { 39 if (sessionsMgr_ == nullptr) { 40 return; 41 } 42 sessionsMgr_->RemoveSession(sessionId); 43 } 44 45 protected: 46 napi_value StartSession(napi_env env, napi_callback_info info, SessionParams &sessionParams, 47 IUpdateSession::DoWorkFunction function); 48 49 napi_value StartParamErrorSession(napi_env env, napi_callback_info info, CALLBACK_POSITION callbackPosition); 50 51 void NotifyEventInfo(const EventInfo &eventInfo); 52 53 std::shared_ptr<SessionManager> sessionsMgr_; 54 }; 55 } // namespace UpdateEngine 56 } // namespace OHOS 57 #endif // UPDATER_INTERFACE_H