Loading libs/androidfw/ResourceTypes.cpp +44 −28 Original line number Original line Diff line number Diff line Loading @@ -1868,10 +1868,7 @@ void ResTable_config::swapHtoD() { /* static */ inline int compareLocales(const ResTable_config &l, const ResTable_config &r) { /* static */ inline int compareLocales(const ResTable_config &l, const ResTable_config &r) { if (l.locale != r.locale) { if (l.locale != r.locale) { // NOTE: This is the old behaviour with respect to comparison orders. return (l.locale > r.locale) ? 1 : -1; // The diff value here doesn't make much sense (given our bit packing scheme) // but it's stable, and that's all we need. return l.locale - r.locale; } } // The language & region are equal, so compare the scripts and variants. // The language & region are equal, so compare the scripts and variants. Loading @@ -1890,30 +1887,49 @@ void ResTable_config::swapHtoD() { } } int ResTable_config::compare(const ResTable_config& o) const { int ResTable_config::compare(const ResTable_config& o) const { int32_t diff = (int32_t)(imsi - o.imsi); if (imsi != o.imsi) { if (diff != 0) return diff; return (imsi > o.imsi) ? 1 : -1; diff = compareLocales(*this, o); } if (diff != 0) return diff; diff = (int32_t)(screenType - o.screenType); int32_t diff = compareLocales(*this, o); if (diff != 0) return diff; if (diff < 0) { diff = (int32_t)(input - o.input); return -1; if (diff != 0) return diff; } diff = (int32_t)(screenSize - o.screenSize); if (diff > 0) { if (diff != 0) return diff; return 1; diff = (int32_t)(version - o.version); } if (diff != 0) return diff; diff = (int32_t)(screenLayout - o.screenLayout); if (screenType != o.screenType) { if (diff != 0) return diff; return (screenType > o.screenType) ? 1 : -1; diff = (int32_t)(screenLayout2 - o.screenLayout2); } if (diff != 0) return diff; if (input != o.input) { diff = (int32_t)(colorMode - o.colorMode); return (input > o.input) ? 1 : -1; if (diff != 0) return diff; } diff = (int32_t)(uiMode - o.uiMode); if (screenSize != o.screenSize) { if (diff != 0) return diff; return (screenSize > o.screenSize) ? 1 : -1; diff = (int32_t)(smallestScreenWidthDp - o.smallestScreenWidthDp); } if (diff != 0) return diff; if (version != o.version) { diff = (int32_t)(screenSizeDp - o.screenSizeDp); return (version > o.version) ? 1 : -1; return (int)diff; } if (screenLayout != o.screenLayout) { return (screenLayout > o.screenLayout) ? 1 : -1; } if (screenLayout2 != o.screenLayout2) { return (screenLayout2 > o.screenLayout2) ? 1 : -1; } if (colorMode != o.colorMode) { return (colorMode > o.colorMode) ? 1 : -1; } if (uiMode != o.uiMode) { return (uiMode > o.uiMode) ? 1 : -1; } if (smallestScreenWidthDp != o.smallestScreenWidthDp) { return (smallestScreenWidthDp > o.smallestScreenWidthDp) ? 1 : -1; } if (screenSizeDp != o.screenSizeDp) { return (screenSizeDp > o.screenSizeDp) ? 1 : -1; } return 0; } } int ResTable_config::compareLogical(const ResTable_config& o) const { int ResTable_config::compareLogical(const ResTable_config& o) const { Loading Loading
libs/androidfw/ResourceTypes.cpp +44 −28 Original line number Original line Diff line number Diff line Loading @@ -1868,10 +1868,7 @@ void ResTable_config::swapHtoD() { /* static */ inline int compareLocales(const ResTable_config &l, const ResTable_config &r) { /* static */ inline int compareLocales(const ResTable_config &l, const ResTable_config &r) { if (l.locale != r.locale) { if (l.locale != r.locale) { // NOTE: This is the old behaviour with respect to comparison orders. return (l.locale > r.locale) ? 1 : -1; // The diff value here doesn't make much sense (given our bit packing scheme) // but it's stable, and that's all we need. return l.locale - r.locale; } } // The language & region are equal, so compare the scripts and variants. // The language & region are equal, so compare the scripts and variants. Loading @@ -1890,30 +1887,49 @@ void ResTable_config::swapHtoD() { } } int ResTable_config::compare(const ResTable_config& o) const { int ResTable_config::compare(const ResTable_config& o) const { int32_t diff = (int32_t)(imsi - o.imsi); if (imsi != o.imsi) { if (diff != 0) return diff; return (imsi > o.imsi) ? 1 : -1; diff = compareLocales(*this, o); } if (diff != 0) return diff; diff = (int32_t)(screenType - o.screenType); int32_t diff = compareLocales(*this, o); if (diff != 0) return diff; if (diff < 0) { diff = (int32_t)(input - o.input); return -1; if (diff != 0) return diff; } diff = (int32_t)(screenSize - o.screenSize); if (diff > 0) { if (diff != 0) return diff; return 1; diff = (int32_t)(version - o.version); } if (diff != 0) return diff; diff = (int32_t)(screenLayout - o.screenLayout); if (screenType != o.screenType) { if (diff != 0) return diff; return (screenType > o.screenType) ? 1 : -1; diff = (int32_t)(screenLayout2 - o.screenLayout2); } if (diff != 0) return diff; if (input != o.input) { diff = (int32_t)(colorMode - o.colorMode); return (input > o.input) ? 1 : -1; if (diff != 0) return diff; } diff = (int32_t)(uiMode - o.uiMode); if (screenSize != o.screenSize) { if (diff != 0) return diff; return (screenSize > o.screenSize) ? 1 : -1; diff = (int32_t)(smallestScreenWidthDp - o.smallestScreenWidthDp); } if (diff != 0) return diff; if (version != o.version) { diff = (int32_t)(screenSizeDp - o.screenSizeDp); return (version > o.version) ? 1 : -1; return (int)diff; } if (screenLayout != o.screenLayout) { return (screenLayout > o.screenLayout) ? 1 : -1; } if (screenLayout2 != o.screenLayout2) { return (screenLayout2 > o.screenLayout2) ? 1 : -1; } if (colorMode != o.colorMode) { return (colorMode > o.colorMode) ? 1 : -1; } if (uiMode != o.uiMode) { return (uiMode > o.uiMode) ? 1 : -1; } if (smallestScreenWidthDp != o.smallestScreenWidthDp) { return (smallestScreenWidthDp > o.smallestScreenWidthDp) ? 1 : -1; } if (screenSizeDp != o.screenSizeDp) { return (screenSizeDp > o.screenSizeDp) ? 1 : -1; } return 0; } } int ResTable_config::compareLogical(const ResTable_config& o) const { int ResTable_config::compareLogical(const ResTable_config& o) const { Loading