Skip to content

Commit

Permalink
Fix crash when switching back from Samsung DeX to Phone mode.
Browse files Browse the repository at this point in the history
Regressed in d875cac

Bug: 780593
Change-Id: Ifee7a93ada73f5b757a35ece75b0bef61ea767c2
Reviewed-on: https://chromium-review.googlesource.com/820531
Reviewed-by: Theresa <twellington@chromium.org>
Reviewed-by: Ted Choc (back but slow, ping me) <tedchoc@chromium.org>
Commit-Queue: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#527117}
  • Loading branch information
agrieve authored and Commit Bot committed Jan 4, 2018
1 parent 5d57700 commit e23729f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,13 @@ 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.
// Android will load the tab strip resources.
// See crbug.com/588838, crbug.com/662338, crbug.com/780593.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
if (DeviceFormFactor.isTablet()) {
Configuration overrideConfiguration = new Configuration();
overrideConfiguration.smallestScreenWidthDp =
DeviceFormFactor.getSmallestDeviceWidthDp();
applyOverrideConfiguration(overrideConfiguration);
}
Configuration overrideConfiguration = new Configuration();
overrideConfiguration.smallestScreenWidthDp =
DeviceFormFactor.getSmallestDeviceWidthDp();
applyOverrideConfiguration(overrideConfiguration);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,12 @@ public class DeviceFormFactor {
public static final int MINIMUM_TABLET_WIDTH_DP = 600;

/**
* @return Whether the app should treat the device as a tablet for layout. This method is not
* affected by Android N multi-window.
* @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
*/
@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);
}

Expand Down

0 comments on commit e23729f

Please sign in to comment.