+++ /dev/null
-/*
-* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* Licensed under the Apache License, Version 2.0 (the License);
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an AS IS BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-using System;
-using System.Collections.Generic;
-
-
-namespace Tizen.System
-{
- /// <summary>
- /// Class for constants
- /// </summary>
- internal static class Constants
- {
- internal const int NumberOfPattern = 39;
- }
-
- /// <summary>
- /// The Feedback API provides functions to control haptic and sound.
- /// The Feedback API provides the way to play and stop feedback and get the information whether specific pattern is supported.
- /// Below is supported pattern string.
- /// Tap
- /// SoftInputPanel
- /// Key0
- /// Key1
- /// Key2
- /// Key3
- /// Key4
- /// Key5
- /// Key6
- /// Key7
- /// Key8
- /// Key9
- /// KeyStar
- /// KeySharp
- /// KeyBack
- /// Hold
- /// HardwareKeyPressed
- /// HardwareKeyHold
- /// Message
- /// Email
- /// WakeUp
- /// Schedule
- /// Timer
- /// General
- /// PowerOn
- /// PowerOff
- /// ChargerConnected
- /// ChargingError
- /// FullyCharged
- /// LowBattery
- /// Lock
- /// UnLock
- /// VibrationModeAbled
- /// SilentModeDisabled
- /// BluetoothDeviceConnected
- /// BluetoothDeviceDisconnected
- /// ListReorder
- /// ListSlider
- /// VolumeKeyPressed
- /// </summary>
- /// <privilege>
- /// For controlling haptic device:
- /// http://tizen.org/privilege/haptic
- /// For controlling sound, previlege is not needed.
- /// </privilege>
- /// <code>
- /// Feedback feedback = new Feedback();
- /// bool res = feedback.IsSupportedPattern(FeedbackType.Vibration, "Tap");
- /// </code>
- public class Feedback
- {
- private const string LogTag = "Tizen.System.Feedback";
-
- private readonly FeedbackPattern[] Pattern = new FeedbackPattern[39];
- public Feedback()
- {
- Pattern[0].PatternNumber = 0;
- Pattern[0].PatternString = "Tap";
- Pattern[1].PatternNumber = 1;
- Pattern[1].PatternString = "SoftInputPanel";
- Pattern[2].PatternNumber = 6;
- Pattern[2].PatternString = "Key0";
- Pattern[3].PatternNumber = 7;
- Pattern[3].PatternString = "Key1";
- Pattern[4].PatternNumber = 8;
- Pattern[4].PatternString = "Key2";
- Pattern[5].PatternNumber = 9;
- Pattern[5].PatternString = "Key3";
- Pattern[6].PatternNumber = 10;
- Pattern[6].PatternString = "Key4";
- Pattern[7].PatternNumber = 11;
- Pattern[7].PatternString = "Key5";
- Pattern[8].PatternNumber = 12;
- Pattern[8].PatternString = "Key6";
- Pattern[9].PatternNumber = 13;
- Pattern[9].PatternString = "Key7";
- Pattern[10].PatternNumber = 14;
- Pattern[10].PatternString = "Key8";
- Pattern[11].PatternNumber = 15;
- Pattern[11].PatternString = "Key9";
- Pattern[12].PatternNumber = 16;
- Pattern[12].PatternString = "KeyStar";
- Pattern[13].PatternNumber = 17;
- Pattern[13].PatternString = "KeySharp";
- Pattern[14].PatternNumber = 18;
- Pattern[14].PatternString = "KeyBack";
- Pattern[15].PatternNumber = 19;
- Pattern[15].PatternString = "Hold";
- Pattern[16].PatternNumber = 21;
- Pattern[16].PatternString = "HardwareKeyPressed";
- Pattern[17].PatternNumber = 22;
- Pattern[17].PatternString = "HardwareKeyHold";
- Pattern[18].PatternNumber = 23;
- Pattern[18].PatternString = "Message";
- Pattern[19].PatternNumber = 25;
- Pattern[19].PatternString = "Email";
- Pattern[20].PatternNumber = 27;
- Pattern[20].PatternString = "WakeUp";
- Pattern[21].PatternNumber = 29;
- Pattern[21].PatternString = "Schedule";
- Pattern[22].PatternNumber = 31;
- Pattern[22].PatternString = "Timer";
- Pattern[23].PatternNumber = 33;
- Pattern[23].PatternString = "General";
- Pattern[24].PatternNumber = 36;
- Pattern[24].PatternString = "PowerOn";
- Pattern[25].PatternNumber = 37;
- Pattern[25].PatternString = "PowerOff";
- Pattern[26].PatternNumber = 38;
- Pattern[26].PatternString = "ChargerConnected";
- Pattern[27].PatternNumber = 40;
- Pattern[27].PatternString = "ChargingError";
- Pattern[28].PatternNumber = 42;
- Pattern[28].PatternString = "FullyCharged";
- Pattern[29].PatternNumber = 44;
- Pattern[29].PatternString = "LowBattery";
- Pattern[30].PatternNumber = 46;
- Pattern[30].PatternString = "Lock";
- Pattern[31].PatternNumber = 47;
- Pattern[31].PatternString = "UnLock";
- Pattern[32].PatternNumber = 55;
- Pattern[32].PatternString = "VibrationModeAbled";
- Pattern[33].PatternNumber = 56;
- Pattern[33].PatternString = "SilentModeDisabled";
- Pattern[34].PatternNumber = 57;
- Pattern[34].PatternString = "BluetoothDeviceConnected";
- Pattern[35].PatternNumber = 58;
- Pattern[35].PatternString = "BluetoothDeviceDisconnected";
- Pattern[36].PatternNumber = 62;
- Pattern[36].PatternString = "ListReorder";
- Pattern[37].PatternNumber = 63;
- Pattern[37].PatternString = "ListSlider";
- Pattern[38].PatternNumber = 64;
- Pattern[38].PatternString = "VolumeKeyPressed";
-
- Interop.Feedback.FeedbackError res = (Interop.Feedback.FeedbackError)Interop.Feedback.Initialize();
- if (res != Interop.Feedback.FeedbackError.None)
- {
- Log.Warn(LogTag, string.Format("Failed to initialize feedback. err = {0}", res));
- switch (res)
- {
- case Interop.Feedback.FeedbackError.NotSupported:
- throw new NotSupportedException("Device is not supported");
- default:
- throw new InvalidOperationException("Failed to initialize");
- }
- }
- }
-
- ~Feedback()
- {
- Interop.Feedback.FeedbackError res = (Interop.Feedback.FeedbackError)Interop.Feedback.Deinitialize();
- if (res != Interop.Feedback.FeedbackError.None)
- {
- Log.Warn(LogTag, string.Format("Failed to deinitialize feedback. err = {0}", res));
- switch (res)
- {
- case Interop.Feedback.FeedbackError.NotInitialized:
- throw new Exception("Not initialized");
- default:
- throw new InvalidOperationException("Failed to initialize");
- }
- }
- }
-
- /// <summary>
- /// Get supported information about specific type and pattern
- /// </summary>
- /// <remarks>
- /// Now, IsSupportedPattern is not working for FeedbackType.All.
- /// This API is working for FeedbackType.Sound and FeedbackType.Vibration only.
- /// If you use FeedbackType.All for type parameter, this API will throw ArgumentException.
- /// To get supported information for Vibration type, app should have http://tizen.org/privilege/haptic privilege.
- /// </remarks>
- /// <param name="type">Feedback type</param>
- /// <param name="pattern">Feedback pattern string</param>
- /// <returns>Information whether pattern is supported</returns>
- /// <exception cref="Exception">Thrown when failed because feedback is not initialized</exception>
- /// <exception cref="ArgumentException">Thrown when failed because of a invalid arguament</exception>
- /// <exception cref="NotSupportedException">Thrown when failed becuase device(haptic, sound) is not supported</exception>
- /// <exception cref="UnauthorizedAccessException">Thrown when failed because access is not granted(No privilege)</exception>
- /// <exception cref="InvalidOperationException">Thrown when failed because of system error</exception>
- /// <privilege>http://tizen.org/privilege/haptic</privilege>
- /// <example>
- /// <code>
- /// Feedback feedback = new Feedback();
- /// bool res = feedback.IsSupportedPattern(FeedbackType.Vibration, "Tap");
- /// </code>
- /// </example>
- public bool IsSupportedPattern(FeedbackType type, String pattern)
- {
- bool supported = false;
- bool found = false;
- int i = 0;
- Interop.Feedback.FeedbackError res;
-
- for (i = 0; i < Constants.NumberOfPattern; i++)
- {
- if (String.Compare(pattern, Pattern[i].PatternString) == 0)
- {
- found = true;
- break;
- }
- }
-
- if (!found)
- throw new ArgumentException("Invalid Arguments");
-
- res = (Interop.Feedback.FeedbackError)Interop.Feedback.IsSupportedPattern((Interop.Feedback.FeedbackType)type, Pattern[i].PatternNumber, out supported);
-
-
- if (res != Interop.Feedback.FeedbackError.None)
- {
- Log.Warn(LogTag, string.Format("Failed to get supported information. err = {0}", res));
- switch (res)
- {
- case Interop.Feedback.FeedbackError.NotInitialized:
- throw new Exception("Not initialized");
- case Interop.Feedback.FeedbackError.InvalidParameter:
- throw new ArgumentException("Invalid Arguments");
- case Interop.Feedback.FeedbackError.NotSupported:
- throw new NotSupportedException("Device is not supported");
- case Interop.Feedback.FeedbackError.PermissionDenied:
- throw new UnauthorizedAccessException("Access is not granted");
- case Interop.Feedback.FeedbackError.OperationFailed:
- default:
- throw new InvalidOperationException("Failed to get supported information");
- }
- }
- return supported;
- }
-
- /// <summary>
- /// Play specific feedback pattern
- /// </summary>
- /// <remarks>
- /// To play Vibration type, app should have http://tizen.org/privilege/haptic privilege.
- /// </remarks>
- /// <param name="type">Feedback type</param>
- /// <param name="pattern">Feedback pattern string</param>
- /// <exception cref="Exception">Thrown when failed because feedback is not initialized</exception>
- /// <exception cref="ArgumentException">Thrown when failed because of a invalid arguament</exception>
- /// <exception cref="NotSupportedException">Thrown when failed because device(haptic, sound) or specific pattern is not supported</exception>
- /// <exception cref="UnauthorizedAccessException">Thrown when failed because access is not granted(No privilege)</exception>
- /// <exception cref="InvalidOperationException">Thrown when failed because of system error</exception>
- /// <privilege>http://tizen.org/privilege/haptic</privilege>
- /// <example>
- /// <code>
- /// Feedback feedback = new Feedback();
- /// feedback.Play(FeedbackType.All, "Tap");
- /// </code>
- /// </example>
- public void Play(FeedbackType type, String pattern)
- {
- bool found = false;
- int i = 0;
- Interop.Feedback.FeedbackError res;
-
- for (i = 0; i < Constants.NumberOfPattern; i++)
- {
- if (String.Compare(pattern, Pattern[i].PatternString) == 0)
- {
- found = true;
- break;
- }
- }
-
- if (!found)
- throw new ArgumentException("Invalid Arguments");
-
- if (type == FeedbackType.All)
- res = (Interop.Feedback.FeedbackError)Interop.Feedback.Play(Pattern[i].PatternNumber);
- else
- res = (Interop.Feedback.FeedbackError)Interop.Feedback.PlayType((Interop.Feedback.FeedbackType)type, Pattern[i].PatternNumber);
-
- if (res != Interop.Feedback.FeedbackError.None)
- {
- Log.Warn(LogTag, string.Format("Failed to play feedback. err = {0}", res));
- switch (res)
- {
- case Interop.Feedback.FeedbackError.NotInitialized:
- throw new Exception("Not initialized");
- case Interop.Feedback.FeedbackError.InvalidParameter:
- throw new ArgumentException("Invalid Arguments");
- case Interop.Feedback.FeedbackError.NotSupported:
- throw new NotSupportedException("Not supported");
- case Interop.Feedback.FeedbackError.PermissionDenied:
- throw new UnauthorizedAccessException("Access is not granted");
- case Interop.Feedback.FeedbackError.OperationFailed:
- default:
- throw new InvalidOperationException("Failed to play pattern");
- }
- }
- }
-
- /// <summary>
- /// Stop to play feedback
- /// </summary>
- /// <remarks>
- /// To stop vibration, app should have http://tizen.org/privilege/haptic privilege.
- /// </remarks>
- /// <exception cref="Exception">Thrown when failed because feedback is not initialized</exception>
- /// <exception cref="ArgumentException">Thrown when failed because of a invalid arguament</exception>
- /// <exception cref="NotSupportedException">Thrown when failed because device(haptic, sound) or specific pattern is not supported</exception>
- /// <exception cref="UnauthorizedAccessException">Thrown when failed because access is not granted(No privilege)</exception>
- /// <exception cref="InvalidOperationException">Thrown when failed because of system error</exception>
- /// <privilege>http://tizen.org/privilege/haptic</privilege>
- /// <example>
- /// <code>
- /// Feedback Feedback1 = new Feedback();
- /// Feedback1.Stop();
- /// </code>
- /// </example>
- public void Stop()
- {
- Interop.Feedback.FeedbackError res = (Interop.Feedback.FeedbackError)Interop.Feedback.Stop();
-
- if (res != Interop.Feedback.FeedbackError.None)
- {
- Log.Warn(LogTag, string.Format("Failed to stop feedback. err = {0}", res));
- switch (res)
- {
- case Interop.Feedback.FeedbackError.NotInitialized:
- throw new Exception("Not initialized");
- case Interop.Feedback.FeedbackError.InvalidParameter:
- throw new ArgumentException("Invalid Arguments");
- case Interop.Feedback.FeedbackError.NotSupported:
- throw new NotSupportedException("Not supported");
- case Interop.Feedback.FeedbackError.PermissionDenied:
- throw new UnauthorizedAccessException("Access is not granted");
- case Interop.Feedback.FeedbackError.OperationFailed:
- default:
- throw new InvalidOperationException("Failed to play pattern");
- }
- }
- }
- }
-}
+++ /dev/null
-/*
-* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* Licensed under the Apache License, Version 2.0 (the License);
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an AS IS BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-namespace Tizen.System
-{
- /// <summary>
- /// String and Enumeration for feedback patterns.
- /// </summary>
- internal struct FeedbackPattern
- {
- internal int PatternNumber;
- internal string PatternString;
-
- internal FeedbackPattern(int n, string s)
- {
- PatternNumber = n;
- PatternString = s;
- }
- }
-}
+++ /dev/null
-/*
-* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* Licensed under the Apache License, Version 2.0 (the License);
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an AS IS BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-namespace Tizen.System
-{
- /// <summary>
- /// Enumeration for feedback device types.
- /// </summary>
- public enum FeedbackType
- {
- /// <summary>
- /// Sound and Vibration
- /// </summary>
- All = 0,
- /// <summary>
- /// Sound feedback
- /// </summary>
- Sound = Interop.Feedback.FeedbackType.Sound,
- /// <summary>
- /// Vibration
- /// /// </summary>
- Vibration = Interop.Feedback.FeedbackType.Vibration,
- }
-}
+++ /dev/null
-/*
-* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* Licensed under the Apache License, Version 2.0 (the License);
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an AS IS BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-using System;
-using System.Runtime.InteropServices;
-
-internal static partial class Interop
-{
- internal static partial class Feedback
- {
- internal enum FeedbackError
- {
- None = Tizen.Internals.Errors.ErrorCode.None,
- OperationFailed = Tizen.Internals.Errors.ErrorCode.NotPermitted,
- InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
- NotSupported = Tizen.Internals.Errors.ErrorCode.NoSuchDevice,
- PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
- NotInitialized = -0x00020000 | 0x12,
- }
-
- // Any change here might require changes in Tizen.System.FeedbackType enum
- internal enum FeedbackType
- {
- Sound = 1,
- Vibration = 2,
- }
-
- [DllImport(Libraries.Feedback, EntryPoint = "feedback_initialize")]
- internal static extern int Initialize();
-
- [DllImport(Libraries.Feedback, EntryPoint = "feedback_deinitialize")]
- internal static extern int Deinitialize();
-
- [DllImport(Libraries.Feedback, EntryPoint = "feedback_play")]
- internal static extern int Play(int pattern);
-
- [DllImport(Libraries.Feedback, EntryPoint = "feedback_play_type")]
- internal static extern int PlayType(FeedbackType type, int pattern);
-
- [DllImport(Libraries.Feedback, EntryPoint = "feedback_stop")]
- internal static extern int Stop();
-
- [DllImport(Libraries.Feedback, EntryPoint = "feedback_is_supported_pattern")]
- internal static extern int IsSupportedPattern(FeedbackType type, int pattern, out bool supported);
- }
-}
internal static partial class Libraries
{
internal const string RuntimeInfo = "libcapi-system-runtime-info.so.0";
- internal const string Storage = "libstorage.so.0.1";
internal const string SystemInfo = "libcapi-system-info.so.0";
- internal const string Feedback = "libfeedback.so.0";
}
}
+++ /dev/null
-/*
-* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* Licensed under the Apache License, Version 2.0 (the License);
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an AS IS BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-using System;
-using System.Runtime.InteropServices;
-
-internal static partial class Interop
-{
- internal static partial class Storage
- {
- internal enum ErrorCode
- {
- None = Tizen.Internals.Errors.ErrorCode.None,
- InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
- OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
- NotSupported = Tizen.Internals.Errors.ErrorCode.NoSuchDevice,
- OperationFailed = -0x00020000 | 0x12,
- }
-
- // Any change here might require changes in Tizen.System.StorageArea enum
- internal enum StorageArea
- {
- Internal = 0,
- External = 1,
- }
-
- // Any change here might require changes in Tizen.System.StorageState enum
- internal enum StorageState
- {
- Unmountable = -2,
- Removed = -1,
- Mounted = 0,
- MountedReadOnly = 1,
- }
-
- // Any change here might require changes in Tizen.System.directoryType enum
- internal enum DirectoryType
- {
- Images = 0,
- Sounds = 1,
- Videos = 2,
- Camera = 3,
- Downloads = 4,
- Music = 5,
- Documents = 6,
- Others = 7,
- Ringtones = 8,
- }
-
- [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
- internal delegate void StorageStateChangedCallback(int id, StorageState state, IntPtr userData);
-
- [DllImport(Libraries.Storage, EntryPoint = "storage_get_root_directory")]
- internal static extern ErrorCode StorageGetRootDirectory(int id, out string path);
-
- [DllImport(Libraries.Storage, EntryPoint = "storage_get_directory")]
- internal static extern ErrorCode StorageGetAbsoluteDirectory(int id, DirectoryType type, out string path);
-
- [DllImport(Libraries.Storage, EntryPoint = "storage_get_state")]
- internal static extern ErrorCode StorageGetState(int id, out StorageState state);
-
- [DllImport(Libraries.Storage, EntryPoint = "storage_get_type")]
- internal static extern ErrorCode StorageGetType(int id, out StorageArea type);
-
- [DllImport(Libraries.Storage, EntryPoint = "storage_set_state_changed_cb")]
- internal static extern ErrorCode StorageSetStateChanged(int id, StorageStateChangedCallback callback, IntPtr userData);
-
- [DllImport(Libraries.Storage, EntryPoint = "storage_unset_state_changed_cb")]
- internal static extern ErrorCode StorageUnsetStateChanged(int id, StorageStateChangedCallback callback);
-
- [DllImport(Libraries.Storage, EntryPoint = "storage_get_total_space")]
- internal static extern ErrorCode StorageGetTotalSpace(int id, out ulong bytes);
-
- [DllImport(Libraries.Storage, EntryPoint = "storage_get_available_space")]
- internal static extern ErrorCode StorageGetAvailableSpace(int id, out ulong bytes);
-
- [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
- internal delegate bool StorageDeviceSupportedCallback(int storageID, StorageArea type, StorageState state, string rootDirectory, IntPtr userData);
-
- [DllImport(Libraries.Storage, EntryPoint = "storage_foreach_device_supported")]
- public static extern ErrorCode StorageManagerGetForeachDeviceSupported(StorageDeviceSupportedCallback callback, IntPtr userData);
- }
-}
+++ /dev/null
-/*
-* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* Licensed under the Apache License, Version 2.0 (the License);
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an AS IS BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-namespace Tizen.System
-{
- /// <summary>
- /// Enumeration of the storage directory types.
- /// </summary>
- public enum DirectoryType
- {
- /// <summary>
- /// Image directory
- /// </summary>
- Images = Interop.Storage.DirectoryType.Images,
- /// <summary>
- /// Sounds directory
- /// </summary>
- Sounds = Interop.Storage.DirectoryType.Sounds,
- /// <summary>
- /// Videos directory
- /// </summary>
- Videos = Interop.Storage.DirectoryType.Videos,
- /// <summary>
- /// Camera directory
- /// </summary>
- Camera = Interop.Storage.DirectoryType.Camera,
- /// <summary>
- /// Downloads directory
- /// </summary>
- Downloads = Interop.Storage.DirectoryType.Downloads,
- /// <summary>
- /// Music directory
- /// </summary>
- Music = Interop.Storage.DirectoryType.Music,
- /// <summary>
- /// Documents directory
- /// </summary>
- Documents = Interop.Storage.DirectoryType.Documents,
- /// <summary>
- /// Others directory
- /// </summary>
- Others = Interop.Storage.DirectoryType.Others,
- /// <summary>
- /// System ringtones directory. Only available for internal storage.
- /// </summary>
- Ringtones = Interop.Storage.DirectoryType.Ringtones,
- }
-}
+++ /dev/null
-/*
-* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* Licensed under the Apache License, Version 2.0 (the License);
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an AS IS BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-using System;
-
-namespace Tizen.System
-{
- /// <summary>
- /// class to access storage device information
- /// </summary>
- public class Storage
- {
- private const string LogTag = "Tizen.System";
- private Interop.Storage.StorageState _state;
- private ulong _totalSpace;
-
- internal Storage(int storageID, Interop.Storage.StorageArea storageType, Interop.Storage.StorageState storagestate, string rootDirectory)
- {
- Id = storageID;
- StorageType = (StorageArea)storageType;
- RootDirectory = rootDirectory;
- _state = storagestate;
-
- Interop.Storage.ErrorCode err = Interop.Storage.StorageGetTotalSpace(Id, out _totalSpace);
- if (err != Interop.Storage.ErrorCode.None)
- {
- Log.Warn(LogTag, string.Format("Failed to get total storage space for storage Id: {0}. err = {1}", Id, err));
- }
-
- s_stateChangedEventCallback = (id, state, userData) =>
- {
- if (id == Id)
- {
- _state = state;
- s_stateChangedEventHandler?.Invoke(this, EventArgs.Empty);
- }
- };
- }
-
- private EventHandler s_stateChangedEventHandler;
- private Interop.Storage.StorageStateChangedCallback s_stateChangedEventCallback;
-
- private void RegisterStateChangedEvent()
- {
- Interop.Storage.ErrorCode err = Interop.Storage.StorageSetStateChanged(Id, s_stateChangedEventCallback, IntPtr.Zero);
- if (err != Interop.Storage.ErrorCode.None)
- {
- Log.Warn(LogTag, string.Format("Failed to Register state changed event callback for storage Id: {0}. err = {1}", Id, err));
- }
- }
-
- private void UnregisterStateChangedEvent()
- {
- Interop.Storage.ErrorCode err = Interop.Storage.StorageUnsetStateChanged(Id, s_stateChangedEventCallback);
- if (err != Interop.Storage.ErrorCode.None)
- {
- Log.Warn(LogTag, string.Format("Failed to Register state changed event callback for storage Id: {0}. err = {1}", Id, err));
- }
- }
-
- /// <summary>
- /// StorageStateChanged event. This event is occurred when a storage state changes.
- /// </summary>
- /// <remarks>
- /// Storage state will be updated before calling event handler.
- /// </remarks>
- /// <example>
- /// <code>
- /// myStorage.StorageStateChanged += (s, e) =>
- /// {
- /// var storage = s as Storage;
- /// Console.WriteLine(string.Format("State Changed to {0}", storage.State));
- /// }
- /// </code>
- /// </example>
- public event EventHandler StorageStateChanged
- {
- add
- {
- if (s_stateChangedEventHandler == null)
- {
- _state = (Interop.Storage.StorageState)State;
- RegisterStateChangedEvent();
- }
- s_stateChangedEventHandler += value;
- }
- remove
- {
- if (s_stateChangedEventHandler != null)
- {
- s_stateChangedEventHandler -= value;
- if (s_stateChangedEventHandler == null)
- {
- UnregisterStateChangedEvent();
- }
- }
- }
- }
-
- /// <summary>
- /// Storage ID
- /// </summary>
- public int Id { get; }
- /// <summary>
- /// Type of the storage
- /// </summary>
- public StorageArea StorageType { get; }
- /// <summary>
- /// Root directory for the storage
- /// </summary>
- public string RootDirectory { get; }
- /// <summary>
- /// Total storage size in bytes
- /// </summary>
- public ulong TotalSpace { get { return _totalSpace; } }
-
- /// <summary>
- /// Storage state
- /// </summary>
- public StorageState State
- {
- get
- {
- if (s_stateChangedEventHandler == null)
- {
- Interop.Storage.ErrorCode err = Interop.Storage.StorageGetState(Id, out _state);
- if (err != Interop.Storage.ErrorCode.None)
- {
- Log.Warn(LogTag, string.Format("Failed to get storage state for storage Id: {0}. err = {1}", Id, err));
- }
- }
- return (StorageState)_state;
- }
- }
-
- /// <summary>
- /// Available storage size in bytes
- /// </summary>
- public ulong AvaliableSpace
- {
- get
- {
- ulong available;
- Interop.Storage.ErrorCode err = Interop.Storage.StorageGetAvailableSpace(Id, out available);
- if (err != Interop.Storage.ErrorCode.None)
- {
- Log.Warn(LogTag, string.Format("Failed to get available storage stace for storage Id: {0}. err = {1}", Id, err));
- }
-
- return available;
- }
- }
-
- /// <summary>
- /// Absolute path for given directory type in storage
- /// </summary>
- /// <remarks>
- /// returned directory path may not exist, so you must make sure that it exists before using it.
- /// For accessing internal storage except Ringtones directory, app should have http://tizen.org/privilege/mediastorage privilege.
- /// For accessing Ringtones directory, app should have http://tizen.org/privilege/systemsettings privilege.
- /// For accessing external storage, app should have http://tizen.org/privilege/externalstorage privilege.
- /// </remarks>
- /// <param name="dirType">Directory type</param>
- /// <returns>Absolute path for given directory type in storage</returns>
- /// <exception cref="ArgumentException">Thrown when failed because of a invalid arguament</exception>
- /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory exception</exception>
- /// <exception cref="NotSupportedException">Thrown when failed if storage is not supported or app does not have permission to access directory path</exception>
- /// <privilege>http://tizen.org/privilege/mediastorage</privilege>
- /// <privilege>http://tizen.org/privilege/systemsettings</privilege>
- /// <privilege>http://tizen.org/privilege/externalstorage</privilege>
- /// <example>
- /// <code>
- /// // To get video directories for all supported storage,
- /// var storageList = StorageManager.Storages as List<Storage>;
- /// foreach (var storage in storageList)
- /// {
- /// string pathForVideoDir = storage.GetAbsolutePath(DirectoryType.Videos);
- /// }
- /// </code>
- /// </example>
- public string GetAbsolutePath(DirectoryType dirType)
- {
- string path;
- Interop.Storage.ErrorCode err = Interop.Storage.StorageGetAbsoluteDirectory(Id, (Interop.Storage.DirectoryType)dirType, out path);
- if (err != Interop.Storage.ErrorCode.None)
- {
- Log.Warn(LogTag, string.Format("Failed to get package Id. err = {0}", err));
- switch (err)
- {
- case Interop.Storage.ErrorCode.InvalidParameter:
- throw new ArgumentException("Invalid Arguments");
- case Interop.Storage.ErrorCode.OutOfMemory:
- throw new OutOfMemoryException("Out of Memory");
- case Interop.Storage.ErrorCode.NotSupported:
- throw new NotSupportedException("Operation Not Supported");
- default:
- throw new InvalidOperationException("Error = " + err);
- }
- }
- return path;
- }
- }
-}
+++ /dev/null
-/*
-* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* Licensed under the Apache License, Version 2.0 (the License);
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an AS IS BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-namespace Tizen.System
-{
- /// <summary>
- /// Enumeration for storage area types.
- /// </summary>
- public enum StorageArea
- {
- /// <summary>
- /// Internal device storage (built-in storage in a device, non-removable)
- /// </summary>
- Internal = Interop.Storage.StorageArea.Internal,
- /// <summary>
- /// External storage
- /// </summary>
- External = Interop.Storage.StorageArea.External,
- }
-}
+++ /dev/null
-/*
-* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* Licensed under the Apache License, Version 2.0 (the License);
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an AS IS BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-using System;
-using System.Collections.Generic;
-
-namespace Tizen.System
-{
- /// <summary>
- /// Storage Manager, provides properties/ methods to access storage in the device.
- /// </summary>
- public static class StorageManager
- {
- private const string LogTag = "Tizen.System";
-
- /// <summary>
- /// List of all storage in the device
- /// </summary>
- public static IEnumerable<Storage> Storages
- {
- get
- {
- List<Storage> storageList = new List<Storage>();
- Interop.Storage.StorageDeviceSupportedCallback cb = (int storageID, Interop.Storage.StorageArea type, Interop.Storage.StorageState state, string rootDirectory, IntPtr userData) =>
- {
- storageList.Add(new Storage(storageID, type, state, rootDirectory));
- return true;
- };
-
- Interop.Storage.ErrorCode err = Interop.Storage.StorageManagerGetForeachDeviceSupported(cb, IntPtr.Zero);
- if (err != Interop.Storage.ErrorCode.None)
- {
- Log.Warn(LogTag, string.Format("Failed to get storage list. err = {0}", err));
- }
- return storageList;
- }
- }
- }
-}
+++ /dev/null
-/*
-* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* Licensed under the Apache License, Version 2.0 (the License);
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an AS IS BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-namespace Tizen.System
-{
- /// <summary>
- /// Enumeration for the state of storage devices.
- /// </summary>
- public enum StorageState
- {
- /// <summary>
- /// Storage is present but cannot be mounted. Typically it happens if the file system of the storage is corrupted
- /// </summary>
- Unmountable = Interop.Storage.StorageState.Unmountable,
- /// <summary>
- /// Storage is not present or removed
- /// </summary>
- Removed = Interop.Storage.StorageState.Removed,
- /// <summary>
- /// Storage is mounted with read/write access
- /// </summary>
- Mounted = Interop.Storage.StorageState.Mounted,
- /// <summary>
- /// Storage is mounted with read only access
- /// </summary>
- MountedReadOnly = Interop.Storage.StorageState.MountedReadOnly,
- }
-}
<Compile Include="Device\Power.cs" />\r
<Compile Include="Device\IR.cs" />\r
<Compile Include="Device\DeviceEventArgs.cs" />\r
- <Compile Include="Feedback\Feedback.cs" />\r
- <Compile Include="Feedback\FeedbackPattern.cs" />\r
- <Compile Include="Feedback\FeedbackType.cs" />\r
- <Compile Include="Interop\Interop.Feedback.cs" />\r
<Compile Include="Interop\Interop.Device.cs" />\r
<Compile Include="Interop\Interop.RuntimeInfo.cs" />\r
<Compile Include="Interop\Interop.Libraries.cs" />\r
- <Compile Include="Interop\Interop.Storage.cs" />\r
<Compile Include="Interop\Interop.SystemInfo.cs" />\r
<Compile Include="Properties\AssemblyInfo.cs" />\r
<Compile Include="RuntimeInfo\CpuUsage.cs" />\r
<Compile Include="RuntimeInfo\RuntimeInformation.cs" />\r
<Compile Include="RuntimeInfo\RuntimeKeyStatusChangedEventArgs.cs" />\r
<Compile Include="RuntimeInfo\MemoryInformation.cs" />\r
- <Compile Include="Storage\DirectoryType.cs" />\r
- <Compile Include="Storage\Storage.cs" />\r
- <Compile Include="Storage\StorageArea.cs" />\r
- <Compile Include="Storage\StorageManager.cs" />\r
- <Compile Include="Storage\StorageState.cs" />\r
<Compile Include="SystemInfo\SystemInfo.cs" />\r
</ItemGroup>\r
<ItemGroup>\r
<Target Name="AfterBuild">\r
</Target>\r
-->\r
-</Project>
\ No newline at end of file
+</Project>\r
<Compile Include="Device\Power.cs" />\r
<Compile Include="Device\IR.cs" />\r
<Compile Include="Device\DeviceEventArgs.cs" />\r
- <Compile Include="Feedback\Feedback.cs" />\r
- <Compile Include="Feedback\FeedbackPattern.cs" />\r
- <Compile Include="Feedback\FeedbackType.cs" />\r
- <Compile Include="Interop\Interop.Feedback.cs" />\r
<Compile Include="Interop\Interop.Device.cs" />\r
<Compile Include="Interop\Interop.RuntimeInfo.cs" />\r
<Compile Include="Interop\Interop.Libraries.cs" />\r
- <Compile Include="Interop\Interop.Storage.cs" />\r
<Compile Include="Interop\Interop.SystemInfo.cs" />\r
<Compile Include="Properties\AssemblyInfo.cs" />\r
<Compile Include="RuntimeInfo\CpuUsage.cs" />\r
<Compile Include="RuntimeInfo\RuntimeInformation.cs" />\r
<Compile Include="RuntimeInfo\RuntimeKeyStatusChangedEventArgs.cs" />\r
<Compile Include="RuntimeInfo\MemoryInformation.cs" />\r
- <Compile Include="Storage\DirectoryType.cs" />\r
- <Compile Include="Storage\Storage.cs" />\r
- <Compile Include="Storage\StorageArea.cs" />\r
- <Compile Include="Storage\StorageManager.cs" />\r
- <Compile Include="Storage\StorageState.cs" />\r
<Compile Include="SystemInfo\SystemInfo.cs" />\r
</ItemGroup>\r
<ItemGroup>\r
<_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>\r
<AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>\r
</PropertyGroup>\r
-</Project>
\ No newline at end of file
+</Project>\r
<projectUrl>https://www.tizen.org/</projectUrl>
<iconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</iconUrl>
<copyright>© Samsung Electronics Co., Ltd All Rights Reserved</copyright>
- <description>Provide classes for SystemInformation, RuntimeInformation, Device, Feedback, and Storage API</description>
+ <description>Provide classes for SystemInformation, RuntimeInformation, and Device API</description>
<dependencies>
<dependency id="Tizen" version="1.0.2" />
</dependencies>
Name: csapi-system
Summary: Tizen System API for C#
-Version: 1.0.5
+Version: 1.0.6
Release: 1
Group: Development/Libraries
License: Apache-2.0