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 EXPORT_API int dpm_security_lockout_screen(device_policy_manager_h handle)
26 RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
28 DevicePolicyClient &client = GetDevicePolicyClient(handle);
30 Status<int> status { -1 };
31 status = client.methodCall<int>("Security::lockoutScreen");
38 EXPORT_API int dpm_security_set_internal_storage_encryption(device_policy_manager_h handle, bool encrypt)
40 RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
42 DevicePolicyClient &client = GetDevicePolicyClient(handle);
44 Status<int> status { -1 };
45 status = client.methodCall<int>("Security::setInternalStorageEncryption", encrypt);
52 EXPORT_API int dpm_security_is_internal_storage_encrypted(device_policy_manager_h handle, bool *is_encrypted)
54 RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
55 RET_ON_FAILURE(is_encrypted, DPM_ERROR_INVALID_PARAMETER);
57 DevicePolicyClient &client = GetDevicePolicyClient(handle);
59 Status<bool> status { false };
60 status = client.methodCall<int>("Security::isInternalStorageEncrypted");
61 *is_encrypted = status.get();
66 return DPM_ERROR_NONE;
69 EXPORT_API int dpm_security_set_external_storage_encryption(device_policy_manager_h handle, bool encrypt)
71 RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
73 DevicePolicyClient &client = GetDevicePolicyClient(handle);
75 Status<int> status { -1 };
76 status = client.methodCall<int>("Security::setExternalStorageEncryption", encrypt);
83 EXPORT_API int dpm_security_is_external_storage_encrypted(device_policy_manager_h handle, bool *is_encrypted)
85 RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
86 RET_ON_FAILURE(is_encrypted, DPM_ERROR_INVALID_PARAMETER);
88 DevicePolicyClient &client = GetDevicePolicyClient(handle);
90 Status<bool> status { false };
91 status = client.methodCall<int>("Security::isExternalStorageEncrypted");
92 *is_encrypted = status.get();
97 return DPM_ERROR_NONE;
100 EXPORT_API int dpm_security_wipe_data(device_policy_manager_h handle, dpm_security_wipe_type_e type)
102 int mask = type & (DPM_SECURITY_WIPE_INTERNAL_STORAGE | DPM_SECURITY_WIPE_EXTERNAL_STORAGE);
104 RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
105 RET_ON_FAILURE(mask, DPM_ERROR_INVALID_PARAMETER);
107 DevicePolicyClient &client = GetDevicePolicyClient(handle);
109 Status<int> status { -1 };
110 status = client.methodCall<int>("Security::wipeData", mask);