{
DevicePolicyContext* client = new(std::nothrow) DevicePolicyContext();
- assert(client);
+ if (client == nullptr) {
+ return NULL;
+ }
if (client->connect() < 0) {
delete client;
int dpm_context_destroy(dpm_context_h handle)
{
- assert(handle);
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
delete &GetDevicePolicyContext(handle);
int dpm_context_add_policy_changed_cb(dpm_context_h handle, const char* name, dpm_policy_changed_cb callback, void* user_data, int* id)
{
- assert(handle);
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(id, DPM_ERROR_INVALID_PARAMETER);
DevicePolicyContext& client = GetDevicePolicyContext(handle);
int ret = client.subscribePolicyChange(name, callback, user_data);
int dpm_context_remove_policy_changed_cb(dpm_context_h handle, int id)
{
- assert(handle);
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(id >= 0, DPM_ERROR_INVALID_PARAMETER);
DevicePolicyContext& client = GetDevicePolicyContext(handle);
client.unsubscribePolicyChange(id);
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(signal, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(id, DPM_ERROR_INVALID_PARAMETER);
DevicePolicyContext& context = GetDevicePolicyContext(handle);
int ret = context.subscribeSignal(signal, callback, user_data);
return 0;
}
-int dpm_context_remove_signal_cb(dpm_context_h handle, int callback_id)
+int dpm_context_remove_signal_cb(dpm_context_h handle, int id)
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(callback_id >= 0, DPM_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(id >= 0, DPM_ERROR_INVALID_PARAMETER);
DevicePolicyContext& context = GetDevicePolicyContext(handle);
- return context.unsubscribeSignal(callback_id);
+ return context.unsubscribeSignal(id);
}
EXPORT_API device_policy_manager_h dpm_manager_create(void)
{
DevicePolicyContext* client = new(std::nothrow) DevicePolicyContext();
-
- assert(client);
+ if (client == nullptr) {
+ return NULL;
+ }
if (client->connect() < 0) {
delete client;
EXPORT_API int dpm_manager_destroy(device_policy_manager_h handle)
{
- assert(handle);
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
delete &GetDevicePolicyContext(handle);
void* user_data,
int* id)
{
- assert(handle);
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(id, DPM_ERROR_INVALID_PARAMETER);
DevicePolicyContext& client = GetDevicePolicyContext(handle);
int ret = client.subscribePolicyChange(name, callback, user_data);
EXPORT_API int dpm_remove_policy_changed_cb(device_policy_manager_h handle, int id)
{
- assert(handle);
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(id >= 0, DPM_ERROR_INVALID_PARAMETER);
DevicePolicyContext& client = GetDevicePolicyContext(handle);
- client.unsubscribePolicyChange(id);
-
- return 0;
+ return client.unsubscribePolicyChange(id);
}
EXPORT_API int dpm_add_signal_cb(device_policy_manager_h handle, const char* signal,
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(signal, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(id, DPM_ERROR_INVALID_PARAMETER);
DevicePolicyContext& context = GetDevicePolicyContext(handle);
int ret = context.subscribeSignal(signal, callback, user_data);
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
DevicePolicyContext &client = GetDevicePolicyContext(handle);
ZonePolicy zone = client.createPolicyInterface<ZonePolicy>();
EXPORT_API int dpm_zone_foreach_name(device_policy_manager_h handle, dpm_zone_state_e state,
dpm_zone_foreach_name_cb callback, void* user_data)
{
+ int mask = state & (DPM_ZONE_STATE_LOCKED | DPM_ZONE_STATE_RUNNING);
+
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(mask, DPM_ERROR_INVALID_PARAMETER);
DevicePolicyContext &client = GetDevicePolicyContext(handle);
ZonePolicy zone = client.createPolicyInterface<ZonePolicy>();