-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Android] Save back handling state in Activity/Fragment bundle #56715
Conversation
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.
LGTM from my side 👍 . This would have taken me quite a long time to figure out on my own so thank you!
So this is unrelated to predictive back being unsupported on FlutterFragmentActivity?
Yes, that is correct. Though from what I can tell, predictive back when leaving the app seems to work with a Separately, I noticed that #52302 seems to have unintentionally had the effect of not allowing people to "opt out" of predictive back. This is actually aligned with what the android docs say should happen:
But this wasn't actually true for flutter apps before #52302, because we were not calling override fun onBackPressed() {
onBackPressedDispatcher.onBackPressed()
} So while the docs imply that removing the @Override
@SuppressWarnings("MissingSuperCall")
public void onBackPressed() {
flutterFragment.onBackPressed();
} What all this means is that apps that aren't opting in to predictive back had their back handling migrated to the new code path automatically, which is part of what happened in b/355556397: the bug this pr fixes affects all of FFA/FA/FF, but they noticed a behavior difference between FlutterActivity and FlutterFragmentActivity because of
|
I also think we may want to restore the ability for people to opt out, so that FlutterActivity and FlutterFragmentActivity have the same behavior wrt the |
For now I think we should make decisions as if we will be supporting predictive back and legacy back forever. |
shell/platform/android/io/flutter/embedding/android/FlutterActivity.java
Outdated
Show resolved
Hide resolved
Thanks for the detailed explanation on what's going on here. I'm on board with allowing opt-out and supporting both predictive and non-predictive back. |
shell/platform/android/test/io/flutter/embedding/android/FlutterActivityTest.java
Outdated
Show resolved
Hide resolved
@@ -1071,6 +1072,12 @@ public void onAttach(@NonNull Context context) { | |||
@Override | |||
public void onCreate(@Nullable Bundle savedInstanceState) { | |||
super.onCreate(savedInstanceState); | |||
if (savedInstanceState != null) { | |||
boolean frameworkHandlesBack = |
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.
No need to change the pr now but when we have a second variable then all of this code should go into a "save everything" and "restore everything" methods.
shell/platform/android/test/io/flutter/embedding/android/FlutterActivityTest.java
Outdated
Show resolved
Hide resolved
…159776) flutter/engine@938f816...1e6864c 2024-12-04 34871572+gmackall@users.noreply.github.com [Android] Save back handling state in Activity/Fragment bundle (flutter/engine#56715) 2024-12-03 robert.ancell@canonical.com Split keyevent channel into own class (flutter/engine#56911) 2024-12-03 robert.ancell@canonical.com Add tests for errors encoding message channel request and method calls. (flutter/engine#56914) 2024-12-03 skia-flutter-autoroll@skia.org Roll Skia from 8dc8bdc364f5 to e02d856f86fb (3 revisions) (flutter/engine#56926) 2024-12-03 jonahwilliams@google.com [Impeller] invalidate cached atlas data, take 2. (flutter/engine#56925) 2024-12-03 jason-simmons@users.noreply.github.com Add typeface_proxy dependency to the Skia build script for the Android font manager (flutter/engine#56924) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC bdero@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…er/engine#56715) Fixes flutter#159158, and fixes b/355556397 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Fixes flutter/flutter#159158, and fixes b/355556397
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.