Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Guard against NewAPI failures #8048

Merged
merged 5 commits into from
Mar 8, 2019
Merged

Guard against NewAPI failures #8048

merged 5 commits into from
Mar 8, 2019

Conversation

mklim
Copy link
Contributor

@mklim mklim commented Mar 5, 2019

The Java linter is pointing out some code paths that will cause crashes in older supported API versions. Most of this PR is just adding clear guards for code paths that look like they wouldn't effectively have been executed in lower SDKs anyway, but I did see a couple cases here that look pretty suspicious. We may want to file followup bugs for them.

flutter/flutter#28848

@@ -242,7 +251,7 @@ private boolean extractUpdate(File dataDir) {
for (String asset : mResources) {
String resource = null;
ZipEntry entry = null;
if (asset.endsWith(".so")) {
if (asset.endsWith(".so") && Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not being able to fetch these on older SDKs may be a bug? Build.SUPPORTED_ABIS is the problem.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be better to guard the for loop with this, and in the else block just get it from "lib/" + asset; or whatever the appropriate non-ABI aware thing is for lower APIs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here again with mixing SDK checks and app logic.

@mklim mklim marked this pull request as ready for review March 5, 2019 23:05
@mklim mklim requested a review from goderbauer March 5, 2019 23:07
@@ -325,7 +327,7 @@ public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) {
result.setClassName("android.widget.HorizontalScrollView");
}
} else {
if (shouldSetCollectionInfo(object)) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2 && shouldSetCollectionInfo(object)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and elsewhere, can you add comments about what happens if the SDK versions are not met?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to the inline comments above this block.

@@ -242,7 +251,7 @@ private boolean extractUpdate(File dataDir) {
for (String asset : mResources) {
String resource = null;
ZipEntry entry = null;
if (asset.endsWith(".so")) {
if (asset.endsWith(".so") && Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here again with mixing SDK checks and app logic.

Copy link
Contributor Author

@mklim mklim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch should address all pending feedback. Let me know if I missed something and I'll circle back.

@@ -325,7 +327,7 @@ public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) {
result.setClassName("android.widget.HorizontalScrollView");
}
} else {
if (shouldSetCollectionInfo(object)) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2 && shouldSetCollectionInfo(object)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to the inline comments above this block.

Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Will you be able to document what's not supported here? Do we have an issue filed to track that?

@mklim
Copy link
Contributor Author

mklim commented Mar 8, 2019

Will you be able to document what's not supported here? Do we have an issue filed to track that?

Filed flutter/flutter#29019 to track the Accessibility gap. I'm good to document it further if you think it should have its own wiki page. I thought an issue made sense for now since we probably do want to close this gap though.

The other larger uncovered gap here is with the SUPPORTED_ABIs. I'm not sure if this was intended to be available on older APIs originally, but if so I'll follow up. /cc @sbaranov

@matthew-carroll
Copy link
Contributor

LGTM - would be helpful if this could land after AccessibilityBridge comments and refactor:
#8061

Michael Klimushyn added 5 commits March 8, 2019 09:53
@mklim
Copy link
Contributor Author

mklim commented Mar 8, 2019

would be helpful if this could land after AccessibilityBridge comments and refactor: #8061

Discussed offline, that PR is blocked on these lint failures. Going to merge this first and fix conflicts there.

@mklim mklim merged commit 1d10e0e into flutter:master Mar 8, 2019
@mklim mklim deleted the newapi branch March 8, 2019 21:34
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 9, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 9, 2019
engine-flutter-autoroll added a commit to flutter/flutter that referenced this pull request Mar 9, 2019
flutter/engine@87edd94...c48774c

git log 87edd94..c48774c --no-merges --oneline
c48774c Roll src/third_party/dart 571ea80e11..2fb6cd9f5f (122 commits) (flutter/engine#8086)
3c8ef04 Allow embedders to post tasks onto the render thread. (flutter/engine#8089)
1d10e0e Guard against NewAPI failures (flutter/engine#8048)

The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+/master/autoroll/README.md

If the roll is causing failures, please contact the current sheriff (mklim@google.com), and stop
the roller if necessary.
inthroxify added a commit to inthroxify/engine that referenced this pull request Jul 15, 2019
PR flutter#8048 in flutter/engine produced a bug (flutter/flutter flutter#34791) in flutter for Android that doesn't permit the Recents app bar color to be changed. This restores the original arguments to the function found in the previous version (https://github.com/flutter/engine/blob/2f4a38dbd33061e950cf83ddc31785803d58c126/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java) of PlatformPlugin.java while preserving the enhancements for the linter.
mklim pushed a commit that referenced this pull request Aug 15, 2019
This is a fix for [flutter/flutter issue #34791](flutter/flutter#34791).

PR #8048 in flutter/engine produced a bug/regression (flutter/flutter #34791) in flutter for Android that doesn't permit the Recents app bar color to be changed. This restores the original arguments to the function found in the previous version (https://github.com/flutter/engine/blob/2f4a38dbd33061e950cf83ddc31785803d58c126/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java) of PlatformPlugin.java while preserving the enhancements for the linter.

I've compiled and tested this fix locally. The bar changes color again.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants