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
Use io.flutter.Build.API_LEVELS rather than android.os.Build.VERSION_CODES
#51171
Merged
Merged
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
297270a
Guard against API 22
dnfield feaeae9
Ban android.Build.VERSION_CODES
dnfield d516bb0
merge
dnfield b245c6a
unintended change
dnfield 5d824e2
missing symbol
dnfield c419ebf
Merge remote-tracking branch 'upstream/main' into version_Codes
dnfield da04a27
Use class
dnfield 0bd7854
missing imports
dnfield 262afee
Doc update, checker update, TargetApi/RequiresApi update
dnfield da7f0c2
more imports
dnfield ced3f92
Merge branch 'main' into version_Codes
dnfield eb297be
reid review
dnfield 71f3490
missing files
dnfield 9586efb
one last missing import
dnfield 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // 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; | ||
|
|
||
| /** A replacement of utilities from android.os.Build. */ | ||
| public class Build { | ||
| /** For use in place of the Android VERSION CODES class. */ | ||
| public static class API_LEVELS { | ||
| public static final int API_21 = 21; | ||
| public static final int API_22 = 22; | ||
| public static final int API_23 = 23; | ||
| public static final int API_24 = 24; | ||
| public static final int API_25 = 25; | ||
| public static final int API_26 = 26; | ||
| public static final int API_27 = 27; | ||
| public static final int API_28 = 28; | ||
| public static final int API_29 = 29; | ||
| public static final int API_30 = 30; | ||
| public static final int API_31 = 31; | ||
| public static final int API_32 = 32; | ||
| public static final int API_33 = 33; | ||
| public static final int API_34 = 34; | ||
| public static final int API_35 = 35; | ||
| } | ||
| } | ||
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 |
|---|---|---|
|
|
@@ -4,6 +4,8 @@ | |
|
|
||
| package io.flutter.embedding.android; | ||
|
|
||
| import static io.flutter.Build.API_LEVELS; | ||
|
|
||
| import android.annotation.SuppressLint; | ||
| import android.annotation.TargetApi; | ||
| import android.content.Context; | ||
|
|
@@ -109,7 +111,7 @@ private static ImageReader createImageReader(int width, int height) { | |
| logW("ImageReader height must be greater than 0, but given height=%d, set height=1", height); | ||
| height = 1; | ||
| } | ||
| if (android.os.Build.VERSION.SDK_INT >= 29) { | ||
| if (android.os.Build.VERSION.SDK_INT >= API_LEVELS.API_29) { | ||
| return ImageReader.newInstance( | ||
| width, | ||
| height, | ||
|
|
@@ -253,7 +255,7 @@ private void closeCurrentImage() { | |
|
|
||
| @TargetApi(29) | ||
|
||
| private void updateCurrentBitmap() { | ||
| if (android.os.Build.VERSION.SDK_INT >= 29) { | ||
| if (android.os.Build.VERSION.SDK_INT >= API_LEVELS.API_29) { | ||
| final HardwareBuffer buffer = currentImage.getHardwareBuffer(); | ||
| currentBitmap = Bitmap.wrapHardwareBuffer(buffer, ColorSpace.get(ColorSpace.Named.SRGB)); | ||
| buffer.close(); | ||
|
|
||
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
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.
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?