Commit ca4e4fb7 authored by Matthew Jones's avatar Matthew Jones Committed by Commit Bot

Revert "Remove not-tablet check in DeviceFormFactor"

This reverts commit a6b5210c.

Reason for revert: Breaks all tablets

Original change's description:
> Remove not-tablet check in DeviceFormFactor
> 
> This patch removes an early return from
> DeviceFormFactor#detectScreenWidthBucket that will allow tablets to
> return their screen width "bucket". This should prevent tablets from
> trying to load phone resources in certain cases.
> 
> Bug: 850096
> Change-Id: Ie25c66d7dcc5278300f628cdd58e7e7c8f1052da
> Reviewed-on: https://chromium-review.googlesource.com/1095642
> Reviewed-by: Ted Choc <tedchoc@chromium.org>
> Reviewed-by: agrieve <agrieve@chromium.org>
> Commit-Queue: Matthew Jones <mdjones@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#566246}

TBR=tedchoc@chromium.org,agrieve@chromium.org,mdjones@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 850096
Change-Id: Ia214bd8fc00e0c20bc79bb74f1d092348527bb1f
Reviewed-on: https://chromium-review.googlesource.com/1099395Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566945}
parent 37aade5a
......@@ -92,7 +92,8 @@ public class DeviceFormFactor {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1
// TODO(agrieve): Remove thread check and audit for background usages.
// https://crbug.com/669974
&& ThreadUtils.runningOnUiThread()) {
&& ThreadUtils.runningOnUiThread()
&& !isTabletDisplay(DisplayAndroid.getNonMultiDisplay(context))) {
// There have been no cases where tablet resources end up being used on phone-sized
// displays. Short-circuit this common-case since checking resources is slower (and
// triggers a strict-mode violation when value is not cached).
......@@ -104,7 +105,9 @@ public class DeviceFormFactor {
private static int detectScreenWidthBucket(WindowAndroid windowAndroid) {
ThreadUtils.assertOnUiThread();
Context context = windowAndroid.getContext().get();
if (context == null) return 0;
if (context == null || !isTabletDisplay(windowAndroid.getDisplay())) {
return 0;
}
return context.getResources().getInteger(R.integer.min_screen_width_bucket);
}
......@@ -124,4 +127,9 @@ public class DeviceFormFactor {
public static int getMinimumTabletWidthPx(DisplayAndroid display) {
return DisplayUtil.dpToPx(display, DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP);
}
// Function is private to ensure that Context is also consulted when answering this query.
private static boolean isTabletDisplay(DisplayAndroid display) {
return DisplayUtil.getSmallestWidth(display) >= getMinimumTabletWidthPx(display);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment