From 3f25cfcce7a10639564b267bffcc67dbbe376e1a Mon Sep 17 00:00:00 2001 From: agrieve Date: Fri, 19 Jan 2018 02:55:37 +0000 Subject: [PATCH] Revert "Fix crash when switching back from Samsung DeX to Phone mode." This reverts commit e23729f31db28a378f92a25f7672ba1a51324c5e. Reason for revert: Probably causing other crashing (see bug) Original change's description: > Fix crash when switching back from Samsung DeX to Phone mode. > > Regressed in d875cacbdc450d8594b560d4511bef1e88c5f01b > > Bug: 780593 > Change-Id: Ifee7a93ada73f5b757a35ece75b0bef61ea767c2 > Reviewed-on: https://chromium-review.googlesource.com/820531 > Reviewed-by: Theresa > Reviewed-by: Ted Choc (back but slow, ping me) > Commit-Queue: agrieve > Cr-Commit-Position: refs/heads/master@{#527117} TBR=tedchoc@chromium.org,twellington@chromium.org,agrieve@chromium.org # Not skipping CQ checks because original CL landed > 1 day ago. Bug: 780593, 794551 Change-Id: Ia91f278b1dff52af4f4fc1bbd33743168dfb5e4a Reviewed-on: https://chromium-review.googlesource.com/874803 Reviewed-by: agrieve Commit-Queue: agrieve Cr-Commit-Position: refs/heads/master@{#530406} --- .../browser/init/AsyncInitializationActivity.java | 13 +++++++------ .../src/org/chromium/ui/base/DeviceFormFactor.java | 9 ++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/chrome/android/java/src/org/chromium/chrome/browser/init/AsyncInitializationActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/init/AsyncInitializationActivity.java index d9eacfc087da3..1af2d853196f9 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/init/AsyncInitializationActivity.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/init/AsyncInitializationActivity.java @@ -110,13 +110,14 @@ protected void attachBaseContext(Context newBase) { // On N+, Chrome should always retain the tab strip layout on tablets. Normally in // multi-window, if Chrome is launched into a smaller screen Android will load the tab // switcher resources. Overriding the smallestScreenWidthDp in the Configuration ensures - // Android will load the tab strip resources. - // See crbug.com/588838, crbug.com/662338, crbug.com/780593. + // Android will load the tab strip resources. See crbug.com/588838. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - Configuration overrideConfiguration = new Configuration(); - overrideConfiguration.smallestScreenWidthDp = - DeviceFormFactor.getSmallestDeviceWidthDp(); - applyOverrideConfiguration(overrideConfiguration); + if (DeviceFormFactor.isTablet()) { + Configuration overrideConfiguration = new Configuration(); + overrideConfiguration.smallestScreenWidthDp = + DeviceFormFactor.getSmallestDeviceWidthDp(); + applyOverrideConfiguration(overrideConfiguration); + } } } diff --git a/ui/android/java/src/org/chromium/ui/base/DeviceFormFactor.java b/ui/android/java/src/org/chromium/ui/base/DeviceFormFactor.java index fb4e10740e271..9c538a8113f12 100644 --- a/ui/android/java/src/org/chromium/ui/base/DeviceFormFactor.java +++ b/ui/android/java/src/org/chromium/ui/base/DeviceFormFactor.java @@ -23,12 +23,15 @@ public class DeviceFormFactor { public static final int MINIMUM_TABLET_WIDTH_DP = 600; /** - * @return Whether the app should currently treat the device as a tablet for layout. This method - * is not affected by Android N multi-window, but can change for external displays. - * E.g. http://developer.samsung.com/samsung-dex/testing + * @return Whether the app should treat the device as a tablet for layout. This method is not + * affected by Android N multi-window. */ @CalledByNative public static boolean isTablet() { + // On some devices, OEM modifications have been made to the resource loader that cause the + // DeviceFormFactor calculation of whether a device is using tablet resources to be + // incorrect. Check which resources were actually loaded rather than look at screen size. + // See crbug.com/662338. return ContextUtils.getApplicationContext().getResources().getBoolean(R.bool.is_tablet); }