2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
18 #include <tizen_type.h>
20 #include <dpm/pil/policy-client.h>
24 #define RET_ON_FAILURE(cond, ret) \
30 EXPORT_API int dpm_security_lockout_screen(device_policy_manager_h handle)
32 RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
34 DevicePolicyClient &client = GetDevicePolicyClient(handle);
36 Status<int> status { -1 };
37 status = client.methodCall<int>("Security::lockoutScreen");
44 EXPORT_API int dpm_security_set_internal_storage_encryption(device_policy_manager_h handle, bool encrypt)
46 RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
48 DevicePolicyClient &client = GetDevicePolicyClient(handle);
50 Status<int> status { -1 };
51 status = client.methodCall<int>("Security::setInternalStorageEncryption", encrypt);
58 EXPORT_API int dpm_security_is_internal_storage_encrypted(device_policy_manager_h handle, bool *is_encrypted)
60 RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
61 RET_ON_FAILURE(is_encrypted, DPM_ERROR_INVALID_PARAMETER);
63 DevicePolicyClient &client = GetDevicePolicyClient(handle);
65 Status<bool> status { false };
66 status = client.methodCall<int>("Security::isInternalStorageEncrypted");
67 *is_encrypted = status.get();
72 return DPM_ERROR_NONE;
75 EXPORT_API int dpm_security_set_external_storage_encryption(device_policy_manager_h handle, bool encrypt)
77 RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
79 DevicePolicyClient &client = GetDevicePolicyClient(handle);
81 Status<int> status { -1 };
82 status = client.methodCall<int>("Security::setExternalStorageEncryption", encrypt);
89 EXPORT_API int dpm_security_is_external_storage_encrypted(device_policy_manager_h handle, bool *is_encrypted)
91 RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
92 RET_ON_FAILURE(is_encrypted, DPM_ERROR_INVALID_PARAMETER);
94 DevicePolicyClient &client = GetDevicePolicyClient(handle);
96 Status<bool> status { false };
97 status = client.methodCall<int>("Security::isExternalStorageEncrypted");
98 *is_encrypted = status.get();
103 return DPM_ERROR_NONE;
106 EXPORT_API int dpm_security_wipe_data(device_policy_manager_h handle, dpm_security_wipe_type_e type)
108 int mask = type & (DPM_SECURITY_WIPE_INTERNAL_STORAGE | DPM_SECURITY_WIPE_EXTERNAL_STORAGE);
110 RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
111 RET_ON_FAILURE(mask, DPM_ERROR_INVALID_PARAMETER);
113 DevicePolicyClient &client = GetDevicePolicyClient(handle);
115 Status<int> status { -1 };
116 status = client.methodCall<int>("Security::wipeData", mask);