Add Restriction API related to USB Client State 65/147165/2 accepted/tizen/4.0/unified/20170915.202849 accepted/tizen/unified/20170918.093923 submit/tizen/20170915.042428 submit/tizen_4.0/20170915.041935 tizen_4.0.IoT.p1_release tizen_4.0.m2_release
authorLee Sung Jun <sjun221.lee@samsung.com>
Fri, 1 Sep 2017 07:47:40 +0000 (16:47 +0900)
committerLee Sung Jun <sjun221.lee@samsung.com>
Fri, 1 Sep 2017 07:49:45 +0000 (16:49 +0900)
Change-Id: Ib5b7e59b241658bb252c34c1456c5cd456f74ec2
Signed-off-by: Lee Sung Jun <sjun221.lee@samsung.com>
libs/dpm/restriction.h
libs/restriction.cpp

index 9262341..a2c083e 100644 (file)
@@ -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);
+
 /**
  * @}
  */
index 662ddff..1544b3f 100644 (file)
@@ -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<int> status { -1 };
+               status = client.methodCall<int>("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<bool> status { true };
+               status = client.methodCall<bool>("Usb::getClientState");
+               *is_allowed = status.get();
+       } catch(...) {
+               return -1;
+       }
+
+       return DPM_ERROR_NONE;
+}