Merge "Revert "Coordinate configuration changes and window frame size."" into oc-dev

This commit is contained in:
Bryce Lee
2017-06-07 23:23:17 +00:00
committed by Android (Google) Code Review
6 changed files with 17 additions and 117 deletions

View File

@@ -16,7 +16,10 @@
package android.content.res; package android.content.res;
import android.graphics.Point;
import android.graphics.Rect; import android.graphics.Rect;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.DisplayInfo; import android.view.DisplayInfo;
import com.android.internal.util.XmlUtils; import com.android.internal.util.XmlUtils;
@@ -42,12 +45,6 @@ import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Locale; import java.util.Locale;
import static android.view.Surface.ROTATION_UNDEFINED;
import static android.view.Surface.ROTATION_0;
import static android.view.Surface.ROTATION_90;
import static android.view.Surface.ROTATION_180;
import static android.view.Surface.ROTATION_270;
/** /**
* This class describes all device configuration information that can * This class describes all device configuration information that can
* impact the resources the application retrieves. This includes both * impact the resources the application retrieves. This includes both
@@ -603,13 +600,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
*/ */
public int orientation; public int orientation;
/**
* The rotation used at the time orientation was determined.
* TODO(b/36812336): Move rotation out of {@link Configuration}.
* {@hide}
*/
private int rotation;
/** Constant for {@link #uiMode}: bits that encode the mode type. */ /** Constant for {@link #uiMode}: bits that encode the mode type. */
public static final int UI_MODE_TYPE_MASK = 0x0f; public static final int UI_MODE_TYPE_MASK = 0x0f;
/** Constant for {@link #uiMode}: a {@link #UI_MODE_TYPE_MASK} /** Constant for {@link #uiMode}: a {@link #UI_MODE_TYPE_MASK}
@@ -897,7 +887,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
navigation = o.navigation; navigation = o.navigation;
navigationHidden = o.navigationHidden; navigationHidden = o.navigationHidden;
orientation = o.orientation; orientation = o.orientation;
rotation = o.rotation;
screenLayout = o.screenLayout; screenLayout = o.screenLayout;
colorMode = o.colorMode; colorMode = o.colorMode;
uiMode = o.uiMode; uiMode = o.uiMode;
@@ -1001,14 +990,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
case ORIENTATION_PORTRAIT: sb.append(" port"); break; case ORIENTATION_PORTRAIT: sb.append(" port"); break;
default: sb.append(" orien="); sb.append(orientation); break; default: sb.append(" orien="); sb.append(orientation); break;
} }
switch (rotation) {
case ROTATION_UNDEFINED: sb.append(" ?rotation"); break;
case ROTATION_0: sb.append(" rot0"); break;
case ROTATION_90: sb.append(" rot90"); break;
case ROTATION_180: sb.append(" rot180"); break;
case ROTATION_270: sb.append(" rot270"); break;
default: sb.append(" rot="); sb.append(rotation); break;
}
switch ((uiMode&UI_MODE_TYPE_MASK)) { switch ((uiMode&UI_MODE_TYPE_MASK)) {
case UI_MODE_TYPE_UNDEFINED: sb.append(" ?uimode"); break; case UI_MODE_TYPE_UNDEFINED: sb.append(" ?uimode"); break;
case UI_MODE_TYPE_NORMAL: /* normal is not interesting to print */ break; case UI_MODE_TYPE_NORMAL: /* normal is not interesting to print */ break;
@@ -1096,7 +1077,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
navigation = NAVIGATION_UNDEFINED; navigation = NAVIGATION_UNDEFINED;
navigationHidden = NAVIGATIONHIDDEN_UNDEFINED; navigationHidden = NAVIGATIONHIDDEN_UNDEFINED;
orientation = ORIENTATION_UNDEFINED; orientation = ORIENTATION_UNDEFINED;
rotation = ROTATION_UNDEFINED;
screenLayout = SCREENLAYOUT_UNDEFINED; screenLayout = SCREENLAYOUT_UNDEFINED;
colorMode = COLOR_MODE_UNDEFINED; colorMode = COLOR_MODE_UNDEFINED;
uiMode = UI_MODE_TYPE_UNDEFINED; uiMode = UI_MODE_TYPE_UNDEFINED;
@@ -1205,11 +1185,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
changed |= ActivityInfo.CONFIG_ORIENTATION; changed |= ActivityInfo.CONFIG_ORIENTATION;
orientation = delta.orientation; orientation = delta.orientation;
} }
if (delta.rotation != ROTATION_UNDEFINED
&& rotation != delta.rotation) {
changed |= ActivityInfo.CONFIG_ORIENTATION;
rotation = delta.rotation;
}
if (((delta.screenLayout & SCREENLAYOUT_SIZE_MASK) != SCREENLAYOUT_SIZE_UNDEFINED) if (((delta.screenLayout & SCREENLAYOUT_SIZE_MASK) != SCREENLAYOUT_SIZE_UNDEFINED)
&& (delta.screenLayout & SCREENLAYOUT_SIZE_MASK) && (delta.screenLayout & SCREENLAYOUT_SIZE_MASK)
@@ -1404,10 +1379,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
&& orientation != delta.orientation) { && orientation != delta.orientation) {
changed |= ActivityInfo.CONFIG_ORIENTATION; changed |= ActivityInfo.CONFIG_ORIENTATION;
} }
if ((compareUndefined || delta.rotation != ROTATION_UNDEFINED)
&& rotation != delta.rotation) {
changed |= ActivityInfo.CONFIG_ORIENTATION;
}
if ((compareUndefined || getScreenLayoutNoDirection(delta.screenLayout) != if ((compareUndefined || getScreenLayoutNoDirection(delta.screenLayout) !=
(SCREENLAYOUT_SIZE_UNDEFINED | SCREENLAYOUT_LONG_UNDEFINED)) (SCREENLAYOUT_SIZE_UNDEFINED | SCREENLAYOUT_LONG_UNDEFINED))
&& getScreenLayoutNoDirection(screenLayout) != && getScreenLayoutNoDirection(screenLayout) !=
@@ -1544,7 +1515,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
dest.writeInt(navigation); dest.writeInt(navigation);
dest.writeInt(navigationHidden); dest.writeInt(navigationHidden);
dest.writeInt(orientation); dest.writeInt(orientation);
dest.writeInt(rotation);
dest.writeInt(screenLayout); dest.writeInt(screenLayout);
dest.writeInt(colorMode); dest.writeInt(colorMode);
dest.writeInt(uiMode); dest.writeInt(uiMode);
@@ -1581,7 +1551,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
navigation = source.readInt(); navigation = source.readInt();
navigationHidden = source.readInt(); navigationHidden = source.readInt();
orientation = source.readInt(); orientation = source.readInt();
rotation = source.readInt();
screenLayout = source.readInt(); screenLayout = source.readInt();
colorMode = source.readInt(); colorMode = source.readInt();
uiMode = source.readInt(); uiMode = source.readInt();
@@ -1666,8 +1635,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
if (n != 0) return n; if (n != 0) return n;
n = this.orientation - that.orientation; n = this.orientation - that.orientation;
if (n != 0) return n; if (n != 0) return n;
n = this.rotation - that.rotation;
if (n != 0) return n;
n = this.colorMode - that.colorMode; n = this.colorMode - that.colorMode;
if (n != 0) return n; if (n != 0) return n;
n = this.screenLayout - that.screenLayout; n = this.screenLayout - that.screenLayout;
@@ -1796,24 +1763,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
appBounds.set(left, top, right, bottom); appBounds.set(left, top, right, bottom);
} }
/**
* @hide
*
* Setter for orientation converts from {@link Surface} values to internal representation.
*/
public void setRotation(int rotation) {
this.rotation = rotation;
}
/**
* @hide
*
* Getter for orientation. Converts from internal representation to {@link Surface} values.
*/
public int getRotation() {
return rotation != ROTATION_UNDEFINED ? rotation : ROTATION_0;
}
/** /**
* @hide * @hide
* *
@@ -2051,23 +2000,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
break; break;
} }
switch (config.rotation) {
case ROTATION_0:
parts.add("rot0");
break;
case ROTATION_90:
parts.add("rot90");
break;
case ROTATION_180:
parts.add("rot180");
break;
case ROTATION_270:
parts.add("rot270");
break;
default:
break;
}
switch (config.uiMode & Configuration.UI_MODE_TYPE_MASK) { switch (config.uiMode & Configuration.UI_MODE_TYPE_MASK) {
case Configuration.UI_MODE_TYPE_APPLIANCE: case Configuration.UI_MODE_TYPE_APPLIANCE:
parts.add("appliance"); parts.add("appliance");
@@ -2262,10 +2194,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
delta.orientation = change.orientation; delta.orientation = change.orientation;
} }
if (base.rotation != change.rotation) {
base.rotation = change.rotation;
}
if ((base.screenLayout & SCREENLAYOUT_SIZE_MASK) != if ((base.screenLayout & SCREENLAYOUT_SIZE_MASK) !=
(change.screenLayout & SCREENLAYOUT_SIZE_MASK)) { (change.screenLayout & SCREENLAYOUT_SIZE_MASK)) {
delta.screenLayout |= change.screenLayout & SCREENLAYOUT_SIZE_MASK; delta.screenLayout |= change.screenLayout & SCREENLAYOUT_SIZE_MASK;
@@ -2337,7 +2265,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
private static final String XML_ATTR_NAVIGATION = "nav"; private static final String XML_ATTR_NAVIGATION = "nav";
private static final String XML_ATTR_NAVIGATION_HIDDEN = "navHid"; private static final String XML_ATTR_NAVIGATION_HIDDEN = "navHid";
private static final String XML_ATTR_ORIENTATION = "ori"; private static final String XML_ATTR_ORIENTATION = "ori";
private static final String XML_ATTR_ROTATION = "rot";
private static final String XML_ATTR_SCREEN_LAYOUT = "scrLay"; private static final String XML_ATTR_SCREEN_LAYOUT = "scrLay";
private static final String XML_ATTR_COLOR_MODE = "clrMod"; private static final String XML_ATTR_COLOR_MODE = "clrMod";
private static final String XML_ATTR_UI_MODE = "ui"; private static final String XML_ATTR_UI_MODE = "ui";
@@ -2397,8 +2324,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
DENSITY_DPI_UNDEFINED); DENSITY_DPI_UNDEFINED);
configOut.appBounds = configOut.appBounds =
Rect.unflattenFromString(XmlUtils.readStringAttribute(parser, XML_ATTR_APP_BOUNDS)); Rect.unflattenFromString(XmlUtils.readStringAttribute(parser, XML_ATTR_APP_BOUNDS));
configOut.rotation = XmlUtils.readIntAttribute(parser, XML_ATTR_ROTATION,
ROTATION_UNDEFINED);
// For persistence, we don't care about assetsSeq, so do not read it out. // For persistence, we don't care about assetsSeq, so do not read it out.
} }
@@ -2475,10 +2400,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
config.appBounds.flattenToString()); config.appBounds.flattenToString());
} }
if (config.rotation != ROTATION_UNDEFINED) {
XmlUtils.writeIntAttribute(xml, XML_ATTR_ROTATION, config.rotation);
}
// For persistence, we do not care about assetsSeq, so do not write it out. // For persistence, we do not care about assetsSeq, so do not write it out.
} }
} }

View File

@@ -96,7 +96,7 @@ interface IWindowSession {
int flags, out Rect outFrame, out Rect outOverscanInsets, int flags, out Rect outFrame, out Rect outOverscanInsets,
out Rect outContentInsets, out Rect outVisibleInsets, out Rect outStableInsets, out Rect outContentInsets, out Rect outVisibleInsets, out Rect outStableInsets,
out Rect outOutsets, out Rect outBackdropFrame, out Rect outOutsets, out Rect outBackdropFrame,
inout MergedConfiguration mergedConfiguration, out Surface outSurface); out MergedConfiguration outMergedConfiguration, out Surface outSurface);
/* /*
* Notify the window manager that an application is relaunching and * Notify the window manager that an application is relaunching and

View File

@@ -129,16 +129,10 @@ public class Surface implements Parcelable {
public static final int SCALING_MODE_NO_SCALE_CROP = 3; public static final int SCALING_MODE_NO_SCALE_CROP = 3;
/** @hide */ /** @hide */
@IntDef({ROTATION_UNDEFINED, ROTATION_0, ROTATION_90, ROTATION_180, ROTATION_270}) @IntDef({ROTATION_0, ROTATION_90, ROTATION_180, ROTATION_270})
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
public @interface Rotation {} public @interface Rotation {}
/**
* Rotation constant: undefined
* @hide
*/
public static final int ROTATION_UNDEFINED = -1;
/** /**
* Rotation constant: 0 degree rotation (natural orientation) * Rotation constant: 0 degree rotation (natural orientation)
*/ */

View File

@@ -1845,12 +1845,8 @@ public final class ViewRootImpl implements ViewParent,
final boolean isViewVisible = viewVisibility == View.VISIBLE; final boolean isViewVisible = viewVisibility == View.VISIBLE;
final boolean windowRelayoutWasForced = mForceNextWindowRelayout; final boolean windowRelayoutWasForced = mForceNextWindowRelayout;
final int contextConfigSeq = mContext.getResources().getConfiguration().seq; if (mFirst || windowShouldResize || insetsChanged ||
final int lastConfigSeq = mLastReportedMergedConfiguration.getMergedConfiguration().seq; viewVisibilityChanged || params != null || mForceNextWindowRelayout) {
final boolean staleConfig = lastConfigSeq != 0 && contextConfigSeq != lastConfigSeq;
if (mFirst || windowShouldResize || insetsChanged || staleConfig || viewVisibilityChanged
|| params != null || mForceNextWindowRelayout) {
mForceNextWindowRelayout = false; mForceNextWindowRelayout = false;
if (isViewVisible) { if (isViewVisible) {
@@ -6087,13 +6083,7 @@ public final class ViewRootImpl implements ViewParent,
if (params != null) { if (params != null) {
if (DBG) Log.d(mTag, "WindowLayout in layoutWindow:" + params); if (DBG) Log.d(mTag, "WindowLayout in layoutWindow:" + params);
} }
mPendingMergedConfiguration.getMergedConfiguration().seq = 0;
if (mPendingMergedConfiguration.getMergedConfiguration().seq == 0) {
mPendingMergedConfiguration.setTo(mLastReportedMergedConfiguration);
}
int initialConfigSeq = mPendingMergedConfiguration.getMergedConfiguration().seq;
//Log.d(mTag, ">>>>>> CALLING relayout"); //Log.d(mTag, ">>>>>> CALLING relayout");
if (params != null && mOrigWindowType != params.type) { if (params != null && mOrigWindowType != params.type) {
// For compatibility with old apps, don't crash here. // For compatibility with old apps, don't crash here.
@@ -6112,10 +6102,6 @@ public final class ViewRootImpl implements ViewParent,
mPendingStableInsets, mPendingOutsets, mPendingBackDropFrame, mPendingStableInsets, mPendingOutsets, mPendingBackDropFrame,
mPendingMergedConfiguration, mSurface); mPendingMergedConfiguration, mSurface);
if (initialConfigSeq == mPendingMergedConfiguration.getMergedConfiguration().seq) {
mPendingMergedConfiguration.getMergedConfiguration().seq = 0;
}
mPendingAlwaysConsumeNavBar = mPendingAlwaysConsumeNavBar =
(relayoutResult & WindowManagerGlobal.RELAYOUT_RES_CONSUME_ALWAYS_NAV_BAR) != 0; (relayoutResult & WindowManagerGlobal.RELAYOUT_RES_CONSUME_ALWAYS_NAV_BAR) != 0;

View File

@@ -1162,8 +1162,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
final int dh = displayInfo.logicalHeight; final int dh = displayInfo.logicalHeight;
config.orientation = (dw <= dh) ? Configuration.ORIENTATION_PORTRAIT : config.orientation = (dw <= dh) ? Configuration.ORIENTATION_PORTRAIT :
Configuration.ORIENTATION_LANDSCAPE; Configuration.ORIENTATION_LANDSCAPE;
config.setRotation(displayInfo.rotation);
config.screenWidthDp = config.screenWidthDp =
(int)(mService.mPolicy.getConfigDisplayWidth(dw, dh, displayInfo.rotation, (int)(mService.mPolicy.getConfigDisplayWidth(dw, dh, displayInfo.rotation,
config.uiMode, mDisplayId) / mDisplayMetrics.density); config.uiMode, mDisplayId) / mDisplayMetrics.density);

View File

@@ -2231,15 +2231,16 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
mWinAnimator.applyEnterAnimationLocked(); mWinAnimator.applyEnterAnimationLocked();
} }
// always report back the new configuration if (isConfigChanged()) {
final Configuration globalConfig = mService.mRoot.getConfiguration(); final Configuration globalConfig = mService.mRoot.getConfiguration();
final Configuration overrideConfig = getMergedOverrideConfiguration(); final Configuration overrideConfig = getMergedOverrideConfiguration();
mergedConfiguration.setConfiguration(globalConfig, overrideConfig); mergedConfiguration.setConfiguration(globalConfig, overrideConfig);
if (DEBUG_CONFIGURATION) Slog.i(TAG, "Window " + this if (DEBUG_CONFIGURATION) Slog.i(TAG, "Window " + this
+ " reporting new global config: " + globalConfig + " visible with new global config: " + globalConfig
+ " merged override config: " + overrideConfig); + " merged override config: " + overrideConfig);
mLastReportedConfiguration.setTo(getConfiguration()); mLastReportedConfiguration.setTo(getConfiguration());
} }
}
void adjustStartingWindowFlags() { void adjustStartingWindowFlags() {
if (mAttrs.type == TYPE_BASE_APPLICATION && mAppToken != null if (mAttrs.type == TYPE_BASE_APPLICATION && mAppToken != null