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 DATA_SHARE_CALLED_CONFIG_H
17 #define DATA_SHARE_CALLED_CONFIG_H
18 
19 #include <cstdint>
20 #include <memory>
21 #include <string>
22 
23 #include "bundle_info.h"
24 #include "bundle_mgr_proxy.h"
25 
26 namespace OHOS {
27 namespace DataShare {
28 class DataShareCalledConfig {
29 public:
30     explicit DataShareCalledConfig(const std::string &uri);
31     ~DataShareCalledConfig() = default;
32 
33     struct ProviderInfo {
34         std::string uri;
35         std::string bundleName;
36         std::string moduleName;
37         std::string readPermission;
38         std::string writePermission;
39         int32_t currentUserId = -1;
40     };
41     std::pair<int, ProviderInfo> GetProviderInfo(uint32_t tokenId);
42 private:
43     int GetFromProxyData();
44     int32_t GetUserByToken(uint32_t tokenId);
45     std::pair<bool, OHOS::AppExecFwk::BundleInfo> GetBundleInfoFromBMS();
46     ProviderInfo providerInfo_;
47     static constexpr const char *PROXY_URI_SCHEMA = "datashareproxy";
48 };
49 } // namespace DataShare
50 } // namespace OHOS
51 #endif // DATA_SHARE_CALLED_CONFIG_H