!86 增加打印企业管控

Merge pull request !86 from jsclpan/master
This commit is contained in:
openharmony_ci 2023-06-30 07:41:48 +00:00 committed by Gitee
commit a10a61e728
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 25 additions and 2 deletions

View File

@ -33,6 +33,7 @@
"core_service", "core_service",
"distributed_notification_service", "distributed_notification_service",
"drivers_interface_ril", "drivers_interface_ril",
"enterprise_device_management",
"eventhandler", "eventhandler",
"hisysevent", "hisysevent",
"hitrace", "hitrace",

View File

@ -8,7 +8,8 @@
"secon" : "u:r:print_service:s0", "secon" : "u:r:print_service:s0",
"permission" : [ "permission" : [
"ohos.permission.securityguard.REPORT_SECURITY_INFO", "ohos.permission.securityguard.REPORT_SECURITY_INFO",
"ohos.permission.MANAGE_PRINT_JOB" "ohos.permission.MANAGE_PRINT_JOB",
"ohos.permission.ENTERPRISE_RESTRICT_POLICY"
] ]
} }
] ]

View File

@ -60,6 +60,7 @@ ohos_shared_library("print_service") {
"core_service:tel_core_service_api", "core_service:tel_core_service_api",
"distributed_notification_service:ans_innerkits", "distributed_notification_service:ans_innerkits",
"drivers_interface_ril:hril_innerkits", "drivers_interface_ril:hril_innerkits",
"enterprise_device_management:edmservice_kits",
"eventhandler:libeventhandler", "eventhandler:libeventhandler",
"hilog:libhilog", "hilog:libhilog",
"hisysevent:libhisysevent", "hisysevent:libhisysevent",

View File

@ -95,6 +95,7 @@ private:
void ReportHisysEvent(const std::shared_ptr<PrintJob> &jobInfo, const std::string &printerId, uint32_t subState); void ReportHisysEvent(const std::shared_ptr<PrintJob> &jobInfo, const std::string &printerId, uint32_t subState);
void ReportCompletedPrint(const std::string & printerId); void ReportCompletedPrint(const std::string & printerId);
void CheckJobQueueBlocked(const PrintJob &jobInfo); void CheckJobQueueBlocked(const PrintJob &jobInfo);
bool CheckIsPrinterDisabled();
private: private:
PrintSecurityGuardManager securityGuardManager_; PrintSecurityGuardManager securityGuardManager_;

View File

@ -42,6 +42,7 @@
#include "print_security_guard_manager.h" #include "print_security_guard_manager.h"
#include "hisys_event_util.h" #include "hisys_event_util.h"
#include "nlohmann/json.hpp" #include "nlohmann/json.hpp"
#include "restrictions_proxy.h"
namespace OHOS::Print { namespace OHOS::Print {
using namespace std; using namespace std;
@ -526,7 +527,11 @@ int32_t PrintServiceAbility::StartPrintJob(const PrintJob &jobInfo)
auto printerId = jobInfo.GetPrinterId(); auto printerId = jobInfo.GetPrinterId();
auto extensionId = PrintUtils::GetExtensionId(printerId); auto extensionId = PrintUtils::GetExtensionId(printerId);
PRINT_HILOGI("StartPrintJob started jobId:%{public}s printerId:%{public}s.", jobId.c_str(), printerId.c_str()); PRINT_HILOGI("StartPrintJob started jobId:%{public}s printerId:%{public}s.", jobId.c_str(), printerId.c_str());
bool IsPrinterDisabled = CheckIsPrinterDisabled();
if (IsPrinterDisabled) {
PRINT_HILOGD("prohibit print");
return E_PRINT_NO_PERMISSION;
}
auto jobIt = printJobList_.find(jobId); auto jobIt = printJobList_.find(jobId);
if (jobIt == printJobList_.end()) { if (jobIt == printJobList_.end()) {
PRINT_HILOGD("invalid job id"); PRINT_HILOGD("invalid job id");
@ -1317,4 +1322,18 @@ void PrintServiceAbility::CheckJobQueueBlocked(const PrintJob &jobInfo)
} }
PRINT_HILOGD("CheckJobQueueBlocked end,isJobQueueBlocked_=%{public}s", isJobQueueBlocked_ ? "true" : "false"); PRINT_HILOGD("CheckJobQueueBlocked end,isJobQueueBlocked_=%{public}s", isJobQueueBlocked_ ? "true" : "false");
} }
bool PrintServiceAbility::CheckIsPrinterDisabled()
{
auto proxy = OHOS::EDM::RestrictionsProxy::GetRestrictionsProxy();
if (proxy != nullptr) {
bool isDisabled = false;
proxy->IsPrinterDisabled(nullptr, isDisabled);
PRINT_HILOGD("PrintServiceAbility::CheckIsPrinterDisabled isDisabled %{public}d", isDisabled);
if (isDisabled) {
return true;
}
}
return false;
}
} // namespace OHOS::Print } // namespace OHOS::Print