diff options
| author | 2019-11-04 23:51:34 +0800 | |
|---|---|---|
| committer | 2019-11-08 19:28:33 +0800 | |
| commit | fc453e176810855849361b77528bcc3ef41a98c3 (patch) | |
| tree | fa038959360acb06cea0bbff9c533896e7dd45a6 | |
| parent | 6e914e8bafbf19286ce5effd305bf784859f4d64 (diff) | |
[mainline] Expose getTetherApnRequired API as system API
1. getTetherApnRequired API rename to isTetherApnRequired.
2. Expose isTetherApnRequired API as system API.
Bug: 142365448
Test: Build pass.
atest TetheringConfigurationTest (PASS)
Change-Id: Iafb2e4fbddb0251e23673742d990ad098a8ae375
Merged-In: Iafb2e4fbddb0251e23673742d990ad098a8ae375
6 files changed, 17 insertions, 12 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index b31f180d73f3..a95c0ea28116 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -8235,6 +8235,7 @@ package android.telephony { method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isPotentialEmergencyNumber(@NonNull String); method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public boolean isRadioOn(); method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public boolean isRinging(); + method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isTetherApnRequired(); method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public boolean isVideoCallingEnabled(); method @Deprecated @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public boolean isVisualVoicemailEnabled(android.telecom.PhoneAccountHandle); method public boolean needsOtaServiceProvisioning(); diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index fc93fe1cce75..6c0fe46563c4 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -529,7 +529,7 @@ - TYPE_ETHERNET (9) is prepended to this list, and - - the return value of TelephonyManager.getTetherApnRequired() + - the return value of TelephonyManager.isTetherApnRequired() determines how the array is further modified: * TRUE (DUN REQUIRED). diff --git a/packages/Tethering/src/com/android/server/connectivity/tethering/TetheringConfiguration.java b/packages/Tethering/src/com/android/server/connectivity/tethering/TetheringConfiguration.java index 77097271c454..cf0e3b2ddda7 100644 --- a/packages/Tethering/src/com/android/server/connectivity/tethering/TetheringConfiguration.java +++ b/packages/Tethering/src/com/android/server/connectivity/tethering/TetheringConfiguration.java @@ -251,7 +251,7 @@ public class TetheringConfiguration { /** Check whether dun is required. */ public static boolean checkDunRequired(Context ctx, int id) { final TelephonyManager tm = (TelephonyManager) ctx.getSystemService(TELEPHONY_SERVICE); - return (tm != null) ? tm.getTetherApnRequired(id) : false; + return (tm != null) ? tm.isTetherApnRequired(id) : false; } private static Collection<Integer> getUpstreamIfaceTypes(Resources res, boolean dunRequired) { diff --git a/packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/TetheringConfigurationTest.java b/packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/TetheringConfigurationTest.java index 9f9221f3010d..9c65c0deed07 100644 --- a/packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/TetheringConfigurationTest.java +++ b/packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/TetheringConfigurationTest.java @@ -145,7 +145,7 @@ public class TetheringConfigurationTest { @Test public void testDunFromTelephonyManagerMeansDun() { - when(mTelephonyManager.getTetherApnRequired(anyInt())).thenReturn(true); + when(mTelephonyManager.isTetherApnRequired(anyInt())).thenReturn(true); final TetheringConfiguration cfgWifi = getTetheringConfiguration(TYPE_WIFI); final TetheringConfiguration cfgMobileWifiHipri = getTetheringConfiguration( @@ -169,7 +169,7 @@ public class TetheringConfigurationTest { @Test public void testDunNotRequiredFromTelephonyManagerMeansNoDun() { - when(mTelephonyManager.getTetherApnRequired(anyInt())).thenReturn(false); + when(mTelephonyManager.isTetherApnRequired(anyInt())).thenReturn(false); final TetheringConfiguration cfgWifi = getTetheringConfiguration(TYPE_WIFI); final TetheringConfiguration cfgMobileWifiHipri = getTetheringConfiguration( @@ -212,7 +212,7 @@ public class TetheringConfigurationTest { @Test public void testNoDefinedUpstreamTypesAddsEthernet() { when(mResources.getIntArray(config_tether_upstream_types)).thenReturn(new int[]{}); - when(mTelephonyManager.getTetherApnRequired(anyInt())).thenReturn(false); + when(mTelephonyManager.isTetherApnRequired(anyInt())).thenReturn(false); final TetheringConfiguration cfg = new TetheringConfiguration( mMockContext, mLog, INVALID_SUBSCRIPTION_ID); @@ -235,7 +235,7 @@ public class TetheringConfigurationTest { public void testDefinedUpstreamTypesSansEthernetAddsEthernet() { when(mResources.getIntArray(config_tether_upstream_types)).thenReturn( new int[]{TYPE_WIFI, TYPE_MOBILE_HIPRI}); - when(mTelephonyManager.getTetherApnRequired(anyInt())).thenReturn(false); + when(mTelephonyManager.isTetherApnRequired(anyInt())).thenReturn(false); final TetheringConfiguration cfg = new TetheringConfiguration( mMockContext, mLog, INVALID_SUBSCRIPTION_ID); @@ -253,7 +253,7 @@ public class TetheringConfigurationTest { public void testDefinedUpstreamTypesWithEthernetDoesNotAddEthernet() { when(mResources.getIntArray(config_tether_upstream_types)) .thenReturn(new int[]{TYPE_WIFI, TYPE_ETHERNET, TYPE_MOBILE_HIPRI}); - when(mTelephonyManager.getTetherApnRequired(anyInt())).thenReturn(false); + when(mTelephonyManager.isTetherApnRequired(anyInt())).thenReturn(false); final TetheringConfiguration cfg = new TetheringConfiguration( mMockContext, mLog, INVALID_SUBSCRIPTION_ID); diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 63cd51189de9..4348e8833e35 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -7634,12 +7634,16 @@ public class TelephonyManager { /** * Check whether DUN APN is required for tethering. + * <p> + * Requires Permission: READ_PRIVILEGED_PHONE_STATE. * * @return {@code true} if DUN APN is required for tethering. * @hide */ - public boolean getTetherApnRequired() { - return getTetherApnRequired(getSubId(SubscriptionManager.getActiveDataSubscriptionId())); + @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) + @SystemApi + public boolean isTetherApnRequired() { + return isTetherApnRequired(getSubId(SubscriptionManager.getActiveDataSubscriptionId())); } /** @@ -7649,11 +7653,11 @@ public class TelephonyManager { * @return {@code true} if DUN APN is required for tethering. * @hide */ - public boolean getTetherApnRequired(int subId) { + public boolean isTetherApnRequired(int subId) { try { ITelephony telephony = getITelephony(); if (telephony != null) - return telephony.getTetherApnRequiredForSubscriber(subId); + return telephony.isTetherApnRequiredForSubscriber(subId); } catch (RemoteException ex) { Rlog.e(TAG, "hasMatchedTetherApnSetting RemoteException", ex); } catch (NullPointerException ex) { diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 414693ef6362..5619fe5f9b3d 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -817,7 +817,7 @@ interface ITelephony { * @return {@code true} if DUN APN is required for tethering. * @hide */ - boolean getTetherApnRequiredForSubscriber(int subId); + boolean isTetherApnRequiredForSubscriber(int subId); /** * Enables framework IMS and triggers IMS Registration. |