From 9001a8427e89f127524415224d6a8a543696a328 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Tue, 8 Mar 2022 14:06:12 +0900 Subject: [PATCH 1/3] Fix auto --- shell/platform/tizen/channels/app_control.cc | 12 ++++++------ shell/platform/tizen/channels/app_control_channel.cc | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/shell/platform/tizen/channels/app_control.cc b/shell/platform/tizen/channels/app_control.cc index a787f679f8be8..700085549cb30 100644 --- a/shell/platform/tizen/channels/app_control.cc +++ b/shell/platform/tizen/channels/app_control.cc @@ -20,7 +20,7 @@ int32_t NativeCreateAppControl(Dart_Handle handle) { Dart_NewFinalizableHandle_DL( handle, app_control.get(), 64, [](void* isolate_callback_data, void* peer) { - auto app_control = reinterpret_cast(peer); + auto* app_control = reinterpret_cast(peer); flutter::AppControlManager::GetInstance().Remove(app_control->id()); }); flutter::AppControlManager::GetInstance().Insert(std::move(app_control)); @@ -28,13 +28,13 @@ int32_t NativeCreateAppControl(Dart_Handle handle) { } bool NativeAttachAppControl(int32_t id, Dart_Handle handle) { - auto app_control = flutter::AppControlManager::GetInstance().FindById(id); + auto* app_control = flutter::AppControlManager::GetInstance().FindById(id); if (!app_control || !app_control->handle()) { return false; } Dart_NewFinalizableHandle_DL( handle, app_control, 64, [](void* isolate_callback_data, void* peer) { - auto app_control = reinterpret_cast(peer); + auto* app_control = reinterpret_cast(peer); flutter::AppControlManager::GetInstance().Remove(app_control->id()); }); return true; @@ -160,7 +160,7 @@ AppControlResult AppControl::SetLaunchMode(const std::string& launch_mode) { bool OnAppControlExtraDataCallback(app_control_h handle, const char* key, void* user_data) { - auto extra_data = static_cast(user_data); + auto* extra_data = static_cast(user_data); bool is_array = false; int ret = app_control_is_extra_data_array(handle, key, &is_array); @@ -306,7 +306,7 @@ AppControlResult AppControl::GetMatchedAppIds(EncodableList& list) { handle_, [](app_control_h app_control, const char* app_id, void* user_data) -> bool { - auto app_ids = static_cast(user_data); + auto* app_ids = static_cast(user_data); app_ids->push_back(EncodableValue(app_id)); return true; }, @@ -325,7 +325,7 @@ AppControlResult AppControl::SendLaunchRequestWithReply( ReplyCallback on_reply) { auto reply_callback = [](app_control_h request, app_control_h reply, app_control_result_e result, void* user_data) { - auto app_control = static_cast(user_data); + auto* app_control = static_cast(user_data); auto reply_app_control = std::make_unique(reply); EncodableMap map; map[EncodableValue("reply")] = reply_app_control->SerializeToMap(); diff --git a/shell/platform/tizen/channels/app_control_channel.cc b/shell/platform/tizen/channels/app_control_channel.cc index 494d0b28d9d0b..055a780ad8f9f 100644 --- a/shell/platform/tizen/channels/app_control_channel.cc +++ b/shell/platform/tizen/channels/app_control_channel.cc @@ -79,7 +79,7 @@ void AppControlChannel::HandleMethodCall( return; } - auto arguments = std::get_if(method_call.arguments()); + auto* arguments = std::get_if(method_call.arguments()); if (!arguments) { result->Error("Invalid arguments"); return; @@ -89,7 +89,7 @@ void AppControlChannel::HandleMethodCall( result->Error("Invalid arguments", "No ID provided."); return; } - auto app_control = AppControlManager::GetInstance().FindById(*id); + auto* app_control = AppControlManager::GetInstance().FindById(*id); if (!app_control) { result->Error("Invalid arguments", "No instance of AppControl matches the given ID."); @@ -147,7 +147,7 @@ void AppControlChannel::Reply( EncodableValueHolder reply_id(arguments, "replyId"); if (reply_id) { - auto reply_app_control = + auto* reply_app_control = AppControlManager::GetInstance().FindById(*reply_id); if (!reply_app_control) { result->Error("Invalid arguments", @@ -170,7 +170,7 @@ void AppControlChannel::Reply( "Either replyId or requestId must be provided."); return; } - auto request_app_control = + auto* request_app_control = AppControlManager::GetInstance().FindById(*request_id); if (!request_app_control) { result->Error("Invalid arguments", @@ -191,7 +191,7 @@ void AppControlChannel::SendLaunchRequest( std::unique_ptr> result) { EncodableValueHolder wait_for_reply(arguments, "waitForReply"); if (wait_for_reply && *wait_for_reply) { - auto result_ptr = result.release(); + auto* result_ptr = result.release(); auto on_reply = [result_ptr](const EncodableValue& response) { result_ptr->Success(response); delete result_ptr; From 065f1fabc84a1babbcd27dd1dac55aae056d6e41 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Tue, 8 Mar 2022 14:11:43 +0900 Subject: [PATCH 2/3] Remove support for deprecated methods --- .../tizen/channels/app_control_channel.cc | 51 +++---------------- 1 file changed, 7 insertions(+), 44 deletions(-) diff --git a/shell/platform/tizen/channels/app_control_channel.cc b/shell/platform/tizen/channels/app_control_channel.cc index 055a780ad8f9f..706ec61e1e40c 100644 --- a/shell/platform/tizen/channels/app_control_channel.cc +++ b/shell/platform/tizen/channels/app_control_channel.cc @@ -65,20 +65,6 @@ void AppControlChannel::HandleMethodCall( std::unique_ptr> result) { const auto& method_name = method_call.method_name(); - // The methods "create" and "dispose" are deprecated and will be removed in - // the future. - if (method_name == "create") { - auto app_control = std::make_unique(); - if (app_control->handle()) { - result->Success(EncodableValue(app_control->id())); - AppControlManager::GetInstance().Insert(std::move(app_control)); - } else { - result->Error("Internal error", - "Could not create an instance of AppControl."); - } - return; - } - auto* arguments = std::get_if(method_call.arguments()); if (!arguments) { result->Error("Invalid arguments"); @@ -96,10 +82,7 @@ void AppControlChannel::HandleMethodCall( return; } - if (method_name == "dispose") { - AppControlManager::GetInstance().Remove(app_control->id()); - result->Success(); - } else if (method_name == "getMatchedAppIds") { + if (method_name == "getMatchedAppIds") { EncodableList app_ids; AppControlResult ret = app_control->GetMatchedAppIds(app_ids); if (ret) { @@ -146,38 +129,18 @@ void AppControlChannel::Reply( } EncodableValueHolder reply_id(arguments, "replyId"); - if (reply_id) { - auto* reply_app_control = - AppControlManager::GetInstance().FindById(*reply_id); - if (!reply_app_control) { - result->Error("Invalid arguments", - "No instance of AppControl matches the given ID."); - return; - } - AppControlResult ret = app_control->Reply(reply_app_control, *result_str); - if (ret) { - result->Success(); - } else { - result->Error(ret.code(), ret.message()); - } - return; - } - - // Deprecated. Use replyId instead. - EncodableValueHolder request_id(arguments, "requestId"); - if (!request_id) { - result->Error("Invalid arguments", - "Either replyId or requestId must be provided."); + if (!reply_id) { + result->Error("Invalid arguments", "No replyId provided."); return; } - auto* request_app_control = - AppControlManager::GetInstance().FindById(*request_id); - if (!request_app_control) { + auto* reply_app_control = + AppControlManager::GetInstance().FindById(*reply_id); + if (!reply_app_control) { result->Error("Invalid arguments", "No instance of AppControl matches the given ID."); return; } - AppControlResult ret = request_app_control->Reply(app_control, *result_str); + AppControlResult ret = app_control->Reply(reply_app_control, *result_str); if (ret) { result->Success(); } else { From cb59ccae872282e1cfd5164be4296e87833df4c7 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Tue, 8 Mar 2022 16:41:30 +0900 Subject: [PATCH 3/3] Do not use auto when not clear --- shell/platform/tizen/channels/app_control.cc | 2 +- .../platform/tizen/channels/app_control_channel.cc | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/shell/platform/tizen/channels/app_control.cc b/shell/platform/tizen/channels/app_control.cc index 700085549cb30..08320c64c62ac 100644 --- a/shell/platform/tizen/channels/app_control.cc +++ b/shell/platform/tizen/channels/app_control.cc @@ -16,7 +16,7 @@ int32_t NativeCreateAppControl(Dart_Handle handle) { if (!app_control->handle()) { return -1; } - auto id = app_control->id(); + int32_t id = app_control->id(); Dart_NewFinalizableHandle_DL( handle, app_control.get(), 64, [](void* isolate_callback_data, void* peer) { diff --git a/shell/platform/tizen/channels/app_control_channel.cc b/shell/platform/tizen/channels/app_control_channel.cc index 706ec61e1e40c..8138fe73c21bb 100644 --- a/shell/platform/tizen/channels/app_control_channel.cc +++ b/shell/platform/tizen/channels/app_control_channel.cc @@ -21,9 +21,11 @@ constexpr char kEventChannelName[] = "tizen/internal/app_control_event"; AppControlChannel::AppControlChannel(BinaryMessenger* messenger) { method_channel_ = std::make_unique>( messenger, kChannelName, &StandardMethodCodec::GetInstance()); - method_channel_->SetMethodCallHandler([this](const auto& call, auto result) { - this->HandleMethodCall(call, std::move(result)); - }); + method_channel_->SetMethodCallHandler( + [this](const MethodCall& call, + std::unique_ptr> result) { + this->HandleMethodCall(call, std::move(result)); + }); event_channel_ = std::make_unique>( messenger, kEventChannelName, &StandardMethodCodec::GetInstance()); @@ -65,7 +67,7 @@ void AppControlChannel::HandleMethodCall( std::unique_ptr> result) { const auto& method_name = method_call.method_name(); - auto* arguments = std::get_if(method_call.arguments()); + const auto* arguments = std::get_if(method_call.arguments()); if (!arguments) { result->Error("Invalid arguments"); return; @@ -75,7 +77,7 @@ void AppControlChannel::HandleMethodCall( result->Error("Invalid arguments", "No ID provided."); return; } - auto* app_control = AppControlManager::GetInstance().FindById(*id); + AppControl* app_control = AppControlManager::GetInstance().FindById(*id); if (!app_control) { result->Error("Invalid arguments", "No instance of AppControl matches the given ID."); @@ -133,7 +135,7 @@ void AppControlChannel::Reply( result->Error("Invalid arguments", "No replyId provided."); return; } - auto* reply_app_control = + AppControl* reply_app_control = AppControlManager::GetInstance().FindById(*reply_id); if (!reply_app_control) { result->Error("Invalid arguments",