/// <summary> /// Releases the lock state. /// </summary> /// <since_tizen> 5 </since_tizen> /// <param name="type"> /// The power type to request lock. /// </param> /// <exception cref="ArgumentException">When an invalid parameter value is set.</exception> /// <exception cref="UnauthorizedAccessException">If the privilege is not set.</exception> /// <exception cref="InvalidOperationException">In case of any system error.</exception> /// <example> /// <code> /// Tizen.System.Power.ReleaseLock(Tizen.System.Power.PowerLock.Cpu); /// </code> /// </example> public static void ReleaseLock(PowerLock type) { DeviceError res = (DeviceError)Interop.Device.DevicePowerReleaseLock((Interop.Device.PowerLock)type); if (res != DeviceError.None) { throw DeviceExceptionFactory.CreateException(res, "unable to release power lock."); } }
/// <summary> /// Locks the given lock state for a specified time. /// After the given timeout (in milliseconds), unlock the given lock state automatically. /// </summary> /// <remarks> /// If the process dies, then every lock will be removed. /// </remarks> /// <since_tizen> 5 </since_tizen> /// <param name="type"> /// The power type to request lock. /// </param> /// <param name="timeout"> /// The positive number in milliseconds or 0 for the permanent lock. /// So you must release the permanent lock of the power state with ReleaseLock() if timeout_ms is zero. /// </param> /// <exception cref="ArgumentException">When an invalid parameter value is set.</exception> /// <exception cref="UnauthorizedAccessException">If the privilege is not set.</exception> /// <exception cref="InvalidOperationException">In case of any system error.</exception> /// <example> /// <code> /// Tizen.System.Power.RequestLock(Tizen.System.Power.PowerLock.Cpu, 2000); /// </code> /// </example> public static void RequestLock(PowerLock type, int timeout) { DeviceError res = (DeviceError)Interop.Device.DevicePowerRequestLock((Interop.Device.PowerLock)type, timeout); if (res != DeviceError.None) { throw DeviceExceptionFactory.CreateException(res, "unable to acquire power lock."); } }
internal static extern int DevicePowerReleaseLock(PowerLock type);
internal static extern int DevicePowerRequestLock(PowerLock type, int timeout_ms);