Skip to content

Commit

Permalink
Update isAtLeastP implementation.
Browse files Browse the repository at this point in the history
P SDK will be 28 - update to final implementation.

Also convert an undesirable use of >OMR1 to isAtLeastP (it's best never
to compare to "greater than the last public version" in case another SDK
is added in between).

Bug: 834499
Change-Id: Ibfcd3fea02317bc1a89d10ebe752e02d0cc3bb46
Reviewed-on: https://chromium-review.googlesource.com/1022396
Reviewed-by: Tobias Sargeant <tobiasjs@chromium.org>
Commit-Queue: Richard Coles <torne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#552841}
  • Loading branch information
tornewuff authored and Commit Bot committed Apr 23, 2018
1 parent 6d6667f commit 62ab79e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public void onFormFieldDidChange(int index, float x, float y, float width, float
public void onTextFieldDidScroll(int index, float x, float y, float width, float height) {
// crbug.com/730764 - from P and above, Android framework listens to the onScrollChanged()
// and repositions the autofill UI automatically.
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O_MR1) return;
if (BuildInfo.isAtLeastP()) return;
if (mRequest == null) return;

short sIndex = (short) index;
Expand Down
12 changes: 3 additions & 9 deletions base/android/java/src/org/chromium/base/BuildInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,23 +176,17 @@ public static boolean isDebugAndroid() {
/**
* Checks if the device is running on a pre-release version of Android P or newer.
* <p>
* <strong>Note:</strong> This method will return {@code false} on devices running release
* versions of Android. When Android P is finalized for release, this method will be deprecated
* and all calls should be replaced with {@code Build.SDK_INT >= Build.VERSION_CODES#P}.
*
* @return {@code true} if P APIs are available for use, {@code false} otherwise
*/
public static boolean isAtLeastP() {
return VERSION.CODENAME.equals("P") || VERSION.CODENAME.equals("Q");
return VERSION.SDK_INT >= 28;
}

/**
* Checks if the application targets pre-release SDK P
* Checks if the application targets at least released SDK P
*/
public static boolean targetsAtLeastP() {
return isAtLeastP()
&& ContextUtils.getApplicationContext().getApplicationInfo().targetSdkVersion
== Build.VERSION_CODES.CUR_DEVELOPMENT;
return ContextUtils.getApplicationContext().getApplicationInfo().targetSdkVersion >= 28;
}

// End:BuildCompat
Expand Down

0 comments on commit 62ab79e

Please sign in to comment.