This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Reapply: Android background platform channels #29346
Merged
gaaclarke
merged 4 commits into
flutter:master
from
gaaclarke:reapply-background-platform-channels
Oct 27, 2021
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
47409d5
Revert "Revert "Android Background Platform Channels (#29147)""
gaaclarke 4d4cc68
Made this PR less of a breaking change by keeping setMessageHandler's…
gaaclarke 4622a04
switched to overloading setMessageHandler
gaaclarke d59fb6b
updated comments
gaaclarke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,7 +42,10 @@ public interface TaskQueue {} | |
| * serial. | ||
| */ | ||
| @UiThread | ||
| TaskQueue makeBackgroundTaskQueue(); | ||
| default TaskQueue makeBackgroundTaskQueue() { | ||
| // TODO(aaclarke): Remove default implementation when it is safe for Google Flutter users. | ||
|
||
| throw new UnsupportedOperationException("makeBackgroundTaskQueue not implemented."); | ||
| } | ||
|
|
||
| /** | ||
| * Sends a binary message to the Flutter application. | ||
|
|
@@ -85,19 +88,32 @@ public interface TaskQueue {} | |
| void setMessageHandler(@NonNull String channel, @Nullable BinaryMessageHandler handler); | ||
|
|
||
| /** | ||
| * Registers a TaskQueue for a specified channel which controls the threading model to follow when | ||
| * invoking the message handler. | ||
| * Registers a handler to be invoked when the Flutter application sends a message to its host | ||
| * platform. | ||
| * | ||
| * <p>A null value for taskQueue means to execute the handler on the platform thread. | ||
| * <p>Registration overwrites any previous registration for the same channel name. Use a null | ||
| * handler to deregister. | ||
| * | ||
| * <p>See also: {@link BinaryMessenger#makeBackgroundTaskQueue()} | ||
| * <p>If no handler has been registered for a particular channel, any incoming message on that | ||
| * channel will be handled silently by sending a null reply. | ||
| * | ||
| * @param channel the name {@link String} of the channel. | ||
| * @param handler a {@link BinaryMessageHandler} to be invoked on incoming messages, or null. | ||
| * @param taskQueue a {@link BinaryMessenger.TaskQueue} that specifies what thread will execute | ||
| * the handler. Specifying null means execute on the platform thread. | ||
| */ | ||
| @UiThread | ||
| void setTaskQueue(@NonNull String channel, @Nullable TaskQueue taskQueue); | ||
| default void setMessageHandler( | ||
| @NonNull String channel, | ||
| @Nullable BinaryMessageHandler handler, | ||
| @Nullable TaskQueue taskQueue) { | ||
| // TODO(aaclarke): Remove default implementation when it is safe for Google Flutter users. | ||
|
||
| if (taskQueue != null) { | ||
| throw new UnsupportedOperationException( | ||
| "setMessageHandler called with nonnull taskQueue is not supported."); | ||
| } | ||
| setMessageHandler(channel, handler); | ||
| } | ||
|
|
||
| /** Handler for incoming binary messages from Flutter. */ | ||
| interface BinaryMessageHandler { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add a comment here (perhaps a TODO) explaining why we're doing this and that it can be simplified after the next stable roll.