From e74055dca32f86e924c15ecda91c6ad2d95f0de8 Mon Sep 17 00:00:00 2001 From: Michal Michalski Date: Mon, 4 Nov 2019 17:19:47 +0100 Subject: [PATCH] [common] Check if external storage is supported. If external.storage feature is not supported on the device, we shouldn't try to fetch external storage devices list. [Verification] On mobile devices external storages are fetched. On wearable devices only internal storages are returned. + tct-filesystem-tizen-tests 100% pass rate (mobile, wearable) Signed-off-by: Michal Michalski Change-Id: I965c91c278ec85adbb81e7ca98b4b98604011b23 --- src/common/common.gyp | 1 + .../filesystem/filesystem_provider_deviced.cc | 30 +++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/common/common.gyp b/src/common/common.gyp index 9f7729a..1baffe0 100644 --- a/src/common/common.gyp +++ b/src/common/common.gyp @@ -71,6 +71,7 @@ 'capi-appfw-app-manager', 'capi-appfw-app-common', 'capi-appfw-package-manager', + 'capi-system-info', 'storage', 'security-privilege-manager', ] diff --git a/src/common/filesystem/filesystem_provider_deviced.cc b/src/common/filesystem/filesystem_provider_deviced.cc index cb33bd7..60bc109 100644 --- a/src/common/filesystem/filesystem_provider_deviced.cc +++ b/src/common/filesystem/filesystem_provider_deviced.cc @@ -15,6 +15,7 @@ */ #include "common/filesystem/filesystem_provider_deviced.h" +#include #include #include @@ -27,11 +28,32 @@ #include "common/logger.h" namespace { + static const char* kBus = "org.tizen.system.storage"; static const char* kBlockManagerIface = "org.tizen.system.storage.BlockManager"; static const char* kPath = "/Org/Tizen/System/Storage/Block/Manager"; static const char* kDeviceChangedMethod = "DeviceChanged"; static const char* kGetDeviceListMethod = "GetDeviceList"; +static const char* kExternalStorageFeature = "http://tizen.org/feature/storage.external"; + +bool isExternalStorageSupported() { + bool external_storage_support = false; + auto ret = system_info_get_platform_bool(kExternalStorageFeature, &external_storage_support); + + if (SYSTEM_INFO_ERROR_NONE != ret) { + LoggerE("system_info_get_platform_bool(storage.external) check failed: %d (%s)", ret, + get_error_message(ret)); + return false; + } + + if (!external_storage_support) { + LoggerW("External storage not supported."); + return false; + } + + return true; +} + } // namespace namespace common { @@ -221,10 +243,13 @@ Storages FilesystemProviderDeviced::GetStorages() { return Storages(); } - // internal storages are gathered with storage api Storages internal = virtual_roots_provider_.GetStorages(); - // external storages are gathered using deviced implementation + if (!isExternalStorageSupported()) { + return internal; + } + + LoggerD("Fetching external storages."); Storages result; GError* error = nullptr; GVariant* variant = g_dbus_connection_call_sync(dbus_, kBus, kPath, kBlockManagerIface, @@ -237,7 +262,6 @@ Storages FilesystemProviderDeviced::GetStorages() { LoggerD("GetDeviceList succeed - handling result"); result = GetStoragesFromGVariant(variant); } - // merging internal and external results together, but internal on the beginning result.insert(result.begin(), internal.begin(), internal.end()); return result; -- 2.7.4