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