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 INTERFACES_INNER_API_BUNDLE_MANAGER_INCLUDE_BUNDLE_MANAGER_PROXY_H 17 #define INTERFACES_INNER_API_BUNDLE_MANAGER_INCLUDE_BUNDLE_MANAGER_PROXY_H 18 #include "enterprise_device_mgr_proxy.h" 19 #include "install_param.h" 20 21 #include "edm_bundle_info.h" 22 #include "func_code.h" 23 24 namespace OHOS { 25 namespace EDM { 26 class BundleManagerProxy { 27 public: 28 BundleManagerProxy(); 29 ~BundleManagerProxy(); 30 static std::shared_ptr<BundleManagerProxy> GetBundleManagerProxy(); 31 int32_t AddBundlesByPolicyType(AppExecFwk::ElementName &admin, std::vector<std::string> &bundles, int32_t userId, 32 int32_t policyType); 33 int32_t RemoveBundlesByPolicyType(AppExecFwk::ElementName &admin, std::vector<std::string> &bundles, int32_t userId, 34 int32_t policyType); 35 int32_t GetBundlesByPolicyType(AppExecFwk::ElementName &admin, int32_t userId, std::vector<std::string> &bundles, 36 int32_t policyType); 37 int32_t Uninstall(AppExecFwk::ElementName &admin, std::string bundleName, int32_t userId, bool isKeepData, 38 std::string &retMessage); 39 int32_t Install(AppExecFwk::ElementName &admin, std::vector<std::string> &hapFilePaths, 40 AppExecFwk::InstallParam &installParam, std::string &retMessage); 41 int32_t GetInstalledBundleInfoList(AppExecFwk::ElementName &admin, int32_t userId, 42 std::vector<EdmBundleInfo> &bundleInfos); 43 int32_t AddOrRemoveInstallationAllowedAppDistributionTypes(MessageParcel &data, FuncOperateType operateType); 44 int32_t GetInstallationAllowedAppDistributionTypes(MessageParcel &data, 45 std::vector<int32_t> &installationAllowedAppDistributionTypes); 46 private: 47 void AddPolicyTypeMap(); 48 static std::shared_ptr<BundleManagerProxy> instance_; 49 static std::once_flag flag_; 50 std::map<int32_t, uint32_t> policyTypeMap_; 51 ErrCode WriteFileToInner(MessageParcel &reply, const std::string &realPath, std::vector<std::string> &servicePaths, 52 std::string &errMessage); 53 ErrCode WriteFileToStream(AppExecFwk::ElementName &admin, const std::string &path, 54 std::vector<std::string> &servicePaths, std::string &errMessage); 55 ErrCode checkHapFilePath(const std::string &hapFilePath, std::string &fileName, std::string &realPath, 56 std::string &errMessage); 57 58 ErrCode InnerGetVectorFromParcelIntelligent(MessageParcel &reply, std::vector<EdmBundleInfo> &parcelableInfos); 59 ErrCode GetParcelInfoFromAshMem(MessageParcel &reply, void *&data); 60 bool GetData(void *&buffer, size_t size, const void *data); 61 bool ContainerSecurityVerify(MessageParcel &parcel, int32_t infoSize, std::vector<EdmBundleInfo> &parcelables); 62 }; 63 } // namespace EDM 64 } // namespace OHOS 65 #endif // INTERFACES_INNER_API_BUNDLE_MANAGER_INCLUDE_BUNDLE_MANAGER_PROXY_H