2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 namespace Tizen.System
22 /// The Power class provides methods to control the power service.
25 /// The Power API provides the way to control the power service.
26 /// It can be made to hold the specific state to avoid CPU state internally.
29 /// http://tizen.org/privilege/display
31 public static class Power
34 /// Locks the CPU for a specified time.
35 /// After the given timeout (in milliseconds), unlock the given lock state automatically.
38 /// If the process dies, then every lock will be removed.
40 /// <since_tizen> 3 </since_tizen>
41 /// <param name="timeout">
42 /// The positive number in milliseconds or 0 for permanent lock
43 /// So you must release the permanent lock of power state with ReleaseCpuLock() if timeout_ms is zero.
45 /// <exception cref="ArgumentException"> When the invalid parameter value is set.</exception>
46 /// <exception cref = "UnauthorizedAccessException"> If the privilege is not set.</exception>
47 /// <exception cref = "InvalidOperationException"> In case of any system error.</exception>
49 /// Tizen.System.Power.RequestCpuLock(2000);
52 public static void RequestCpuLock(int timeout)
54 DeviceError res = (DeviceError)Interop.Device.DevicePowerRequestLock(0, timeout);
55 if (res != DeviceError.None)
57 throw DeviceExceptionFactory.CreateException(res, "unable to acquire power lock.");
61 /// Releases the CPU lock state.
63 /// <since_tizen> 3 </since_tizen>
64 /// <exception cref = "UnauthorizedAccessException"> If the privilege is not set.</exception>
65 /// <exception cref = "InvalidOperationException"> In case of any system error.</exception>
67 /// Tizen.System.Power.ReleaseCpuLock();
69 public static void ReleaseCpuLock()
71 DeviceError res = (DeviceError)Interop.Device.DevicePowerReleaseLock(0);
72 if (res != DeviceError.None)
74 throw DeviceExceptionFactory.CreateException(res, "unable to release power lock.");