/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* 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.
*/
using System;
namespace Tizen.System
{
///
/// The Power class provides methods to control the power service.
///
///
/// The Power API provides the way to control the power service.
/// It can be made to hold the specific state to avoid the CPU state internally.
///
///
/// http://tizen.org/privilege/display
///
public static class Power
{
///
/// Locks the CPU for a specified time.
/// After the given timeout (in milliseconds), unlock the given lock state automatically.
///
///
/// If the process dies, then every lock will be removed.
///
/// 3
///
/// The positive number in milliseconds or 0 for the permanent lock.
/// So you must release the permanent lock of the power state with ReleaseCpuLock() if timeout_ms is zero.
///
/// When an invalid parameter value is set.
/// If the privilege is not set.
/// In case of any system error.
///
/// Tizen.System.Power.RequestCpuLock(2000);
///
public static void RequestCpuLock(int timeout)
{
DeviceError res = (DeviceError)Interop.Device.DevicePowerRequestLock(0, timeout);
if (res != DeviceError.None)
{
throw DeviceExceptionFactory.CreateException(res, "unable to acquire power lock.");
}
}
///
/// Releases the CPU lock state.
///
/// 3
/// If the privilege is not set.
/// In case of any system error.
///
/// Tizen.System.Power.ReleaseCpuLock();
///
public static void ReleaseCpuLock()
{
DeviceError res = (DeviceError)Interop.Device.DevicePowerReleaseLock(0);
if (res != DeviceError.None)
{
throw DeviceExceptionFactory.CreateException(res, "unable to release power lock.");
}
}
}
}