1 /* 2 * Copyright (c) 2021-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 OHOS_BUNDLEMS_SLITE_CLIENT_H 17 #define OHOS_BUNDLEMS_SLITE_CLIENT_H 18 19 #include "nocopyable.h" 20 #include "want.h" 21 #include "bundle_install_msg.h" 22 #include "bundle_service_interface.h" 23 24 namespace OHOS { 25 class BundleMsClient { 26 public: GetInstance()27 static BundleMsClient &GetInstance() 28 { 29 static BundleMsClient instance; 30 return instance; 31 } 32 33 ~BundleMsClient() = default; 34 35 bool Initialize() const; 36 37 bool Install(const char *hapPath, const InstallParam *installParam, InstallerCallback installerCallback) const; 38 39 bool Uninstall(const char *bundleName, const InstallParam *installParam, InstallerCallback installerCallback) const; 40 41 uint8_t QueryAbilityInfo(const Want *want, AbilityInfo *abilityInfo) const; 42 43 uint8_t GetBundleInfo(const char *bundleName, int32_t flags, BundleInfo *bundleInfo) const; 44 45 uint8_t GetBundleInfos(int32_t flags, BundleInfo **bundleInfos, int32_t *len) const; 46 47 bool GetInstallState(const char *bundleName, InstallState *installState, uint8_t *installProcess) const; 48 49 uint32_t GetBundleSize(const char *bundleName) const; 50 51 bool RegisterInstallerCallback(InstallerCallback installerCallback) const; 52 53 void UpdateBundleInfoList() const; 54 55 uint8_t GetBundleInfosNoReplication(const int flags, BundleInfo **bundleInfos, int32_t *len) const; 56 57 uint8_t QueryAbilityInfos(const Want *want, AbilityInfo **abilityInfo, int32_t *len) const; 58 59 PreAppList *InitPreAppInfo(void) const; 60 61 void InsertPreAppInfo(const char *filePath, PreAppList *list) const; 62 63 void SetPreAppInfo(PreAppList *list) const; 64 65 bool RegisterEvent(InstallerCallback installerCallback) const; 66 67 bool UnregisterEvent(InstallerCallback installerCallback) const; 68 69 private: 70 BundleMsClient() = default; 71 72 BmsSliteInterface *bmsProxy_ { nullptr }; 73 74 DISALLOW_COPY_AND_MOVE(BundleMsClient); 75 }; 76 } // namespace OHOS 77 78 #endif // OHOS_BUNDLEMS_SLITE_CLIENT_H