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 #ifndef UDMF_PREPROCESS_UTILS_H 16 #define UDMF_PREPROCESS_UTILS_H 17 18 #include "bundlemgr/bundle_mgr_proxy.h" 19 #include "unified_data.h" 20 21 namespace OHOS { 22 namespace UDMF { 23 class PreProcessUtils { 24 public: 25 static int32_t FillRuntimeInfo(UnifiedData &data, CustomOption &option); 26 static std::string GenerateId(); 27 static time_t GetTimestamp(); 28 static int32_t GetHapUidByToken(uint32_t tokenId, int &userId); 29 static bool GetHapBundleNameByToken(uint32_t tokenId, std::string &bundleName); 30 static bool GetNativeProcessNameByToken(uint32_t tokenId, std::string &processName); 31 static std::string GetLocalDeviceId(); 32 static void SetRemoteData(UnifiedData &data); 33 static int32_t SetRemoteUri(uint32_t tokenId, UnifiedData &data); 34 static bool GetInstIndex(uint32_t tokenId, int32_t &instIndex); 35 static bool IsNetworkingEnabled(); 36 static void ProcessFileType(std::vector<std::shared_ptr<UnifiedRecord>> records, 37 std::function<bool(std::shared_ptr<Object>)> callback); 38 static void GetHtmlFileUris(uint32_t tokenId, UnifiedData &data, bool isLocal, std::vector<std::string> &uris); 39 static void ClearHtmlDfsUris(UnifiedData &data); 40 static void ProcessHtmlFileUris(uint32_t tokenId, UnifiedData &data, bool isLocal, std::vector<Uri> &uris); 41 static void ProcessRecord(std::shared_ptr<UnifiedRecord> record, uint32_t tokenId, 42 bool isLocal, std::vector<std::string> &uris); 43 static void SetRecordUid(UnifiedData &data); 44 static bool GetDetailsFromUData(const UnifiedData &data, UDDetails &details); 45 static Status GetSummaryFromDetails(const UDDetails &details, Summary &summary); 46 static bool GetSpecificBundleNameByTokenId(uint32_t tokenId, std::string &specificBundleName, 47 std::string &bundleName); 48 static sptr<AppExecFwk::IBundleMgr> GetBundleMgr(); 49 private: 50 static bool CheckUriAuthorization(const std::vector<std::string>& uris, uint32_t tokenId); 51 static int32_t GetDfsUrisFromLocal(const std::vector<std::string> &uris, int32_t userId, UnifiedData &data); 52 static std::string GetSdkVersionByToken(uint32_t tokenId); 53 static bool GetSpecificBundleName(const std::string &bundleName, int32_t appIndex, std::string &specificBundleName); 54 }; 55 } // namespace UDMF 56 } // namespace OHOS 57 #endif // UDMF_PREPROCESS_UTILS_H