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 #ifndef SYS_INSTALLER_SERVER_H 16 #define SYS_INSTALLER_SERVER_H 17 18 #include <iostream> 19 #include <thread> 20 #include "if_system_ability_manager.h" 21 #include "sys_installer_manager.h" 22 #include "stream_installer_manager.h" 23 #include "ipc_skeleton.h" 24 #include "iremote_stub.h" 25 #include "isys_installer.h" 26 #include "status_manager.h" 27 #include "stream_status_manager.h" 28 #include "system_ability.h" 29 #include "sys_installer_common.h" 30 #include "sys_installer_stub.h" 31 32 namespace OHOS { 33 namespace SysInstaller { 34 class SysInstallerServer : public SystemAbility, public SysInstallerStub { 35 public: 36 DECLARE_SYSTEM_ABILITY(SysInstallerServer); 37 DISALLOW_COPY_AND_MOVE(SysInstallerServer); 38 SysInstallerServer(int32_t systemAbilityId, bool runOnCreate = false); 39 ~SysInstallerServer() override; 40 41 int32_t SysInstallerInit(bool bStreamUpgrade = false) override; 42 int32_t StartUpdatePackageZip(const std::string &pkgPath) override; 43 int32_t StartStreamUpdate() override; 44 int32_t StopStreamUpdate() override; 45 int32_t ProcessStreamData(const uint8_t *buffer, size_t size) override; 46 int32_t SetUpdateCallback(const sptr<ISysInstallerCallback> &updateCallback) override; 47 int32_t GetUpdateStatus() override; 48 int32_t StartUpdateParaZip(const std::string &pkgPath, 49 const std::string &location, const std::string &cfgDir) override; 50 int32_t StartDeleteParaZip(const std::string &location, const std::string &cfgDir) override; 51 int32_t AccDecompressAndVerifyPkg(const std::string &srcPath, 52 const std::string &dstPath, const uint32_t type) override; 53 int32_t AccDeleteDir(const std::string &dstPath) override; 54 55 #ifndef UPDATER_UT 56 private: 57 #else 58 public: 59 #endif 60 void OnStart() override; 61 void OnStop() override; 62 63 private: 64 bool logInit_ = false; 65 bool bStreamUpgrade_ = false; 66 std::mutex sysInstallerServerLock_; 67 }; 68 } // namespace SysInstaller 69 } // namespace OHOS 70 #endif // SYS_INSTALLER_SERVER_H 71