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