1 /*
2  * Copyright (c) 2024 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 OHOS_AAFWK_FILE_PERMISSION_MANAGER
17 #define OHOS_AAFWK_FILE_PERMISSION_MANAGER
18 
19 #include <deque>
20 #include <string>
21 #include <vector>
22 #include "uri.h"
23 
24 #ifdef ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER
25 #include "sandbox_manager_kit.h"
26 #include "policy_info.h"
27 #else
28 #include "upms_policy_info.h"
29 #endif
30 
31 namespace OHOS {
32 namespace AAFwk {
33 #ifdef ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER
34 using namespace AccessControl::SandboxManager;
35 #endif
36 typedef enum OperationMode {
37     READ_MODE = 1 << 0,
38     WRITE_MODE = 1 << 1,
39 } OperationMode;
40 
41 class FilePermissionManager {
42 public:
43     static std::vector<bool>
44     CheckUriPersistentPermission(std::vector<Uri> &uriVec,
45                                  uint32_t callerTokenId, uint32_t flag,
46                                  std::vector<PolicyInfo> &pathPolicies, const std::string &bundleName);
47 
48     static PolicyInfo GetPathPolicyInfoFromUri(Uri &uri, uint32_t flag, const std::string &bundleName = "");
49 };
50 } // namespace AAFwk
51 } // namespace OHOS
52 #endif // OHOS_AAFWK_FILE_PERMISSION_MANAGER
53