Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
flutter::PlatformMessageHandlerAndroid Class Reference

#include <platform_message_handler_android.h>

Inheritance diagram for flutter::PlatformMessageHandlerAndroid:
flutter::PlatformMessageHandler

Public Member Functions

 PlatformMessageHandlerAndroid (const std::shared_ptr< PlatformViewAndroidJNI > &jni_facade)
 
void HandlePlatformMessage (std::unique_ptr< PlatformMessage > message) override
 
bool DoesHandlePlatformMessageOnPlatformThread () const override
 
void InvokePlatformMessageResponseCallback (int response_id, std::unique_ptr< fml::Mapping > mapping) override
 
void InvokePlatformMessageEmptyResponseCallback (int response_id) override
 
- Public Member Functions inherited from flutter::PlatformMessageHandler
virtual ~PlatformMessageHandler ()=default
 

Detailed Description

Definition at line 18 of file platform_message_handler_android.h.

Constructor & Destructor Documentation

◆ PlatformMessageHandlerAndroid()

flutter::PlatformMessageHandlerAndroid::PlatformMessageHandlerAndroid ( const std::shared_ptr< PlatformViewAndroidJNI > &  jni_facade)
explicit

Definition at line 9 of file platform_message_handler_android.cc.

11 : jni_facade_(jni_facade) {}

Member Function Documentation

◆ DoesHandlePlatformMessageOnPlatformThread()

bool flutter::PlatformMessageHandlerAndroid::DoesHandlePlatformMessageOnPlatformThread ( ) const
inlineoverridevirtual

Returns true if the platform message will ALWAYS be dispatched to the platform thread.

Platforms that support Background Platform Channels will return false.

Implements flutter::PlatformMessageHandler.

Definition at line 23 of file platform_message_handler_android.h.

23 {
24 return false;
25 }

◆ HandlePlatformMessage()

void flutter::PlatformMessageHandlerAndroid::HandlePlatformMessage ( std::unique_ptr< PlatformMessage message)
overridevirtual

Ultimately sends the PlatformMessage to the host platform. This method is invoked on the ui thread.

Implements flutter::PlatformMessageHandler.

Definition at line 56 of file platform_message_handler_android.cc.

57 {
58 // Called from any thread.
59 int response_id = next_response_id_.fetch_add(1);
60 if (auto response = message->response()) {
61 std::lock_guard lock(pending_responses_mutex_);
62 pending_responses_[response_id] = response;
63 }
64 // This call can re-enter in InvokePlatformMessageXxxResponseCallback.
65 jni_facade_->FlutterViewHandlePlatformMessage(std::move(message),
66 response_id);
67}
Win32Message message

◆ InvokePlatformMessageEmptyResponseCallback()

void flutter::PlatformMessageHandlerAndroid::InvokePlatformMessageEmptyResponseCallback ( int  response_id)
overridevirtual

Performs the return procedure for an associated call to HandlePlatformMessage where there is no return value. This method should be thread-safe and able to be invoked on any thread.

Implements flutter::PlatformMessageHandler.

Definition at line 36 of file platform_message_handler_android.cc.

37 {
38 // Called from any thread.
39 if (!response_id) {
40 return;
41 }
43 {
44 std::lock_guard lock(pending_responses_mutex_);
45 auto it = pending_responses_.find(response_id);
46 if (it == pending_responses_.end()) {
47 return;
48 }
49 message_response = std::move(it->second);
50 pending_responses_.erase(it);
51 }
52 message_response->CompleteEmpty();
53}

◆ InvokePlatformMessageResponseCallback()

void flutter::PlatformMessageHandlerAndroid::InvokePlatformMessageResponseCallback ( int  response_id,
std::unique_ptr< fml::Mapping mapping 
)
overridevirtual

Performs the return procedure for an associated call to HandlePlatformMessage. This method should be thread-safe and able to be invoked on any thread.

Implements flutter::PlatformMessageHandler.

Definition at line 13 of file platform_message_handler_android.cc.

15 {
16 // Called from any thread.
17 if (!response_id) {
18 return;
19 }
20 // TODO(gaaclarke): Move the jump to the ui thread here from
21 // PlatformMessageResponseDart so we won't need to use a mutex anymore.
23 {
24 std::lock_guard lock(pending_responses_mutex_);
25 auto it = pending_responses_.find(response_id);
26 if (it == pending_responses_.end()) {
27 return;
28 }
29 message_response = std::move(it->second);
30 pending_responses_.erase(it);
31 }
32
33 message_response->Complete(std::move(mapping));
34}

The documentation for this class was generated from the following files: