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