• 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 <bitset>
19 #include <random>
20 #include <string>
21 #include <vector>
22 
23 #include "unified_data.h"
24 #include "unified_meta.h"
25 
26 namespace OHOS {
27 namespace UDMF {
28 class PreProcessUtils {
29 public:
30     static int32_t RuntimeDataImputation(UnifiedData &data, CustomOption &option);
31     static std::string GenerateId();
32     static time_t GetTimestamp();
33     static int32_t GetHapUidByToken(uint32_t tokenId, int &userId);
34     static bool GetHapBundleNameByToken(int tokenId, std::string &bundleName);
35     static bool GetNativeProcessNameByToken(int tokenId, std::string &processName);
36     static std::string GetLocalDeviceId();
37     static void SetRemoteData(UnifiedData &data);
38     static int32_t SetRemoteUri(uint32_t tokenId, UnifiedData &data);
39     static bool GetInstIndex(uint32_t tokenId, int32_t &instIndex);
40     static bool IsNetworkingEnabled();
41     static void ProcessFileType(std::vector<std::shared_ptr<UnifiedRecord>> records,
42         std::function<bool(std::shared_ptr<Object>)> callback);
43 private:
44     static bool CheckUriAuthorization(const std::vector<std::string>& uris, uint32_t tokenId);
45     static int32_t GetDfsUrisFromLocal(const std::vector<std::string> &uris, int32_t userId, UnifiedData &data);
46     static bool IsFileType(std::shared_ptr<UnifiedRecord> record);
47 };
48 } // namespace UDMF
49 } // namespace OHOS
50 #endif // UDMF_PREPROCESS_UTILS_H