[Storage][Get DeviceType using StorageGetTypeDev] (#357)
authorprjung <33618885+prjung@users.noreply.github.com>
Mon, 30 Jul 2018 07:57:19 +0000 (16:57 +0900)
committerhyotaekshim <35134695+hyotaekshim@users.noreply.github.com>
Mon, 30 Jul 2018 07:57:19 +0000 (07:57 +0000)
Signed-off-by: pr.jung <pr.jung@samsung.com>
src/Tizen.System.Storage/Interop/Interop.Storage.cs
src/Tizen.System.Storage/Storage/Storage.cs

index df6473e..9ead161 100644 (file)
@@ -110,5 +110,8 @@ internal static partial class Interop
 
         [DllImport(Libraries.Storage, EntryPoint = "storage_unset_changed_cb")]
         internal static extern ErrorCode StorageUnsetChanged(int id, StorageChangedCallback callback);
+
+        [DllImport(Libraries.Storage, EntryPoint = "storage_get_type_dev")]
+        internal static extern ErrorCode StorageGetTypeDev(int id, out StorageArea type, out StorageDevice devicetype);
     }
 }
index 2413417..4bb9533 100644 (file)
@@ -26,7 +26,8 @@ namespace Tizen.System
     {
         private const string LogTag = "Tizen.System";
         private Interop.Storage.StorageState _state;
-        private StorageDevice _devicetype;
+        private Interop.Storage.StorageDevice _devicetype;
+            private Interop.Storage.StorageArea _storagetype;
         private string _fstype;
         private string _fsuuid;
         private ulong _totalSpace;
@@ -37,7 +38,7 @@ namespace Tizen.System
         internal Storage(int storageID, Interop.Storage.StorageArea storageType, Interop.Storage.StorageState storagestate, string rootDirectory)
         {
             Id = storageID;
-            StorageType = (StorageArea)storageType;
+            _storagetype = storageType;
             RootDirectory = rootDirectory;
             _state = storagestate;
 
@@ -61,10 +62,10 @@ namespace Tizen.System
         internal Storage(int storageID, Interop.Storage.StorageArea storageType, Interop.Storage.StorageState storagestate, string rootDirectory, Interop.Storage.StorageDevice devicetype, string fstype, string fsuuid, bool primary, int flags)
         {
             Id = storageID;
-            StorageType = (StorageArea)storageType;
+            _storagetype = storageType;
             RootDirectory = rootDirectory;
             _state = storagestate;
-            _devicetype = (StorageDevice)devicetype;
+            _devicetype = devicetype;
             _fstype = fstype;
             _fsuuid = fsuuid;
             _primary = primary;
@@ -157,7 +158,7 @@ namespace Tizen.System
         /// The type of storage.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        public StorageArea StorageType { get; }
+        public StorageArea StorageType { get { return (StorageArea)_storagetype; } }
         /// <summary>
         /// The root directory for the storage.
         /// </summary>
@@ -198,10 +199,10 @@ namespace Tizen.System
         {
             get
             {
-                if (!information_set)
+                Interop.Storage.ErrorCode err = Interop.Storage.StorageGetTypeDev(Id, out _storagetype, out _devicetype);
+                if (err != Interop.Storage.ErrorCode.None)
                 {
-                    Log.Error(LogTag, string.Format("Doesn't know StorageDevice type."));
-                    throw new InvalidOperationException("Doesn't know StorageDevice type");
+                    Log.Warn(LogTag, string.Format("Failed to get storage device type for storage Id: {0}. err = {1}", Id, err));
                 }
                 return (StorageDevice)_devicetype;
             }