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_BUNDLE_OVERLAY_INSTALL_CHECKER_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_OVERLAY_INSTALL_CHECKER_H
18 
19 #include <map>
20 #include <string>
21 
22 #include "inner_bundle_info.h"
23 
24 namespace OHOS {
25 namespace AppExecFwk {
26 class BundleOverlayInstallChecker final {
27 public:
28     BundleOverlayInstallChecker() = default;
29     virtual ~BundleOverlayInstallChecker() = default;
30 
31     ErrCode CheckOverlayInstallation(std::unordered_map<std::string, InnerBundleInfo> &newInfos, int32_t userId,
32         int32_t &overlayType);
33     ErrCode CheckInternalBundle(const std::unordered_map<std::string, InnerBundleInfo> &newInfos,
34         const InnerBundleInfo &innerBundleInfo) const;
35     ErrCode CheckExternalBundle(const InnerBundleInfo &innerBundleInfo, int32_t userId) const;
36     ErrCode CheckTargetBundle(const std::string &targetBundleName, const std::string &targetModuleName,
37         const std::string &fingerprint, int32_t userId) const;
38     ErrCode CheckOverlayUpdate(const InnerBundleInfo &oldInfo, const InnerBundleInfo &newInfo, int32_t userId) const;
39 
40 private:
41     ErrCode CheckHapType(const InnerBundleInfo &info) const;
42     ErrCode CheckBundleType(const InnerBundleInfo &info) const;
43     ErrCode CheckTargetPriority(int32_t priority) const;
44     ErrCode CheckVersionCode(const std::unordered_map<std::string, InnerBundleInfo> &newInfos,
45         const InnerBundleInfo &info) const;
46     ErrCode CheckTargetModule(const std::string &bundleName, const std::string &targetModuleName) const;
47 };
48 } // AppExecFwk
49 } // OHOS
50 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_OVERLAY_INSTALL_CHECKER_H