示例#1
0
文件: libwakelock.c 项目: guhl/mce
/** Use sysfs interface to create and enable a wakelock.
 *
 * @param name The name of the wakelock to obtain
 * @param ns   Time in nanoseconds before the wakelock gets released
 *             automatically, or negative value for no timeout.
 */
void wakelock_lock(const char *name, long long ns)
{
	if( lwl_enabled() && !lwl_shutting_down ) {
		char tmp[64];
		char num[64];
		if( ns < 0 ) {
			lwl_concat(tmp, sizeof tmp, name, "\n", NULL);
		} else {
			lwl_concat(tmp, sizeof tmp, name, " ",
				   lwl_number(num, sizeof num, ns),
				   "\n", NULL);
		}
		lwl_write_file(lwl_lock_path, tmp);
	}
}
示例#2
0
文件: libwakelock.c 项目: guhl/mce
/** Use sysfs interface to disable a wakelock.
 *
 * @param name The name of the wakelock to release
 *
 * Note: This will not delete the wakelocks.
 */
void wakelock_unlock(const char *name)
{
	if( lwl_enabled() ) {
		char tmp[64];
		lwl_concat(tmp, sizeof tmp, name, "\n", NULL);
		lwl_write_file(lwl_unlock_path, tmp);
	}
}
示例#3
0
/** Use sysfs interface to disable a wakelock.
 *
 * @param name The name of the wakelock to release
 *
 * Note: This will not delete the wakelocks.
 */
void wakelock_unlock(const char *name)
{
	if( lwl_probe() > SUSPEND_TYPE_NONE ) {
		char tmp[64];
		lwl_concat(tmp, sizeof tmp, name, "\n", NULL);
		lwl_write_file(lwl_unlock_path, tmp);
	}
}
示例#4
0
/** Use sysfs interface to create and enable a wakelock.
 *
 * @param name The name of the wakelock to obtain
 * @param ns   Time in nanoseconds before the wakelock gets released
 *             automatically, or negative value for no timeout.
 */
void wakelock_lock(const char *name, long long ns)
{
	if( lwl_shutting_down )
		goto EXIT;

	if( lwl_probe() > SUSPEND_TYPE_NONE ) {
		char tmp[64];
		char num[64];
		if( ns < 0 ) {
			lwl_concat(tmp, sizeof tmp, name, "\n", NULL);
		} else {
			lwl_concat(tmp, sizeof tmp, name, " ",
				   lwl_number(num, sizeof num, ns),
				   "\n", NULL);
		}
		lwl_write_file(lwl_lock_path, tmp);
	}

EXIT:
	return;
}