* decorations that can never be removed. That is, system bar or
* button bar.
*/
- public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation);
+ public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation,
+ int uiMode);
/**
* Return the display height available after excluding any screen
* decorations that can never be removed. That is, system bar or
* button bar.
*/
- public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation);
+ public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation,
+ int uiMode);
/**
* Return the available screen width that we should report for the
* {@link #getNonDecorDisplayWidth(int, int, int)}; it may be smaller than
* that to account for more transient decoration like a status bar.
*/
- public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation);
+ public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation,
+ int uiMode);
/**
* Return the available screen height that we should report for the
* {@link #getNonDecorDisplayHeight(int, int, int)}; it may be smaller than
* that to account for more transient decoration like a status bar.
*/
- public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation);
+ public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation,
+ int uiMode);
/**
* Return whether the given window is forcibly hiding all windows except windows with
* @param isDefaultDisplay true if window is on {@link Display#DEFAULT_DISPLAY}.
* @param displayWidth The current full width of the screen.
* @param displayHeight The current full height of the screen.
- * @param displayRotation The current rotation being applied to the base
- * window.
+ * @param displayRotation The current rotation being applied to the base window.
+ * @param uiMode The current uiMode in configuration.
*/
public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight,
- int displayRotation);
+ int displayRotation, int uiMode);
/**
* Returns the bottom-most layer of the system decor, above which no policy decor should
<dimen name="navigation_bar_height_landscape">48dp</dimen>
<!-- Width of the navigation bar when it is placed vertically on the screen -->
<dimen name="navigation_bar_width">48dp</dimen>
+ <!-- Height of the bottom navigation / system bar in car mode. -->
+ <dimen name="navigation_bar_height_car_mode">96dp</dimen>
+ <!-- Height of the bottom navigation bar in portrait; often the same as
+ @dimen/navigation_bar_height_car_mode -->
+ <dimen name="navigation_bar_height_landscape_car_mode">96dp</dimen>
+ <!-- Width of the navigation bar when it is placed vertically on the screen in car mode -->
+ <dimen name="navigation_bar_width_car_mode">96dp</dimen>
<!-- Height of notification icons in the status bar -->
<dimen name="status_bar_icon_size">24dip</dimen>
<!-- Size of the giant number (unread count) in the notifications -->
<java-symbol type="dimen" name="navigation_bar_height" />
<java-symbol type="dimen" name="navigation_bar_height_landscape" />
<java-symbol type="dimen" name="navigation_bar_width" />
+ <java-symbol type="dimen" name="navigation_bar_height_car_mode" />
+ <java-symbol type="dimen" name="navigation_bar_height_landscape_car_mode" />
+ <java-symbol type="dimen" name="navigation_bar_width_car_mode" />
<java-symbol type="dimen" name="status_bar_height" />
<java-symbol type="drawable" name="ic_jog_dial_sound_off" />
<java-symbol type="drawable" name="ic_jog_dial_sound_on" />
<resources>
<dimen name="status_bar_height">@*android:dimen/status_bar_height</dimen>
<dimen name="navigation_bar_height">@*android:dimen/navigation_bar_height</dimen>
+ <dimen name="navigation_bar_height_car_mode">@*android:dimen/navigation_bar_height_car_mode</dimen>
<color name="screen_pinning_primary_text">@*android:color/primary_text_default_material_light</color>
</resources>
View mCurrentView = null;
View[] mRotatedViews = new View[4];
- int mBarSize;
boolean mVertical;
boolean mScreenOn;
int mNavigationIconHints = 0;
private Drawable mBackIcon, mBackLandIcon, mBackAltIcon, mBackAltLandIcon;
+ private Drawable mBackCarModeIcon, mBackLandCarModeIcon;
+ private Drawable mBackAltCarModeIcon, mBackAltLandCarModeIcon;
+ private Drawable mHomeDefaultIcon, mHomeCarModeIcon;
private Drawable mRecentIcon;
private Drawable mRecentLandIcon;
private boolean mIsLayoutRtl;
private boolean mLayoutTransitionsEnabled = true;
private boolean mWakeAndUnlocking;
+ private boolean mCarMode = false;
private class NavTransitionListener implements TransitionListener {
private boolean mBackTransitioning;
public NavigationBarView(Context context, AttributeSet attrs) {
super(context, attrs);
- mDisplay = ((WindowManager)context.getSystemService(
+ mDisplay = ((WindowManager) context.getSystemService(
Context.WINDOW_SERVICE)).getDefaultDisplay();
final Resources res = getContext().getResources();
- mBarSize = res.getDimensionPixelSize(R.dimen.navigation_bar_size);
mVertical = false;
mShowMenu = false;
mGestureHelper = new NavigationBarGestureHelper(context);
- getIcons(res);
+ getIcons(context);
mBarTransitions = new NavigationBarTransitions(this);
}
return getCurrentView().findViewById(R.id.app_shelf);
}
- private void getIcons(Resources res) {
- mBackIcon = res.getDrawable(R.drawable.ic_sysbar_back);
+ private void getCarModeIcons(Context ctx) {
+ mBackCarModeIcon = ctx.getDrawable(R.drawable.ic_sysbar_back_carmode);
+ mBackLandCarModeIcon = mBackCarModeIcon;
+ mBackAltCarModeIcon = ctx.getDrawable(R.drawable.ic_sysbar_back_ime_carmode);
+ mBackAltLandCarModeIcon = mBackAltCarModeIcon;
+ mHomeCarModeIcon = ctx.getDrawable(R.drawable.ic_sysbar_home_carmode);
+ }
+
+ private void getIcons(Context ctx) {
+ mBackIcon = ctx.getDrawable(R.drawable.ic_sysbar_back);
mBackLandIcon = mBackIcon;
- mBackAltIcon = res.getDrawable(R.drawable.ic_sysbar_back_ime);
+ mBackAltIcon = ctx.getDrawable(R.drawable.ic_sysbar_back_ime);
mBackAltLandIcon = mBackAltIcon;
- mRecentIcon = res.getDrawable(R.drawable.ic_sysbar_recent);
+
+ mHomeDefaultIcon = ctx.getDrawable(R.drawable.ic_sysbar_home);
+
+ mRecentIcon = ctx.getDrawable(R.drawable.ic_sysbar_recent);
mRecentLandIcon = mRecentIcon;
+ getCarModeIcons(ctx);
}
@Override
public void setLayoutDirection(int layoutDirection) {
- getIcons(getContext().getResources());
+ getIcons(getContext());
super.setLayoutDirection(layoutDirection);
}
setNavigationIconHints(hints, false);
}
+ private Drawable getBackIconWithAlt(boolean carMode, boolean landscape) {
+ return landscape
+ ? carMode ? mBackAltLandCarModeIcon : mBackAltLandIcon
+ : carMode ? mBackAltCarModeIcon : mBackAltIcon;
+ }
+
+ private Drawable getBackIcon(boolean carMode, boolean landscape) {
+ return landscape
+ ? carMode ? mBackLandCarModeIcon : mBackLandIcon
+ : carMode ? mBackCarModeIcon : mBackIcon;
+ }
+
public void setNavigationIconHints(int hints, boolean force) {
if (!force && hints == mNavigationIconHints) return;
final boolean backAlt = (hints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0;
mNavigationIconHints = hints;
- ((ImageView)getBackButton()).setImageDrawable(backAlt
- ? (mVertical ? mBackAltLandIcon : mBackAltIcon)
- : (mVertical ? mBackLandIcon : mBackIcon));
+ // We have to replace or restore the back and home button icons when exiting or entering
+ // carmode, respectively. Recents are not available in CarMode in nav bar so change
+ // to recent icon is not required.
+ Drawable backIcon = (backAlt)
+ ? getBackIconWithAlt(mCarMode, mVertical)
+ : getBackIcon(mCarMode, mVertical);
- ((ImageView)getRecentsButton()).setImageDrawable(mVertical ? mRecentLandIcon : mRecentIcon);
+ ((ImageView) getBackButton()).setImageDrawable(backIcon);
+
+ ((ImageView) getRecentsButton()).setImageDrawable(
+ mVertical ? mRecentLandIcon : mRecentIcon);
+
+ if (mCarMode) {
+ ((ImageView) getHomeButton()).setImageDrawable(mHomeCarModeIcon);
+ } else {
+ ((ImageView) getHomeButton()).setImageDrawable(mHomeDefaultIcon);
+ }
final boolean showImeButton = ((hints & StatusBarManager.NAVIGATION_HINT_IME_SHOWN) != 0);
getImeSwitchButton().setVisibility(showImeButton ? View.VISIBLE : View.INVISIBLE);
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
+ boolean uiCarModeChanged = updateCarMode(newConfig);
updateRTLOrder();
updateTaskSwitchHelper();
+ if (uiCarModeChanged) {
+ // uiMode changed either from carmode or to carmode.
+ // replace the nav bar button icons based on which mode
+ // we are switching to.
+ setNavigationIconHints(mNavigationIconHints, true);
+ }
+ }
+
+ /**
+ * If the configuration changed, update the carmode and return that it was updated.
+ */
+ private boolean updateCarMode(Configuration newConfig) {
+ boolean uiCarModeChanged = false;
+ if (newConfig != null) {
+ int uiMode = newConfig.uiMode & Configuration.UI_MODE_TYPE_MASK;
+ if (mCarMode && uiMode != Configuration.UI_MODE_TYPE_CAR) {
+ mCarMode = false;
+ uiCarModeChanged = true;
+ } else if (uiMode == Configuration.UI_MODE_TYPE_CAR) {
+ mCarMode = true;
+ uiCarModeChanged = true;
+ }
+ }
+ return uiCarModeChanged;
}
/**
import static android.app.ActivityManager.StackId.DOCKED_STACK_ID;
import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
+import static android.content.res.Configuration.UI_MODE_TYPE_CAR;
+import static android.content.res.Configuration.UI_MODE_TYPE_MASK;
import static android.view.WindowManager.LayoutParams.*;
import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT;
import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_OPEN;
boolean mCanHideNavigationBar = false;
boolean mNavigationBarCanMove = false; // can the navigation bar ever move to the side?
boolean mNavigationBarOnBottom = true; // is the navigation bar on the bottom *right now*?
- int[] mNavigationBarHeightForRotation = new int[4];
- int[] mNavigationBarWidthForRotation = new int[4];
+ int[] mNavigationBarHeightForRotationDefault = new int[4];
+ int[] mNavigationBarWidthForRotationDefault = new int[4];
+ int[] mNavigationBarHeightForRotationInCarMode = new int[4];
+ int[] mNavigationBarWidthForRotationInCarMode = new int[4];
// Whether to allow dock apps with METADATA_DOCK_HOME to temporarily take over the Home key.
// This is for car dock and this is updated from resource.
res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
// Height of the navigation bar when presented horizontally at bottom
- mNavigationBarHeightForRotation[mPortraitRotation] =
- mNavigationBarHeightForRotation[mUpsideDownRotation] =
+ mNavigationBarHeightForRotationDefault[mPortraitRotation] =
+ mNavigationBarHeightForRotationDefault[mUpsideDownRotation] =
res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height);
- mNavigationBarHeightForRotation[mLandscapeRotation] =
- mNavigationBarHeightForRotation[mSeascapeRotation] = res.getDimensionPixelSize(
+ mNavigationBarHeightForRotationDefault[mLandscapeRotation] =
+ mNavigationBarHeightForRotationDefault[mSeascapeRotation] = res.getDimensionPixelSize(
com.android.internal.R.dimen.navigation_bar_height_landscape);
// Width of the navigation bar when presented vertically along one side
- mNavigationBarWidthForRotation[mPortraitRotation] =
- mNavigationBarWidthForRotation[mUpsideDownRotation] =
- mNavigationBarWidthForRotation[mLandscapeRotation] =
- mNavigationBarWidthForRotation[mSeascapeRotation] =
+ mNavigationBarWidthForRotationDefault[mPortraitRotation] =
+ mNavigationBarWidthForRotationDefault[mUpsideDownRotation] =
+ mNavigationBarWidthForRotationDefault[mLandscapeRotation] =
+ mNavigationBarWidthForRotationDefault[mSeascapeRotation] =
res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width);
+ // Height of the navigation bar when presented horizontally at bottom
+ mNavigationBarHeightForRotationInCarMode[mPortraitRotation] =
+ mNavigationBarHeightForRotationInCarMode[mUpsideDownRotation] =
+ res.getDimensionPixelSize(
+ com.android.internal.R.dimen.navigation_bar_height_car_mode);
+ mNavigationBarHeightForRotationInCarMode[mLandscapeRotation] =
+ mNavigationBarHeightForRotationInCarMode[mSeascapeRotation] = res.getDimensionPixelSize(
+ com.android.internal.R.dimen.navigation_bar_height_landscape_car_mode);
+
+ // Width of the navigation bar when presented vertically along one side
+ mNavigationBarWidthForRotationInCarMode[mPortraitRotation] =
+ mNavigationBarWidthForRotationInCarMode[mUpsideDownRotation] =
+ mNavigationBarWidthForRotationInCarMode[mLandscapeRotation] =
+ mNavigationBarWidthForRotationInCarMode[mSeascapeRotation] =
+ res.getDimensionPixelSize(
+ com.android.internal.R.dimen.navigation_bar_width_car_mode);
+
// SystemUI (status bar) layout policy
int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / density;
int longSizeDp = longSize * DisplayMetrics.DENSITY_DEFAULT / density;
return windowTypeToLayerLw(TYPE_STATUS_BAR);
}
+ private int getNavigationBarWidth(int rotation, int uiMode) {
+ if ((uiMode & UI_MODE_TYPE_MASK) == UI_MODE_TYPE_CAR) {
+ return mNavigationBarWidthForRotationInCarMode[rotation];
+ } else {
+ return mNavigationBarWidthForRotationDefault[rotation];
+ }
+ }
+
@Override
- public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation) {
+ public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation,
+ int uiMode) {
if (mHasNavigationBar) {
// For a basic navigation bar, when we are in landscape mode we place
// the navigation bar to the side.
if (mNavigationBarCanMove && fullWidth > fullHeight) {
- return fullWidth - mNavigationBarWidthForRotation[rotation];
+ return fullWidth - getNavigationBarWidth(rotation, uiMode);
}
}
return fullWidth;
}
+ private int getNavigationBarHeight(int rotation, int uiMode) {
+ if ((uiMode & UI_MODE_TYPE_MASK) == UI_MODE_TYPE_CAR) {
+ return mNavigationBarHeightForRotationInCarMode[rotation];
+ } else {
+ return mNavigationBarHeightForRotationDefault[rotation];
+ }
+ }
+
@Override
- public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation) {
+ public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation,
+ int uiMode) {
if (mHasNavigationBar) {
// For a basic navigation bar, when we are in portrait mode we place
// the navigation bar to the bottom.
if (!mNavigationBarCanMove || fullWidth < fullHeight) {
- return fullHeight - mNavigationBarHeightForRotation[rotation];
+ return fullHeight - getNavigationBarHeight(rotation, uiMode);
}
}
return fullHeight;
}
@Override
- public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation) {
- return getNonDecorDisplayWidth(fullWidth, fullHeight, rotation);
+ public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation, int uiMode) {
+ return getNonDecorDisplayWidth(fullWidth, fullHeight, rotation, uiMode);
}
@Override
- public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation) {
+ public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation, int uiMode) {
// There is a separate status bar at the top of the display. We don't count that as part
// of the fixed decor, since it can hide; however, for purposes of configurations,
// we do want to exclude it since applications can't generally use that part
// of the screen.
- return getNonDecorDisplayHeight(fullWidth, fullHeight, rotation) - mStatusBarHeight;
+ return getNonDecorDisplayHeight(
+ fullWidth, fullHeight, rotation, uiMode) - mStatusBarHeight;
}
@Override
/** {@inheritDoc} */
@Override
public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight,
- int displayRotation) {
+ int displayRotation, int uiMode) {
mDisplayRotation = displayRotation;
final int overscanLeft, overscanTop, overscanRight, overscanBottom;
if (isDefaultDisplay) {
navVisible |= !canHideNavigationBar();
boolean updateSysUiVisibility = layoutNavigationBar(displayWidth, displayHeight,
- displayRotation, overscanRight, overscanBottom, dcf, navVisible, navTranslucent,
+ displayRotation, uiMode, overscanRight, overscanBottom, dcf, navVisible, navTranslucent,
navAllowedHidden);
if (DEBUG_LAYOUT) Slog.i(TAG, String.format("mDock rect: (%d,%d - %d,%d)",
mDockLeft, mDockTop, mDockRight, mDockBottom));
}
private boolean layoutNavigationBar(int displayWidth, int displayHeight, int displayRotation,
- int overscanRight, int overscanBottom, Rect dcf, boolean navVisible,
+ int uiMode, int overscanRight, int overscanBottom, Rect dcf, boolean navVisible,
boolean navTranslucent, boolean navAllowedHidden) {
if (mNavigationBar != null) {
boolean transientNavBarShowing = mNavigationBarController.isTransientShowing();
if (mNavigationBarOnBottom) {
// It's a system nav bar or a portrait screen; nav bar goes on bottom.
int top = displayHeight - overscanBottom
- - mNavigationBarHeightForRotation[displayRotation];
+ - getNavigationBarHeight(displayRotation, uiMode);
mTmpNavigationFrame.set(0, top, displayWidth, displayHeight - overscanBottom);
mStableBottom = mStableFullscreenBottom = mTmpNavigationFrame.top;
if (transientNavBarShowing) {
} else {
// Landscape screen; nav bar goes to the right.
int left = displayWidth - overscanRight
- - mNavigationBarWidthForRotation[displayRotation];
+ - getNavigationBarWidth(displayRotation, uiMode);
mTmpNavigationFrame.set(left, 0, displayWidth - overscanRight, displayHeight);
mStableRight = mStableFullscreenRight = mTmpNavigationFrame.left;
if (transientNavBarShowing) {
// the value of the previous configuration.
mTempConfiguration.setToDefaults();
mTempConfiguration.fontScale = currentConfig.fontScale;
+ mTempConfiguration.uiMode = currentConfig.uiMode;
computeScreenConfigurationLocked(mTempConfiguration);
if (currentConfig.diff(mTempConfiguration) != 0) {
mWaitingForConfig = true;
// the top of the method, the caller is obligated to call computeNewConfigurationLocked().
// By updating the Display info here it will be available to
// computeScreenConfigurationLocked later.
- updateDisplayAndOrientationLocked();
+ updateDisplayAndOrientationLocked(mCurConfiguration.uiMode);
final DisplayInfo displayInfo = displayContent.getDisplayInfo();
if (!inTransaction) {
return config;
}
- private void adjustDisplaySizeRanges(DisplayInfo displayInfo, int rotation, int dw, int dh) {
+ private void adjustDisplaySizeRanges(DisplayInfo displayInfo, int rotation, int uiMode,
+ int dw, int dh) {
// TODO: Multidisplay: for now only use with default display.
- final int width = mPolicy.getConfigDisplayWidth(dw, dh, rotation);
+ final int width = mPolicy.getConfigDisplayWidth(dw, dh, rotation, uiMode);
if (width < displayInfo.smallestNominalAppWidth) {
displayInfo.smallestNominalAppWidth = width;
}
if (width > displayInfo.largestNominalAppWidth) {
displayInfo.largestNominalAppWidth = width;
}
- final int height = mPolicy.getConfigDisplayHeight(dw, dh, rotation);
+ final int height = mPolicy.getConfigDisplayHeight(dw, dh, rotation, uiMode);
if (height < displayInfo.smallestNominalAppHeight) {
displayInfo.smallestNominalAppHeight = height;
}
}
private int reduceConfigLayout(int curLayout, int rotation, float density,
- int dw, int dh) {
+ int dw, int dh, int uiMode) {
// TODO: Multidisplay: for now only use with default display.
// Get the app screen size at this rotation.
- int w = mPolicy.getNonDecorDisplayWidth(dw, dh, rotation);
- int h = mPolicy.getNonDecorDisplayHeight(dw, dh, rotation);
+ int w = mPolicy.getNonDecorDisplayWidth(dw, dh, rotation, uiMode);
+ int h = mPolicy.getNonDecorDisplayHeight(dw, dh, rotation, uiMode);
// Compute the screen layout size class for this rotation.
int longSize = w;
}
private void computeSizeRangesAndScreenLayout(DisplayInfo displayInfo, boolean rotated,
- int dw, int dh, float density, Configuration outConfig) {
+ int uiMode, int dw, int dh, float density, Configuration outConfig) {
// TODO: Multidisplay: for now only use with default display.
// We need to determine the smallest width that will occur under normal
displayInfo.smallestNominalAppHeight = 1<<30;
displayInfo.largestNominalAppWidth = 0;
displayInfo.largestNominalAppHeight = 0;
- adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_0, unrotDw, unrotDh);
- adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_90, unrotDh, unrotDw);
- adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_180, unrotDw, unrotDh);
- adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_270, unrotDh, unrotDw);
+ adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_0, uiMode, unrotDw, unrotDh);
+ adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_90, uiMode, unrotDh, unrotDw);
+ adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_180, uiMode, unrotDw, unrotDh);
+ adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_270, uiMode, unrotDh, unrotDw);
int sl = Configuration.resetScreenLayout(outConfig.screenLayout);
- sl = reduceConfigLayout(sl, Surface.ROTATION_0, density, unrotDw, unrotDh);
- sl = reduceConfigLayout(sl, Surface.ROTATION_90, density, unrotDh, unrotDw);
- sl = reduceConfigLayout(sl, Surface.ROTATION_180, density, unrotDw, unrotDh);
- sl = reduceConfigLayout(sl, Surface.ROTATION_270, density, unrotDh, unrotDw);
+ sl = reduceConfigLayout(sl, Surface.ROTATION_0, density, unrotDw, unrotDh, uiMode);
+ sl = reduceConfigLayout(sl, Surface.ROTATION_90, density, unrotDh, unrotDw, uiMode);
+ sl = reduceConfigLayout(sl, Surface.ROTATION_180, density, unrotDw, unrotDh, uiMode);
+ sl = reduceConfigLayout(sl, Surface.ROTATION_270, density, unrotDh, unrotDw, uiMode);
outConfig.smallestScreenWidthDp = (int)(displayInfo.smallestNominalAppWidth / density);
outConfig.screenLayout = sl;
}
- private int reduceCompatConfigWidthSize(int curSize, int rotation, DisplayMetrics dm,
- int dw, int dh) {
+ private int reduceCompatConfigWidthSize(int curSize, int rotation, int uiMode,
+ DisplayMetrics dm, int dw, int dh) {
// TODO: Multidisplay: for now only use with default display.
- dm.noncompatWidthPixels = mPolicy.getNonDecorDisplayWidth(dw, dh, rotation);
- dm.noncompatHeightPixels = mPolicy.getNonDecorDisplayHeight(dw, dh, rotation);
+ dm.noncompatWidthPixels = mPolicy.getNonDecorDisplayWidth(dw, dh, rotation, uiMode);
+ dm.noncompatHeightPixels = mPolicy.getNonDecorDisplayHeight(dw, dh, rotation, uiMode);
float scale = CompatibilityInfo.computeCompatibleScaling(dm, null);
int size = (int)(((dm.noncompatWidthPixels / scale) / dm.density) + .5f);
if (curSize == 0 || size < curSize) {
return curSize;
}
- private int computeCompatSmallestWidth(boolean rotated, DisplayMetrics dm, int dw, int dh) {
+ private int computeCompatSmallestWidth(boolean rotated, int uiMode, DisplayMetrics dm, int dw, int dh) {
// TODO: Multidisplay: for now only use with default display.
mTmpDisplayMetrics.setTo(dm);
final DisplayMetrics tmpDm = mTmpDisplayMetrics;
unrotDw = dw;
unrotDh = dh;
}
- int sw = reduceCompatConfigWidthSize(0, Surface.ROTATION_0, tmpDm, unrotDw, unrotDh);
- sw = reduceCompatConfigWidthSize(sw, Surface.ROTATION_90, tmpDm, unrotDh, unrotDw);
- sw = reduceCompatConfigWidthSize(sw, Surface.ROTATION_180, tmpDm, unrotDw, unrotDh);
- sw = reduceCompatConfigWidthSize(sw, Surface.ROTATION_270, tmpDm, unrotDh, unrotDw);
+ int sw = reduceCompatConfigWidthSize(0, Surface.ROTATION_0, uiMode, tmpDm, unrotDw, unrotDh);
+ sw = reduceCompatConfigWidthSize(sw, Surface.ROTATION_90, uiMode, tmpDm, unrotDh, unrotDw);
+ sw = reduceCompatConfigWidthSize(sw, Surface.ROTATION_180, uiMode, tmpDm, unrotDw, unrotDh);
+ sw = reduceCompatConfigWidthSize(sw, Surface.ROTATION_270, uiMode, tmpDm, unrotDh, unrotDw);
return sw;
}
/** Do not call if mDisplayReady == false */
- DisplayInfo updateDisplayAndOrientationLocked() {
+ DisplayInfo updateDisplayAndOrientationLocked(int uiMode) {
// TODO(multidisplay): For now, apply Configuration to main screen only.
final DisplayContent displayContent = getDefaultDisplayContentLocked();
}
// Update application display metrics.
- final int appWidth = mPolicy.getNonDecorDisplayWidth(dw, dh, mRotation);
- final int appHeight = mPolicy.getNonDecorDisplayHeight(dw, dh, mRotation);
+ final int appWidth = mPolicy.getNonDecorDisplayWidth(dw, dh, mRotation, uiMode);
+ final int appHeight = mPolicy.getNonDecorDisplayHeight(dw, dh, mRotation, uiMode);
final DisplayInfo displayInfo = displayContent.getDisplayInfo();
displayInfo.rotation = mRotation;
displayInfo.logicalWidth = dw;
/** Do not call if mDisplayReady == false */
void computeScreenConfigurationLocked(Configuration config) {
- final DisplayInfo displayInfo = updateDisplayAndOrientationLocked();
+ final DisplayInfo displayInfo = updateDisplayAndOrientationLocked(
+ config.uiMode);
final int dw = displayInfo.logicalWidth;
final int dh = displayInfo.logicalHeight;
config.orientation = (dw <= dh) ? Configuration.ORIENTATION_PORTRAIT :
Configuration.ORIENTATION_LANDSCAPE;
config.screenWidthDp =
- (int)(mPolicy.getConfigDisplayWidth(dw, dh, mRotation) / mDisplayMetrics.density);
+ (int)(mPolicy.getConfigDisplayWidth(dw, dh, mRotation, config.uiMode) /
+ mDisplayMetrics.density);
config.screenHeightDp =
- (int)(mPolicy.getConfigDisplayHeight(dw, dh, mRotation) / mDisplayMetrics.density);
+ (int)(mPolicy.getConfigDisplayHeight(dw, dh, mRotation, config.uiMode) /
+ mDisplayMetrics.density);
final boolean rotated = (mRotation == Surface.ROTATION_90
|| mRotation == Surface.ROTATION_270);
- computeSizeRangesAndScreenLayout(displayInfo, rotated, dw, dh, mDisplayMetrics.density,
- config);
+
+ computeSizeRangesAndScreenLayout(displayInfo, rotated, config.uiMode, dw, dh,
+ mDisplayMetrics.density, config);
config.screenLayout = (config.screenLayout & ~Configuration.SCREENLAYOUT_ROUND_MASK)
| ((displayInfo.flags & Display.FLAG_ROUND) != 0
config.compatScreenWidthDp = (int)(config.screenWidthDp / mCompatibleScreenScale);
config.compatScreenHeightDp = (int)(config.screenHeightDp / mCompatibleScreenScale);
- config.compatSmallestScreenWidthDp = computeCompatSmallestWidth(rotated,
+ config.compatSmallestScreenWidthDp = computeCompatSmallestWidth(rotated, config.uiMode,
mDisplayMetrics, dw, dh);
config.densityDpi = displayInfo.logicalDensityDpi;
boolean configChanged = updateOrientationFromAppTokensLocked(false);
mTempConfiguration.setToDefaults();
mTempConfiguration.fontScale = mCurConfiguration.fontScale;
+ mTempConfiguration.uiMode = mCurConfiguration.uiMode;
computeScreenConfigurationLocked(mTempConfiguration);
configChanged |= mCurConfiguration.diff(mTempConfiguration) != 0;
+ displayContent.layoutNeeded + " dw=" + dw + " dh=" + dh);
}
- mService.mPolicy.beginLayoutLw(isDefaultDisplay, dw, dh, mService.mRotation);
+ mService.mPolicy.beginLayoutLw(isDefaultDisplay, dw, dh, mService.mRotation,
+ mService.mCurConfiguration.uiMode);
if (isDefaultDisplay) {
// Not needed on non-default displays.
mService.mSystemDecorLayer = mService.mPolicy.getSystemDecorLayerLw();