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 16 #ifndef DATASHARESERVICE_CONTEXT_H 17 #define DATASHARESERVICE_CONTEXT_H 18 19 #include <algorithm> 20 #include <list> 21 #include <memory> 22 #include <string> 23 #include <vector> 24 25 #include "bundle_mgr_proxy.h" 26 27 namespace OHOS::DataShare { 28 enum AccessSystemMode : uint8_t { 29 UNDEFINED, 30 USER_SHARED_MODE, 31 USER_SINGLE_MODE, 32 MAX, 33 }; 34 class Context { 35 public: Context()36 explicit Context() {} Context(const std::string & uri)37 explicit Context(const std::string &uri) : uri(uri) {} ~Context()38 virtual ~Context() 39 { 40 if (secretMetaKey.size() > 0) { 41 std::fill(secretMetaKey.begin(), secretMetaKey.end(), '\0'); 42 } 43 } 44 45 std::string uri; 46 int32_t currentUserId = -1; 47 int32_t visitedUserId = -1; 48 int32_t appIndex = 0; 49 int32_t haMode = 0; 50 std::string permission; 51 uint32_t callerTokenId = 0; 52 uint32_t calledTokenId = 0; 53 std::string callerBundleName; 54 std::string calledBundleName; 55 std::string calledModuleName; 56 std::string calledStoreName; 57 std::string calledTableName; 58 std::string calledSourceDir; // the dir of db 59 std::string secretMetaKey; 60 int version = -1; 61 int errCode = -1; 62 bool isRead = false; 63 bool isAllowCrossPer = false; // can cross permission check, for special SA 64 bool needAutoLoadCallerBundleName = false; 65 bool isEncryptDb = false; 66 AccessSystemMode accessSystemMode = AccessSystemMode::UNDEFINED; 67 BundleConfig bundleInfo; 68 std::string type = "rdb"; 69 }; 70 } // namespace OHOS::DataShare 71 #endif // DATASHARESERVICE_CONTEXT_H 72