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 namespace OHOS {
22 namespace EDM {
23 class BundleManagerProxy {
24 public:
25     BundleManagerProxy();
26     ~BundleManagerProxy();
27     static std::shared_ptr<BundleManagerProxy> GetBundleManagerProxy();
28     int32_t AddBundlesByPolicyType(AppExecFwk::ElementName &admin, std::vector<std::string> &bundles, int32_t userId,
29         int32_t policyType);
30     int32_t RemoveBundlesByPolicyType(AppExecFwk::ElementName &admin, std::vector<std::string> &bundles, int32_t userId,
31         int32_t policyType);
32     int32_t GetBundlesByPolicyType(AppExecFwk::ElementName &admin, int32_t userId, std::vector<std::string> &bundles,
33         int32_t policyType);
34     int32_t Uninstall(AppExecFwk::ElementName &admin, std::string bundleName, int32_t userId, bool isKeepData,
35         std::string &retMessage);
36     int32_t Install(AppExecFwk::ElementName &admin, std::vector<std::string> &hapFilePaths,
37         AppExecFwk::InstallParam &installParam, std::string &retMessage);
38 
39 private:
40     void AddPolicyTypeMap();
41     static std::shared_ptr<BundleManagerProxy> instance_;
42     static std::mutex mutexLock_;
43     std::map<int32_t, uint32_t> policyTypeMap_;
44     ErrCode WriteFileToInner(MessageParcel &reply, const std::string &realPath, std::vector<std::string> &servicePaths,
45         std::string &errMessage);
46     ErrCode WriteFileToStream(AppExecFwk::ElementName &admin, const std::string &path,
47         std::vector<std::string> &servicePaths, std::string &errMessage);
48     ErrCode checkHapFilePath(const std::string &hapFilePath, std::string &fileName, std::string &realPath,
49         std::string &errMessage);
50 };
51 } // namespace EDM
52 } // namespace OHOS
53 #endif // INTERFACES_INNER_API_BUNDLE_MANAGER_INCLUDE_BUNDLE_MANAGER_PROXY_H