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_BUNDLEMANAGER_BUNDLE_FRAMEWORK_SERVICE_BUNDLEMGR_INCLUDE_VERIFY_VERIFY_MANAGER_PROXY_H 17 #define FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_SERVICE_BUNDLEMGR_INCLUDE_VERIFY_VERIFY_MANAGER_PROXY_H 18 19 #include <mutex> 20 #include <shared_mutex> 21 #include "verify_manager_host.h" 22 23 namespace OHOS { 24 namespace AppExecFwk { 25 class VerifyManagerHostImpl : public VerifyManagerHost { 26 public: 27 VerifyManagerHostImpl(); 28 virtual ~VerifyManagerHostImpl(); 29 30 ErrCode Verify(const std::vector<std::string> &abcPaths) override; 31 32 ErrCode DeleteAbc(const std::string &path) override; 33 34 private: 35 ErrCode InnerVerify(const std::string &bundleName, 36 const std::vector<std::string> &abcPaths); 37 bool CopyFilesToTempDir(const std::string &bundleName, int32_t userId, 38 const std::vector<std::string> &abcPaths); 39 bool VerifyAbc(const std::vector<std::string> &abcPaths); 40 bool MoveAbc(const std::string &bundleName, 41 const std::vector<std::string> &abcPaths); 42 void Rollback(const std::vector<std::string> &paths); 43 bool GetFileName(const std::string &sourcePath, std::string &fileName); 44 bool GetFileDir(const std::string &sourcePath, std::string &fileDir); 45 void RemoveTempFiles(const std::string &bundleName); 46 void RemoveTempFiles(const std::vector<std::string> &paths); 47 bool VerifyAbc( 48 const std::string &rootDir, const std::vector<std::string> &names); 49 bool CheckFileParam(const std::vector<std::string> &abcPaths); 50 void Rollback(const std::string &rootDir, const std::vector<std::string> &names); 51 ErrCode MkdirIfNotExist(const std::string &dir); 52 std::mutex &GetBundleMutex(const std::string &bundleName); 53 std::string GetRealPath(const std::string &bundleName, 54 int32_t userId, const std::string &relativePath); 55 bool GetCallingBundleName(std::string &bundleName); 56 57 std::atomic<uint32_t> id_ = 0; 58 // using for locking by bundleName 59 std::unordered_map<std::string, std::mutex> bundleMutexMap_; 60 mutable std::shared_mutex bundleMutex_; 61 }; 62 } // AppExecFwk 63 } // OHOS 64 #endif // FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_SERVICE_BUNDLEMGR_INCLUDE_VERIFY_VERIFY_MANAGER_PROXY_H 65