只有一个extension的时候,直接拉起

Signed-off-by: wangjiaqiang <wangjiaqiang11@huawei.com>
This commit is contained in:
wangjiaqiang 2024-08-24 19:33:23 +08:00
parent 1ddf7c5d63
commit f755d664a7
3 changed files with 13 additions and 2 deletions

View File

@ -66,12 +66,18 @@ int DataProviderConfig::GetFromProxyData()
return errCode;
}
providerInfo_.singleton = bundleInfo.singleton;
int datashareExtensionCount = 0;
for (auto &item : bundleInfo.extensionInfos) {
if (item.type != AppExecFwk::ExtensionAbilityType::DATASHARE) {
continue;
}
providerInfo_.hasExtension = true;
break;
++datashareExtensionCount;
providerInfo_.extensionUri = item.uri;
if (datashareExtensionCount > 1) {
providerInfo_.extensionUri = "";
break;
}
}
for (auto &hapModuleInfo : bundleInfo.hapModuleInfos) {
auto &proxyDatas = hapModuleInfo.proxyDatas;

View File

@ -41,6 +41,7 @@ public:
std::string writePermission;
std::string type = "rdb";
std::string backup;
std::string extensionUri;
bool singleton = false;
bool hasExtension = false;
bool allowEmptyPermission = false;

View File

@ -1043,7 +1043,11 @@ std::pair<int32_t, int32_t> DataShareServiceImpl::ExecuteEx(const std::string &u
return std::make_pair(ERROR_PERMISSION_DENIED, 0);
}
DataShareDbConfig dbConfig;
DataShareDbConfig::DbConfig config {providerInfo.uri, extUri, providerInfo.bundleName,
std::string extensionUri = extUri;
if (extensionUri.empty()) {
extensionUri = providerInfo.extensionUri;
}
DataShareDbConfig::DbConfig config {providerInfo.uri, extensionUri, providerInfo.bundleName,
providerInfo.storeName, providerInfo.backup,
providerInfo.singleton ? 0 : providerInfo.currentUserId, providerInfo.hasExtension};
auto [code, metaData, dbDelegate] = dbConfig.GetDbConfig(config);