diff options
3 files changed, 21 insertions, 9 deletions
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/ScannerTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/ScannerTest.java index 2191b0c75cb..85899f3f3c0 100644 --- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/ScannerTest.java +++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/ScannerTest.java @@ -5694,7 +5694,9 @@ public class ScannerTest extends TestCase { } // http://code.google.com/p/android/issues/detail?id=57050 - public void testPerformance() throws Exception { + // Disable this test since it causes oom failures in follow on + // tests. See b/160171148 for details. + public void disableTestPerformance() throws Exception { int count = 100000; ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -5739,5 +5741,6 @@ public class ScannerTest extends TestCase { fail(); } } + System.gc(); } } diff --git a/luni/src/main/java/libcore/icu/LocaleData.java b/luni/src/main/java/libcore/icu/LocaleData.java index 3e4e1d7b386..12b978de154 100644 --- a/luni/src/main/java/libcore/icu/LocaleData.java +++ b/luni/src/main/java/libcore/icu/LocaleData.java @@ -25,6 +25,8 @@ import android.icu.impl.ICUResourceBundle; import android.icu.text.NumberingSystem; import android.icu.util.UResourceBundle; +import dalvik.system.VMRuntime; + import java.text.DateFormat; import java.util.HashMap; import java.util.Locale; @@ -71,6 +73,9 @@ public final class LocaleData { * * Note that Locale.ROOT is used as language/country neutral locale or fallback locale, * and does not guarantee to represent English locale. + * + * This flag is only for documentation and can't be overridden by app. Please use + * {@code targetSdkVersion} to enable the new behavior. */ @ChangeId @EnabledAfter(targetSdkVersion=29 /* Android Q */) @@ -215,10 +220,14 @@ public final class LocaleData { * @return a compatible locale for the bug b/159514442 */ public static Locale getCompatibleLocaleForBug159514442(Locale locale) { - if (Locale.ROOT.equals(locale) && - // isChangeEnabled() always returns true in non-app process - !Compatibility.isChangeEnabled(USE_REAL_ROOT_LOCALE)) { - locale = LOCALE_EN_US_POSIX; + if (Locale.ROOT.equals(locale)) { + int targetSdkVersion = VMRuntime.getRuntime().getTargetSdkVersion(); + // Don't use Compatibility.isChangeEnabled(USE_REAL_ROOT_LOCALE) because the app compat + // framework lives in libcore and can depend on this class via various format methods, + // e.g. String.format(). See b/160912695. + if (targetSdkVersion <= 29 /* Android Q */) { + locale = LOCALE_EN_US_POSIX; + } } return locale; } diff --git a/luni/src/test/java/libcore/libcore/icu/LocaleDataTest.java b/luni/src/test/java/libcore/libcore/icu/LocaleDataTest.java index 60572a0bc91..eace2333c98 100644 --- a/luni/src/test/java/libcore/libcore/icu/LocaleDataTest.java +++ b/luni/src/test/java/libcore/libcore/icu/LocaleDataTest.java @@ -32,7 +32,7 @@ import java.util.Locale; import java.util.TimeZone; import libcore.icu.LocaleData; -import libcore.junit.util.compat.CoreCompatChangeRule; +import libcore.junit.util.SwitchTargetSdkVersionRule; import org.junit.Rule; import org.junit.Test; @@ -44,7 +44,7 @@ import org.junit.runners.JUnit4; public class LocaleDataTest { @Rule - public TestRule compatChangeRule = new CoreCompatChangeRule(); + public TestRule switchTargetSdkVersionRule = SwitchTargetSdkVersionRule.getInstance(); @Test public void testAll() throws Exception { @@ -191,7 +191,7 @@ public class LocaleDataTest { // Test for b/159514442 @Test - @CoreCompatChangeRule.EnableCompatChanges({LocaleData.USE_REAL_ROOT_LOCALE}) + @SwitchTargetSdkVersionRule.TargetSdkVersion(30) public void test_rootLocale_useRealRootLocaleData() { assertRootDataEqualsToTargetLocaleData(Locale.ROOT); @@ -203,7 +203,7 @@ public class LocaleDataTest { // Test for b/159514442 @Test - @CoreCompatChangeRule.DisableCompatChanges({LocaleData.USE_REAL_ROOT_LOCALE}) + @SwitchTargetSdkVersionRule.TargetSdkVersion(29) public void test_rootLocale_notUseRealRootLocaleData() { Locale LOCALE_EN_US_POSIX = new Locale("en", "US", "POSIX"); assertRootDataEqualsToTargetLocaleData(LOCALE_EN_US_POSIX); |