Merge "Small fixes and cleanup of resource config handling." into honeycomb-mr2
This commit is contained in:
committed by
Android (Google) Code Review
commit
ff7622992f
@@ -193,11 +193,7 @@ public class Resources {
|
|||||||
Configuration config, CompatibilityInfo compInfo) {
|
Configuration config, CompatibilityInfo compInfo) {
|
||||||
mAssets = assets;
|
mAssets = assets;
|
||||||
mMetrics.setToDefaults();
|
mMetrics.setToDefaults();
|
||||||
if (compInfo == null) {
|
mCompatibilityInfo = compInfo;
|
||||||
mCompatibilityInfo = CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO;
|
|
||||||
} else {
|
|
||||||
mCompatibilityInfo = compInfo;
|
|
||||||
}
|
|
||||||
updateConfiguration(config, metrics);
|
updateConfiguration(config, metrics);
|
||||||
assets.ensureStringBlocks();
|
assets.ensureStringBlocks();
|
||||||
}
|
}
|
||||||
@@ -1416,7 +1412,9 @@ public class Resources {
|
|||||||
int configChanges = 0xfffffff;
|
int configChanges = 0xfffffff;
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
mTmpConfig.setTo(config);
|
mTmpConfig.setTo(config);
|
||||||
mCompatibilityInfo.applyToConfiguration(mTmpConfig);
|
if (mCompatibilityInfo != null) {
|
||||||
|
mCompatibilityInfo.applyToConfiguration(mTmpConfig);
|
||||||
|
}
|
||||||
configChanges = mConfiguration.updateFrom(mTmpConfig);
|
configChanges = mConfiguration.updateFrom(mTmpConfig);
|
||||||
configChanges = ActivityInfo.activityInfoConfigToNative(configChanges);
|
configChanges = ActivityInfo.activityInfoConfigToNative(configChanges);
|
||||||
}
|
}
|
||||||
@@ -1434,7 +1432,9 @@ public class Resources {
|
|||||||
// it would be cleaner and more maintainble to just be
|
// it would be cleaner and more maintainble to just be
|
||||||
// consistently dealing with a compatible display everywhere in
|
// consistently dealing with a compatible display everywhere in
|
||||||
// the framework.
|
// the framework.
|
||||||
mCompatibilityInfo.applyToDisplayMetrics(mMetrics);
|
if (mCompatibilityInfo != null) {
|
||||||
|
mCompatibilityInfo.applyToDisplayMetrics(mMetrics);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mMetrics.scaledDensity = mMetrics.density * mConfiguration.fontScale;
|
mMetrics.scaledDensity = mMetrics.density * mConfiguration.fontScale;
|
||||||
|
|
||||||
@@ -1565,11 +1565,12 @@ public class Resources {
|
|||||||
* Return the compatibility mode information for the application.
|
* Return the compatibility mode information for the application.
|
||||||
* The returned object should be treated as read-only.
|
* The returned object should be treated as read-only.
|
||||||
*
|
*
|
||||||
* @return compatibility info. null if the app does not require compatibility mode.
|
* @return compatibility info.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public CompatibilityInfo getCompatibilityInfo() {
|
public CompatibilityInfo getCompatibilityInfo() {
|
||||||
return mCompatibilityInfo;
|
return mCompatibilityInfo != null ? mCompatibilityInfo
|
||||||
|
: CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1452,24 +1452,20 @@ struct ResTable_config
|
|||||||
// settings is the requested settings
|
// settings is the requested settings
|
||||||
inline bool match(const ResTable_config& settings) const {
|
inline bool match(const ResTable_config& settings) const {
|
||||||
if (imsi != 0) {
|
if (imsi != 0) {
|
||||||
if ((settings.mcc != 0 && mcc != 0
|
if (mcc != 0 && mcc != settings.mcc) {
|
||||||
&& mcc != settings.mcc) ||
|
|
||||||
(settings.mcc == 0 && mcc != 0)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((settings.mnc != 0 && mnc != 0
|
if (mnc != 0 && mnc != settings.mnc) {
|
||||||
&& mnc != settings.mnc) ||
|
|
||||||
(settings.mnc == 0 && mnc != 0)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (locale != 0) {
|
if (locale != 0) {
|
||||||
if (settings.language[0] != 0 && language[0] != 0
|
if (language[0] != 0
|
||||||
&& (language[0] != settings.language[0]
|
&& (language[0] != settings.language[0]
|
||||||
|| language[1] != settings.language[1])) {
|
|| language[1] != settings.language[1])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (settings.country[0] != 0 && country[0] != 0
|
if (country[0] != 0
|
||||||
&& (country[0] != settings.country[0]
|
&& (country[0] != settings.country[0]
|
||||||
|| country[1] != settings.country[1])) {
|
|| country[1] != settings.country[1])) {
|
||||||
return false;
|
return false;
|
||||||
@@ -1480,66 +1476,56 @@ struct ResTable_config
|
|||||||
const int setScreenSize = settings.screenLayout&MASK_SCREENSIZE;
|
const int setScreenSize = settings.screenLayout&MASK_SCREENSIZE;
|
||||||
// Any screen sizes for larger screens than the setting do not
|
// Any screen sizes for larger screens than the setting do not
|
||||||
// match.
|
// match.
|
||||||
if ((setScreenSize != 0 && screenSize != 0
|
if (screenSize != 0 && screenSize > setScreenSize) {
|
||||||
&& screenSize > setScreenSize) ||
|
|
||||||
(setScreenSize == 0 && screenSize != 0)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int screenLong = screenLayout&MASK_SCREENLONG;
|
const int screenLong = screenLayout&MASK_SCREENLONG;
|
||||||
const int setScreenLong = settings.screenLayout&MASK_SCREENLONG;
|
const int setScreenLong = settings.screenLayout&MASK_SCREENLONG;
|
||||||
if (setScreenLong != 0 && screenLong != 0
|
if (screenLong != 0 && screenLong != setScreenLong) {
|
||||||
&& screenLong != setScreenLong) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int uiModeType = uiMode&MASK_UI_MODE_TYPE;
|
const int uiModeType = uiMode&MASK_UI_MODE_TYPE;
|
||||||
const int setUiModeType = settings.uiMode&MASK_UI_MODE_TYPE;
|
const int setUiModeType = settings.uiMode&MASK_UI_MODE_TYPE;
|
||||||
if (setUiModeType != 0 && uiModeType != 0
|
if (uiModeType != 0 && uiModeType != setUiModeType) {
|
||||||
&& uiModeType != setUiModeType) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int uiModeNight = uiMode&MASK_UI_MODE_NIGHT;
|
const int uiModeNight = uiMode&MASK_UI_MODE_NIGHT;
|
||||||
const int setUiModeNight = settings.uiMode&MASK_UI_MODE_NIGHT;
|
const int setUiModeNight = settings.uiMode&MASK_UI_MODE_NIGHT;
|
||||||
if (setUiModeNight != 0 && uiModeNight != 0
|
if (uiModeNight != 0 && uiModeNight != setUiModeNight) {
|
||||||
&& uiModeNight != setUiModeNight) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.smallestScreenWidthDp != 0 && smallestScreenWidthDp != 0
|
if (smallestScreenWidthDp != 0
|
||||||
&& smallestScreenWidthDp > settings.smallestScreenWidthDp) {
|
&& smallestScreenWidthDp > settings.smallestScreenWidthDp) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (screenSizeDp != 0) {
|
if (screenSizeDp != 0) {
|
||||||
if (settings.screenWidthDp != 0 && screenWidthDp != 0
|
if (screenWidthDp != 0 && screenWidthDp > settings.screenWidthDp) {
|
||||||
&& screenWidthDp > settings.screenWidthDp) {
|
|
||||||
//LOGI("Filtering out width %d in requested %d", screenWidthDp, settings.screenWidthDp);
|
//LOGI("Filtering out width %d in requested %d", screenWidthDp, settings.screenWidthDp);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (settings.screenHeightDp != 0 && screenHeightDp != 0
|
if (screenHeightDp != 0 && screenHeightDp > settings.screenHeightDp) {
|
||||||
&& screenHeightDp > settings.screenHeightDp) {
|
|
||||||
//LOGI("Filtering out height %d in requested %d", screenHeightDp, settings.screenHeightDp);
|
//LOGI("Filtering out height %d in requested %d", screenHeightDp, settings.screenHeightDp);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (screenType != 0) {
|
if (screenType != 0) {
|
||||||
if (settings.orientation != 0 && orientation != 0
|
if (orientation != 0 && orientation != settings.orientation) {
|
||||||
&& orientation != settings.orientation) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// density always matches - we can scale it. See isBetterThan
|
// density always matches - we can scale it. See isBetterThan
|
||||||
if (settings.touchscreen != 0 && touchscreen != 0
|
if (touchscreen != 0 && touchscreen != settings.touchscreen) {
|
||||||
&& touchscreen != settings.touchscreen) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (input != 0) {
|
if (input != 0) {
|
||||||
const int keysHidden = inputFlags&MASK_KEYSHIDDEN;
|
const int keysHidden = inputFlags&MASK_KEYSHIDDEN;
|
||||||
const int setKeysHidden = settings.inputFlags&MASK_KEYSHIDDEN;
|
const int setKeysHidden = settings.inputFlags&MASK_KEYSHIDDEN;
|
||||||
if (setKeysHidden != 0 && keysHidden != 0
|
if (keysHidden != 0 && keysHidden != setKeysHidden) {
|
||||||
&& keysHidden != setKeysHidden) {
|
|
||||||
// For compatibility, we count a request for KEYSHIDDEN_NO as also
|
// For compatibility, we count a request for KEYSHIDDEN_NO as also
|
||||||
// matching the more recent KEYSHIDDEN_SOFT. Basically
|
// matching the more recent KEYSHIDDEN_SOFT. Basically
|
||||||
// KEYSHIDDEN_NO means there is some kind of keyboard available.
|
// KEYSHIDDEN_NO means there is some kind of keyboard available.
|
||||||
@@ -1551,36 +1537,29 @@ struct ResTable_config
|
|||||||
}
|
}
|
||||||
const int navHidden = inputFlags&MASK_NAVHIDDEN;
|
const int navHidden = inputFlags&MASK_NAVHIDDEN;
|
||||||
const int setNavHidden = settings.inputFlags&MASK_NAVHIDDEN;
|
const int setNavHidden = settings.inputFlags&MASK_NAVHIDDEN;
|
||||||
if (setNavHidden != 0 && navHidden != 0
|
if (navHidden != 0 && navHidden != setNavHidden) {
|
||||||
&& navHidden != setNavHidden) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (settings.keyboard != 0 && keyboard != 0
|
if (keyboard != 0 && keyboard != settings.keyboard) {
|
||||||
&& keyboard != settings.keyboard) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (settings.navigation != 0 && navigation != 0
|
if (navigation != 0 && navigation != settings.navigation) {
|
||||||
&& navigation != settings.navigation) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (screenSize != 0) {
|
if (screenSize != 0) {
|
||||||
if (settings.screenWidth != 0 && screenWidth != 0
|
if (screenWidth != 0 && screenWidth > settings.screenWidth) {
|
||||||
&& screenWidth > settings.screenWidth) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (settings.screenHeight != 0 && screenHeight != 0
|
if (screenHeight != 0 && screenHeight > settings.screenHeight) {
|
||||||
&& screenHeight > settings.screenHeight) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (version != 0) {
|
if (version != 0) {
|
||||||
if (settings.sdkVersion != 0 && sdkVersion != 0
|
if (sdkVersion != 0 && sdkVersion > settings.sdkVersion) {
|
||||||
&& sdkVersion > settings.sdkVersion) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (settings.minorVersion != 0 && minorVersion != 0
|
if (minorVersion != 0 && minorVersion != settings.minorVersion) {
|
||||||
&& minorVersion != settings.minorVersion) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user