namespace Tizen.System
{
/// <summary>
- /// Enumeration for the battery level.
+ /// Enumeration for the Battery level.
/// </summary>
public enum BatteryLevelStatus
{
}
/// <summary>
- /// The Battery API provides functions to get information about the battery.
+ /// The Battery class provides the Properties and Events for device battery.
/// </summary>
/// <remarks>
- /// The Battery API provides the way to get the current battery capacity value,
- /// battery state and charging state. It also supports the API for an application
- /// to receive the battery events from the system. To receive the battery event
- /// it should be described by the callback function.
+ /// The Battery API provides the way to get the current battery capacity value (Percent),
+ /// battery state and charging state. It also provides Events for an application
+ /// to receive the battery status change events from the device.
+ /// To receive the battery event, application should register with respective EventHandler.
/// </remarks>
+ /// <code>
+ /// Console.WriteLine("battery Charging state is: {0}", Tizen.System.Battery.IsCharging);
+ /// Console.WriteLine("battery Percent is: {0}", Tizen.System.Battery.Percent);
+ /// </code>
public static class Battery
{
private static readonly object s_lock = new object();
}
}
/// <summary>
- /// Gets the battery level.
+ /// Gets the current Battery level.
/// </summary>
public static BatteryLevelStatus Level
{
}
}
/// <summary>
- /// Gets the charging state.
+ /// Gets the current charging state.
/// </summary>
public static bool IsCharging
{
/// CapacityChanged is triggered when the battery charge percentage is changed
/// </summary>
/// <param name="sender"></param>
- /// <param name="e">A BatteryCapacityChangedEventArgs object that contains changed battery capacity</param>
-
+ /// <param name="e">A BatteryCapacityChangedEventArgs object that contains changed battery capacity (Percent)</param>
+ /// <code>
+ /// public static async Task BatteryEventHandler()
+ /// {
+ /// EventHandler<BatteryPercentChangedEventArgs> handler = null;
+ /// handler = (object sender, BatteryChargingStateChangedEventArgs args) =>
+ /// {
+ /// Console.WriteLine("battery Percent is: {0}", args.Percent);
+ /// }
+ /// Battery.PercentChanged += handler;
+ /// await Task.Delay(20000);
+ /// }
+ /// </code>
public static event EventHandler<BatteryPercentChangedEventArgs> PercentChanged
{
add
/// </summary>
/// <param name="sender"></param>
/// <param name="e">A BatteryLevelChangedEventArgs object that contains changed battery level </param>
+ /// <code>
+ /// public static async Task BatteryEventHandler()
+ /// {
+ /// EventHandler<BatteryLevelChangedEventArgs> handler = null;
+ /// handler = (object sender, BatteryLevelChangedEventArgs args) =>
+ /// {
+ /// Console.WriteLine("battery Level is: {0}", args.Level);
+ /// }
+ /// Battery.LevelChanged += handler;
+ /// await Task.Delay(20000);
+ /// }
+ /// </code>
public static event EventHandler<BatteryLevelChangedEventArgs> LevelChanged
{
add
private static event EventHandler<BatteryChargingStateChangedEventArgs> s_chargingStateChanged;
/// <summary>
- /// ChargingStatusChanged is triggered when the battery charging status is changed
+ /// ChargingStatusChanged is triggered when the Battery charging status is changed.
+ /// This event is triggered when Charger is connected/Disconnected.
/// </summary>
/// <param name="sender"></param>
/// <param name="e">A BatteryChargingStateChangedEventArgs object that contains changed battery charging state</param>
-
+ /// <code>
+ /// public static async Task BatteryEventHandler()
+ /// {
+ /// EventHandler<BatteryChargingStateChangedEventArgs> handler = null;
+ /// handler = (object sender, BatteryChargingStateChangedEventArgs args) =>
+ /// {
+ /// Console.WriteLine("battery Level is: {0}", args.IsCharging);
+ /// }
+ /// Battery.ChargingStateChanged += handler;
+ /// await Task.Delay(20000);
+ /// }
+ /// </code>
public static event EventHandler<BatteryChargingStateChangedEventArgs> ChargingStateChanged
{
add
namespace Tizen.System
{
- // Battery
+ /// <summary>
+ /// BatteryPercentChangedEventArgs is an extended EventArgs class. This class contains event arguments for BatteryPercentChanged event from Battery class.
+ /// </summary>
public class BatteryPercentChangedEventArgs : EventArgs
{
internal BatteryPercentChangedEventArgs(){}
public int Percent { get; internal set; }
}
+ /// <summary>
+ /// BatteryLevelChangedEventArgs is an extended EventArgs class. This class contains event arguments for BatteryLevelChanged event from Battery class.
+ /// </summary>
public class BatteryLevelChangedEventArgs : EventArgs
{
internal BatteryLevelChangedEventArgs(){}
public BatteryLevelStatus Level { get; internal set; }
}
+ /// <summary>
+ /// BatteryChargingStateChangedEventArgs is an extended EventArgs class. This class contains event arguments for BatteryChargingStateChanged event from Battery class.
+ /// </summary>
public class BatteryChargingStateChangedEventArgs : EventArgs
{
internal BatteryChargingStateChangedEventArgs() {}
public bool IsCharging { get; internal set; }
}
- // Display
+ /// <summary>
+ /// DisplayStateChangedEventArgs is an extended EventArgs class. This class contains event arguments for DisplayStateChanged event from Display class.
+ /// </summary>
public class DisplayStateChangedEventArgs : EventArgs
{
internal DisplayStateChangedEventArgs() {}
public DisplayState State { get; internal set; }
}
- // Led
+ /// <summary>
+ /// LedBrightnessChangedEventArgs is an extended EventArgs class. This class contains event arguments for LedBrightnessChanged event from Led class.
+ /// </summary>
public class LedBrightnessChangedEventArgs : EventArgs
{
internal LedBrightnessChangedEventArgs() {}
switch (err)
{
case DeviceError.InvalidParameter:
+ case DeviceError.NotInitialized:
+ //fall through
exp = new ArgumentException(msg);
break;
case DeviceError.NotSupported:
- exp = new InvalidOperationException(msg +" : Device does not support the Operation.");
+ exp = new NotSupportedException(msg +" : Device does not support the Operation.");
break;
case DeviceError.AlreadyInProgress:
//fall through
//fall through
case DeviceError.OperationFailed:
//fall through
- case DeviceError.NotInitialized:
- //fall through
- case DeviceError.PermissionDenied:
- //fall through
case DeviceError.InvalidOperation:
exp = new InvalidOperationException(msg);
break;
+ case DeviceError.PermissionDenied:
+ exp = new UnauthorizedAccessException(msg);
+ break;
default:
exp = new InvalidOperationException("Unknown error occured.");
break;
namespace Tizen.System
{
/// <summary>
- /// Enumeration for the available display states.
+ /// Enumeration for the available Display states.
/// An application cannot put the device into the power off state or the suspend state.
/// </summary>
public enum DisplayState
}
/// <summary>
- /// The Display class provides properties and methods to control the display status and brightness.
+ /// The Display class provides Properties and Events to control the display status and brightness.
/// </summary>
+ /// <remarks>
+ /// The Display API provides the way to get the current Display brightness value,
+ /// display state and toal number of available displayes.
+ /// It also provides Events for an application to receive the Display state change events from the device.
+ /// To receive the Display event, application should register with assocated EventHandler.
+ /// </remarks>
+ /// <previlege>
+ /// http://tizen.org/privilege/display
+ /// </previlege>
+ /// <code>
+ /// Console.WriteLine("Display current state is: {0}", Tizen.System.Display.State);
+ /// Console.WriteLine("Total number of Displays are: {0}", Tizen.System.Display.NumberOfDisplays);
+ /// </code>
public class Display
{
private readonly int _displayId;
}
/// <summary>
- /// The number of display devices.
+ /// The number of available display devices.
/// </summary>
public static int NumberOfDisplays
{
}
/// <summary>
/// Get all the avaialble Displays.
+ /// The Display at index zero is always assigned to the main display.
/// </summary>
public static IReadOnlyList<Display> Displays
{
}
/// <summary>
- /// The maximum brightness value that can be set.
+ /// The maximum brightness value that can be set for the specific Display.
/// </summary>
+ /// <code>
+ /// Display display = Display.Displays[0];
+ /// Console.WriteLine("Display MaxBrightness is: {0}", display.MaxBrightness);
+ /// </code>
public int MaxBrightness
{
get
{
int max = 0;
- DeviceError res = (DeviceError) Interop.Device.DeviceDisplayGetMaxBrightness(_displayId, out max);
+ DeviceError res = (DeviceError)Interop.Device.DeviceDisplayGetMaxBrightness(_displayId, out max);
if (res != DeviceError.None)
{
Log.Warn(DeviceExceptionFactory.LogTag, "unable to get max brightness.");
}
/// <summary>
- /// The display brightness value.
+ /// The display brightness valu of the Display.
/// </summary>
+ /// <remarks>
+ /// Brightness value should be less than are equal to MaxBrightness value.
+ /// </remarks>
+ /// <exception cref="ArgumentException"> When the invalid parameter value is set.</exception>
+ /// <exception cref = "UnauthorizedAccessException"> If the privilege is not set.</exception>
+ /// <code>
+ /// Display display = Display.Displays[0];
+ /// Console.WriteLine("Display current Brightness is: {0}", display.Brightness);
+ /// </code>
public int Brightness
{
get
{
int brightness = 0;
- DeviceError res = (DeviceError) Interop.Device.DeviceDisplayGetBrightness(_displayId, out brightness);
+ DeviceError res = (DeviceError)Interop.Device.DeviceDisplayGetBrightness(_displayId, out brightness);
if (res != DeviceError.None)
{
Log.Warn(DeviceExceptionFactory.LogTag, "unable to get brightness.");
set
{
//TODO: Check for maximum throw exception..
- DeviceError res = (DeviceError) Interop.Device.DeviceDisplaySetBrightness(_displayId, value);
+ DeviceError res = (DeviceError)Interop.Device.DeviceDisplaySetBrightness(_displayId, value);
if (res != DeviceError.None)
{
throw DeviceExceptionFactory.CreateException(res, "unable to set brightness value");
}
}
/// <summary>
- /// The current display state.
+ /// The current device display state.
/// </summary>
public static DisplayState State
{
get
{
int state = 0;
- DeviceError res = (DeviceError) Interop.Device.DeviceDisplayGetState(out state);
+ DeviceError res = (DeviceError)Interop.Device.DeviceDisplayGetState(out state);
if (res != DeviceError.None)
{
Log.Warn(DeviceExceptionFactory.LogTag, "unable to get Display state.");
/// </summary>
/// <param name="sender"></param>
/// <param name="e">An DisplayStateChangedEventArgs object that contains the changed state</param>
-
+ /// <code>
+ /// public static async Task DisplayEventHandler()
+ /// {
+ /// EventHandler<DisplayStateChangedEventArgs> handler = null;
+ /// handler = (object sender, DisplayStateChangedEventArgs args) =>
+ /// {
+ /// Console.WriteLine("Display State is: {0}", args.State);
+ /// }
+ /// Battery.StateChanged += handler;
+ /// await Task.Delay(20000);
+ /// }
+ /// </code>
public static event EventHandler<DisplayStateChangedEventArgs> StateChanged
{
add
namespace Tizen.System
{
/// <summary>
- /// The Haptic class provides properties and methods to control a vibrator.
+ /// The Vibrator class provides properties and methods to control a vibrator.
/// </summary>
+ /// <remarks>
+ /// The Vibrator API provides the way to access the Vibrators in the device.
+ /// It allows the management of the device's vibrator parameters, such as the vibration count and level.
+ /// It provides methods to Vibrate and Stop the vibration.
+ /// </remarks>
+ /// <previlege>
+ /// http://tizen.org/privilege/haptic
+ /// </previlege>
+ /// <code>
+ /// Console.WriteLine("Total number of Vibrators are: {0}", Tizen.System.Vibrator.NumberOfVibrators);
+ /// </code>
public class Vibrator : IDisposable
{
private readonly int _vibratorId;
- private IntPtr _hapticHandle;
+ private IntPtr _hapticHandle = IntPtr.Zero;
private bool _disposedValue = false;
private static Lazy<IReadOnlyList<Vibrator>> _lazyVibrators;
private static int _maxcount = 0;
private Vibrator(int id)
{
_vibratorId = id;
- DeviceError res = (DeviceError) Interop.Device.DeviceHapticOpen(_vibratorId, out _hapticHandle);
+ DeviceError res = (DeviceError)Interop.Device.DeviceHapticOpen(_vibratorId, out _hapticHandle);
if (res != DeviceError.None)
{
throw DeviceExceptionFactory.CreateException(res, "unable to create Vibrator for given Id");
private static IReadOnlyList<Vibrator> GetAllVibrators()
{
int count = 0;
- List< Vibrator > vibrators = new List<Vibrator>();
+ List<Vibrator> vibrators = new List<Vibrator>();
DeviceError res = (DeviceError)Interop.Device.DeviceHapticGetCount(out count);
if (res != DeviceError.None)
{
throw DeviceExceptionFactory.CreateException(res, "unable to get Vibrators count.");
}
- for(int i = 0; i< NumberOfVibrators; i++)
+ for (int i = 0; i < NumberOfVibrators; i++)
{
vibrators.Add(new Vibrator(i));
}
/// </summary>
/// <param name="duration">The play duration in milliseconds </param>
/// <param name="feedback">The amount of the intensity variation (0 ~ 100) </param>
+ /// <exception cref="ArgumentException"> When the 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>
+ /// <exception cref = "NotSupportedException"> In case of device does not support this behavior.</exception>
+ /// <code>
+ /// Vibrator vibrator = Vibrator.Vibrators[0];
+ /// try
+ /// {
+ /// vibrator.Vibrate(2000, 70);
+ /// }
+ /// Catch(Exception e)
+ /// {
+ /// }
+ /// </code>
+
public void Vibrate(int duration, int feedback)
{
IntPtr effect;
DeviceError res = DeviceError.None;
if (_hapticHandle == IntPtr.Zero)
{
- res = (DeviceError) Interop.Device.DeviceHapticOpen(_vibratorId, out _hapticHandle);
+ res = (DeviceError)Interop.Device.DeviceHapticOpen(_vibratorId, out _hapticHandle);
if (res != DeviceError.None)
{
throw DeviceExceptionFactory.CreateException(res, "unable to get vibrator.");
}
}
- res = (DeviceError) Interop.Device.DeviceHapticVibrate(_hapticHandle, duration, feedback, out effect);
+ res = (DeviceError)Interop.Device.DeviceHapticVibrate(_hapticHandle, duration, feedback, out effect);
if (res != DeviceError.None)
{
throw DeviceExceptionFactory.CreateException(res, "unable to vibrate the current vibrator.");
/// Stops all vibration effects which are being played.
/// This function can be used to stop all effects started by Vibrate().
/// </summary>
+ /// <exception cref="ArgumentException"> In case of invalid vibrator instance is used.</exception>
+ /// <exception cref = "UnauthorizedAccessException"> If the privilege is not set.</exception>
+ /// <exception cref = "InvalidOperationException"> In case of any system error.</exception>
+ /// <exception cref = "NotSupportedException"> In case of device does not support this behavior.</exception>
+ /// <code>
+ /// Vibrator vibrator = Vibrator.Vibrators[0];
+ /// try
+ /// {
+ /// vibrator.Stop();
+ /// }
+ /// Catch(Exception e)
+ /// {
+ /// }
+ /// </code>
public void Stop()
{
if (_hapticHandle != IntPtr.Zero)
/// The IR API provides functions to control a IR transmitter.
/// The IR API provides the way to get the information whether IR is available and transmit IR command.
/// </summary>
+ /// <previlege>
+ /// http://tizen.org/privilege/use_ir
+ /// </previlege>
+ /// <code>
+ /// Console.WriteLine("IR availablity for this device is: {0}", IR.IsAvailable);
+ /// </code>
public static class IR
{
/// <summary>
get
{
bool available = false;
- DeviceError res = (DeviceError) Interop.Device.DeviceIRIsAvailable(out available);
+ DeviceError res = (DeviceError)Interop.Device.DeviceIRIsAvailable(out available);
if (res != DeviceError.None)
{
Log.Warn(DeviceExceptionFactory.LogTag, "unable to get ir status.");
/// <param name="pattern">
/// IR command list of type interger.
/// </param>
+ /// <exception cref="ArgumentException"> When the 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>
+ /// <exception cref = "NotSupportedException"> In case of device does not support this behavior.</exception>
+ /// <code>
+ /// try
+ /// {
+ /// List<int> pattern = new List<int>();
+ /// pattern.Add(10);
+ /// pattern.Add(50);
+ /// IR.Transmit(60657, pattern);
+ /// }
+ /// catch(Exception e)
+ /// {
+ /// }
+ /// </code>
public static void Transmit(int carrierFreequency, IList<int> pattern)
{
int[] patternArray = pattern.ToArray();
- DeviceError res = (DeviceError) Interop.Device.DeviceIRTransmit(carrierFreequency, patternArray, pattern.Count());
+ DeviceError res = (DeviceError)Interop.Device.DeviceIRTransmit(carrierFreequency, patternArray, pattern.Count());
if (res != DeviceError.None)
{
throw DeviceExceptionFactory.CreateException(res, "unable to trasmit IR command.");
/// <summary>
/// The Led class provides properties and methods to control the attached led device.
/// </summary>
+ /// <remarks>
+ /// The Led API provides the way to control the attached LED device such as the camera flash and service LED.It supports to turn on the camera flash and set the pattern to the service LED which is located to the front of a device.
+ /// Related Features
+ /// http://tizen.org/feature/led
+ /// http://tizen.org/feature/camera.back.flash
+ /// It is recommended to design feature related codes in your application for reliability.
+ /// You can check if a device supports the related features for this API by using System Information, thereby controlling the procedure of your application.
+ /// </remarks>
+ /// <previlege>
+ /// http://tizen.org/privilege/led
+ /// </previlege>
+ /// <code>
+ /// Console.WriteLine("Led MaxBrightness is: {0}", Tizen.System.Led.MaxBrightness);
+ /// Console.WriteLine("Led current Brightness is: {0}", Tizen.System.Led.Brightness);
+ /// </code>
public static class Led
{
/// <summary>
get
{
int max = 0;
- DeviceError res = (DeviceError) Interop.Device.DeviceFlashGetMaxBrightness(out max);
+ DeviceError res = (DeviceError)Interop.Device.DeviceFlashGetMaxBrightness(out max);
if (res != DeviceError.None)
{
Log.Warn(DeviceExceptionFactory.LogTag, "unable to get max brightness value.");
/// <summary>
/// Gets the brightness value of a LED that is located next to the camera.
/// </summary>
+ /// <remarks>The brightness value range of LED is 0 to Tizen.System.Led.MaxBrightness value.
+ /// Changing the brightness value will invoke the registered EventHandler for led BrightnessChanged (If any).
+ /// </remarks>
+ /// <exception cref="ArgumentException"> When the invalid parameter value is set.</exception>
+ /// <exception cref = "UnauthorizedAccessException"> If the privilege is not set.</exception>
+ /// <code>
+ /// Console.WriteLine("Led current Brightness is: {0}", Tizen.System.Led.Brightness);
+ /// Tizen.System.Led.Brightness = 50;
+ /// Console.WriteLine("Led current Brightness is: {0}", Tizen.System.Led.Brightness);
+ /// </code>
+
public static int Brightness
{
get
{
int brightness = 0;
- DeviceError res = (DeviceError) Interop.Device.DeviceFlashGetBrightness(out brightness);
+ DeviceError res = (DeviceError)Interop.Device.DeviceFlashGetBrightness(out brightness);
if (res != DeviceError.None)
{
Log.Warn(DeviceExceptionFactory.LogTag, "unable to get brightness value.");
}
set
{
- Interop.Device.DeviceFlashSetBrightness(value);
+ DeviceError res = (DeviceError) Interop.Device.DeviceFlashSetBrightness(value);
+ if (res != DeviceError.None)
+ {
+ throw DeviceExceptionFactory.CreateException(res, "unable to set brightness value");
+ }
}
}
/// The Color value
/// The first byte means opaque and the other 3 bytes are RGB values.
/// </param>
+ /// <exception cref="ArgumentException"> When the 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>
+ /// <exception cref = "NotSupportedException"> In case of device does not support this behavior.</exception>
+ /// <code>
+ /// try
+ /// {
+ /// Led.Play(500, 200, Color.FromRgba(255, 255, 255, 1));
+ /// }
+ /// Catch(Exception e)
+ /// {
+ /// }
+ /// </code>
public static void Play(int on, int off, Color color)
{
//looks like only blink option is supported. So hard coded to default blink option.
/// <summary>
/// Stops the LED that is located to the front of a device.
/// </summary>
+ /// <exception cref = "UnauthorizedAccessException"> If the privilege is not set.</exception>
+ /// <exception cref = "InvalidOperationException"> In case of any system error.</exception>
+ /// <exception cref = "NotSupportedException"> In case of device does not support this behavior.</exception>
+ /// <code>
+ /// try
+ /// {
+ /// Led.Play(500, 200, Color.FromRgba(255, 255, 255, 1));
+ /// //wait for a while and stop...
+ /// Led.Stop();
+ /// }
+ /// Catch(Exception e)
+ /// {
+ /// }
+ /// </code>
+
public static void Stop()
{
- DeviceError res = (DeviceError) Interop.Device.DeviceLedStopCustom();
- if(res != DeviceError.None)
+ DeviceError res = (DeviceError)Interop.Device.DeviceLedStopCustom();
+ if (res != DeviceError.None)
{
throw DeviceExceptionFactory.CreateException(res, "failed to stop Led.");
}
/// <summary>
/// The Power class provides methods to control the power service.
/// </summary>
+ /// <remarks>
+ /// The Power API provides the way to control the power service.
+ /// It can be made to hold the specific state to avoid CPU state internally.
+ /// </remarks>
+ /// <previlege>
+ /// http://tizen.org/privilege/display
+ /// </previlege>
public static class Power
{
/// <summary>
/// Locks the CPU 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>
/// <param name="timeout">
/// The positive number in milliseconds or 0 for permanent lock
/// So you must release the permanent lock of power state with ReleaseCpuLock() if timeout_ms is zero.
/// </param>
+ /// <exception cref="ArgumentException"> When the 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>
+ /// <code>
+ /// Tizen.System.Power.RequestCpuLock(2000);
+ /// </code>
+
public static void RequestCpuLock(int timeout)
{
- DeviceError res = (DeviceError) Interop.Device.DevicePowerRequestLock(0, timeout);
+ DeviceError res = (DeviceError)Interop.Device.DevicePowerRequestLock(0, timeout);
if (res != DeviceError.None)
{
throw DeviceExceptionFactory.CreateException(res, "unable to acquire power lock.");
}
}
-
/// <summary>
/// Releases the CPU lock state.
/// </summary>
+ /// <exception cref = "UnauthorizedAccessException"> If the privilege is not set.</exception>
+ /// <exception cref = "InvalidOperationException"> In case of any system error.</exception>
+ /// <code>
+ /// Tizen.System.Power.ReleaseCpuLock();
+ /// </code>
public static void ReleaseCpuLock()
{
- DeviceError res = (DeviceError) Interop.Device.DevicePowerReleaseLock(0);
+ DeviceError res = (DeviceError)Interop.Device.DevicePowerReleaseLock(0);
if (res != DeviceError.None)
{
throw DeviceExceptionFactory.CreateException(res, "unable to release power lock.");