am 69cb8757: Add new "-swNNNdp" resource qualifier.

* commit '69cb87576ba163b61bb0e6477a3b7c57a9b11d40':
  Add new "-swNNNdp" resource qualifier.
This commit is contained in:
Dianne Hackborn
2011-05-19 19:30:32 -07:00
committed by Android Git Automerger
21 changed files with 498 additions and 180 deletions

View File

@ -57911,6 +57911,17 @@
visibility="public"
>
</field>
<field name="CONFIG_SMALLEST_SCREEN_SIZE"
type="int"
transient="false"
volatile="false"
value="2048"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="CONFIG_TOUCHSCREEN"
type="int"
transient="false"
@ -63995,6 +64006,17 @@
visibility="public"
>
</field>
<field name="SMALLEST_SCREEN_WIDTH_DP_UNDEFINED"
type="int"
transient="false"
volatile="false"
value="0"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="TOUCHSCREEN_FINGER"
type="int"
transient="false"
@ -64268,6 +64290,16 @@
visibility="public"
>
</field>
<field name="smallestScreenWidthDp"
type="int"
transient="false"
volatile="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="touchscreen"
type="int"
transient="false"

View File

@ -338,6 +338,12 @@ public class ActivityInfo extends ComponentInfo
* {@link android.R.attr#configChanges} attribute.
*/
public static final int CONFIG_SCREEN_SIZE = 0x0400;
/**
* Bit in {@link #configChanges} that indicates that the activity
* can itself handle the smallest screen size. Set from the
* {@link android.R.attr#configChanges} attribute.
*/
public static final int CONFIG_SMALLEST_SCREEN_SIZE = 0x0800;
/**
* Bit in {@link #configChanges} that indicates that the activity
* can itself handle changes to the font scaling factor. Set from the
@ -364,6 +370,7 @@ public class ActivityInfo extends ComponentInfo
0x0800, // SCREEN LAYOUT
0x1000, // UI MODE
0x0200, // SCREEN SIZE
0x2000, // SMALLEST SCREEN SIZE
};
/** @hide
* Convert Java change bits to native.

View File

@ -396,7 +396,7 @@ public class PackageParser {
int cookie = assmgr.addAssetPath(mArchiveSourcePath);
if (cookie != 0) {
res = new Resources(assmgr, metrics, null);
assmgr.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
assmgr.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Build.VERSION.RESOURCES_SDK_INT);
parser = assmgr.openXmlResourceParser(cookie, "AndroidManifest.xml");
assetError = false;
@ -596,7 +596,7 @@ public class PackageParser {
AssetManager assmgr = null;
try {
assmgr = new AssetManager();
assmgr.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
assmgr.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Build.VERSION.RESOURCES_SDK_INT);
int cookie = assmgr.addAssetPath(packageFilePath);
parser = assmgr.openXmlResourceParser(cookie, "AndroidManifest.xml");
@ -1933,7 +1933,8 @@ public class PackageParser {
0);
if (owner.applicationInfo.targetSdkVersion
< android.os.Build.VERSION_CODES.HONEYCOMB_MR2) {
a.info.configChanges |= ActivityInfo.CONFIG_SCREEN_SIZE;
a.info.configChanges |= ActivityInfo.CONFIG_SCREEN_SIZE
| ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
}
a.info.softInputMode = sa.getInt(
com.android.internal.R.styleable.AndroidManifestActivity_windowSoftInputMode,

View File

@ -652,8 +652,8 @@ public final class AssetManager {
public native final void setConfiguration(int mcc, int mnc, String locale,
int orientation, int touchscreen, int density, int keyboard,
int keyboardHidden, int navigation, int screenWidth, int screenHeight,
int screenWidthDp, int screenHeightDp, int screenLayout, int uiMode,
int majorVersion);
int smallestScreenWidthDp, int screenWidthDp, int screenHeightDp,
int screenLayout, int uiMode, int majorVersion);
/**
* Retrieve the resource identifier for the given resource name.

View File

@ -259,6 +259,15 @@ public final class Configuration implements Parcelable, Comparable<Configuration
*/
public int screenHeightDp;
public static final int SMALLEST_SCREEN_WIDTH_DP_UNDEFINED = 0;
/**
* The smallest screen size an application will see in normal operation.
* This is the smallest value of both screenWidthDp and screenHeightDp
* in both portrait and landscape.
*/
public int smallestScreenWidthDp;
/**
* @hide Internal book-keeping.
*/
@ -298,6 +307,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
uiMode = o.uiMode;
screenWidthDp = o.screenWidthDp;
screenHeightDp = o.screenHeightDp;
smallestScreenWidthDp = o.smallestScreenWidthDp;
seq = o.seq;
}
@ -315,6 +325,56 @@ public final class Configuration implements Parcelable, Comparable<Configuration
} else {
sb.append(" (no locale)");
}
if (smallestScreenWidthDp != SMALLEST_SCREEN_WIDTH_DP_UNDEFINED) {
sb.append(" sw"); sb.append(smallestScreenWidthDp); sb.append("dp");
} else {
sb.append("?swdp");
}
if (screenWidthDp != SCREEN_WIDTH_DP_UNDEFINED) {
sb.append(" w"); sb.append(screenWidthDp); sb.append("dp");
} else {
sb.append("?wdp");
}
if (screenHeightDp != SCREEN_HEIGHT_DP_UNDEFINED) {
sb.append(" h"); sb.append(screenHeightDp); sb.append("dp");
} else {
sb.append("?hdp");
}
switch ((screenLayout&SCREENLAYOUT_SIZE_MASK)) {
case SCREENLAYOUT_SIZE_UNDEFINED: sb.append(" ?lsize"); break;
case SCREENLAYOUT_SIZE_SMALL: sb.append(" smll"); break;
case SCREENLAYOUT_SIZE_NORMAL: sb.append(" nrml"); break;
case SCREENLAYOUT_SIZE_LARGE: sb.append(" lrg"); break;
case SCREENLAYOUT_SIZE_XLARGE: sb.append(" xlrg"); break;
default: sb.append(" layoutSize=");
sb.append(screenLayout&SCREENLAYOUT_SIZE_MASK); break;
}
switch ((screenLayout&SCREENLAYOUT_LONG_MASK)) {
case SCREENLAYOUT_LONG_UNDEFINED: sb.append(" ?long"); break;
case SCREENLAYOUT_LONG_NO: /* not-long is not interesting to print */ break;
case SCREENLAYOUT_LONG_YES: sb.append(" long"); break;
default: sb.append(" layoutLong=");
sb.append(screenLayout&SCREENLAYOUT_LONG_MASK); break;
}
switch (orientation) {
case ORIENTATION_UNDEFINED: sb.append(" ?orien"); break;
case ORIENTATION_LANDSCAPE: sb.append(" land"); break;
case ORIENTATION_PORTRAIT: sb.append(" port"); break;
default: sb.append(" orien="); sb.append(orientation); break;
}
switch ((uiMode&UI_MODE_TYPE_MASK)) {
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_DESK: sb.append(" desk"); break;
case UI_MODE_TYPE_CAR: sb.append(" car"); break;
default: sb.append(" uimode="); sb.append(uiMode&UI_MODE_TYPE_MASK); break;
}
switch ((uiMode&UI_MODE_NIGHT_MASK)) {
case UI_MODE_NIGHT_UNDEFINED: sb.append(" ?night"); break;
case UI_MODE_NIGHT_NO: /* not-night is not interesting to print */ break;
case UI_MODE_NIGHT_YES: sb.append(" night"); break;
default: sb.append(" night="); sb.append(uiMode&UI_MODE_NIGHT_MASK); break;
}
switch (touchscreen) {
case TOUCHSCREEN_UNDEFINED: sb.append(" ?touch"); break;
case TOUCHSCREEN_NOTOUCH: sb.append(" -touch"); break;
@ -356,51 +416,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
case NAVIGATIONHIDDEN_YES: sb.append("/h"); break;
default: sb.append("/"); sb.append(navigationHidden); break;
}
switch (orientation) {
case ORIENTATION_UNDEFINED: sb.append(" ?orien"); break;
case ORIENTATION_LANDSCAPE: sb.append(" land"); break;
case ORIENTATION_PORTRAIT: sb.append(" port"); break;
default: sb.append(" orien="); sb.append(orientation); break;
}
switch ((screenLayout&SCREENLAYOUT_SIZE_MASK)) {
case SCREENLAYOUT_SIZE_UNDEFINED: sb.append(" ?lsize"); break;
case SCREENLAYOUT_SIZE_SMALL: sb.append(" smll"); break;
case SCREENLAYOUT_SIZE_NORMAL: sb.append(" nrml"); break;
case SCREENLAYOUT_SIZE_LARGE: sb.append(" lrg"); break;
case SCREENLAYOUT_SIZE_XLARGE: sb.append(" xlrg"); break;
default: sb.append(" layoutSize=");
sb.append(screenLayout&SCREENLAYOUT_SIZE_MASK); break;
}
switch ((screenLayout&SCREENLAYOUT_LONG_MASK)) {
case SCREENLAYOUT_LONG_UNDEFINED: sb.append(" ?long"); break;
case SCREENLAYOUT_LONG_NO: /* not-long is not interesting to print */ break;
case SCREENLAYOUT_LONG_YES: sb.append(" long"); break;
default: sb.append(" layoutLong=");
sb.append(screenLayout&SCREENLAYOUT_LONG_MASK); break;
}
switch ((uiMode&UI_MODE_TYPE_MASK)) {
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_DESK: sb.append(" desk"); break;
case UI_MODE_TYPE_CAR: sb.append(" car"); break;
default: sb.append(" uimode="); sb.append(uiMode&UI_MODE_TYPE_MASK); break;
}
switch ((uiMode&UI_MODE_NIGHT_MASK)) {
case UI_MODE_NIGHT_UNDEFINED: sb.append(" ?night"); break;
case UI_MODE_NIGHT_NO: /* not-night is not interesting to print */ break;
case UI_MODE_NIGHT_YES: sb.append(" night"); break;
default: sb.append(" night="); sb.append(uiMode&UI_MODE_NIGHT_MASK); break;
}
if (screenWidthDp != SCREEN_WIDTH_DP_UNDEFINED) {
sb.append(" w"); sb.append(screenWidthDp); sb.append("dp");
} else {
sb.append("?wdp");
}
if (screenHeightDp != SCREEN_HEIGHT_DP_UNDEFINED) {
sb.append(" h"); sb.append(screenHeightDp); sb.append("dp");
} else {
sb.append("?hdp");
}
if (seq != 0) {
sb.append(" s.");
sb.append(seq);
@ -428,6 +443,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
uiMode = UI_MODE_TYPE_UNDEFINED;
screenWidthDp = SCREEN_WIDTH_DP_UNDEFINED;
screenHeightDp = SCREEN_HEIGHT_DP_UNDEFINED;
smallestScreenWidthDp = SMALLEST_SCREEN_WIDTH_DP_UNDEFINED;
seq = 0;
}
@ -531,6 +547,11 @@ public final class Configuration implements Parcelable, Comparable<Configuration
changed |= ActivityInfo.CONFIG_SCREEN_SIZE;
screenHeightDp = delta.screenHeightDp;
}
if (delta.smallestScreenWidthDp != SMALLEST_SCREEN_WIDTH_DP_UNDEFINED
&& smallestScreenWidthDp != delta.smallestScreenWidthDp) {
changed |= ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
smallestScreenWidthDp = delta.smallestScreenWidthDp;
}
if (delta.seq != 0) {
seq = delta.seq;
@ -564,7 +585,9 @@ public final class Configuration implements Parcelable, Comparable<Configuration
* {@link android.content.pm.ActivityInfo#CONFIG_SCREEN_LAYOUT
* PackageManager.ActivityInfo.CONFIG_SCREEN_LAYOUT}, or
* {@link android.content.pm.ActivityInfo#CONFIG_SCREEN_SIZE
* PackageManager.ActivityInfo.CONFIG_SCREEN_SIZE}.
* PackageManager.ActivityInfo.CONFIG_SCREEN_SIZE}, or
* {@link android.content.pm.ActivityInfo#CONFIG_SMALLEST_SCREEN_SIZE
* PackageManager.ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE}.
*/
public int diff(Configuration delta) {
int changed = 0;
@ -625,6 +648,10 @@ public final class Configuration implements Parcelable, Comparable<Configuration
&& screenHeightDp != delta.screenHeightDp) {
changed |= ActivityInfo.CONFIG_SCREEN_SIZE;
}
if (delta.smallestScreenWidthDp != SMALLEST_SCREEN_WIDTH_DP_UNDEFINED
&& smallestScreenWidthDp != delta.smallestScreenWidthDp) {
changed |= ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
}
return changed;
}
@ -708,6 +735,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
dest.writeInt(uiMode);
dest.writeInt(screenWidthDp);
dest.writeInt(screenHeightDp);
dest.writeInt(smallestScreenWidthDp);
dest.writeInt(seq);
}
@ -731,6 +759,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
uiMode = source.readInt();
screenWidthDp = source.readInt();
screenHeightDp = source.readInt();
smallestScreenWidthDp = source.readInt();
seq = source.readInt();
}
@ -795,6 +824,8 @@ public final class Configuration implements Parcelable, Comparable<Configuration
n = this.screenWidthDp - that.screenWidthDp;
if (n != 0) return n;
n = this.screenHeightDp - that.screenHeightDp;
if (n != 0) return n;
n = this.smallestScreenWidthDp - that.smallestScreenWidthDp;
//if (n != 0) return n;
return n;
}
@ -830,6 +861,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
result = 31 * result + uiMode;
result = 31 * result + screenWidthDp;
result = 31 * result + screenHeightDp;
result = 31 * result + smallestScreenWidthDp;
return result;
}
}

View File

@ -1458,6 +1458,7 @@ public class Resources {
mConfiguration.touchscreen,
(int)(mMetrics.density*160), mConfiguration.keyboard,
keyboardHidden, mConfiguration.navigation, width, height,
mConfiguration.smallestScreenWidthDp,
mConfiguration.screenWidthDp, mConfiguration.screenHeightDp,
mConfiguration.screenLayout, mConfiguration.uiMode,
Build.VERSION.RESOURCES_SDK_INT);

View File

@ -464,16 +464,34 @@ public interface WindowManagerPolicy {
public int getMaxWallpaperLayer();
/**
* Return the display width available after excluding the window
* decor.
* Return the display width available after excluding any screen
* decorations that can never be removed. That is, system bar or
* button bar.
*/
public int getNonDecorDisplayWidth(int fullWidth);
public int getNonDecorDisplayWidth(int rotation, int fullWidth);
/**
* Return the display height available after excluding the screen
* decor.
* 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 fullHeight);
public int getNonDecorDisplayHeight(int rotation, int fullHeight);
/**
* Return the available screen width that we should report for the
* configuration. This must be no larger than
* {@link #getNonDecorDisplayWidth(int, int)}; it may be smaller than
* that to account for more transient decoration like a status bar.
*/
public int getConfigDisplayWidth(int rotation, int fullWidth);
/**
* Return the available screen height that we should report for the
* configuration. This must be no larger than
* {@link #getNonDecorDisplayHeight(int, int)}; it may be smaller than
* that to account for more transient decoration like a status bar.
*/
public int getConfigDisplayHeight(int rotation, int fullHeight);
/**
* Return whether the given window should forcibly hide everything

View File

@ -40,6 +40,9 @@ static struct {
jfieldID navigationHidden;
jfieldID orientation;
jfieldID uiMode;
jfieldID screenWidthDp;
jfieldID screenHeightDp;
jfieldID smallestScreenWidthDp;
} gConfigurationClassInfo;
void android_Configuration_getFromJava(
@ -62,6 +65,11 @@ void android_Configuration_getFromJava(
out->orientation = env->GetIntField(clazz, gConfigurationClassInfo.orientation);
out->uiMode = env->GetIntField(clazz, gConfigurationClassInfo.uiMode);
out->screenWidthDp = env->GetIntField(clazz, gConfigurationClassInfo.screenWidthDp);
out->screenHeightDp = env->GetIntField(clazz, gConfigurationClassInfo.screenHeightDp);
out->smallestScreenWidthDp = env->GetIntField(clazz,
gConfigurationClassInfo.smallestScreenWidthDp);
}
/*
@ -110,6 +118,12 @@ int register_android_content_res_Configuration(JNIEnv* env)
"orientation", "I");
GET_FIELD_ID(gConfigurationClassInfo.uiMode, gConfigurationClassInfo.clazz,
"uiMode", "I");
GET_FIELD_ID(gConfigurationClassInfo.screenWidthDp, gConfigurationClassInfo.clazz,
"screenWidthDp", "I");
GET_FIELD_ID(gConfigurationClassInfo.screenHeightDp, gConfigurationClassInfo.clazz,
"screenHeightDp", "I");
GET_FIELD_ID(gConfigurationClassInfo.smallestScreenWidthDp, gConfigurationClassInfo.clazz,
"smallestScreenWidthDp", "I");
return AndroidRuntime::registerNativeMethods(env, "android/content/res/Configuration", gMethods,
NELEM(gMethods));

View File

@ -532,6 +532,7 @@ static void android_content_AssetManager_setConfiguration(JNIEnv* env, jobject c
jint keyboard, jint keyboardHidden,
jint navigation,
jint screenWidth, jint screenHeight,
jint smallestScreenWidthDp,
jint screenWidthDp, jint screenHeightDp,
jint screenLayout, jint uiMode,
jint sdkVersion)
@ -556,6 +557,7 @@ static void android_content_AssetManager_setConfiguration(JNIEnv* env, jobject c
config.navigation = (uint8_t)navigation;
config.screenWidth = (uint16_t)screenWidth;
config.screenHeight = (uint16_t)screenHeight;
config.smallestScreenWidthDp = (uint16_t)smallestScreenWidthDp;
config.screenWidthDp = (uint16_t)screenWidthDp;
config.screenHeightDp = (uint16_t)screenHeightDp;
config.screenLayout = (uint8_t)screenLayout;
@ -1696,7 +1698,7 @@ static JNINativeMethod gAssetManagerMethods[] = {
(void*) android_content_AssetManager_setLocale },
{ "getLocales", "()[Ljava/lang/String;",
(void*) android_content_AssetManager_getLocales },
{ "setConfiguration", "(IILjava/lang/String;IIIIIIIIIIIII)V",
{ "setConfiguration", "(IILjava/lang/String;IIIIIIIIIIIIII)V",
(void*) android_content_AssetManager_setConfiguration },
{ "getResourceIdentifier","(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I",
(void*) android_content_AssetManager_getResourceIdentifier },

View File

@ -24,10 +24,6 @@
<!-- Size of the giant number (unread count) in the notifications -->
<dimen name="status_bar_content_number_size">48sp</dimen>
<!-- Margin at the edge of the screen to ignore touch events for in the windowshade. -->
<!-- Margin for permanent screen decorations at the bottom. -->
<dimen name="screen_margin_bottom">48dip</dimen>
<!-- Default height of a key in the password keyboard for alpha -->
<dimen name="password_keyboard_key_height_alpha">75dip</dimen>
<!-- Default height of a key in the password keyboard for numeric -->

View File

@ -590,11 +590,21 @@
<!-- The global user interface mode has changed. For example,
going in or out of car mode, night mode changing, etc. -->
<flag name="uiMode" value="0x0200" />
<!-- The current available screen size has changed. If applications don't
target at least {@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}
then the activity will always handle this itself (the change
will not result in a restart). This represents a change in the
currently available size, so will change when the user switches
between landscape and portrait. -->
<flag name="screenSize" value="0x0400" />
<!-- The physical screen size has changed. If applications don't
target at least {@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}
then the activity will always handle this itself (the change
will not result in a restart). -->
<flag name="screenSize" value="0x0400" />
will not result in a restart). This represents a change in size
regardless of orientation, so will only change when the actual
physical screen size has changed such as switching to an external
display. -->
<flag name="smallestScreenSize" value="0x0800" />
<!-- The font scaling factor has changed, that is the user has
selected a new global font size. -->
<flag name="fontScale" value="0x40000000" />

View File

@ -36,8 +36,6 @@
<dimen name="status_bar_icon_size">25dip</dimen>
<!-- Margin at the edge of the screen to ignore touch events for in the windowshade. -->
<dimen name="status_bar_edge_ignore">5dp</dimen>
<!-- Margin for permanent screen decorations at the bottom. -->
<dimen name="screen_margin_bottom">0dip</dimen>
<!-- Size of the fastscroll hint letter -->
<dimen name="fastscroll_overlay_size">104dp</dimen>
<!-- Width of the fastscroll thumb -->

View File

@ -966,8 +966,7 @@ struct ResTable_config
struct {
uint8_t screenLayout;
uint8_t uiMode;
uint8_t screenConfigPad1;
uint8_t screenConfigPad2;
uint16_t smallestScreenWidthDp;
};
uint32_t screenConfig;
};
@ -1000,6 +999,7 @@ struct ResTable_config
screenHeight = dtohs(screenHeight);
sdkVersion = dtohs(sdkVersion);
minorVersion = dtohs(minorVersion);
smallestScreenWidthDp = dtohs(smallestScreenWidthDp);
screenWidthDp = dtohs(screenWidthDp);
screenHeightDp = dtohs(screenHeightDp);
}
@ -1013,6 +1013,7 @@ struct ResTable_config
screenHeight = htods(screenHeight);
sdkVersion = htods(sdkVersion);
minorVersion = htods(minorVersion);
smallestScreenWidthDp = htods(smallestScreenWidthDp);
screenWidthDp = htods(screenWidthDp);
screenHeightDp = htods(screenHeightDp);
}
@ -1034,6 +1035,8 @@ struct ResTable_config
if (diff != 0) return diff;
diff = (int32_t)(uiMode - o.uiMode);
if (diff != 0) return diff;
diff = (int32_t)(smallestScreenWidthDp - o.smallestScreenWidthDp);
if (diff != 0) return diff;
diff = (int32_t)(screenSizeDp - o.screenSizeDp);
return (int)diff;
}
@ -1052,6 +1055,7 @@ struct ResTable_config
CONFIG_ORIENTATION = ACONFIGURATION_ORIENTATION,
CONFIG_DENSITY = ACONFIGURATION_DENSITY,
CONFIG_SCREEN_SIZE = ACONFIGURATION_SCREEN_SIZE,
CONFIG_SMALLEST_SCREEN_SIZE = ACONFIGURATION_SMALLEST_SCREEN_SIZE,
CONFIG_VERSION = ACONFIGURATION_VERSION,
CONFIG_SCREEN_LAYOUT = ACONFIGURATION_SCREEN_LAYOUT,
CONFIG_UI_MODE = ACONFIGURATION_UI_MODE
@ -1075,6 +1079,7 @@ struct ResTable_config
if (version != o.version) diffs |= CONFIG_VERSION;
if (screenLayout != o.screenLayout) diffs |= CONFIG_SCREEN_LAYOUT;
if (uiMode != o.uiMode) diffs |= CONFIG_UI_MODE;
if (smallestScreenWidthDp != o.smallestScreenWidthDp) diffs |= CONFIG_SMALLEST_SCREEN_SIZE;
if (screenSizeDp != o.screenSizeDp) diffs |= CONFIG_SCREEN_SIZE;
return diffs;
}
@ -1109,14 +1114,10 @@ struct ResTable_config
}
}
if (screenLayout || o.screenLayout) {
if (((screenLayout^o.screenLayout) & MASK_SCREENSIZE) != 0) {
if (!(screenLayout & MASK_SCREENSIZE)) return false;
if (!(o.screenLayout & MASK_SCREENSIZE)) return true;
}
if (((screenLayout^o.screenLayout) & MASK_SCREENLONG) != 0) {
if (!(screenLayout & MASK_SCREENLONG)) return false;
if (!(o.screenLayout & MASK_SCREENLONG)) return true;
if (smallestScreenWidthDp || o.smallestScreenWidthDp) {
if (smallestScreenWidthDp != o.smallestScreenWidthDp) {
if (!smallestScreenWidthDp) return false;
if (!o.smallestScreenWidthDp) return true;
}
}
@ -1132,6 +1133,17 @@ struct ResTable_config
}
}
if (screenLayout || o.screenLayout) {
if (((screenLayout^o.screenLayout) & MASK_SCREENSIZE) != 0) {
if (!(screenLayout & MASK_SCREENSIZE)) return false;
if (!(o.screenLayout & MASK_SCREENSIZE)) return true;
}
if (((screenLayout^o.screenLayout) & MASK_SCREENLONG) != 0) {
if (!(screenLayout & MASK_SCREENLONG)) return false;
if (!(o.screenLayout & MASK_SCREENLONG)) return true;
}
}
if (orientation != o.orientation) {
if (!orientation) return false;
if (!o.orientation) return true;
@ -1238,6 +1250,37 @@ struct ResTable_config
}
}
if (smallestScreenWidthDp || o.smallestScreenWidthDp) {
// The configuration closest to the actual size is best.
// We assume that larger configs have already been filtered
// out at this point. That means we just want the largest one.
return smallestScreenWidthDp >= o.smallestScreenWidthDp;
}
if (screenSizeDp || o.screenSizeDp) {
// "Better" is based on the sum of the difference between both
// width and height from the requested dimensions. We are
// assuming the invalid configs (with smaller dimens) have
// already been filtered. Note that if a particular dimension
// is unspecified, we will end up with a large value (the
// difference between 0 and the requested dimension), which is
// good since we will prefer a config that has specified a
// dimension value.
int myDelta = 0, otherDelta = 0;
if (requested->screenWidthDp) {
myDelta += requested->screenWidthDp - screenWidthDp;
otherDelta += requested->screenWidthDp - o.screenWidthDp;
}
if (requested->screenHeightDp) {
myDelta += requested->screenHeightDp - screenHeightDp;
otherDelta += requested->screenHeightDp - o.screenHeightDp;
}
//LOGI("Comparing this %dx%d to other %dx%d in %dx%d: myDelta=%d otherDelta=%d",
// screenWidthDp, screenHeightDp, o.screenWidthDp, o.screenHeightDp,
// requested->screenWidthDp, requested->screenHeightDp, myDelta, otherDelta);
return (myDelta <= otherDelta);
}
if (screenLayout || o.screenLayout) {
if (((screenLayout^o.screenLayout) & MASK_SCREENSIZE) != 0
&& (requested->screenLayout & MASK_SCREENSIZE)) {
@ -1270,30 +1313,6 @@ struct ResTable_config
}
}
if (screenSizeDp || o.screenSizeDp) {
// Better is based on the sum of the difference between both
// width and height from the requested dimensions. We are
// assuming the invalid configs (with smaller dimens) have
// already been filtered. Note that if a particular dimension
// is unspecified, we will end up with a large value (the
// difference between 0 and the requested dimension), which is
// good since we will prefer a config that has specified a
// dimension value.
int myDelta = 0, otherDelta = 0;
if (requested->screenWidthDp) {
myDelta += requested->screenWidthDp - screenWidthDp;
otherDelta += requested->screenWidthDp - o.screenWidthDp;
}
if (requested->screenHeightDp) {
myDelta += requested->screenHeightDp - screenHeightDp;
otherDelta += requested->screenHeightDp - o.screenHeightDp;
}
//LOGI("Comparing this %dx%d to other %dx%d in %dx%d: myDelta=%d otherDelta=%d",
// screenWidthDp, screenHeightDp, o.screenWidthDp, o.screenHeightDp,
// requested->screenWidthDp, requested->screenHeightDp, myDelta, otherDelta);
return (myDelta <= otherDelta);
}
if ((orientation != o.orientation) && requested->orientation) {
return (orientation);
}
@ -1388,14 +1407,24 @@ struct ResTable_config
}
if (screenSize || o.screenSize) {
if ((screenWidth != o.screenWidth) && requested->screenWidth) {
return (screenWidth);
// "Better" is based on the sum of the difference between both
// width and height from the requested dimensions. We are
// assuming the invalid configs (with smaller sizes) have
// already been filtered. Note that if a particular dimension
// is unspecified, we will end up with a large value (the
// difference between 0 and the requested dimension), which is
// good since we will prefer a config that has specified a
// size value.
int myDelta = 0, otherDelta = 0;
if (requested->screenWidth) {
myDelta += requested->screenWidth - screenWidth;
otherDelta += requested->screenWidth - o.screenWidth;
}
if ((screenHeight != o.screenHeight) &&
requested->screenHeight) {
return (screenHeight);
if (requested->screenHeight) {
myDelta += requested->screenHeight - screenHeight;
otherDelta += requested->screenHeight - o.screenHeight;
}
return (myDelta <= otherDelta);
}
if (version || o.version) {
@ -1476,15 +1505,20 @@ struct ResTable_config
&& uiModeNight != setUiModeNight) {
return false;
}
if (settings.smallestScreenWidthDp != 0 && smallestScreenWidthDp != 0
&& smallestScreenWidthDp > settings.smallestScreenWidthDp) {
return false;
}
}
if (screenSizeDp != 0) {
if (settings.screenWidthDp != 0 && screenWidthDp != 0
&& screenWidthDp > settings.screenWidthDp) {
&& screenWidthDp > settings.screenWidthDp) {
//LOGI("Filtering out width %d in requested %d", screenWidthDp, settings.screenWidthDp);
return false;
}
if (settings.screenHeightDp != 0 && screenHeightDp != 0
&& screenHeightDp > settings.screenHeightDp) {
&& screenHeightDp > settings.screenHeightDp) {
//LOGI("Filtering out height %d in requested %d", screenHeightDp, settings.screenHeightDp);
return false;
}
@ -1531,11 +1565,11 @@ struct ResTable_config
}
if (screenSize != 0) {
if (settings.screenWidth != 0 && screenWidth != 0
&& screenWidth != settings.screenWidth) {
&& screenWidth > settings.screenWidth) {
return false;
}
if (settings.screenHeight != 0 && screenHeight != 0
&& screenHeight != settings.screenHeight) {
&& screenHeight > settings.screenHeight) {
return false;
}
}
@ -1568,13 +1602,13 @@ struct ResTable_config
String8 toString() const {
char buf[200];
sprintf(buf, "imsi=%d/%d lang=%c%c reg=%c%c orient=%d touch=%d dens=%d "
"kbd=%d nav=%d input=%d ssz=%dx%d %ddp x %ddp sz=%d long=%d "
"kbd=%d nav=%d input=%d ssz=%dx%d sw%ddp w%ddp h%ddp sz=%d long=%d "
"ui=%d night=%d vers=%d.%d",
mcc, mnc,
language[0] ? language[0] : '-', language[1] ? language[1] : '-',
country[0] ? country[0] : '-', country[1] ? country[1] : '-',
orientation, touchscreen, density, keyboard, navigation, inputFlags,
screenWidth, screenHeight, screenWidthDp, screenHeightDp,
screenWidth, screenHeight, smallestScreenWidthDp, screenWidthDp, screenHeightDp,
screenLayout&MASK_SCREENSIZE, screenLayout&MASK_SCREENLONG,
uiMode&MASK_UI_MODE_TYPE, uiMode&MASK_UI_MODE_NIGHT,
sdkVersion, minorVersion);

View File

@ -2424,7 +2424,7 @@ void ResTable::setParameters(const ResTable_config* params)
{
mLock.lock();
TABLE_GETENTRY(LOGI("Setting parameters: imsi:%d/%d lang:%c%c cnt:%c%c "
"orien:%d touch:%d density:%d key:%d inp:%d nav:%d sz:%dx%d %ddp x %ddp\n",
"orien:%d touch:%d density:%d key:%d inp:%d nav:%d sz:%dx%d sw%ddp w%ddp h%ddp\n",
params->mcc, params->mnc,
params->language[0] ? params->language[0] : '-',
params->language[1] ? params->language[1] : '-',
@ -2438,6 +2438,7 @@ void ResTable::setParameters(const ResTable_config* params)
params->navigation,
params->screenWidth,
params->screenHeight,
params->smallestScreenWidthDp,
params->screenWidthDp,
params->screenHeightDp));
mParams = *params;
@ -3763,7 +3764,7 @@ ssize_t ResTable::getEntry(
TABLE_GETENTRY(LOGI("Match entry 0x%x in type 0x%x (sz 0x%x): imsi:%d/%d=%d/%d "
"lang:%c%c=%c%c cnt:%c%c=%c%c orien:%d=%d touch:%d=%d "
"density:%d=%d key:%d=%d inp:%d=%d nav:%d=%d w:%d=%d h:%d=%d "
"wdp:%d=%d hdp:%d=%d\n",
"swdp:%d=%d wdp:%d=%d hdp:%d=%d\n",
entryIndex, typeIndex+1, dtohl(thisType->config.size),
thisConfig.mcc, thisConfig.mnc,
config ? config->mcc : 0, config ? config->mnc : 0,
@ -3791,6 +3792,8 @@ ssize_t ResTable::getEntry(
config ? config->screenWidth : 0,
thisConfig.screenHeight,
config ? config->screenHeight : 0,
thisConfig.smallestScreenWidthDp,
config ? config->smallestScreenWidthDp : 0,
thisConfig.screenWidthDp,
config ? config->screenWidthDp : 0,
thisConfig.screenHeightDp,
@ -4076,7 +4079,7 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg,
thisConfig.copyFromDtoH(type->config);
LOGI("Adding config to type %d: imsi:%d/%d lang:%c%c cnt:%c%c "
"orien:%d touch:%d density:%d key:%d inp:%d nav:%d w:%d h:%d "
"wdp:%d hdp:%d\n",
"swdp:%d wdp:%d hdp:%d\n",
type->id,
thisConfig.mcc, thisConfig.mnc,
thisConfig.language[0] ? thisConfig.language[0] : '-',
@ -4091,6 +4094,7 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg,
thisConfig.navigation,
thisConfig.screenWidth,
thisConfig.screenHeight,
thisConfig.smallestScreenWidthDp,
thisConfig.screenWidthDp,
thisConfig.screenHeightDp));
t->configs.add(type);
@ -4455,6 +4459,9 @@ void ResTable::print(bool inclValues) const
if (type->config.screenHeight != 0) {
printf(" h=%d", dtohs(type->config.screenHeight));
}
if (type->config.smallestScreenWidthDp != 0) {
printf(" swdp=%d", dtohs(type->config.smallestScreenWidthDp));
}
if (type->config.screenWidthDp != 0) {
printf(" wdp=%d", dtohs(type->config.screenWidthDp));
}

View File

@ -111,6 +111,18 @@ int32_t AConfiguration_getUiModeNight(AConfiguration* config) {
}
int32_t AConfiguration_getScreenWidthDp(AConfiguration* config) {
return config->screenWidthDp;
}
int32_t AConfiguration_getScreenHeightDp(AConfiguration* config) {
return config->screenHeightDp;
}
int32_t AConfiguration_getSmallestScreenWidthDp(AConfiguration* config) {
return config->smallestScreenWidthDp;
}
// ----------------------------------------------------------------------
void AConfiguration_setMcc(AConfiguration* config, int32_t mcc) {
@ -186,6 +198,18 @@ void AConfiguration_setUiModeNight(AConfiguration* config, int32_t uiModeNight)
}
void AConfiguration_setScreenWidthDp(AConfiguration* config, int32_t value) {
config->screenWidthDp = value;
}
void AConfiguration_setScreenHeightDp(AConfiguration* config, int32_t value) {
config->screenHeightDp = value;
}
void AConfiguration_setSmallestScreenWidthDp(AConfiguration* config, int32_t value) {
config->smallestScreenWidthDp = value;
}
// ----------------------------------------------------------------------
int32_t AConfiguration_diff(AConfiguration* config1, AConfiguration* config2) {

View File

@ -82,6 +82,12 @@ enum {
ACONFIGURATION_UI_MODE_NIGHT_NO = 0x1,
ACONFIGURATION_UI_MODE_NIGHT_YES = 0x2,
ACONFIGURATION_SCREEN_WIDTH_DP_ANY = 0x0000,
ACONFIGURATION_SCREEN_HEIGHT_DP_ANY = 0x0000,
ACONFIGURATION_SMALLEST_SCREEN_WIDTH_DP_ANY = 0x0000,
ACONFIGURATION_MCC = 0x0001,
ACONFIGURATION_MNC = 0x0002,
ACONFIGURATION_LOCALE = 0x0004,
@ -95,6 +101,7 @@ enum {
ACONFIGURATION_VERSION = 0x0400,
ACONFIGURATION_SCREEN_LAYOUT = 0x0800,
ACONFIGURATION_UI_MODE = 0x1000,
ACONFIGURATION_SMALLEST_SCREEN_SIZE = 0x2000,
};
/**
@ -285,6 +292,39 @@ int32_t AConfiguration_getUiModeNight(AConfiguration* config);
*/
void AConfiguration_setUiModeNight(AConfiguration* config, int32_t uiModeNight);
/**
* Return the current configuration screen width in dp units, or
* ACONFIGURATION_SCREEN_WIDTH_DP_ANY if not set.
*/
int32_t AConfiguration_getScreenWidthDp(AConfiguration* config);
/**
* Set the configuration's current screen width in dp units.
*/
void AConfiguration_setScreenWidthDp(AConfiguration* config, int32_t value);
/**
* Return the current configuration screen height in dp units, or
* ACONFIGURATION_SCREEN_HEIGHT_DP_ANY if not set.
*/
int32_t AConfiguration_getScreenHeightDp(AConfiguration* config);
/**
* Set the configuration's current screen width in dp units.
*/
void AConfiguration_setScreenHeightDp(AConfiguration* config, int32_t value);
/**
* Return the configuration's smallest screen width in dp units, or
* ACONFIGURATION_SMALLEST_SCREEN_WIDTH_DP_ANY if not set.
*/
int32_t AConfiguration_getSmallestScreenWidthDp(AConfiguration* config);
/**
* Set the configuration's smallest screen width in dp units.
*/
void AConfiguration_setSmallestScreenWidthDp(AConfiguration* config, int32_t value);
/**
* Perform a diff between two configurations. Returns a bit mask of
* ACONFIGURATION_* constants, each bit set meaning that configuration element

View File

@ -227,7 +227,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
boolean mSafeMode;
WindowState mStatusBar = null;
boolean mStatusBarCanHide;
int mScreenMarginBottom;
int mStatusBarHeight;
final ArrayList<WindowState> mStatusBarPanels = new ArrayList<WindowState>();
WindowState mKeyguard = null;
KeyguardViewMediator mKeyguardMediator;
@ -1055,12 +1055,20 @@ public class PhoneWindowManager implements WindowManagerPolicy {
return STATUS_BAR_LAYER;
}
public int getNonDecorDisplayWidth(int fullWidth) {
public int getNonDecorDisplayWidth(int rotation, int fullWidth) {
return fullWidth;
}
public int getNonDecorDisplayHeight(int fullHeight) {
return fullHeight - mScreenMarginBottom;
public int getNonDecorDisplayHeight(int rotation, int fullHeight) {
return mStatusBarCanHide ? fullHeight : (fullHeight - mStatusBarHeight);
}
public int getConfigDisplayWidth(int rotation, int fullWidth) {
return fullWidth;
}
public int getConfigDisplayHeight(int rotation, int fullHeight) {
return fullHeight - mStatusBarHeight;
}
public boolean doesForceHide(WindowState win, WindowManager.LayoutParams attrs) {
@ -1212,8 +1220,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// The Configuration will be stable by now, so we can load this
mStatusBarCanHide = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_statusBarCanHide);
mScreenMarginBottom = mContext.getResources().getDimensionPixelSize(
com.android.internal.R.dimen.screen_margin_bottom);
mStatusBarHeight = mContext.getResources().getDimensionPixelSize(
com.android.internal.R.dimen.status_bar_height);
break;
case TYPE_STATUS_BAR_PANEL:

View File

@ -4779,8 +4779,8 @@ public class WindowManagerService extends IWindowManager.Stub
synchronized(mWindowMap) {
long ident = Binder.clearCallingIdentity();
dw = mPolicy.getNonDecorDisplayWidth(mCurDisplayWidth);
dh = mPolicy.getNonDecorDisplayHeight(mCurDisplayHeight);
dw = mPolicy.getNonDecorDisplayWidth(mRotation, mCurDisplayWidth);
dh = mPolicy.getNonDecorDisplayHeight(mRotation, mCurDisplayHeight);
int aboveAppLayer = mPolicy.windowTypeToLayerLw(
WindowManager.LayoutParams.TYPE_APPLICATION) * TYPE_LAYER_MULTIPLIER
@ -5497,6 +5497,14 @@ public class WindowManagerService extends IWindowManager.Stub
return config;
}
private int reduceConfigWidthSize(int curSize, int rotation, float density, int dw) {
int size = (int)(mPolicy.getConfigDisplayWidth(rotation, dw) / density);
if (size < curSize) {
curSize = size;
}
return curSize;
}
boolean computeNewConfigurationLocked(Configuration config) {
if (mDisplay == null) {
return false;
@ -5547,14 +5555,37 @@ public class WindowManagerService extends IWindowManager.Stub
// Override display width and height with what we are computing,
// to be sure they remain consistent.
dm.widthPixels = dm.realWidthPixels = mPolicy.getNonDecorDisplayWidth(dw);
dm.heightPixels = dm.realHeightPixels = mPolicy.getNonDecorDisplayHeight(dh);
dm.widthPixels = dm.realWidthPixels = mPolicy.getNonDecorDisplayWidth(
mRotation, dw);
dm.heightPixels = dm.realHeightPixels = mPolicy.getNonDecorDisplayHeight(
mRotation, dh);
mCompatibleScreenScale = CompatibilityInfo.updateCompatibleScreenFrame(
dm, mCompatibleScreenFrame, null);
config.screenWidthDp = (int)(dm.widthPixels / dm.density);
config.screenHeightDp = (int)(dm.heightPixels / dm.density);
config.screenWidthDp = (int)(mPolicy.getConfigDisplayWidth(mRotation, dw) / dm.density);
config.screenHeightDp = (int)(mPolicy.getConfigDisplayHeight(mRotation, dh) / dm.density);
// We need to determine the smallest width that will occur under normal
// operation. To this, start with the base screen size and compute the
// width under the different possible rotations. We need to un-rotate
// the current screen dimensions before doing this.
int unrotDw, unrotDh;
if (rotated) {
unrotDw = dh;
unrotDh = dw;
} else {
unrotDw = dw;
unrotDh = dh;
}
config.smallestScreenWidthDp = reduceConfigWidthSize(unrotDw,
Surface.ROTATION_0, dm.density, unrotDw);
config.smallestScreenWidthDp = reduceConfigWidthSize(config.smallestScreenWidthDp,
Surface.ROTATION_90, dm.density, unrotDh);
config.smallestScreenWidthDp = reduceConfigWidthSize(config.smallestScreenWidthDp,
Surface.ROTATION_180, dm.density, unrotDw);
config.smallestScreenWidthDp = reduceConfigWidthSize(config.smallestScreenWidthDp,
Surface.ROTATION_270, dm.density, unrotDh);
// Compute the screen layout size class.
int screenLayout;
@ -6806,9 +6837,6 @@ public class WindowManagerService extends IWindowManager.Stub
final int dw = mCurDisplayWidth;
final int dh = mCurDisplayHeight;
final int innerDw = mPolicy.getNonDecorDisplayWidth(dw);
final int innerDh = mPolicy.getNonDecorDisplayHeight(dh);
final int N = mWindows.size();
int i;
@ -6929,8 +6957,8 @@ public class WindowManagerService extends IWindowManager.Stub
final int dw = mCurDisplayWidth;
final int dh = mCurDisplayHeight;
final int innerDw = mPolicy.getNonDecorDisplayWidth(dw);
final int innerDh = mPolicy.getNonDecorDisplayHeight(dh);
final int innerDw = mPolicy.getNonDecorDisplayWidth(mRotation, dw);
final int innerDh = mPolicy.getNonDecorDisplayHeight(mRotation, dh);
int i;

View File

@ -142,17 +142,10 @@ AaptGroupEntry::parseNamePart(const String8& part, int* axis, uint32_t* value)
return 0;
}
// screen layout size
if (getScreenLayoutSizeName(part.string(), &config)) {
*axis = AXIS_SCREENLAYOUTSIZE;
*value = (config.screenLayout&ResTable_config::MASK_SCREENSIZE);
return 0;
}
// screen layout long
if (getScreenLayoutLongName(part.string(), &config)) {
*axis = AXIS_SCREENLAYOUTLONG;
*value = (config.screenLayout&ResTable_config::MASK_SCREENLONG);
// smallest screen dp width
if (getSmallestScreenWidthDpName(part.string(), &config)) {
*axis = AXIS_SMALLESTSCREENWIDTHDP;
*value = config.smallestScreenWidthDp;
return 0;
}
@ -170,6 +163,20 @@ AaptGroupEntry::parseNamePart(const String8& part, int* axis, uint32_t* value)
return 0;
}
// screen layout size
if (getScreenLayoutSizeName(part.string(), &config)) {
*axis = AXIS_SCREENLAYOUTSIZE;
*value = (config.screenLayout&ResTable_config::MASK_SCREENSIZE);
return 0;
}
// screen layout long
if (getScreenLayoutLongName(part.string(), &config)) {
*axis = AXIS_SCREENLAYOUTLONG;
*value = (config.screenLayout&ResTable_config::MASK_SCREENLONG);
return 0;
}
// orientation
if (getOrientationName(part.string(), &config)) {
*axis = AXIS_ORIENTATION;
@ -257,7 +264,7 @@ AaptGroupEntry::initFromDirName(const char* dir, String8* resType)
String8 mcc, mnc, loc, layoutsize, layoutlong, orient, den;
String8 touch, key, keysHidden, nav, navHidden, size, vers;
String8 uiModeType, uiModeNight, widthdp, heightdp;
String8 uiModeType, uiModeNight, smallestwidthdp, widthdp, heightdp;
const char *p = dir;
const char *q;
@ -344,8 +351,8 @@ AaptGroupEntry::initFromDirName(const char* dir, String8* resType)
//printf("not region: %s\n", part.string());
}
if (getScreenLayoutSizeName(part.string())) {
layoutsize = part;
if (getSmallestScreenWidthDpName(part.string())) {
smallestwidthdp = part;
index++;
if (index == N) {
@ -353,19 +360,7 @@ AaptGroupEntry::initFromDirName(const char* dir, String8* resType)
}
part = parts[index];
} else {
//printf("not screen layout size: %s\n", part.string());
}
if (getScreenLayoutLongName(part.string())) {
layoutlong = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
} else {
//printf("not screen layout long: %s\n", part.string());
//printf("not smallest screen width dp: %s\n", part.string());
}
if (getScreenWidthDpName(part.string())) {
@ -392,6 +387,30 @@ AaptGroupEntry::initFromDirName(const char* dir, String8* resType)
//printf("not screen height dp: %s\n", part.string());
}
if (getScreenLayoutSizeName(part.string())) {
layoutsize = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
} else {
//printf("not screen layout size: %s\n", part.string());
}
if (getScreenLayoutLongName(part.string())) {
layoutlong = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
} else {
//printf("not screen layout long: %s\n", part.string());
}
// orientation
if (getOrientationName(part.string())) {
orient = part;
@ -541,6 +560,7 @@ success:
this->locale = loc;
this->screenLayoutSize = layoutsize;
this->screenLayoutLong = layoutlong;
this->smallestScreenWidthDp = smallestwidthdp;
this->screenWidthDp = widthdp;
this->screenHeightDp = heightdp;
this->orientation = orient;
@ -570,14 +590,16 @@ AaptGroupEntry::toString() const
s += ",";
s += this->locale;
s += ",";
s += screenLayoutSize;
s += ",";
s += screenLayoutLong;
s += smallestScreenWidthDp;
s += ",";
s += screenWidthDp;
s += ",";
s += screenHeightDp;
s += ",";
s += screenLayoutSize;
s += ",";
s += screenLayoutLong;
s += ",";
s += this->orientation;
s += ",";
s += uiModeType;
@ -618,13 +640,9 @@ AaptGroupEntry::toDirName(const String8& resType) const
s += "-";
s += locale;
}
if (this->screenLayoutSize != "") {
if (this->smallestScreenWidthDp != "") {
s += "-";
s += screenLayoutSize;
}
if (this->screenLayoutLong != "") {
s += "-";
s += screenLayoutLong;
s += smallestScreenWidthDp;
}
if (this->screenWidthDp != "") {
s += "-";
@ -634,6 +652,14 @@ AaptGroupEntry::toDirName(const String8& resType) const
s += "-";
s += screenHeightDp;
}
if (this->screenLayoutSize != "") {
s += "-";
s += screenLayoutSize;
}
if (this->screenLayoutLong != "") {
s += "-";
s += screenLayoutLong;
}
if (this->orientation != "") {
s += "-";
s += orientation;
@ -1126,6 +1152,31 @@ bool AaptGroupEntry::getScreenSizeName(const char* name, ResTable_config* out)
return true;
}
bool AaptGroupEntry::getSmallestScreenWidthDpName(const char* name, ResTable_config* out)
{
if (strcmp(name, kWildcardName) == 0) {
if (out) {
out->smallestScreenWidthDp = out->SCREENWIDTH_ANY;
}
return true;
}
if (*name != 's') return false;
name++;
if (*name != 'w') return false;
name++;
const char* x = name;
while (*x >= '0' && *x <= '9') x++;
if (x == name || x[0] != 'd' || x[1] != 'p' || x[2] != 0) return false;
String8 xName(name, x-name);
if (out) {
out->smallestScreenWidthDp = (uint16_t)atoi(xName.string());
}
return true;
}
bool AaptGroupEntry::getScreenWidthDpName(const char* name, ResTable_config* out)
{
if (strcmp(name, kWildcardName) == 0) {
@ -1206,10 +1257,11 @@ int AaptGroupEntry::compare(const AaptGroupEntry& o) const
if (v == 0) v = mnc.compare(o.mnc);
if (v == 0) v = locale.compare(o.locale);
if (v == 0) v = vendor.compare(o.vendor);
if (v == 0) v = screenLayoutSize.compare(o.screenLayoutSize);
if (v == 0) v = screenLayoutLong.compare(o.screenLayoutLong);
if (v == 0) v = smallestScreenWidthDp.compare(o.smallestScreenWidthDp);
if (v == 0) v = screenWidthDp.compare(o.screenWidthDp);
if (v == 0) v = screenHeightDp.compare(o.screenHeightDp);
if (v == 0) v = screenLayoutSize.compare(o.screenLayoutSize);
if (v == 0) v = screenLayoutLong.compare(o.screenLayoutLong);
if (v == 0) v = orientation.compare(o.orientation);
if (v == 0) v = uiModeType.compare(o.uiModeType);
if (v == 0) v = uiModeNight.compare(o.uiModeNight);
@ -1231,10 +1283,11 @@ ResTable_config AaptGroupEntry::toParams() const
getMccName(mcc.string(), &params);
getMncName(mnc.string(), &params);
getLocaleName(locale.string(), &params);
getScreenLayoutSizeName(screenLayoutSize.string(), &params);
getScreenLayoutLongName(screenLayoutLong.string(), &params);
getSmallestScreenWidthDpName(smallestScreenWidthDp.string(), &params);
getScreenWidthDpName(screenWidthDp.string(), &params);
getScreenHeightDpName(screenHeightDp.string(), &params);
getScreenLayoutSizeName(screenLayoutSize.string(), &params);
getScreenLayoutLongName(screenLayoutLong.string(), &params);
getOrientationName(orientation.string(), &params);
getUiModeTypeName(uiModeType.string(), &params);
getUiModeNightName(uiModeNight.string(), &params);
@ -1249,9 +1302,10 @@ ResTable_config AaptGroupEntry::toParams() const
// Fix up version number based on specified parameters.
int minSdk = 0;
if (params.screenWidthDp != ResTable_config::SCREENWIDTH_ANY
if (params.smallestScreenWidthDp != ResTable_config::SCREENWIDTH_ANY
|| params.screenWidthDp != ResTable_config::SCREENWIDTH_ANY
|| params.screenHeightDp != ResTable_config::SCREENHEIGHT_ANY) {
minSdk = SDK_ICS;
minSdk = SDK_HONEYCOMB_MR2;
} else if ((params.uiMode&ResTable_config::MASK_UI_MODE_TYPE)
!= ResTable_config::UI_MODE_TYPE_ANY
|| (params.uiMode&ResTable_config::MASK_UI_MODE_NIGHT)

View File

@ -42,6 +42,7 @@ enum {
AXIS_NAVHIDDEN,
AXIS_NAVIGATION,
AXIS_SCREENSIZE,
AXIS_SMALLESTSCREENWIDTHDP,
AXIS_SCREENWIDTHDP,
AXIS_SCREENHEIGHTDP,
AXIS_VERSION
@ -54,7 +55,7 @@ enum {
SDK_ECLAIR_0_1 = 6,
SDK_MR1 = 7,
SDK_FROYO = 8,
SDK_ICS = 13,
SDK_HONEYCOMB_MR2 = 13,
};
/**
@ -72,10 +73,11 @@ public:
String8 mnc;
String8 locale;
String8 vendor;
String8 screenLayoutSize;
String8 screenLayoutLong;
String8 smallestScreenWidthDp;
String8 screenWidthDp;
String8 screenHeightDp;
String8 screenLayoutSize;
String8 screenLayoutLong;
String8 orientation;
String8 uiModeType;
String8 uiModeNight;
@ -107,6 +109,7 @@ public:
static bool getNavigationName(const char* name, ResTable_config* out = NULL);
static bool getNavHiddenName(const char* name, ResTable_config* out = NULL);
static bool getScreenSizeName(const char* name, ResTable_config* out = NULL);
static bool getSmallestScreenWidthDpName(const char* name, ResTable_config* out = NULL);
static bool getScreenWidthDpName(const char* name, ResTable_config* out = NULL);
static bool getScreenHeightDpName(const char* name, ResTable_config* out = NULL);
static bool getVersionName(const char* name, ResTable_config* out = NULL);

View File

@ -2607,6 +2607,9 @@ ResourceFilter::match(const ResTable_config& config) const
if (!match(AXIS_SCREENSIZE, config.screenSize)) {
return false;
}
if (!match(AXIS_SMALLESTSCREENWIDTHDP, config.smallestScreenWidthDp)) {
return false;
}
if (!match(AXIS_SCREENWIDTHDP, config.screenWidthDp)) {
return false;
}
@ -2809,7 +2812,8 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<AaptFile>& dest)
ConfigDescription config = t->getUniqueConfigs().itemAt(ci);
NOISY(printf("Writing config %d config: imsi:%d/%d lang:%c%c cnt:%c%c "
"orien:%d ui:%d touch:%d density:%d key:%d inp:%d nav:%d sz:%dx%d %ddp x %ddp\n",
"orien:%d ui:%d touch:%d density:%d key:%d inp:%d nav:%d sz:%dx%d "
"sw%ddp w%ddp h%ddp\n",
ti+1,
config.mcc, config.mnc,
config.language[0] ? config.language[0] : '-',
@ -2825,6 +2829,7 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<AaptFile>& dest)
config.navigation,
config.screenWidth,
config.screenHeight,
config.smallestScreenWidthDp,
config.screenWidthDp,
config.screenHeightDp));
@ -2849,7 +2854,8 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<AaptFile>& dest)
tHeader->entriesStart = htodl(typeSize);
tHeader->config = config;
NOISY(printf("Writing type %d config: imsi:%d/%d lang:%c%c cnt:%c%c "
"orien:%d ui:%d touch:%d density:%d key:%d inp:%d nav:%d sz:%dx%d %ddp x %ddp\n",
"orien:%d ui:%d touch:%d density:%d key:%d inp:%d nav:%d sz:%dx%d "
"sw%ddp w%ddp h%ddp\n",
ti+1,
tHeader->config.mcc, tHeader->config.mnc,
tHeader->config.language[0] ? tHeader->config.language[0] : '-',
@ -2865,6 +2871,7 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<AaptFile>& dest)
tHeader->config.navigation,
tHeader->config.screenWidth,
tHeader->config.screenHeight,
tHeader->config.smallestScreenWidthDp,
tHeader->config.screenWidthDp,
tHeader->config.screenHeightDp));
tHeader->config.swapHtoD();
@ -3448,7 +3455,8 @@ sp<ResourceTable::Entry> ResourceTable::Type::getEntry(const String16& entry,
if (e == NULL) {
if (config != NULL) {
NOISY(printf("New entry at %s:%d: imsi:%d/%d lang:%c%c cnt:%c%c "
"orien:%d touch:%d density:%d key:%d inp:%d nav:%d sz:%dx%d %ddp x %ddp\n",
"orien:%d touch:%d density:%d key:%d inp:%d nav:%d sz:%dx%d "
"sw%ddp w%ddp h%ddp\n",
sourcePos.file.string(), sourcePos.line,
config->mcc, config->mnc,
config->language[0] ? config->language[0] : '-',
@ -3463,6 +3471,7 @@ sp<ResourceTable::Entry> ResourceTable::Type::getEntry(const String16& entry,
config->navigation,
config->screenWidth,
config->screenHeight,
config->smallestScreenWidthDp,
config->screenWidthDp,
config->screenHeightDp));
} else {