From: Lee Sung Jun Date: Fri, 1 Sep 2017 07:47:40 +0000 (+0900) Subject: Add Restriction API related to USB Client State X-Git-Tag: accepted/tizen/4.0/unified/20170915.202849^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5bfebbd72ba1f4efa298bc6735e5e1a6b965d859;p=platform%2Fcore%2Fsecurity%2Fdevice-policy-client.git Add Restriction API related to USB Client State Change-Id: Ib5b7e59b241658bb252c34c1456c5cd456f74ec2 Signed-off-by: Lee Sung Jun --- diff --git a/libs/dpm/restriction.h b/libs/dpm/restriction.h index 9262341..a2c083e 100644 --- a/libs/dpm/restriction.h +++ b/libs/dpm/restriction.h @@ -685,6 +685,9 @@ int dpm_restriction_set_browser_state(device_policy_manager_h handle, int allow) */ int dpm_restriction_get_browser_state(device_policy_manager_h handle, int *is_allowed); +int dpm_restriction_set_usb_client_state(device_policy_manager_h handle, int allow); +int dpm_restriction_get_usb_client_state(device_policy_manager_h handle, int *is_allowed); + /** * @} */ diff --git a/libs/restriction.cpp b/libs/restriction.cpp index 662ddff..1544b3f 100644 --- a/libs/restriction.cpp +++ b/libs/restriction.cpp @@ -547,3 +547,36 @@ EXPORT_API int dpm_restriction_get_browser_state(device_policy_manager_h handle, return DPM_ERROR_NONE; } + +EXPORT_API int dpm_restriction_set_usb_client_state(device_policy_manager_h handle, int allow) +{ + RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER); + + DevicePolicyClient &client = GetDevicePolicyClient(handle); + + try { + Status status { -1 }; + status = client.methodCall("Usb::setClientState", allow); + return status.get(); + } catch(...) { + return -1; + } +} + +EXPORT_API int dpm_restriction_get_usb_client_state(device_policy_manager_h handle, int *is_allowed) +{ + RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER); + + DevicePolicyClient &client = GetDevicePolicyClient(handle); + + try{ + Status status { true }; + status = client.methodCall("Usb::getClientState"); + *is_allowed = status.get(); + } catch(...) { + return -1; + } + + return DPM_ERROR_NONE; +}