1 /* 2 * Copyright (c) 2021 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 24 namespace OHOS { 25 namespace AppExecFwk { 26 class InstalldService { 27 public: 28 InstalldService(); 29 virtual ~InstalldService(); 30 /** 31 * @brief Start the installd service. 32 * @return 33 */ 34 void Start(); 35 /** 36 * @brief Stop the installd service. 37 * @return 38 */ 39 void Stop(); 40 /** 41 * @brief Check whether if the installd service is ready. 42 * @return Returns true if the installd service is ready; returns false otherwise. 43 */ IsServiceReady()44 bool IsServiceReady() const 45 { 46 return isReady_; 47 } 48 49 private: 50 /** 51 * @brief Initialize the installd service context. 52 * @return Returns true if initialized successfully; returns false otherwise. 53 */ 54 bool Init(); 55 /** 56 * @brief Initialize to create a directory. 57 * @param path Indicates the directory path to create. 58 * @return Returns true if directory created successfully; returns false otherwise. 59 */ 60 bool InitDir(const std::string &path); 61 62 private: 63 bool isReady_ = false; 64 sptr<InstalldHostImpl> hostImpl_; 65 66 DISALLOW_COPY_AND_MOVE(InstalldService); 67 }; 68 } // namespace AppExecFwk 69 } // namespace OHOS 70 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INSTALLD_SERVICE_H