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
Enforce exclusivity for activity and fragments attached to the FlutterEngine #21272
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6924873
Let FlutterActivity subclasses detach from engine
xster c9eaae6
Enforce exclusivity for activity and fragments attached to FlutterEngine
xster 501f886
docs
xster 2c21857
add test
xster 436ecd6
format
xster f3e00aa
missed a license file
xster 1f42415
review
xster a8d3e4b
add some more explicit errors than null reference for using destroyed…
xster 4b9483a
rename FlutterEnginePluginRegistry to FlutterEngineConectionRegistry
xster 9537f33
autoformat
xster 7281a80
make events droppable
xster 88442f5
autoformat
xster 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
35 changes: 35 additions & 0 deletions
35
shell/platform/android/io/flutter/embedding/android/ExclusiveAppComponent.java
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 |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| package io.flutter.embedding.android; | ||
|
|
||
| import androidx.annotation.NonNull; | ||
|
|
||
| /** | ||
| * An Android App Component exclusively attached to a {@link | ||
| * io.flutter.embedding.engine.FlutterEngine}. | ||
| * | ||
| * <p>An exclusive App Component's {@link #detachFromFlutterEngine} is invoked when another App | ||
| * Component is becoming attached to the {@link io.flutter.embedding.engine.FlutterEngine}. | ||
| * | ||
| * <p>The term "App Component" refer to the 4 component types: Activity, Service, Broadcast | ||
| * Receiver, and Content Provider, as defined in | ||
| * https://developer.android.com/guide/components/fundamentals. | ||
| * | ||
| * @param <T> The App Component behind this exclusive App Component. | ||
| */ | ||
| public interface ExclusiveAppComponent<T> { | ||
| /** | ||
| * Called when another App Component is about to become attached to the {@link | ||
| * io.flutter.embedding.engine.FlutterEngine} this App Component is currently attached to. | ||
| * | ||
| * <p>This App Component's connections to the {@link io.flutter.embedding.engine.FlutterEngine} | ||
| * are still valid at the moment of this call. | ||
| */ | ||
| void detachFromFlutterEngine(); | ||
|
|
||
| /** Retrieve the App Component behind this exclusive App Component. */ | ||
| @NonNull | ||
| T getAppComponent(); | ||
| } |
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
Oops, something went wrong.
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.
We might need to check the delegate nullness in lifecycle methods below as well (
onActivityResultand such). At the very least, let's confirm with an Android expert (perhaps clm) that those methods are never called afteronPause().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.
Ya, sensible. Ping'ed him on the bug.