From 6898487bab7ebee1145d4f246aa838943980f070 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Fri, 28 Apr 2017 13:39:35 +0200 Subject: [PATCH 01/16] [Notification] added missing include [Verification] code compiles without errors. Change-Id: I1654f853b424a96dfc6b48439aef0bdc6b34406e Signed-off-by: Piotr Kosko --- src/notification/notification_manager.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/notification/notification_manager.cc b/src/notification/notification_manager.cc index afaae6e..84adcd9 100644 --- a/src/notification/notification_manager.cc +++ b/src/notification/notification_manager.cc @@ -23,6 +23,7 @@ #include #include #include +#include #include "common/converter.h" #include "common/logger.h" -- 2.7.4 From af30006a3c1bffc4e3f572d8ddacfd4ee00192cd Mon Sep 17 00:00:00 2001 From: Tomasz Marciniak Date: Fri, 28 Apr 2017 15:42:19 +0200 Subject: [PATCH 02/16] [Common] Fix for temporary object returned. [Bug] Some rvalue objects were returned. Now only reference to picojson string is returned. Change is applied in Alarm and Application modules. [Verification] Code compiles. Change-Id: Ic0c59467bf994813b3799235cc9e22d98700d23b Signed-off-by: Tomasz Marciniak --- src/alarm/alarm_utils.cc | 2 +- src/application/application_utils.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/alarm/alarm_utils.cc b/src/alarm/alarm_utils.cc index e4e9015..5d72544 100755 --- a/src/alarm/alarm_utils.cc +++ b/src/alarm/alarm_utils.cc @@ -117,7 +117,7 @@ PlatformResult AppControlToServiceExtraData(const picojson::object& app_obj, size_t i = 0; for (auto iter = values.begin(); iter != values.end(); ++iter, ++i) { - arr[i] = iter->to_str().c_str(); + arr[i] = iter->get().c_str(); } int ret = APP_CONTROL_ERROR_NONE; diff --git a/src/application/application_utils.cc b/src/application/application_utils.cc index 1c39776..a7860c1 100644 --- a/src/application/application_utils.cc +++ b/src/application/application_utils.cc @@ -270,7 +270,7 @@ PlatformResult ApplicationUtils::ApplicationControlDataToServiceExtraData( size_t i = 0; for (auto iter = value.begin(); iter != value.end(); ++iter, ++i) { - arr[i] = iter->to_str().c_str(); + arr[i] = iter->get().c_str(); } if (1 == size) { -- 2.7.4 From 0965f6053202d1a5e2115fa7a331bc5a1fa59eeb Mon Sep 17 00:00:00 2001 From: Tomasz Marciniak Date: Fri, 28 Apr 2017 15:42:19 +0200 Subject: [PATCH 03/16] [Common] Fix for temporary object returned. [Bug] Some rvalue objects were returned. Now only reference to picojson string is returned. Change is applied in Alarm and Application modules. [Verification] Code compiles. Change-Id: Ic0c59467bf994813b3799235cc9e22d98700d23b Signed-off-by: Tomasz Marciniak --- src/alarm/alarm_utils.cc | 2 +- src/application/application_utils.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/alarm/alarm_utils.cc b/src/alarm/alarm_utils.cc index 09b2c20..1c9ee9d 100755 --- a/src/alarm/alarm_utils.cc +++ b/src/alarm/alarm_utils.cc @@ -109,7 +109,7 @@ PlatformResult AppControlToServiceExtraData(const picojson::object& app_obj, size_t i = 0; for (auto iter = values.begin(); iter != values.end(); ++iter, ++i) { - arr[i] = iter->to_str().c_str(); + arr[i] = iter->get().c_str(); } int ret = APP_CONTROL_ERROR_NONE; diff --git a/src/application/application_utils.cc b/src/application/application_utils.cc index 1c39776..a7860c1 100644 --- a/src/application/application_utils.cc +++ b/src/application/application_utils.cc @@ -270,7 +270,7 @@ PlatformResult ApplicationUtils::ApplicationControlDataToServiceExtraData( size_t i = 0; for (auto iter = value.begin(); iter != value.end(); ++iter, ++i) { - arr[i] = iter->to_str().c_str(); + arr[i] = iter->get().c_str(); } if (1 == size) { -- 2.7.4 From 3a73e8d095ebea00dca5e32575e2eb7fc6aeb975 Mon Sep 17 00:00:00 2001 From: Pawel Wasowski Date: Mon, 8 May 2017 13:14:33 +0200 Subject: [PATCH 04/16] [Convergence] Fix SVACE issue BUG WGID: 174706, WID: 22870047 [Verification] Code compiles Change-Id: I03b1535f85a22d84aef244b4dc5a872e4d9a9ab7 --- src/convergence/convergence_instance.cc | 8 ++++---- src/convergence/convergence_service.cc | 5 ----- src/convergence/convergence_service.h | 3 +-- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/convergence/convergence_instance.cc b/src/convergence/convergence_instance.cc index c00109b..8634375 100644 --- a/src/convergence/convergence_instance.cc +++ b/src/convergence/convergence_instance.cc @@ -453,7 +453,7 @@ common::TizenResult ConvergenceInstance::AppCommunicationServiceStart(const pico auto channel_arg = ConvergenceUtils::GetArg(args, kJSArgumentChannel); std::vector::iterator channel_it = service->GetChannel(channel_arg); - if (service->IsChannelStarted(channel_it)) { + if (service->opened_channels.end() != channel_it) { result = LogAndCreateTizenError(InvalidStateError, "Service is already started for the channel.", ("Service is already started for the channel.")); } else { @@ -505,7 +505,7 @@ common::TizenResult ConvergenceInstance::AppCommunicationServiceSend(const picoj auto channel_arg = ConvergenceUtils::GetArg(args, kJSArgumentChannel); std::vector::iterator channel_it = service->GetChannel(channel_arg); - if (!service->IsChannelStarted(channel_it)) { + if (service->opened_channels.end() == channel_it) { result = LogAndCreateTizenError(InvalidStateError, "Service is not started for the channel.", ("Service is not started for the channel.")); } else { @@ -556,7 +556,7 @@ common::TizenResult ConvergenceInstance::AppCommunicationServiceStop(const picoj auto channel_arg = ConvergenceUtils::GetArg(args, kJSArgumentChannel); std::vector::iterator channel_it = service->GetChannel(channel_arg); - if (!service->IsChannelStarted(channel_it)) { + if (service->opened_channels.end() == channel_it) { result = LogAndCreateTizenError(InvalidStateError, "Service is not started for the channel.", ("Service is not started for the channel.")); } else { @@ -609,7 +609,7 @@ common::TizenResult ConvergenceInstance::AppCommunicationServiceGetClientList(co auto channel_arg = ConvergenceUtils::GetArg(args, kJSArgumentChannel); std::vector::iterator channel_it = service->GetChannel(channel_arg); - if (!service->IsChannelStarted(channel_it)) { + if (service->opened_channels.end() == channel_it) { result = LogAndCreateTizenError(InvalidStateError, "Service is not started for the channel.", ("Service is not started for the channel.")); } else { diff --git a/src/convergence/convergence_service.cc b/src/convergence/convergence_service.cc index 29992d7..f2b2bbe 100644 --- a/src/convergence/convergence_service.cc +++ b/src/convergence/convergence_service.cc @@ -203,11 +203,6 @@ std::vector::iterator ConvergenceService::GetChannel(const return opened_channels.end(); } -bool ConvergenceService::IsChannelStarted(std::vector::iterator it) { - ScopeLogger(); - return it != opened_channels.end(); -} - void ConvergenceService::RemoveChannel(std::vector::iterator it) { ScopeLogger(); opened_channels.erase(it); diff --git a/src/convergence/convergence_service.h b/src/convergence/convergence_service.h index 42ff0a6..9f4b4e4 100644 --- a/src/convergence/convergence_service.h +++ b/src/convergence/convergence_service.h @@ -46,13 +46,13 @@ class ConvergenceService { public: void Refresh(); std::vector::iterator GetChannel(const picojson::value &channel_json); - bool IsChannelStarted(std::vector::iterator); void RemoveChannel(std::vector::iterator); public: //conv_service_e get_type() const { return type_; } //conv_device_h get_device() const {return device_; } picojson::value ToJson() const; + std::vector opened_channels; protected: conv_service_h FindServiceHandle() const; @@ -68,7 +68,6 @@ class ConvergenceService { conv_device_h device_; // TODO rename to device_handle_ conv_service_e type_; mutable conv_service_h service_handle_; - std::vector opened_channels; friend class ConvergenceAppCommunicationServerService; // It is needed to register the local service private: conv_service_connection_state_e connection_state_; -- 2.7.4 From 44917c81ea07d2609d6ee103d90e32752788261e Mon Sep 17 00:00:00 2001 From: Pawel Wasowski Date: Mon, 8 May 2017 18:05:27 +0200 Subject: [PATCH 05/16] [Filesystem] Rewrite f_isSubDir to handle symbolic links correctly The function did not resolve indirect paths, i.e. containing symbolic links. The problem was reported in following PLM issues: P170503-03986, P170309-04700 [Verification] tct-filesystem-tizen-tests 100% pass rate The problem reported in mentioned PLM issues does not show up after applying the patch. Change-Id: Ie9056e2f504333d2706622b9f3824807373902c6 Signed-off-by: Pawel Wasowski --- src/filesystem/filesystem_instance.cc | 22 ++++++++++++++++++++++ src/filesystem/filesystem_instance.h | 1 + src/filesystem/filesystem_manager.cc | 24 ++++++++++++++++++++++++ src/filesystem/filesystem_manager.h | 4 ++++ src/filesystem/js/common.js | 21 ++++++++++++++++++--- 5 files changed, 69 insertions(+), 3 deletions(-) diff --git a/src/filesystem/filesystem_instance.cc b/src/filesystem/filesystem_instance.cc index 47ffc97..5434c51 100644 --- a/src/filesystem/filesystem_instance.cc +++ b/src/filesystem/filesystem_instance.cc @@ -69,6 +69,7 @@ FilesystemInstance::FilesystemInstance() { REGISTER_ASYNC("File_unlinkFile", UnlinkFile); REGISTER_ASYNC("File_removeDirectory", RemoveDirectory); REGISTER_ASYNC("File_copyTo", CopyTo); + REGISTER_SYNC("FileSystemManager_getCanonicalPath", FileSystemManagerGetCanonicalPath); #undef REGISTER_SYNC #undef REGISTER_ASYNC FilesystemManager::GetInstance().AddListener(this); @@ -653,6 +654,27 @@ void FilesystemInstance::PrepareError(const FilesystemError& error, picojson::ob } } +void FilesystemInstance::FileSystemManagerGetCanonicalPath(const picojson::value& args, picojson::object& out) +{ + LoggerD("Enter"); + //TODO: any privilege needed? + CHECK_EXIST(args, "path", out); + + const std::string& path = args.get("path").get(); + + auto onSuccess = [&](const std::string& canonicalPath) { + LoggerD("Enter"); + ReportSuccess(picojson::value(canonicalPath), out); + }; + + auto onError = [&](FilesystemError e) { + LoggerD("Enter"); + PrepareError(e, out); + }; + + FilesystemManager::GetInstance().GetCanonicalPath(path, onSuccess, onError); +} + #undef CHECK_EXIST } // namespace filesystem diff --git a/src/filesystem/filesystem_instance.h b/src/filesystem/filesystem_instance.h index b46ef7d..e70d7c7 100644 --- a/src/filesystem/filesystem_instance.h +++ b/src/filesystem/filesystem_instance.h @@ -57,6 +57,7 @@ class FilesystemInstance : public common::ParsedInstance, void onFilesystemStateChangeErrorCallback(); void onFilesystemStateChangeSuccessCallback(const common::Storage& storage); void PrepareError(const FilesystemError& error, picojson::object& out); + void FileSystemManagerGetCanonicalPath(const picojson::value& args, picojson::object& out); }; } // namespace filesystem diff --git a/src/filesystem/filesystem_manager.cc b/src/filesystem/filesystem_manager.cc index dc96e58..6039be1 100644 --- a/src/filesystem/filesystem_manager.cc +++ b/src/filesystem/filesystem_manager.cc @@ -31,6 +31,7 @@ #endif #include #undef _XOPEN_SOURCE +#include #include "common/logger.h" #include "common/tools.h" @@ -482,5 +483,28 @@ void FilesystemManager::RemoveListener() { LoggerD("enter"); listener_ = NULL; } + +void FilesystemManager::GetCanonicalPath(const std::string& path, + const std::function& success_cb, + const std::function& error_cb) { + LoggerD("Enter"); + char *canonicalPath = nullptr; + + SCOPE_EXIT { + free(canonicalPath); + }; + + canonicalPath = realpath(path.c_str(), nullptr); + int tmpErrno; + if (!canonicalPath) { + tmpErrno = errno; + LoggerE("Cannot get realpath of %s. Error: %s!", path.c_str(), strerror(tmpErrno)); + error_cb(FilesystemError::Other); + } + + std::string canonicalPathStr(canonicalPath); + success_cb(canonicalPathStr); +} + } // namespace filesystem } // namespace extension diff --git a/src/filesystem/filesystem_manager.h b/src/filesystem/filesystem_manager.h index b2060fb..0ef1815 100644 --- a/src/filesystem/filesystem_manager.h +++ b/src/filesystem/filesystem_manager.h @@ -117,6 +117,10 @@ void CopyTo(const std::string& originFilePath, common::StorageState _old, common::StorageState _new); void AddListener(FilesystemStateChangeListener* listener); void RemoveListener(); + + void GetCanonicalPath(const std::string& path, + const std::function& success_cb, + const std::function& error_cb); }; } // namespace filesystem } // namespace extension diff --git a/src/filesystem/js/common.js b/src/filesystem/js/common.js index 6eeddca..adf52c7 100644 --- a/src/filesystem/js/common.js +++ b/src/filesystem/js/common.js @@ -331,10 +331,25 @@ var commonFS_ = (function() { return true; } + function toCanonicalPath(path) { + var result = native_.callSync('FileSystemManager_getCanonicalPath', { "path": path}); + if (native_.isFailure(result)) { + throw native_.getErrorObject(result); + } + + return native_.getResultObject(result); + } + function f_isSubDir(fullPathToCheck, fullPath) { - var realFullPath = toRealPath(fullPath); - return ((-1 !== fullPathToCheck.indexOf(realFullPath)) && (fullPathToCheck !== realFullPath)); - }; + var fullCanonicalPathToCheck = toCanonicalPath(toRealPath(fullPathToCheck)); + var fullCanonicalPath = toCanonicalPath(toRealPath(fullPath)); + + if (fullCanonicalPathToCheck === fullCanonicalPath) { + return false; + } + + return fullCanonicalPathToCheck.indexOf(fullCanonicalPath) === 0; + } function f_isCorrectRelativePath(relativePath) { return ((0 !== relativePath.indexOf('/')) -- 2.7.4 From f484919358a28e11f392275eaabd352b1f39107a Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Wed, 10 May 2017 08:56:00 +0200 Subject: [PATCH 06/16] [version] 1.82 Change-Id: Icca95a45fd114a0785ff4086e8c35405c828d8b4 Signed-off-by: Piotr Kosko --- packaging/webapi-plugins.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index 99df838..1cae2de 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -10,7 +10,7 @@ %define crosswalk_extensions_path %{_libdir}/%{crosswalk_extensions} Name: webapi-plugins -Version: 1.81 +Version: 1.82 Release: 0 License: Apache-2.0 and BSD-3-Clause and MIT Group: Development/Libraries -- 2.7.4 From 2e9c223209f31b22045ecd673ac246ece089753a Mon Sep 17 00:00:00 2001 From: Tomasz Marciniak Date: Wed, 10 May 2017 11:45:37 +0200 Subject: [PATCH 07/16] [MessagePort] Fix for temporary object returned. [Bug] rvalue objects were returned instead of reference to picojson string. [Verification] Code compiles. TCT pass rate 100% (51/51/0/0/0) Change-Id: I30b6c3f3d2ec4730f2e810a66d1b6ebb17f5a418 Signed-off-by: Tomasz Marciniak --- src/messageport/messageport_instance.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/messageport/messageport_instance.cc b/src/messageport/messageport_instance.cc index 60b9911..36aa678 100755 --- a/src/messageport/messageport_instance.cc +++ b/src/messageport/messageport_instance.cc @@ -410,7 +410,7 @@ void MessageportInstance::RemoteMessagePortSendmessage size_t i = 0; for (auto iter = value_array.begin(); iter != value_array.end(); ++iter, ++i) { - arr[i] = iter->to_str().c_str(); + arr[i] = iter->get().c_str(); } bundle_add_str_array(bundle, (*it).get("key").to_str().c_str(), arr, size); -- 2.7.4 From cd1002caac22c6c570f73a2927570966645b3ea0 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Wed, 10 May 2017 11:21:01 +0200 Subject: [PATCH 08/16] [Application] Wrapped code for context API with ifdef [Verification] Code compiles without errors. Feature checked in chrome console. Change-Id: I6e88d5d8da383e1f0d227e11905eeffb3235d1ba Signed-off-by: Piotr Kosko --- src/application/application_instance.cc | 6 ------ src/application/application_manager.cc | 8 ++++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/application/application_instance.cc b/src/application/application_instance.cc index 0d05a28..eb4ee2d 100755 --- a/src/application/application_instance.cc +++ b/src/application/application_instance.cc @@ -163,15 +163,9 @@ void ApplicationInstance::GetAppMetaData(const picojson::value& args, picojson:: void ApplicationInstance::GetBatteryUsageInfo(const picojson::value& args, picojson::object& out) { LoggerD("Entered"); -#ifdef TIZEN_MOBILE CHECK_PRIVILEGE_ACCESS(kPrivilegeAppHistoryRead, &out); manager_.GetBatteryUsageInfo(args, &out); -#else - LogAndReportError(PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "This feature is not supported on this profile."), &out, - ("NOT_SUPPORTED_ERR: This feature is not supported on this profile")); - return; -#endif } void ApplicationInstance::AddAppInfoEventListener(const picojson::value& args, picojson::object& out) { diff --git a/src/application/application_manager.cc b/src/application/application_manager.cc index 8a33081..8af357a 100755 --- a/src/application/application_manager.cc +++ b/src/application/application_manager.cc @@ -29,7 +29,9 @@ #include #include #include +#ifdef TIZEN_MOBILE #include +#endif #include "common/current_application.h" #include "common/logger.h" @@ -1159,6 +1161,7 @@ void ApplicationManager::GetAppSharedUri(const std::string& app_id, picojson::ob void ApplicationManager::GetBatteryUsageInfo(const picojson::value& args, picojson::object* out) { LoggerD("Entered"); +#ifdef TIZEN_MOBILE context_history_list_h list = nullptr; context_history_h handle = nullptr; context_history_filter_h filter = nullptr; @@ -1274,6 +1277,11 @@ void ApplicationManager::GetBatteryUsageInfo(const picojson::value& args, picojs } } ReportSuccess(result_array, *out); +#else + // 20170510 Context API is supported only for mobile profile, other ones would result with NotSupportedError + LogAndReportError(PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "This feature is not supported on this profile."), out, + ("NOT_SUPPORTED_ERR: This feature is not supported on this profile")); +#endif } void ApplicationManager::GetAppMetaData(const std::string& app_id, picojson::object* out) { -- 2.7.4 From ad8423704629342052e81b33fbb497609c979f85 Mon Sep 17 00:00:00 2001 From: Tomasz Marciniak Date: Wed, 10 May 2017 12:00:56 +0200 Subject: [PATCH 09/16] [Convergence] Fix for temporary object returned [Bug] rvalue objects were returned instead of reference to picojson string. [Verification] Code compiles. Change-Id: Iee750c9bd00699c76808e7a6cf268221916a0f7d Signed-off-by: Tomasz Marciniak --- src/convergence/convergence_remote_app_control_service.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/convergence/convergence_remote_app_control_service.cc b/src/convergence/convergence_remote_app_control_service.cc index cdd1716..7116645 100644 --- a/src/convergence/convergence_remote_app_control_service.cc +++ b/src/convergence/convergence_remote_app_control_service.cc @@ -520,7 +520,7 @@ TizenResult ConvergenceRemoteAppControlService::ApplicationControlDataToServiceE size_t i = 0; for (auto iter = value.begin(); iter != value.end(); ++iter, ++i) { - arr[i] = iter->to_str().c_str(); + arr[i] = iter->get().c_str(); } if (1 == size) { -- 2.7.4 From 3ac69f20a2fd32246a95d6afcbde5507895d1192 Mon Sep 17 00:00:00 2001 From: Lukasz Bardeli Date: Thu, 11 May 2017 14:17:21 +0200 Subject: [PATCH 10/16] [NBS] fix for NetworkSuccessCallback [Verification] Code compile without error. Passrate 100% (25/25/0/0/0) Change-Id: Iac73307c53fe98e68f051001ebc5323e97a9589f Signed-off-by: Lukasz Bardeli --- src/networkbearerselection/networkbearerselection_api.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/networkbearerselection/networkbearerselection_api.js b/src/networkbearerselection/networkbearerselection_api.js index 379ea2a..fde026b 100644 --- a/src/networkbearerselection/networkbearerselection_api.js +++ b/src/networkbearerselection/networkbearerselection_api.js @@ -38,7 +38,7 @@ function _networkBearerSelectionCallback(result) { var id, callback; for (id in callbacks) { - if (callbacks.hasOwnProperty(result.id)) { + if (callbacks.hasOwnProperty(result.id) && result.id == id) { callback = callbacks[id]; if (result.state === 'Success') { native_.callIfPossible(callback.onsuccess); @@ -53,6 +53,7 @@ function _networkBearerSelectionCallback(result) { native_.removeListener('NetworkBearerSelectionCallback_' + id); delete callbacks[id]; } + break; } } } -- 2.7.4 From 09ecccacb3fa382d4c2350687e5bd96aeca1afb9 Mon Sep 17 00:00:00 2001 From: Lukasz Bardeli Date: Thu, 11 May 2017 14:17:21 +0200 Subject: [PATCH 11/16] [NBS] fix for NetworkSuccessCallback [Verification] Code compile without error. Passrate 100% (25/25/0/0/0) Change-Id: Iac73307c53fe98e68f051001ebc5323e97a9589f Signed-off-by: Lukasz Bardeli --- src/networkbearerselection/networkbearerselection_api.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/networkbearerselection/networkbearerselection_api.js b/src/networkbearerselection/networkbearerselection_api.js index 379ea2a..fde026b 100644 --- a/src/networkbearerselection/networkbearerselection_api.js +++ b/src/networkbearerselection/networkbearerselection_api.js @@ -38,7 +38,7 @@ function _networkBearerSelectionCallback(result) { var id, callback; for (id in callbacks) { - if (callbacks.hasOwnProperty(result.id)) { + if (callbacks.hasOwnProperty(result.id) && result.id == id) { callback = callbacks[id]; if (result.state === 'Success') { native_.callIfPossible(callback.onsuccess); @@ -53,6 +53,7 @@ function _networkBearerSelectionCallback(result) { native_.removeListener('NetworkBearerSelectionCallback_' + id); delete callbacks[id]; } + break; } } } -- 2.7.4 From e08574531a0ba5dac7bbaad8e2c630614ba2d4d8 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Fri, 12 May 2017 09:09:58 +0200 Subject: [PATCH 12/16] [Filesystem] SVACE issue fix Change-Id: I3f8d221154225a45462e8e1e931031f4ef0bb772 Signed-off-by: Piotr Kosko --- src/filesystem/filesystem_manager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/filesystem/filesystem_manager.cc b/src/filesystem/filesystem_manager.cc index 6039be1..43f7462 100644 --- a/src/filesystem/filesystem_manager.cc +++ b/src/filesystem/filesystem_manager.cc @@ -498,7 +498,7 @@ void FilesystemManager::GetCanonicalPath(const std::string& path, int tmpErrno; if (!canonicalPath) { tmpErrno = errno; - LoggerE("Cannot get realpath of %s. Error: %s!", path.c_str(), strerror(tmpErrno)); + LoggerE("Cannot get realpath of %s. Error: %s!", path.c_str(), GetErrorString(tmpErrno).c_str()); error_cb(FilesystemError::Other); } -- 2.7.4 From 02ecea2776f9807a6e6f8d0fa0ac9cec5b2f0440 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Wed, 17 May 2017 10:53:56 +0200 Subject: [PATCH 13/16] [version] 1.83 Change-Id: Ib1ddf07b8fc019d0145271fa6728f674060f3073 --- packaging/webapi-plugins.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index 1cae2de..48dd7ee 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -10,7 +10,7 @@ %define crosswalk_extensions_path %{_libdir}/%{crosswalk_extensions} Name: webapi-plugins -Version: 1.82 +Version: 1.83 Release: 0 License: Apache-2.0 and BSD-3-Clause and MIT Group: Development/Libraries -- 2.7.4 From 6fc2be29662e7b327e9435519d5ed4f8b3c1ba0a Mon Sep 17 00:00:00 2001 From: Tomasz Marciniak Date: Thu, 18 May 2017 10:37:21 +0200 Subject: [PATCH 14/16] [Feedback] Error codes adjusted to the documentation. [Verification] Code compiles. TCT pass rate 100% (TW1) Change-Id: I38fc1ad18b445253c0e87366c6c2841ebd54f13e Signed-off-by: Tomasz Marciniak --- src/feedback/feedback_manager.cc | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/feedback/feedback_manager.cc b/src/feedback/feedback_manager.cc index 91e0e09..57f3e0c 100644 --- a/src/feedback/feedback_manager.cc +++ b/src/feedback/feedback_manager.cc @@ -133,18 +133,23 @@ common::PlatformResult FeedbackManager::isPatternSupported(const std::string &pa const std::string &type, bool* patternStatus) { LoggerD("Entered"); + auto &pattern_e = m_feedbackMapsPtr->getPatternFromMap(pattern); auto &type_e = m_feedbackMapsPtr->getTypeFromMap(type); + if (m_feedbackMapsPtr->isPatternSupportChecked(pattern_e, type_e)) { *patternStatus = m_feedbackMapsPtr->isPatternSupported(pattern_e, type_e); return PlatformResult(ErrorCode::NO_ERROR); } + int ret = feedback_is_supported_pattern(type_e, pattern_e, patternStatus); if (ret != FEEDBACK_ERROR_NONE) { LoggerE("isPatternSupported failed: %d", ret); - return CodeToResult(ret, getFeedbackErrorMessage(ret).c_str()); + return CodeToResult(FEEDBACK_ERROR_NOT_SUPPORTED, "Pattern not supported"); } + m_feedbackMapsPtr->setPatternSupport(pattern_e, type_e, *patternStatus); + return PlatformResult(ErrorCode::NO_ERROR); } @@ -156,9 +161,11 @@ common::PlatformResult FeedbackManager::play(const std::string &pattern, const s } else { bool patternSupport = false; auto result = isPatternSupported(pattern, type, &patternSupport); + if (!result) { return result; } + if (patternSupport) { ret = feedback_play_type(m_feedbackMapsPtr->getTypeFromMap(type), m_feedbackMapsPtr->getPatternFromMap(pattern)); @@ -166,41 +173,45 @@ common::PlatformResult FeedbackManager::play(const std::string &pattern, const s return CodeToResult(FEEDBACK_ERROR_NOT_SUPPORTED, "Not supported device"); } } + if (ret != FEEDBACK_ERROR_NONE) { LoggerE("play failed: %d", ret); return CodeToResult(ret, getFeedbackErrorMessage(ret).c_str()); } + return PlatformResult(ErrorCode::NO_ERROR); } common::PlatformResult FeedbackManager::stop() { LoggerD("Entered"); + int ret = feedback_stop(); if(ret != FEEDBACK_ERROR_NONE && ret != FEEDBACK_ERROR_NOT_SUPPORTED) { LoggerE("stop failed: %d", ret); return CodeToResult(ret, getFeedbackErrorMessage(ret).c_str()); - } + } + return PlatformResult(ErrorCode::NO_ERROR); } PlatformResult FeedbackManager::CodeToResult(const int errorCode, const std::string& message) { LoggerD("Entered"); + switch(errorCode) { - case FEEDBACK_ERROR_INVALID_PARAMETER: - return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, message); - case FEEDBACK_ERROR_OPERATION_FAILED: - return LogAndCreateResult(ErrorCode::SECURITY_ERR, message); case FEEDBACK_ERROR_NOT_SUPPORTED: return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR, message); + case FEEDBACK_ERROR_INVALID_PARAMETER: + case FEEDBACK_ERROR_OPERATION_FAILED: case FEEDBACK_ERROR_NOT_INITIALIZED: default: - return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, message); + return LogAndCreateResult(ErrorCode::ABORT_ERR, message); } } const std::string FeedbackManager::getFeedbackErrorMessage(const int error_code) { LoggerD("Error code : %d", error_code); + switch(error_code) { case FEEDBACK_ERROR_OPERATION_FAILED: return "Operation not permitted"; @@ -211,7 +222,7 @@ const std::string FeedbackManager::getFeedbackErrorMessage(const int error_code) case FEEDBACK_ERROR_NOT_INITIALIZED: return "Not initialized"; default: - return "UnknownError"; + return "Abort Error"; } } -- 2.7.4 From 3c44b8fe425f22c41bea2c54ce04de60e29135e4 Mon Sep 17 00:00:00 2001 From: Pawel Wasowski Date: Thu, 18 May 2017 11:50:31 +0200 Subject: [PATCH 15/16] [Filesystem] Add validation of decoded UTF-8 characters _utf8_decode function used to throw a RangeError exception, when an invalid UTF-8 sequence was converted to a Unicode code point. Byte sequences, invalid in terms of UTF-8, are now substituted with an Unicode replacement character. [Verification] TCT tct-filesystem-tizen-tests and tct-file-cordova-tests pass rate on a Z400 mobile device is 100%. Decoding was tested manually against numerous problematic byte sequences. Change-Id: If8aefd3434a1b96ead11e36a1db1ddee4f2c3904 Signed-off-by: Pawel Wasowski --- src/filesystem/js/base64.js | 76 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 11 deletions(-) diff --git a/src/filesystem/js/base64.js b/src/filesystem/js/base64.js index edd4513..4074d48 100755 --- a/src/filesystem/js/base64.js +++ b/src/filesystem/js/base64.js @@ -126,35 +126,89 @@ var Base64 = { return utfarray; }, + + /* + * This function validates read characters. Non-standard UTF-8 characters are substituted with + * a replacement symbol. + * + * Used validation check cases are described in http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt, + * by Markus Kuhn, distributed under CC-BY 4.0 license (https://creativecommons.org/licenses/by/4.0/legalcode). + */ + _utf8_decode: function(utfarray) { var str = ''; - var i = 0, c = 0, c1 = 0, c2 = 0, c3 = 0; + var i = 0, c = 0, c1 = 0, c2 = 0, c3 = 0, charCode = 0; + var INVALID_CHARACTER = String.fromCharCode(0xFFFD); while (i < utfarray.length) { - c = utfarray[i]; if (c < 128) { str += String.fromCharCode(c); i++; - } - else if ((c >= 192) && (c < 224)) { + } else if ((c >= 194) && (c < 224) && (utfarray[i + 1] & 0x80)) { c1 = utfarray[i + 1]; - str += String.fromCharCode(((c & 31) << 6) | (c1 & 63)); + charCode = ((c & 31) << 6) | (c1 & 63); + /* + * Below condition is true, if the sequence could be encoded in less than 2 bytes. + * Such a byte series is invalid in terms of UTF-8. + * This and similar, longer, sequences will be refered to as "overlong sequence". + */ + if (!(charCode & 0xFF80)) { + str += INVALID_CHARACTER; + } else { + str += String.fromCharCode(charCode); + } + i += 2; - } - else if((c >= 224) && (c < 240)) { + } else if ((c >= 224) && (c < 240) && (utfarray[i + 1] & 0x80) && (utfarray[i + 2] & 0x80)) { c1 = utfarray[i + 1]; c2 = utfarray[i + 2]; - str += String.fromCharCode(((c & 15) << 12) | ((c1 & 63) << 6) | (c2 & 63)); + charCode = ((c & 15) << 12) | ((c1 & 63) << 6) | (c2 & 63); + + if (!(charCode & 0xF800) //overlong sequence test + /* + * Below test checks, if the character is an UTF-16 surrogate halve, + * UTF-16 surrogate halves are invalid Unicode codepoints. + */ + || (0xD800 <= charCode && charCode <=0xDFFF)) { + str += INVALID_CHARACTER; + } else { + str += String.fromCharCode(charCode); + } + i += 3; - } - else {//support 4 bytes characters e.g. Emojis + } else if ((c >= 240) && (c < 245) & (utfarray[i + 1] & 0x80) && (utfarray[i + 2] & 0x80) && (utfarray[i + 3] & 0x80)) { c1 = utfarray[i + 1]; c2 = utfarray[i + 2]; c3 = utfarray[i + 3]; - str += String.fromCodePoint(((c & 7) << 18) | ((c1 & 63) << 12) | ((c2 & 63) << 6) | (c3 & 63)); + charCode = ((c & 7) << 18) | ((c1 & 63) << 12) | ((c2 & 63) << 6) | (c3 & 63); + + if (!(charCode & 0x1F0000)) { //overlong sequence test + str += INVALID_CHARACTER; + } else { + str += String.fromCharCode(charCode); + } i += 4; + /* + * Below condition is true if a continuation byte appeared without a proper leading byte + */ + } else if ((c & 0x80) && (~c & 0x40)) { + str += INVALID_CHARACTER; + i++; + } else { + /* + * One or more continuation bytes are missing + * OR 'c' is a prohibited byte in terms of UTF-8 standard. + */ + str += INVALID_CHARACTER; + + /* + * All following continuation bytes are skipped. + */ + do { + i++; + } while((utfarray[i] & 0x80) && (~utfarray[i] & 0x40)); } } -- 2.7.4 From 88bd2531ef7af65bfc236c980bf0bfec452c4c66 Mon Sep 17 00:00:00 2001 From: Szymon Jastrzebski Date: Fri, 19 May 2017 12:58:22 +0200 Subject: [PATCH 16/16] [SystemInfo] Throwing NOT_SUPPORTED_ERR added [Verification] TCT SystemInfo passed 100% (TM1, TW1, TV) Signed-off-by: Szymon Jastrzebski Change-Id: I18753fcf052b954dd3f88839db58616b137bfd3b --- src/systeminfo/systeminfo_api.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/systeminfo/systeminfo_api.js b/src/systeminfo/systeminfo_api.js index 21bef45..38e48da 100644 --- a/src/systeminfo/systeminfo_api.js +++ b/src/systeminfo/systeminfo_api.js @@ -46,6 +46,17 @@ var SystemInfoPropertyId = { ADS : 'ADS' }; +var SystemInfoPropertyIdToFeature = { + BATTERY : 'http://tizen.org/feature/battery', + CAMERA_FLASH : 'http://tizen.org/feature/camera.back.flash', + CELLULAR_NETWORK : 'http://tizen.org/feature/network.telephony', + DISPLAY : 'http://tizen.org/feature/screen', + ETHERNET_NETWORK : 'http://tizen.org/feature/network.ethernet', + SIM : 'http://tizen.org/feature/network.telephony', + NET_PROXY_NETWORK : 'http://tizen.org/feature/network.net_proxy', + WIFI_NETWORK : 'http://tizen.org/feature/network.wifi' +}; + //class SystemInfoDeviceCapability //////////////////////////////////////////////////// function SystemInfoDeviceCapability(data) { Object.defineProperties(this, { @@ -800,6 +811,15 @@ var _createPropertyArray = function (property, data) { return propertyArray; }; +var _checkPropertySupported = function(property){ + if (SystemInfoPropertyIdToFeature[property]) { + var supported = tizen.systeminfo.getCapability(SystemInfoPropertyIdToFeature[property]); + if (!supported) { + return false; + } + } + return true; +}; var getPropertyFunction = function(cppLabel, objectCreateFunction) { return function() { @@ -828,6 +848,16 @@ var getPropertyFunction = function(cppLabel, objectCreateFunction) { if (!propObject) { throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Property with id: ' + args.property + ' is not supported.'); } + + if (_checkPropertySupported(args.property) === false) { + setTimeout(function() { + native_.callIfPossible(args.errorCallback, + new WebAPIException(WebAPIException.NOT_SUPPORTED_ERR, + 'Property with id: ' + args.property + ' is not supported.')); + }, 0); + return; + } + var callback = function(result) { if (native_.isFailure(result)) { setTimeout(function() { @@ -1339,6 +1369,15 @@ var getListenerFunction = function (isArray) { } ]); + if (_checkPropertySupported(args.property) === false) { + setTimeout(function() { + native_.callIfPossible(args.errorCallback, + new WebAPIException(WebAPIException.NOT_SUPPORTED_ERR, + 'Property with id: ' + args.property + ' is not supported.')); + }, 0); + return; + } + var listener = { callback : args.successCallback, isArrayType : isArray, -- 2.7.4