[NUI] Add SystemSettings.FontTypeChanged in Text components
[platform/core/csapi/tizenfx.git] / src / Tizen.System / Device / Power.cs
1 /*
2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17 using System;
18 using System.ComponentModel;
19
20 namespace Tizen.System
21 {
22     /// <summary>
23     /// Enumeration for power lock type.
24     /// </summary>
25     /// <remarks>
26     /// DisplayDim may be ignored if the DIM state is disabled on the platform.
27     /// </remarks>
28     /// <since_tizen> 5 </since_tizen>
29     public enum PowerLock
30     {
31         /// <summary>
32         /// CPU lock.
33         /// </summary>
34         /// <since_tizen> 5 </since_tizen>
35         Cpu = Interop.Device.PowerLock.Cpu,
36         /// <summary>
37         /// Display the normal lock.
38         /// </summary>
39         /// <since_tizen> 5 </since_tizen>
40         DisplayNormal = Interop.Device.PowerLock.DisplayNormal,
41         /// <summary>
42         /// Display the dim lock.
43         /// </summary>
44         /// <since_tizen> 5 </since_tizen>
45         DisplayDim = Interop.Device.PowerLock.DisplayDim,
46     }
47
48     /// <summary>
49     /// The Power class provides methods to control the power service.
50     /// </summary>
51     /// <remarks>
52     /// The Power API provides the way to control the power service.
53     /// It can be made to hold the specific state to avoid the CPU state internally.
54     /// </remarks>
55     /// <privilege>
56     /// http://tizen.org/privilege/display
57     /// </privilege>
58     /// <since_tizen> 3 </since_tizen>
59     public static class Power
60     {
61         /// <summary>
62         /// [Obsolete("Please do not use! this will be deprecated")]
63         /// </summary>
64         /// <remarks>
65         /// If the process dies, then every lock will be removed.
66         /// </remarks>
67         /// <since_tizen> 3 </since_tizen>
68         /// <param name="timeout">
69         /// The positive number in milliseconds or 0 for the permanent lock.
70         /// So you must release the permanent lock of the power state with ReleaseCpuLock() if timeout_ms is zero.
71         /// </param>
72         /// <exception cref="ArgumentException">When an invalid parameter value is set.</exception>
73         /// <exception cref="UnauthorizedAccessException">If the privilege is not set.</exception>
74         /// <exception cref="InvalidOperationException">In case of any system error.</exception>
75         /// Please do not use! This will be deprecated!
76         /// Please use RequestLock instead!
77         [Obsolete("Please do not use! This will be deprecated! Please use RequestLock instead!")]
78         public static void RequestCpuLock(int timeout)
79         {
80             DeviceError res = (DeviceError)Interop.Device.DevicePowerRequestLock(Interop.Device.PowerLock.Cpu, timeout);
81             if (res != DeviceError.None)
82             {
83                 throw DeviceExceptionFactory.CreateException(res, "unable to acquire power lock.");
84             }
85         }
86         /// <summary>
87         /// [Obsolete("Please do not use! this will be deprecated")]
88         /// </summary>
89         /// <since_tizen> 3 </since_tizen>
90         /// <exception cref="UnauthorizedAccessException">If the privilege is not set.</exception>
91         /// <exception cref="InvalidOperationException">In case of any system error.</exception>
92         /// Please do not use! This will be deprecated!
93         /// Please use ReleaseLock instead!
94         [Obsolete("Please do not use! This will be deprecated! Please use ReleaseLock instead!")]
95         public static void ReleaseCpuLock()
96         {
97             DeviceError res = (DeviceError)Interop.Device.DevicePowerReleaseLock(Interop.Device.PowerLock.Cpu);
98             if (res != DeviceError.None)
99             {
100                 throw DeviceExceptionFactory.CreateException(res, "unable to release power lock.");
101             }
102         }
103
104         /// <summary>
105         /// Locks the given lock state for a specified time.
106         /// After the given timeout (in milliseconds), unlock the given lock state automatically.
107         /// </summary>
108         /// <remarks>
109         /// If the process dies, then every lock will be removed.
110         /// </remarks>
111         /// <since_tizen> 5 </since_tizen>
112         /// <param name="type">
113         /// The power type to request lock.
114         /// </param>
115         /// <param name="timeout">
116         /// The positive number in milliseconds or 0 for the permanent lock.
117         /// So you must release the permanent lock of the power state with ReleaseLock() if timeout_ms is zero.
118         /// </param>
119         /// <exception cref="ArgumentException">When an invalid parameter value is set.</exception>
120         /// <exception cref="UnauthorizedAccessException">If the privilege is not set.</exception>
121         /// <exception cref="InvalidOperationException">In case of any system error.</exception>
122         /// <example>
123         /// <code>
124         /// Tizen.System.Power.RequestLock(Tizen.System.Power.PowerLock.Cpu, 2000);
125         /// </code>
126         /// </example>
127         public static void RequestLock(PowerLock type, int timeout)
128         {
129             DeviceError res = (DeviceError)Interop.Device.DevicePowerRequestLock((Interop.Device.PowerLock)type, timeout);
130             if (res != DeviceError.None)
131             {
132                 throw DeviceExceptionFactory.CreateException(res, "unable to acquire power lock.");
133             }
134         }
135         /// <summary>
136         /// Releases the lock state.
137         /// </summary>
138         /// <since_tizen> 5 </since_tizen>
139         /// <param name="type">
140         /// The power type to request lock.
141         /// </param>
142         /// <exception cref="ArgumentException">When an invalid parameter value is set.</exception>
143         /// <exception cref="UnauthorizedAccessException">If the privilege is not set.</exception>
144         /// <exception cref="InvalidOperationException">In case of any system error.</exception>
145         /// <example>
146         /// <code>
147         /// Tizen.System.Power.ReleaseLock(Tizen.System.Power.PowerLock.Cpu);
148         /// </code>
149         /// </example>
150         public static void ReleaseLock(PowerLock type)
151         {
152             DeviceError res = (DeviceError)Interop.Device.DevicePowerReleaseLock((Interop.Device.PowerLock)type);
153             if (res != DeviceError.None)
154             {
155                 throw DeviceExceptionFactory.CreateException(res, "unable to release power lock.");
156             }
157         }
158         /// <summary>
159         /// Power off the device.
160         /// </summary>
161         /// <privilege>http://tizen.org/privilege/reboot</privilege>
162         /// <privlevel>platform</privlevel>
163         /// <exception cref="UnauthorizedAccessException">If the privilege is not set.</exception>
164         /// <exception cref="InvalidOperationException">In case of any system error.</exception>
165         /// <example>
166         /// <code>
167         /// Tizen.System.Power.PowerOff();
168         /// </code>
169         /// </example>
170         [EditorBrowsable(EditorBrowsableState.Never)]
171         public static void PowerOff()
172         {
173             DeviceError res = (DeviceError)Interop.Device.DevicePowerPowerOff();
174             if (res != DeviceError.None)
175             {
176                 throw DeviceExceptionFactory.CreateException(res, "unable to power off the device.");
177             }
178         }
179         /// <summary>
180         /// Reboot the device.
181         /// </summary>
182         /// <privilege>http://tizen.org/privilege/reboot</privilege>
183         /// <privlevel>platform</privlevel>
184         /// <exception cref="UnauthorizedAccessException">If the privilege is not set.</exception>
185         /// <exception cref="InvalidOperationException">In case of any system error.</exception>
186         /// <example>
187         /// <code>
188         /// Tizen.System.Power.Reboot(null);
189         /// </code>
190         /// </example>
191         [EditorBrowsable(EditorBrowsableState.Never)]
192         public static void Reboot(string reason)
193         {
194             DeviceError res = (DeviceError)Interop.Device.DevicePowerReboot(reason);
195             if (res != DeviceError.None)
196             {
197                 throw DeviceExceptionFactory.CreateException(res, "unable to reboot the device.");
198             }
199         }
200     }
201 }