|
|
|
|
@@ -42,6 +42,9 @@ import java.lang.annotation.RetentionPolicy;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
|
|
import static android.view.Surface.ROTATION_0;
|
|
|
|
|
import static android.view.Surface.ROTATION_UNDEFINED;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This class describes all device configuration information that can
|
|
|
|
|
* impact the resources the application retrieves. This includes both
|
|
|
|
|
@@ -597,6 +600,13 @@ public final class Configuration implements Parcelable, Comparable<Configuration
|
|
|
|
|
*/
|
|
|
|
|
public int orientation;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The mRotation used at the time orientation was determined.
|
|
|
|
|
* TODO(b/36812336): Move mRotation out of {@link Configuration}.
|
|
|
|
|
* {@hide}
|
|
|
|
|
*/
|
|
|
|
|
private int mRotation;
|
|
|
|
|
|
|
|
|
|
/** Constant for {@link #uiMode}: bits that encode the mode type. */
|
|
|
|
|
public static final int UI_MODE_TYPE_MASK = 0x0f;
|
|
|
|
|
/** Constant for {@link #uiMode}: a {@link #UI_MODE_TYPE_MASK}
|
|
|
|
|
@@ -884,6 +894,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
|
|
|
|
|
navigation = o.navigation;
|
|
|
|
|
navigationHidden = o.navigationHidden;
|
|
|
|
|
orientation = o.orientation;
|
|
|
|
|
mRotation = o.mRotation;
|
|
|
|
|
screenLayout = o.screenLayout;
|
|
|
|
|
colorMode = o.colorMode;
|
|
|
|
|
uiMode = o.uiMode;
|
|
|
|
|
@@ -1074,6 +1085,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
|
|
|
|
|
navigation = NAVIGATION_UNDEFINED;
|
|
|
|
|
navigationHidden = NAVIGATIONHIDDEN_UNDEFINED;
|
|
|
|
|
orientation = ORIENTATION_UNDEFINED;
|
|
|
|
|
mRotation = ROTATION_UNDEFINED;
|
|
|
|
|
screenLayout = SCREENLAYOUT_UNDEFINED;
|
|
|
|
|
colorMode = COLOR_MODE_UNDEFINED;
|
|
|
|
|
uiMode = UI_MODE_TYPE_UNDEFINED;
|
|
|
|
|
@@ -1182,6 +1194,11 @@ public final class Configuration implements Parcelable, Comparable<Configuration
|
|
|
|
|
changed |= ActivityInfo.CONFIG_ORIENTATION;
|
|
|
|
|
orientation = delta.orientation;
|
|
|
|
|
}
|
|
|
|
|
if (delta.mRotation != ROTATION_UNDEFINED
|
|
|
|
|
&& mRotation != delta.mRotation) {
|
|
|
|
|
changed |= ActivityInfo.CONFIG_ORIENTATION;
|
|
|
|
|
mRotation = delta.mRotation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (((delta.screenLayout & SCREENLAYOUT_SIZE_MASK) != SCREENLAYOUT_SIZE_UNDEFINED)
|
|
|
|
|
&& (delta.screenLayout & SCREENLAYOUT_SIZE_MASK)
|
|
|
|
|
@@ -1376,6 +1393,10 @@ public final class Configuration implements Parcelable, Comparable<Configuration
|
|
|
|
|
&& orientation != delta.orientation) {
|
|
|
|
|
changed |= ActivityInfo.CONFIG_ORIENTATION;
|
|
|
|
|
}
|
|
|
|
|
if ((compareUndefined || delta.mRotation != ROTATION_UNDEFINED)
|
|
|
|
|
&& mRotation != delta.mRotation) {
|
|
|
|
|
changed |= ActivityInfo.CONFIG_ORIENTATION;
|
|
|
|
|
}
|
|
|
|
|
if ((compareUndefined || getScreenLayoutNoDirection(delta.screenLayout) !=
|
|
|
|
|
(SCREENLAYOUT_SIZE_UNDEFINED | SCREENLAYOUT_LONG_UNDEFINED))
|
|
|
|
|
&& getScreenLayoutNoDirection(screenLayout) !=
|
|
|
|
|
@@ -1512,6 +1533,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
|
|
|
|
|
dest.writeInt(navigation);
|
|
|
|
|
dest.writeInt(navigationHidden);
|
|
|
|
|
dest.writeInt(orientation);
|
|
|
|
|
dest.writeInt(mRotation);
|
|
|
|
|
dest.writeInt(screenLayout);
|
|
|
|
|
dest.writeInt(colorMode);
|
|
|
|
|
dest.writeInt(uiMode);
|
|
|
|
|
@@ -1548,6 +1570,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
|
|
|
|
|
navigation = source.readInt();
|
|
|
|
|
navigationHidden = source.readInt();
|
|
|
|
|
orientation = source.readInt();
|
|
|
|
|
mRotation = source.readInt();
|
|
|
|
|
screenLayout = source.readInt();
|
|
|
|
|
colorMode = source.readInt();
|
|
|
|
|
uiMode = source.readInt();
|
|
|
|
|
@@ -1632,6 +1655,8 @@ public final class Configuration implements Parcelable, Comparable<Configuration
|
|
|
|
|
if (n != 0) return n;
|
|
|
|
|
n = this.orientation - that.orientation;
|
|
|
|
|
if (n != 0) return n;
|
|
|
|
|
n = this.mRotation - that.mRotation;
|
|
|
|
|
if (n != 0) return n;
|
|
|
|
|
n = this.colorMode - that.colorMode;
|
|
|
|
|
if (n != 0) return n;
|
|
|
|
|
n = this.screenLayout - that.screenLayout;
|
|
|
|
|
@@ -1760,6 +1785,24 @@ public final class Configuration implements Parcelable, Comparable<Configuration
|
|
|
|
|
appBounds.set(left, top, right, bottom);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @hide
|
|
|
|
|
*
|
|
|
|
|
* Setter for orientation converts from {@link Surface} values to internal representation.
|
|
|
|
|
*/
|
|
|
|
|
public void setRotation(int rotation) {
|
|
|
|
|
this.mRotation = rotation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @hide
|
|
|
|
|
*
|
|
|
|
|
* Getter for orientation. Converts from internal representation to {@link Surface} values.
|
|
|
|
|
*/
|
|
|
|
|
public int getRotation() {
|
|
|
|
|
return mRotation != ROTATION_UNDEFINED ? mRotation : ROTATION_0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @hide
|
|
|
|
|
*
|
|
|
|
|
@@ -2193,6 +2236,10 @@ public final class Configuration implements Parcelable, Comparable<Configuration
|
|
|
|
|
delta.orientation = change.orientation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (base.mRotation != change.mRotation) {
|
|
|
|
|
base.mRotation = change.mRotation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((base.screenLayout & SCREENLAYOUT_SIZE_MASK) !=
|
|
|
|
|
(change.screenLayout & SCREENLAYOUT_SIZE_MASK)) {
|
|
|
|
|
delta.screenLayout |= change.screenLayout & SCREENLAYOUT_SIZE_MASK;
|
|
|
|
|
@@ -2264,6 +2311,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
|
|
|
|
|
private static final String XML_ATTR_NAVIGATION = "nav";
|
|
|
|
|
private static final String XML_ATTR_NAVIGATION_HIDDEN = "navHid";
|
|
|
|
|
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_COLOR_MODE = "clrMod";
|
|
|
|
|
private static final String XML_ATTR_UI_MODE = "ui";
|
|
|
|
|
@@ -2323,6 +2371,8 @@ public final class Configuration implements Parcelable, Comparable<Configuration
|
|
|
|
|
DENSITY_DPI_UNDEFINED);
|
|
|
|
|
configOut.appBounds =
|
|
|
|
|
Rect.unflattenFromString(XmlUtils.readStringAttribute(parser, XML_ATTR_APP_BOUNDS));
|
|
|
|
|
configOut.mRotation = XmlUtils.readIntAttribute(parser, XML_ATTR_ROTATION,
|
|
|
|
|
ROTATION_UNDEFINED);
|
|
|
|
|
|
|
|
|
|
// For persistence, we don't care about assetsSeq, so do not read it out.
|
|
|
|
|
}
|
|
|
|
|
@@ -2399,6 +2449,10 @@ public final class Configuration implements Parcelable, Comparable<Configuration
|
|
|
|
|
config.appBounds.flattenToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (config.mRotation != ROTATION_UNDEFINED) {
|
|
|
|
|
XmlUtils.writeIntAttribute(xml, XML_ATTR_ROTATION, config.mRotation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// For persistence, we do not care about assetsSeq, so do not write it out.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|