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 /// Enumeration for power lock type.
25 /// DisplayDim may be ignored if the DIM state is disabled on the platform.
27 /// <since_tizen> 5 </since_tizen>
33 /// <since_tizen> 5 </since_tizen>
34 Cpu = Interop.Device.PowerLock.Cpu,
36 /// Display the normal lock.
38 /// <since_tizen> 5 </since_tizen>
39 DisplayNormal = Interop.Device.PowerLock.DisplayNormal,
41 /// Display the dim lock.
43 /// <since_tizen> 5 </since_tizen>
44 DisplayDim = Interop.Device.PowerLock.DisplayDim,
48 /// The Power class provides methods to control the power service.
51 /// The Power API provides the way to control the power service.
52 /// It can be made to hold the specific state to avoid the CPU state internally.
55 /// http://tizen.org/privilege/display
57 /// <since_tizen> 3 </since_tizen>
58 public static class Power
61 /// [Obsolete("Please do not use! this will be deprecated")]
64 /// If the process dies, then every lock will be removed.
66 /// <since_tizen> 3 </since_tizen>
67 /// <param name="timeout">
68 /// The positive number in milliseconds or 0 for the permanent lock.
69 /// So you must release the permanent lock of the power state with ReleaseCpuLock() if timeout_ms is zero.
71 /// <exception cref="ArgumentException">When an invalid parameter value is set.</exception>
72 /// <exception cref="UnauthorizedAccessException">If the privilege is not set.</exception>
73 /// <exception cref="InvalidOperationException">In case of any system error.</exception>
74 /// Please do not use! This will be deprecated!
75 /// Please use RequestLock instead!
76 [Obsolete("Please do not use! This will be deprecated! Please use RequestLock instead!")]
77 public static void RequestCpuLock(int timeout)
79 DeviceError res = (DeviceError)Interop.Device.DevicePowerRequestLock(Interop.Device.PowerLock.Cpu, timeout);
80 if (res != DeviceError.None)
82 throw DeviceExceptionFactory.CreateException(res, "unable to acquire power lock.");
86 /// [Obsolete("Please do not use! this will be deprecated")]
88 /// <since_tizen> 3 </since_tizen>
89 /// <exception cref="UnauthorizedAccessException">If the privilege is not set.</exception>
90 /// <exception cref="InvalidOperationException">In case of any system error.</exception>
91 /// Please do not use! This will be deprecated!
92 /// Please use ReleaseLock instead!
93 [Obsolete("Please do not use! This will be deprecated! Please use ReleaseLock instead!")]
94 public static void ReleaseCpuLock()
96 DeviceError res = (DeviceError)Interop.Device.DevicePowerReleaseLock(Interop.Device.PowerLock.Cpu);
97 if (res != DeviceError.None)
99 throw DeviceExceptionFactory.CreateException(res, "unable to release power lock.");
104 /// Locks the given lock state for a specified time.
105 /// After the given timeout (in milliseconds), unlock the given lock state automatically.
108 /// If the process dies, then every lock will be removed.
110 /// <since_tizen> 5 </since_tizen>
111 /// <param name="type">
112 /// The power type to request lock.
114 /// <param name="timeout">
115 /// The positive number in milliseconds or 0 for the permanent lock.
116 /// So you must release the permanent lock of the power state with ReleaseLock() if timeout_ms is zero.
118 /// <exception cref="ArgumentException">When an invalid parameter value is set.</exception>
119 /// <exception cref="UnauthorizedAccessException">If the privilege is not set.</exception>
120 /// <exception cref="InvalidOperationException">In case of any system error.</exception>
123 /// Tizen.System.Power.RequestLock(Tizen.System.Power.PowerLock.Cpu, 2000);
126 public static void RequestLock(PowerLock type, int timeout)
128 DeviceError res = (DeviceError)Interop.Device.DevicePowerRequestLock((Interop.Device.PowerLock)type, timeout);
129 if (res != DeviceError.None)
131 throw DeviceExceptionFactory.CreateException(res, "unable to acquire power lock.");
135 /// Releases the lock state.
137 /// <since_tizen> 5 </since_tizen>
138 /// <param name="type">
139 /// The power type to request lock.
141 /// <exception cref="ArgumentException">When an invalid parameter value is set.</exception>
142 /// <exception cref="UnauthorizedAccessException">If the privilege is not set.</exception>
143 /// <exception cref="InvalidOperationException">In case of any system error.</exception>
146 /// Tizen.System.Power.ReleaseLock(Tizen.System.Power.PowerLock.Cpu);
149 public static void ReleaseLock(PowerLock type)
151 DeviceError res = (DeviceError)Interop.Device.DevicePowerReleaseLock((Interop.Device.PowerLock)type);
152 if (res != DeviceError.None)
154 throw DeviceExceptionFactory.CreateException(res, "unable to release power lock.");