-
Notifications
You must be signed in to change notification settings - Fork 6k
Use io.flutter.Build.API_LEVELS
rather than android.os.Build.VERSION_CODES
#51171
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.
As long as we're consistent one way or another (and it works with our linting strategy), I'm LGTM.
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.
I'm fine with either way (but agreed we should have only one way). I find the integers more readable but I also like that the codes are more easily searchable
shell/platform/android/io/flutter/view/AccessibilityBridge.java
Outdated
Show resolved
Hide resolved
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.
Also LGTM! Glad to have something consistent moving forward.
This seems like a step backwards in terms of code readability. Before: "Build.VERSION_FOO" We lose our ability to search for something meaningful. Why are we making this change? At the very least, why don't we introduce our own "AndroidBuild.VERSION_N" for all N and use that instead of the raw integer? |
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.
See my comment on the issue.
I think this works for me - but I'd want the raw integer in there, e.g. |
I have two reasons for wanting this change:
|
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! Glad we found a solution that maximizes both searchability and readability
Thanks for making my requested changes @dnfield |
|
||
/** A replacement of utilities from android.os.Build. */ | ||
public class Build { | ||
/** For use in place of the Android VERSION CODES class. */ |
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.
Rewrite the comment so if someone searched for the official class they would find this:
/** For use in place of Build.VERSION_CODES class */
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.
I can do that, but I'll have to special case the forbidden imports script to allow it in this file.
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.
Can the linter detect that text is contained inside of a comment?
import android.view.PointerIcon; | ||
import androidx.annotation.NonNull; | ||
import androidx.annotation.RequiresApi; | ||
import io.flutter.embedding.engine.systemchannels.MouseCursorChannel; | ||
import java.util.HashMap; | ||
|
||
/** A mandatory plugin that handles mouse cursor requests. */ | ||
@TargetApi(Build.VERSION_CODES.N) | ||
@RequiresApi(Build.VERSION_CODES.N) | ||
@TargetApi(24) |
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.
Fix here and below
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.
I lost track of what these were - I'll update them all.
@@ -134,8 +136,8 @@ private void cacheResolveInfos() { | |||
* <p>When an activity does not return a value. the request is completed successfully and returns | |||
* null. | |||
*/ | |||
@TargetApi(Build.VERSION_CODES.M) | |||
@RequiresApi(Build.VERSION_CODES.M) | |||
@TargetApi(23) |
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.
fix here and below
@@ -789,8 +791,8 @@ private void releaseAccessibilityNodeProvider() { | |||
// -------- Start: Mouse ------- | |||
|
|||
@Override | |||
@TargetApi(Build.VERSION_CODES.N) | |||
@RequiresApi(Build.VERSION_CODES.N) | |||
@TargetApi(24) |
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.
fix here and here
@@ -253,7 +255,7 @@ private void closeCurrentImage() { | |||
|
|||
@TargetApi(29) |
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.
fix
@@ -25,7 +26,7 @@ | |||
|
|||
@Config( | |||
manifest = Config.NONE, | |||
minSdk = 24, | |||
minSdk = API_LEVELS.API_24, | |||
shadows = {}) | |||
@RunWith(AndroidJUnit4.class) | |||
@TargetApi(24) |
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.
fix
@@ -24,10 +23,10 @@ | |||
|
|||
@Config(manifest = Config.NONE) | |||
@RunWith(AndroidJUnit4.class) | |||
@TargetApi(P) | |||
@TargetApi(28) |
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.
fix
@@ -36,8 +35,8 @@ | |||
import org.mockito.ArgumentCaptor; | |||
|
|||
@RunWith(AndroidJUnit4.class) | |||
@TargetApi(Build.VERSION_CODES.N) | |||
@RequiresApi(Build.VERSION_CODES.N) | |||
@TargetApi(24) |
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.
fix here and below
Build.VERSION_CODES
io.flutter.Build.API_LEVELS
rather than android.os.Build.VERSION_CODES
@@ -81,7 +82,7 @@ public void itDescribesNonTextFieldsWithAContentDescription() { | |||
} | |||
|
|||
@Config(sdk = 28) |
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.
I think all the @config values in this file should change to API_LEVELS.*
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.
Fixed.
@@ -82,7 +81,7 @@ public void testRotatedMediaSurface_270() throws Exception { | |||
} | |||
|
|||
@Test | |||
@SdkSuppress(minSdkVersion = VERSION_CODES.M) | |||
@SdkSuppress(minSdkVersion = 23) |
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.
Why are these not API_LEVELS?
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.
Fixed.
FLUTTER_LOG_CLASS) or CheckBadFiles( | ||
bad_trace_files, 'android[x].tracing.Trace', FLUTTER_TRACE_CLASS | ||
) or CheckBadFiles( | ||
bad_version_codes_files, 'android.os.Build.VERSION_CODES', |
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.
Consider adding either a description here or a pointer to why these are considered bad files.
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.
Added some comments.
auto label is removed for flutter/engine/51171, due to - The status or check suite Linux linux_android_debug_engine has failed. Please fix the issues identified (or deflake) before re-applying this label. |
…uild.VERSION_CODES` (flutter/engine#51171)
…144844) flutter/engine@05fdf94...e099277 2024-03-08 [email protected] Use `io.flutter.Build.API_LEVELS` rather than `android.os.Build.VERSION_CODES` (flutter/engine#51171) 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 [email protected],[email protected] 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
Updates the linting script to ban the use of
VERSION_CODES
.We currently have a mish-mash of using the integers, using
VERSION_CODES
, and even how we import the version codes. This makes it more confusing when doing things like #51070 - I think it is clearer to see22
thanLOLLIPOP_MR1
.I'd like to get LGTM (or at least no opinion) from all the requested reviewers here.