am c058d386: am ff762299: Merge "Small fixes and cleanup of resource config handling." into honeycomb-mr2

* commit 'c058d38602a1ffe00e14b4ab32c876c252eabe6d':
  Small fixes and cleanup of resource config handling.
This commit is contained in:
Dianne Hackborn 2011-05-27 12:47:59 -07:00 committed by Android Git Automerger
commit fff4e3f140

View File

@ -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;
} }
} }