diff options
7 files changed, 115 insertions, 35 deletions
diff --git a/core/java/android/app/UiModeManager.java b/core/java/android/app/UiModeManager.java index 7903f1c0c5c3..f2b0d65bd259 100644 --- a/core/java/android/app/UiModeManager.java +++ b/core/java/android/app/UiModeManager.java @@ -708,7 +708,7 @@ public class UiModeManager { * <p> * The mode can be one of: * <ul> - * <li><em>{@link #MODE_NIGHT_NO}<em> sets the device into + * <li><em>{@link #MODE_NIGHT_NO}</em> sets the device into * {@code notnight} mode</li> * <li><em>{@link #MODE_NIGHT_YES}</em> sets the device into * {@code night} mode</li> @@ -844,7 +844,7 @@ public class UiModeManager { * <p> * The mode can be one of: * <ul> - * <li><em>{@link #MODE_NIGHT_NO}<em> sets the device into + * <li><em>{@link #MODE_NIGHT_NO}</em> sets the device into * {@code notnight} mode</li> * <li><em>{@link #MODE_NIGHT_YES}</em> sets the device into * {@code night} mode</li> diff --git a/core/java/com/android/internal/ravenwood/RavenwoodEnvironment.java b/core/java/com/android/internal/ravenwood/RavenwoodEnvironment.java index 8df3f2abcafd..e522b508b44b 100644 --- a/core/java/com/android/internal/ravenwood/RavenwoodEnvironment.java +++ b/core/java/com/android/internal/ravenwood/RavenwoodEnvironment.java @@ -94,14 +94,21 @@ public final class RavenwoodEnvironment { /** Used for testing */ @Disabled - @ChangeId public static final long TEST_COMPAT_ID_2 = 368131701L; + @ChangeId + public static final long TEST_COMPAT_ID_2 = 368131701L; /** Used for testing */ @EnabledAfter(targetSdkVersion = S) - @ChangeId public static final long TEST_COMPAT_ID_3 = 368131659L; + @ChangeId + public static final long TEST_COMPAT_ID_3 = 368131659L; /** Used for testing */ @EnabledAfter(targetSdkVersion = UPSIDE_DOWN_CAKE) - @ChangeId public static final long TEST_COMPAT_ID_4 = 368132057L; + @ChangeId + public static final long TEST_COMPAT_ID_4 = 368132057L; + + /** Used for testing */ + @ChangeId + public static final long TEST_COMPAT_ID_5 = 387558811L; } } diff --git a/core/res/res/xml/sms_short_codes.xml b/core/res/res/xml/sms_short_codes.xml index bb5380e1312d..06cd44e6544d 100644 --- a/core/res/res/xml/sms_short_codes.xml +++ b/core/res/res/xml/sms_short_codes.xml @@ -34,7 +34,7 @@ http://smscoin.net/software/engine/WordPress/Paid+SMS-registration/ --> <!-- Arab Emirates --> - <shortcode country="ae" pattern="\\d{1,5}" free="1017|1355|3214|6253|6568" /> + <shortcode country="ae" pattern="\\d{1,5}" free="1017|1355|3214|6253|6568|999" /> <!-- Albania: 5 digits, known short codes listed --> <shortcode country="al" pattern="\\d{5}" premium="15191|55[56]00" /> @@ -63,8 +63,8 @@ <!-- Burkina Faso: 1-4 digits (standard system default, not country specific) --> <shortcode country="bf" pattern="\\d{1,4}" free="3558" /> - <!-- Bulgaria: 4-5 digits, plus EU --> - <shortcode country="bg" pattern="\\d{4,5}" premium="18(?:16|423)|19(?:1[56]|35)" free="116\\d{3}|1988|1490" /> + <!-- Bulgaria: 4-6 digits, plus EU --> + <shortcode country="bg" pattern="\\d{4,6}" premium="18(?:16|423)|19(?:1[56]|35)" free="116\\d{3}|1988|1490|162055" /> <!-- Bahrain: 1-5 digits (standard system default, not country specific) --> <shortcode country="bh" pattern="\\d{1,5}" free="81181|85999" /> @@ -81,18 +81,21 @@ <!-- Canada: 5-6 digits --> <shortcode country="ca" pattern="\\d{5,6}" premium="60999|88188|43030" standard="244444" free="455677|24470" /> + <!-- DR Congo: 1-6 digits, known premium codes listed --> + <shortcode country="cd" pattern="\\d{1,6}" free="444123" /> + <!-- Switzerland: 3-5 digits: http://www.swisscom.ch/fxres/kmu/thirdpartybusiness_code_of_conduct_en.pdf --> <shortcode country="ch" pattern="[2-9]\\d{2,4}" premium="543|83111|30118" free="98765|30075|30047" /> <!-- Chile: 4-5 digits (not confirmed), known premium codes listed --> - <shortcode country="cl" pattern="\\d{4,5}" free="9963|9240|1038" /> + <shortcode country="cl" pattern="\\d{4,5}" free="9963|9240|1038|4848" /> <!-- China: premium shortcodes start with "1066", free shortcodes start with "1065": http://clients.txtnation.com/entries/197192-china-premium-sms-short-code-requirements --> <shortcode country="cn" premium="1066.*" free="1065.*" /> <!-- Colombia: 1-6 digits (not confirmed) --> - <shortcode country="co" pattern="\\d{1,6}" free="890350|908160|892255|898002|898880|899960|899948|87739|85517|491289" /> + <shortcode country="co" pattern="\\d{1,6}" free="890350|908160|892255|898002|898880|899960|899948|87739|85517|491289|890119" /> <!-- Costa Rica --> <shortcode country="cr" pattern="\\d{1,6}" free="466453" /> @@ -116,6 +119,9 @@ <!-- Dominican Republic: 1-6 digits (standard system default, not country specific) --> <shortcode country="do" pattern="\\d{1,6}" free="912892|912" /> + <!-- Algeria: 1-5 digits, known premium codes listed --> + <shortcode country="dz" pattern="\\d{1,5}" free="63071" /> + <!-- Ecuador: 1-6 digits (standard system default, not country specific) --> <shortcode country="ec" pattern="\\d{1,6}" free="466453|18512" /> @@ -123,20 +129,23 @@ http://www.tja.ee/public/documents/Elektrooniline_side/Oigusaktid/ENG/Estonian_Numbering_Plan_annex_06_09_2010.mht --> <shortcode country="ee" pattern="1\\d{2,4}" premium="90\\d{5}|15330|1701[0-3]" free="116\\d{3}|95034" /> - <!-- Egypt: 4-5 digits, known codes listed --> - <shortcode country="eg" pattern="\\d{4,5}" free="1499|10020" /> + <!-- Egypt: 4-6 digits, known codes listed --> + <shortcode country="eg" pattern="\\d{4,6}" free="1499|10020|100158" /> <!-- Spain: 5-6 digits: 25xxx, 27xxx, 280xx, 35xxx, 37xxx, 795xxx, 797xxx, 995xxx, 997xxx, plus EU. http://www.legallink.es/?q=en/content/which-current-regulatory-status-premium-rate-services-spain --> <shortcode country="es" premium="[23][57]\\d{3}|280\\d{2}|[79]9[57]\\d{3}" free="116\\d{3}|22791|222145|22189" /> + <!-- Ethiopia: 1-4 digits, known codes listed --> + <shortcode country="et" pattern="\\d{1,4}" free="8527" /> + <!-- Finland: 5-6 digits, premium 0600, 0700: http://en.wikipedia.org/wiki/Telephone_numbers_in_Finland --> <shortcode country="fi" pattern="\\d{5,6}" premium="0600.*|0700.*|171(?:59|63)" free="116\\d{3}|14789|17110" /> <!-- France: 5 digits, free: 3xxxx, premium [4-8]xxxx, plus EU: http://clients.txtnation.com/entries/161972-france-premium-sms-short-code-requirements, visual voicemail code for Orange: 21101 --> - <shortcode country="fr" premium="[4-8]\\d{4}" free="3\\d{4}|116\\d{3}|21101|20366|555|2051|33033" /> + <shortcode country="fr" premium="[4-8]\\d{4}" free="3\\d{4}|116\\d{3}|21101|20366|555|2051|33033|21727" /> <!-- United Kingdom (Great Britain): 4-6 digits, common codes [5-8]xxxx, plus EU: http://www.short-codes.com/media/Co-regulatoryCodeofPracticeforcommonshortcodes170206.pdf, @@ -179,17 +188,17 @@ <shortcode country="il" pattern="\\d{1,5}" premium="4422|4545" free="37477|6681" /> <!-- Iran: 4-8 digits, known premium codes listed --> - <shortcode country="ir" pattern="\\d{4,8}" free="700791|700792|100016|30008360" /> + <shortcode country="ir" pattern="\\d{4,8}" free="700792|100016|30008360" /> <!-- Italy: 5 digits (premium=41xxx,42xxx), plus EU: https://www.itu.int/dms_pub/itu-t/oth/02/02/T020200006B0001PDFE.pdf --> <shortcode country="it" pattern="\\d{5}" premium="44[0-4]\\d{2}|47[0-4]\\d{2}|48[0-4]\\d{2}|44[5-9]\\d{4}|47[5-9]\\d{4}|48[5-9]\\d{4}|455\\d{2}|499\\d{2}" free="116\\d{3}|4112503|40\\d{0,12}" standard="430\\d{2}|431\\d{2}|434\\d{4}|435\\d{4}|439\\d{7}" /> <!-- Jordan: 1-5 digits (standard system default, not country specific) --> - <shortcode country="jo" pattern="\\d{1,5}" free="99066" /> + <shortcode country="jo" pattern="\\d{1,5}" free="99066|99390" /> <!-- Japan: 8083 used by SOFTBANK_DCB_2 --> - <shortcode country="jp" pattern="\\d{1,5}" free="8083" /> + <shortcode country="jp" pattern="\\d{1,9}" free="8083|00050320" /> <!-- Kenya: 5 digits, known premium codes listed --> <shortcode country="ke" pattern="\\d{5}" free="21725|21562|40520|23342|40023|24088|23054" /> @@ -206,6 +215,9 @@ <!-- Kuwait: 1-5 digits (standard system default, not country specific) --> <shortcode country="kw" pattern="\\d{1,5}" free="1378|50420|94006|55991|50976|7112" /> + <!-- Lesotho: 4-5 digits, known codes listed --> + <shortcode country="ls" pattern="\\d{4,5}" free="32012" /> + <!-- Lithuania: 3-5 digits, known premium codes listed, plus EU --> <shortcode country="lt" pattern="\\d{3,5}" premium="13[89]1|1394|16[34]5" free="116\\d{3}|1399|1324" /> @@ -222,11 +234,14 @@ <!-- Macedonia: 1-6 digits (not confirmed), known premium codes listed --> <shortcode country="mk" pattern="\\d{1,6}" free="129005|122" /> + <!-- Mali: 1-5 digits, known codes listed --> + <shortcode country="ml" pattern="\\d{1,5}" free="36098" /> + <!-- Mongolia : 1-6 digits (standard system default, not country specific) --> <shortcode country="mn" pattern="\\d{1,6}" free="44444|45678|445566" /> <!-- Malawi: 1-5 digits (standard system default, not country specific) --> - <shortcode country="mw" pattern="\\d{1,5}" free="4276|4305" /> + <shortcode country="mw" pattern="\\d{1,5}" free="4276|4305|4326" /> <!-- Mozambique: 1-5 digits (standard system default, not country specific) --> <shortcode country="mz" pattern="\\d{1,5}" free="1714" /> @@ -323,11 +338,14 @@ <!-- Tajikistan: 4 digits, known premium codes listed --> <shortcode country="tj" pattern="\\d{4}" premium="11[3-7]1|4161|4333|444[689]" /> + <!-- Timor-Leste 1-5 digits, known codes listed --> + <shortcode country="tl" pattern="\\d{1,5}" free="46645" /> + <!-- Tanzania: 1-5 digits (standard system default, not country specific) --> - <shortcode country="tz" pattern="\\d{1,5}" free="15046|15234|15324|15610" /> + <shortcode country="tz" pattern="\\d{1,5}" free="15046|15324|15610" /> - <!-- Tunisia: 5 digits, known premium codes listed --> - <shortcode country="tn" pattern="\\d{5}" free="85799" /> + <!-- Tunisia: 1-6 digits, known premium codes listed --> + <shortcode country="tn" pattern="\\d{1,6}" free="85799|772024" /> <!-- Turkey --> <shortcode country="tr" pattern="\\d{1,5}" free="7529|5528|6493|3193" /> @@ -336,7 +354,7 @@ <shortcode country="ua" pattern="\\d{4}" premium="444[3-9]|70[579]4|7540" /> <!-- Uganda(UG): 4 digits (standard system default, not country specific) --> - <shortcode country="ug" pattern="\\d{4}" free="8000|8009" /> + <shortcode country="ug" pattern="\\d{4}" free="8009" /> <!-- USA: 5-6 digits (premium codes from https://www.premiumsmsrefunds.com/ShortCodes.htm), visual voicemail code for T-Mobile: 122 --> @@ -349,7 +367,7 @@ <shortcode country="ve" pattern="\\d{1,6}" free="538352" /> <!-- Vietnam: 1-6 digits (standard system default, not country specific) --> - <shortcode country="vn" pattern="\\d{1,6}" free="5001|9055|8079|90002|118989" /> + <shortcode country="vn" pattern="\\d{1,6}" free="5001|9055|90002|118989|46645" /> <!-- Mayotte (French Territory): 1-5 digits (not confirmed) --> <shortcode country="yt" pattern="\\d{1,5}" free="38600,36300,36303,959" /> diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java index 36f62da651db..c9625c405faa 100644 --- a/media/java/android/media/MediaCodec.java +++ b/media/java/android/media/MediaCodec.java @@ -5866,19 +5866,31 @@ final public class MediaCodec { @NonNull MediaCodec codec, @NonNull MediaFormat format); /** - * Called when the metrics for this codec have been flushed due to the - * start of a new subsession. + * Called when the metrics for this codec have been flushed "mid-stream" + * due to the start of a new subsession during execution. * <p> - * This can happen when the codec is reconfigured after stop(), or - * mid-stream e.g. if the video size changes. When this happens, the - * metrics for the previous subsession are flushed, and - * {@link MediaCodec#getMetrics} will return the metrics for the - * new subsession. This happens just before the {@link Callback#onOutputFormatChanged} + * A new codec subsession normally starts when the codec is reconfigured + * after stop(), but it can also happen mid-stream e.g. if the video size + * changes. When this happens, the metrics for the previous subsession + * are flushed, and {@link MediaCodec#getMetrics} will return the metrics + * for the new subsession. + * <p> + * For subsessions that begin due to a reconfiguration, the metrics for + * the prior subsession can be retrieved via {@link MediaCodec#getMetrics} + * prior to calling {@link #configure}. + * <p> + * When a new subsession begins "mid-stream", the metrics for the prior + * subsession are flushed just before the {@link Callback#onOutputFormatChanged} * event, so this <b>optional</b> callback is provided to be able to * capture the final metrics for the previous subsession. * * @param codec The MediaCodec object. - * @param metrics The flushed metrics for this codec. + * @param metrics The flushed metrics for this codec. This is a + * {@link PersistableBundle} containing the set of + * attributes and values available for the media being + * handled by this instance of MediaCodec. The attributes + * are described in {@link MetricsConstants}. Additional + * vendor-specific fields may also be present. */ @FlaggedApi(FLAG_SUBSESSION_METRICS) public void onMetricsFlushed( diff --git a/ravenwood/tests/bivalenttest/Android.bp b/ravenwood/tests/bivalenttest/Android.bp index ac545dfb06cc..c4086c5b3835 100644 --- a/ravenwood/tests/bivalenttest/Android.bp +++ b/ravenwood/tests/bivalenttest/Android.bp @@ -40,6 +40,7 @@ java_defaults { "junit-params", "platform-parametric-runner-lib", + "platform-compat-test-rules", // To make sure it won't cause VerifyError (b/324063814) "platformprotosnano", diff --git a/ravenwood/tests/bivalenttest/test/com/android/ravenwoodtest/bivalenttest/compat/RavenwoodCompatFrameworkTest.kt b/ravenwood/tests/bivalenttest/test/com/android/ravenwoodtest/bivalenttest/compat/RavenwoodCompatFrameworkTest.kt index 882c91c43ee9..540b0822319c 100644 --- a/ravenwood/tests/bivalenttest/test/com/android/ravenwoodtest/bivalenttest/compat/RavenwoodCompatFrameworkTest.kt +++ b/ravenwood/tests/bivalenttest/test/com/android/ravenwoodtest/bivalenttest/compat/RavenwoodCompatFrameworkTest.kt @@ -16,31 +16,52 @@ package com.android.ravenwoodtest.bivalenttest.compat import android.app.compat.CompatChanges +import android.compat.testing.PlatformCompatChangeRule import androidx.test.ext.junit.runners.AndroidJUnit4 import com.android.internal.ravenwood.RavenwoodEnvironment.CompatIdsForTest -import org.junit.Assert +import libcore.junit.util.compat.CoreCompatChangeRule.DisableCompatChanges +import libcore.junit.util.compat.CoreCompatChangeRule.EnableCompatChanges +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class RavenwoodCompatFrameworkTest { + + @get:Rule + val compatRule = PlatformCompatChangeRule() + @Test fun testEnabled() { - Assert.assertTrue(CompatChanges.isChangeEnabled(CompatIdsForTest.TEST_COMPAT_ID_1)) + assertTrue(CompatChanges.isChangeEnabled(CompatIdsForTest.TEST_COMPAT_ID_1)) } @Test fun testDisabled() { - Assert.assertFalse(CompatChanges.isChangeEnabled(CompatIdsForTest.TEST_COMPAT_ID_2)) + assertFalse(CompatChanges.isChangeEnabled(CompatIdsForTest.TEST_COMPAT_ID_2)) } @Test fun testEnabledAfterSForUApps() { - Assert.assertTrue(CompatChanges.isChangeEnabled(CompatIdsForTest.TEST_COMPAT_ID_3)) + assertTrue(CompatChanges.isChangeEnabled(CompatIdsForTest.TEST_COMPAT_ID_3)) } @Test fun testEnabledAfterUForUApps() { - Assert.assertFalse(CompatChanges.isChangeEnabled(CompatIdsForTest.TEST_COMPAT_ID_4)) + assertFalse(CompatChanges.isChangeEnabled(CompatIdsForTest.TEST_COMPAT_ID_4)) + } + + @Test + @EnableCompatChanges(CompatIdsForTest.TEST_COMPAT_ID_5) + fun testEnableCompatChanges() { + assertTrue(CompatChanges.isChangeEnabled(CompatIdsForTest.TEST_COMPAT_ID_5)) + } + + @Test + @DisableCompatChanges(CompatIdsForTest.TEST_COMPAT_ID_5) + fun testDisableCompatChanges() { + assertFalse(CompatChanges.isChangeEnabled(CompatIdsForTest.TEST_COMPAT_ID_5)) } } diff --git a/services/core/java/com/android/server/compat/CompatConfig.java b/services/core/java/com/android/server/compat/CompatConfig.java index e89f43bd7196..20c33275b8f1 100644 --- a/services/core/java/com/android/server/compat/CompatConfig.java +++ b/services/core/java/com/android/server/compat/CompatConfig.java @@ -876,7 +876,28 @@ final class CompatConfig { } @Nullable + @android.ravenwood.annotation.RavenwoodReplace( + blockedBy = PackageManager.class, + reason = "PackageManager.getApplicationInfo() isn't supported yet") private Long getVersionCodeOrNull(String packageName) { + return getVersionCodeOrNullImpl(packageName); + } + + @SuppressWarnings("unused") + @Nullable + private Long getVersionCodeOrNull$ravenwood(String packageName) { + try { + // It's possible that the context is mocked, try the real method first + return getVersionCodeOrNullImpl(packageName); + } catch (Throwable e) { + // For now, Ravenwood doesn't support the concept of "app updates", so let's + // just use a fixed version code for all packages. + return 1L; + } + } + + @Nullable + private Long getVersionCodeOrNullImpl(String packageName) { try { ApplicationInfo applicationInfo = mContext.getPackageManager().getApplicationInfo( packageName, MATCH_ANY_USER); |