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_DRIVER_DRIVER_DRIVER_INSTALLER_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_DRIVER_DRIVER_DRIVER_INSTALLER_H
18 #include <unordered_map>
19 
20 #include "application_info.h"
21 #include "inner_bundle_info.h"
22 
23 namespace OHOS {
24 namespace AppExecFwk {
25 class DriverInstaller {
26 public:
27     DriverInstaller() = default;
28     ~DriverInstaller() = default;
29 
30     ErrCode CopyAllDriverFile(const std::unordered_map<std::string, InnerBundleInfo> &newInfos,
31         const InnerBundleInfo &oldInfo) const;
32 
33     ErrCode FilterDriverSoFile(const InnerBundleInfo &info, const Metadata &meta,
34         std::unordered_multimap<std::string, std::string> &dirMap, bool isModuleExisted) const;
35 
36     void RemoveDriverSoFile(const InnerBundleInfo &info, const std::string &moduleName, bool isModuleExisted) const;
37 
38     std::string CreateDriverSoDestinedDir(const std::string &bundleName, const std::string &moduleName,
39         const std::string &fileName, const std::string &destinedDir, bool isModuleExisted) const;
40 
41 private:
42     ErrCode CopyDriverSoFile(const InnerBundleInfo &info, const std::string &srcPath, bool isModuleExisted) const;
43 
44     void RemoveAndReNameDriverFile(const std::unordered_map<std::string, InnerBundleInfo> &newInfos,
45         const InnerBundleInfo &oldInfo) const;
46 
47     void RenameDriverFile(const InnerBundleInfo &info) const;
48 };
49 } // AppExecFwk
50 } // OHOS
51 #endif  // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_DRIVER_DRIVER_DRIVER_INSTALLER_H
52