#include <libsyscommon/libgdbus.h>
#include <libsyscommon/list.h>
#include <libsyscommon/log.h>
+#include <libsyscommon/resource-manager.h>
+#include <system/syscommon-plugin-deviced-common-interface.h>
+#include <system/syscommon-plugin-deviced-power-interface.h>
#include "shared/device-notifier.h"
-#include "shared/event.h"
#include "input-config.h"
#include "input/input.h"
event_broadcast_id(ieu->id);
if (ieu->wakelock_duration > 0)
- event_acquire_wakelock(ieu->id, ieu->wakelock_duration);
+ syscommon_resman_set_resource_attr_uint64_2(
+ SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_POWER),
+ DEVICED_POWER_ATTR_TUPLE2_SET_WAKELOCK,
+ ieu->id, ieu->wakelock_duration);
if (ieu->notifier)
syscommon_notifier_emit_notify(ieu->notifier, ieu->user_data);
event_broadcast_id(ieu->id);
if (ieu->wakelock_duration > 0)
- event_acquire_wakelock(ieu->id, ieu->wakelock_duration);
+ syscommon_resman_set_resource_attr_uint64_2(
+ SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_POWER),
+ DEVICED_POWER_ATTR_TUPLE2_SET_WAKELOCK,
+ ieu->id, ieu->wakelock_duration);
if (ieu->notifier)
syscommon_notifier_emit_notify(ieu->notifier, ieu->user_data);
#include <hal/device/hal-battery.h>
#include <sys/stat.h>
#include <libsyscommon/ini-parser.h>
+#include <libsyscommon/resource-manager.h>
#include <system/syscommon-plugin-deviced-common-interface.h>
+#include <system/syscommon-plugin-deviced-power-interface.h>
#include "shared/devices.h"
#include "shared/device-notifier.h"
event_handlers[i]->id);
if (event_handlers[i]->wakelock_duration)
- event_acquire_wakelock(event_handlers[i]->id,
- event_handlers[i]->wakelock_duration);
+ syscommon_resman_set_resource_attr_uint64_2(
+ SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_POWER),
+ DEVICED_POWER_ATTR_TUPLE2_SET_WAKELOCK,
+ event_handlers[i]->id,
+ event_handlers[i]->wakelock_duration);
+
if (event_handlers[i]->broadcast)
event_broadcast_id(event_handlers[i]->id);
+++ /dev/null
-/*
- * deviced
- *
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <glib.h>
-#include <stdint.h>
-
-#include "device-notifier.h"
-#include "log.h"
-
-static int wakelock_counter;
-
-static gboolean event_release_wakelock(gpointer data)
-{
- int eventid = (int)(intptr_t) data;
-
- --wakelock_counter;
-
- _D("Decreased counter=%d, eventid=%d", wakelock_counter, eventid);
-
- if (wakelock_counter == 0)
- syscommon_notifier_emit_notify(DEVICED_NOTIFIER_EVENT_RELEASE_WAKELOCK, NULL);
-
- return G_SOURCE_REMOVE;
-}
-
-void event_acquire_wakelock(int eventid, int timeout)
-{
- if (timeout <= 0)
- return;
-
- ++wakelock_counter;
-
- _D("Increased counter=%d, eventid=%d, timeout=%d", wakelock_counter, eventid, timeout);
- g_timeout_add_seconds(timeout, event_release_wakelock, (gpointer)(intptr_t) eventid);
-
- if (wakelock_counter == 1)
- syscommon_notifier_emit_notify(DEVICED_NOTIFIER_EVENT_ACQUIRE_WAKELOCK, NULL);
-}
g_variant_new("(i)", id));
}
-/**
- * Hold wakelock for a specified timeout.
- * The parameter eventid is only used for logging
- */
-void event_acquire_wakelock(int eventid, int timeout);
-
#endif //__DD_EVENT_H__