Fix for UTC fail cases 22/77822/3
authorSungbae Yoo <sungbae.yoo@samsung.com>
Fri, 1 Jul 2016 07:25:59 +0000 (16:25 +0900)
committeryeji01kim <yeji01.kim@samsung.com>
Fri, 1 Jul 2016 10:27:39 +0000 (19:27 +0900)
Change-Id: I8d82063b2c8d8cb5eccc69993cfd0f161871579d
Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Signed-off-by: yeji01kim <yeji01.kim@samsung.com>
libs/dpm/password.cpp [changed mode: 0644->0755]
libs/dpm/restriction.cpp
libs/dpm/zone.cpp [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index be8ea25..0a741f7
@@ -39,6 +39,7 @@ EXPORT_API int dpm_password_set_quality(device_policy_manager_h handle, dpm_pass
 EXPORT_API int dpm_password_get_quality(device_policy_manager_h handle, dpm_password_quality_e *quality)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(quality, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
@@ -56,6 +57,7 @@ EXPORT_API int dpm_password_get_quality(device_policy_manager_h handle, dpm_pass
 EXPORT_API int dpm_password_set_minimum_length(device_policy_manager_h handle, int value)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
@@ -84,6 +86,7 @@ EXPORT_API int dpm_password_get_minimum_length(device_policy_manager_h handle, i
 EXPORT_API int dpm_password_set_min_complex_chars(device_policy_manager_h handle, int value)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
@@ -94,6 +97,7 @@ EXPORT_API int dpm_password_set_min_complex_chars(device_policy_manager_h handle
 EXPORT_API int dpm_password_get_min_complex_chars(device_policy_manager_h handle, int *value)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
@@ -111,6 +115,7 @@ EXPORT_API int dpm_password_get_min_complex_chars(device_policy_manager_h handle
 EXPORT_API int dpm_password_set_maximum_failed_attempts_for_wipe(device_policy_manager_h handle, int value)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
@@ -139,6 +144,7 @@ EXPORT_API int dpm_password_get_maximum_failed_attempts_for_wipe(device_policy_m
 EXPORT_API int dpm_password_set_expires(device_policy_manager_h handle, int value)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
@@ -149,6 +155,7 @@ EXPORT_API int dpm_password_set_expires(device_policy_manager_h handle, int valu
 EXPORT_API int dpm_password_get_expires(device_policy_manager_h handle, int *value)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
@@ -166,6 +173,7 @@ EXPORT_API int dpm_password_get_expires(device_policy_manager_h handle, int *val
 EXPORT_API int dpm_password_set_history(device_policy_manager_h handle, int value)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
@@ -176,6 +184,7 @@ EXPORT_API int dpm_password_set_history(device_policy_manager_h handle, int valu
 EXPORT_API int dpm_password_get_history(device_policy_manager_h handle, int *value)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
@@ -225,6 +234,7 @@ EXPORT_API int dpm_password_enforce_change(device_policy_manager_h handle)
 EXPORT_API int dpm_password_set_max_inactivity_time_device_lock(device_policy_manager_h handle, int value)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
@@ -253,6 +263,9 @@ EXPORT_API int dpm_password_get_max_inactivity_time_device_lock(device_policy_ma
 EXPORT_API int dpm_password_set_status(device_policy_manager_h handle, dpm_password_status_e status)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(status >= DPM_PASSWORD_STATUS_NORMAL &&
+                    status <= DPM_PASSWORD_STATUS_MAX_ATTEMPTS_EXCEEDED,
+                    DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
@@ -273,7 +286,7 @@ EXPORT_API int dpm_password_delete_pattern(device_policy_manager_h handle)
 EXPORT_API int dpm_password_get_pattern(device_policy_manager_h handle, char **pattern)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(*pattern, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(pattern, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
@@ -286,6 +299,7 @@ EXPORT_API int dpm_password_get_pattern(device_policy_manager_h handle, char **p
 EXPORT_API int dpm_password_set_maximum_character_occurrences(device_policy_manager_h handle, int value)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
@@ -314,6 +328,7 @@ EXPORT_API int dpm_password_get_maximum_character_occurrences(device_policy_mana
 EXPORT_API int dpm_password_set_maximum_numeric_sequence_length(device_policy_manager_h handle, int value)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
@@ -377,6 +392,10 @@ EXPORT_API int dpm_password_destroy_iterator(dpm_password_iterator_h iter)
 
 EXPORT_API int dpm_password_set_forbidden_strings(device_policy_manager_h handle, const char *strings[], int length)
 {
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(strings, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(length >= 0, DPM_ERROR_INVALID_PARAMETER);
+
     int iter;
     std::vector<std::string> forbiddenStrings;
 
index 7b720b5..ec09b46 100644 (file)
@@ -27,7 +27,7 @@ using namespace DevicePolicyManager;
 
 EXPORT_API int dpm_restriction_set_camera_state(device_policy_manager_h handle, int allow)
 {
-       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
@@ -36,7 +36,7 @@ EXPORT_API int dpm_restriction_set_camera_state(device_policy_manager_h handle,
 
 EXPORT_API int dpm_restriction_get_camera_state(device_policy_manager_h handle, int *is_allowed)
 {
-       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
     RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
@@ -52,7 +52,7 @@ EXPORT_API int dpm_restriction_get_camera_state(device_policy_manager_h handle,
 
 EXPORT_API int dpm_restriction_set_microphone_state(device_policy_manager_h handle, int allow)
 {
-       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
@@ -61,7 +61,8 @@ EXPORT_API int dpm_restriction_set_microphone_state(device_policy_manager_h hand
 
 EXPORT_API int dpm_restriction_get_microphone_state(device_policy_manager_h handle, int *is_allowed)
 {
-       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
@@ -100,7 +101,7 @@ EXPORT_API int dpm_restriction_get_location_state(device_policy_manager_h handle
 
 EXPORT_API int dpm_restriction_set_usb_debugging_state(device_policy_manager_h handle, int allow)
 {
-       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
@@ -109,8 +110,8 @@ EXPORT_API int dpm_restriction_set_usb_debugging_state(device_policy_manager_h h
 
 EXPORT_API int dpm_restriction_get_usb_debugging_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);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
@@ -148,17 +149,17 @@ EXPORT_API int dpm_restriction_get_usb_tethering_state(device_policy_manager_h h
 
 EXPORT_API int dpm_restriction_set_settings_changes_state(device_policy_manager_h handle, int allow)
 {
-       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
-       return restriction.setSettingsChangesState(allow);
+    return restriction.setSettingsChangesState(allow);
 }
 
 EXPORT_API int dpm_restriction_get_settings_changes_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);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
@@ -173,21 +174,21 @@ EXPORT_API int dpm_restriction_get_settings_changes_state(device_policy_manager_
 
 EXPORT_API int dpm_restriction_set_external_storage_state(device_policy_manager_h handle, int allow)
 {
-       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
-       return restriction.setExternalStorageState(allow);
+    return restriction.setExternalStorageState(allow);
 }
 
 EXPORT_API int dpm_restriction_get_external_storage_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);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
-       int ret = restriction.getExternalStorageState();
+    int ret = restriction.getExternalStorageState();
     if (ret < 0) {
         return 0;
     }
@@ -197,17 +198,17 @@ EXPORT_API int dpm_restriction_get_external_storage_state(device_policy_manager_
 
 EXPORT_API int dpm_restriction_set_clipboard_state(device_policy_manager_h handle, int allow)
 {
-       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
-       return restriction.setClipboardState(allow);
+    return restriction.setClipboardState(allow);
 }
 
 EXPORT_API int dpm_restriction_get_clipboard_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);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
@@ -343,7 +344,7 @@ EXPORT_API int dpm_restriction_get_bluetooth_desktop_connectivity_state(device_p
 
 EXPORT_API int dpm_restriction_set_bluetooth_pairing_state(device_policy_manager_h handle, int allow)
 {
-       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
@@ -352,7 +353,7 @@ EXPORT_API int dpm_restriction_set_bluetooth_pairing_state(device_policy_manager
 
 EXPORT_API int dpm_restriction_get_bluetooth_pairing_state(device_policy_manager_h handle, int *is_allowed)
 {
-       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
     RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
old mode 100644 (file)
new mode 100755 (executable)
index 704d224..6e02e5f
@@ -70,9 +70,8 @@ EXPORT_API int dpm_zone_foreach_name(device_policy_manager_h handle, dpm_zone_st
     DevicePolicyContext &client = GetDevicePolicyContext(handle);
     ZonePolicy zone = client.createPolicyInterface<ZonePolicy>();
     std::vector<std::string> list = zone.getZoneList(state);
-    for (std::vector<std::string>::iterator it = list.begin();
-         it != list.end(); it++) {
-        callback((*it).c_str(), user_data);
+    for (const std::string& name : list) {
+        callback(name.c_str(), user_data);
     }
 
     return DPM_ERROR_NONE;