1 /* 2 * Copyright (c) 2023 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 FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INSTALLD_SERVICE_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INSTALLD_SERVICE_H 18 19 #include <memory> 20 21 #include "installd/installd_host_impl.h" 22 #include "ipc/installd_host.h" 23 #include "system_ability.h" 24 25 namespace OHOS { 26 namespace AppExecFwk { 27 class InstalldService : public SystemAbility { 28 29 DECLARE_SYSTEM_ABILITY(InstalldService); 30 31 public: 32 InstalldService(int32_t saId, bool runOnCreate); 33 InstalldService(); 34 virtual ~InstalldService(); 35 36 void OnStart() override; 37 38 void OnStop() override; 39 40 /** 41 * @brief Start the installd service. 42 * @return 43 */ 44 void Start(); 45 /** 46 * @brief Stop the installd service. 47 * @return 48 */ 49 void Stop(); 50 /** 51 * @brief Check whether if the installd service is ready. 52 * @return Returns true if the installd service is ready; returns false otherwise. 53 */ IsServiceReady()54 bool IsServiceReady() const 55 { 56 return isReady_; 57 } 58 59 private: 60 /** 61 * @brief Initialize the installd service context. 62 * @return Returns true if initialized successfully; returns false otherwise. 63 */ 64 bool Init(); 65 /** 66 * @brief Initialize to create a directory. 67 * @param path Indicates the directory path to create. 68 * @return Returns true if directory created successfully; returns false otherwise. 69 */ 70 bool InitDir(const std::string &path); 71 72 private: 73 bool isReady_ = false; 74 sptr<InstalldHostImpl> hostImpl_; 75 76 DISALLOW_COPY_AND_MOVE(InstalldService); 77 }; 78 } // namespace AppExecFwk 79 } // namespace OHOS 80 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INSTALLD_SERVICE_H