!522 修复部分检视出的问题

Merge pull request !522 from 杨抑/master
This commit is contained in:
openharmony_ci 2024-11-22 08:42:55 +00:00 committed by Gitee
commit ba4cb9c9cd
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 15 additions and 10 deletions

View File

@ -418,10 +418,13 @@ bool UpdatePrinterInfoWithDiscovery(PrinterInfo &info, const Print_DiscoveryItem
option["printerName"] = name;
option["printerUri"] = std::string(discoveryItem->printerUri);
option["make"] = std::string(discoveryItem->makeAndModel);
nlohmann::json detailInfo = nlohmann::json::parse(std::string(discoveryItem->detailInfo));
if (detailInfo != nullptr && detailInfo.contains("bsunidriver_support") &&
detailInfo["bsunidriver_support"].is_string()) {
option["bsunidriverSupport"] = std::string(detailInfo["bsunidriver_support"]);
std::string detailInfoStr = std::string(discoveryItem->detailInfo);
if (nlohmann::json::accept(detailInfoStr)) {
nlohmann::json detailInfo = nlohmann::json::parse(detailInfoStr);
if (!detailInfo.is_null() && detailInfo.contains("bsunidriver_support") &&
detailInfo["bsunidriver_support"].is_string()) {
option["bsunidriverSupport"] = detailInfo["bsunidriver_support"].get<std::string>();
}
}
info.SetOption(option.dump());
}

View File

@ -20,8 +20,6 @@
#include "vendor_ipp_everywhere.h"
#include "vendor_ppd_driver.h"
#include "print_log.h"
#include "vendor_ppd_driver.h"
#include "print_utils.h"
#include "print_utils.h"
using namespace OHOS::Print;
@ -469,7 +467,11 @@ bool VendorManager::IsPrivatePpdDriver(const std::string &vendorName, const Prin
PRINT_HILOGD("IsPrivatePpdDriver vendorName=%{public}s", vendorName.c_str());
PRINT_HILOGD("IsPrivatePpdDriver printerName=%{public}s", printerInfo.GetPrinterName().c_str());
if (vendorName == "driver.bsuni") {
nlohmann::json option = nlohmann::json::parse(std::string(printerInfo.GetOption()));
std::string optionStr = std::string(printerInfo.GetOption());
if (!nlohmann::json::accept(optionStr)) {
return false;
}
nlohmann::json option = nlohmann::json::parse(optionStr);
if (option != nullptr && option.contains("bsunidriverSupport") && option["bsunidriverSupport"].is_string()) {
PRINT_HILOGD("IsPrivatePpdDriver bsunidriverSupport=%{public}s",
std::string(option["bsunidriverSupport"]).c_str());

View File

@ -35,10 +35,10 @@ public:
MOCK_METHOD0(ClearConnectingPrinter, void ());
MOCK_METHOD2(QueryPrinterCapabilityByUri, bool (const std::string &, PrinterCapability &));
MOCK_METHOD2(QueryPrinterStatusByUri, bool (const std::string &, PrinterStatus &));
MOCK_METHOD2(QueryDiscoveredPrinterInfoById, std::shared_ptr<PrinterInfo>(const std::string &,
MOCK_METHOD2(QueryDiscoveredPrinterInfoById, std::shared_ptr<PrinterInfo> (const std::string &,
const std::string &));
MOCK_METHOD3(QueryPrinterInfoByPrinterId, int32_t(const std::string &, const std::string &, PrinterInfo &));
MOCK_METHOD2(QueryPPDInformation, bool(const char *, std::vector<std::string> &));
MOCK_METHOD3(QueryPrinterInfoByPrinterId, int32_t (const std::string &, const std::string &, PrinterInfo &));
MOCK_METHOD2(QueryPPDInformation, bool (const char *, std::vector<std::string> &));
};
} // namespace Print
} // namespace OHOS