* @return the config
*/
@SuppressWarnings("SuspiciousNameCombination") // Deliberately swapping orientations
@NonNull
public HardwareConfig getConfig() {
Screen screen = mDevice.getDefaultHardware().getScreen();
// compute width and height to take orientation into account.
int x = screen.getXDimension();
int y = screen.getYDimension();
int width, height;
if (x > y) {
if (mScreenOrientation == ScreenOrientation.LANDSCAPE) {
width = x;
height = y;
} else {
width = y;
height = x;
}
} else {
if (mScreenOrientation == ScreenOrientation.LANDSCAPE) {
width = y;
height = x;
} else {
width = x;
height = y;
}
}
if (mOverrideRenderHeight != -1) {
width = mOverrideRenderWidth;
}
if (mOverrideRenderHeight != -1) {
height = mOverrideRenderHeight;
}
if (mMaxRenderWidth != -1) {
width = mMaxRenderWidth;
}
if (mMaxRenderHeight != -1) {
height = mMaxRenderHeight;
}
return new HardwareConfig(
width,
height,
screen.getPixelDensity(),
(float) screen.getXdpi(),
(float) screen.getYdpi(),
screen.getSize(),
mScreenOrientation,
mDevice.getDefaultHardware().getButtonType() == ButtonType.SOFT);
}