From 9ae1afee27631aee9ed946071f78267e8d8f3e4c Mon Sep 17 00:00:00 2001 From: Shuo Qian Date: Tue, 3 Mar 2020 19:51:13 -0800 Subject: [PATCH] API Council Feedbacks 1) Update doc of ACTION_UPDATE_EMERGENCY_NUMBER_DB 2) Add new APIs EXTRA_VERSION and EXTRA_REQUIRED_HASH 3) Rename isDataConnectionEnabled to IsDataConnectionAllowed 4) Format the API documentations with html format 5) Throw errors for shutdownAllRadios, isAnyRadioPoweredOn 6) Modify the doc of TelephonyManager.getEmergencyNumberDbVersion 7) Add UPDATE_CONFIG permission for ACTION_UPDATE_EMERGENCY_NUMBER_DB Test: Treehugger; Manual made a call; make -j offline-sdk-docs Bug: 147696692 Bug: 147805285 Bug: 148217670 Bug: 148218347 Change-Id: Idf3dee3de5ebf75ca8b8fbaaf879e69f7ae4b754 Merged-In: Idf3dee3de5ebf75ca8b8fbaaf879e69f7ae4b754 (cherry picked from commit dc86120fca73df7a77dfc978bef78a2956c15eb7) --- api/system-current.txt | 8 +- api/test-current.txt | 2 +- core/java/android/os/ConfigUpdate.java | 31 +++++-- .../policy/MobileSignalController.java | 2 +- .../policy/NetworkControllerBaseTest.java | 2 +- .../policy/NetworkControllerDataTest.java | 12 +-- .../telephony/CarrierConfigManager.java | 89 ++++++++++--------- .../android/telephony/TelephonyManager.java | 37 ++++---- 8 files changed, 107 insertions(+), 76 deletions(-) diff --git a/api/system-current.txt b/api/system-current.txt index 7646373925a42..8f8ccdf8481dd 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -5982,13 +5982,15 @@ package android.os { field public static final String ACTION_UPDATE_CARRIER_PROVISIONING_URLS = "android.intent.action.UPDATE_CARRIER_PROVISIONING_URLS"; field public static final String ACTION_UPDATE_CONVERSATION_ACTIONS = "android.intent.action.UPDATE_CONVERSATION_ACTIONS"; field public static final String ACTION_UPDATE_CT_LOGS = "android.intent.action.UPDATE_CT_LOGS"; - field public static final String ACTION_UPDATE_EMERGENCY_NUMBER_DB = "android.os.action.UPDATE_EMERGENCY_NUMBER_DB"; + field @RequiresPermission("android.permission.UPDATE_CONFIG") public static final String ACTION_UPDATE_EMERGENCY_NUMBER_DB = "android.os.action.UPDATE_EMERGENCY_NUMBER_DB"; field public static final String ACTION_UPDATE_INTENT_FIREWALL = "android.intent.action.UPDATE_INTENT_FIREWALL"; field public static final String ACTION_UPDATE_LANG_ID = "android.intent.action.UPDATE_LANG_ID"; field public static final String ACTION_UPDATE_NETWORK_WATCHLIST = "android.intent.action.UPDATE_NETWORK_WATCHLIST"; field public static final String ACTION_UPDATE_PINS = "android.intent.action.UPDATE_PINS"; field public static final String ACTION_UPDATE_SMART_SELECTION = "android.intent.action.UPDATE_SMART_SELECTION"; field public static final String ACTION_UPDATE_SMS_SHORT_CODES = "android.intent.action.UPDATE_SMS_SHORT_CODES"; + field public static final String EXTRA_REQUIRED_HASH = "android.os.extra.REQUIRED_HASH"; + field public static final String EXTRA_VERSION = "android.os.extra.VERSION"; } public class Environment { @@ -9361,7 +9363,7 @@ package android.telephony { method @NonNull public java.util.List getDevicePolicyOverrideApns(@NonNull android.content.Context); method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getDeviceSoftwareVersion(int); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean getEmergencyCallbackMode(); - method public int getEmergencyNumberDbVersion(); + method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getEmergencyNumberDbVersion(); method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getIsimDomain(); method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String[] getIsimImpu(); method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getIsimIst(); @@ -9391,7 +9393,7 @@ package android.telephony { method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isApplicationOnUicc(int); method public boolean isCurrentSimOperator(@NonNull String, int, @Nullable String); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isDataAllowedInVoiceCall(); - method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isDataConnectionEnabled(); + method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isDataConnectionAllowed(); method public boolean isDataConnectivityPossible(); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isDataEnabledForApn(int); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isEmergencyAssistanceEnabled(); diff --git a/api/test-current.txt b/api/test-current.txt index 0c7db06bc0ba0..d316b3584e0e9 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -3244,7 +3244,7 @@ package android.telephony { method public java.util.List getCarrierPackageNamesForIntent(android.content.Intent); method @Nullable public static android.content.ComponentName getDefaultRespondViaMessageApplication(@NonNull android.content.Context, boolean); method @NonNull public java.util.List getDevicePolicyOverrideApns(@NonNull android.content.Context); - method public int getEmergencyNumberDbVersion(); + method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public int getEmergencyNumberDbVersion(); method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getLine1AlphaTag(); method @NonNull @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public String getNetworkCountryIso(int); method public android.util.Pair getRadioHalVersion(); diff --git a/core/java/android/os/ConfigUpdate.java b/core/java/android/os/ConfigUpdate.java index 9c999b2027976..590fbb36a0e86 100644 --- a/core/java/android/os/ConfigUpdate.java +++ b/core/java/android/os/ConfigUpdate.java @@ -16,6 +16,7 @@ package android.os; +import android.annotation.RequiresPermission; import android.annotation.SystemApi; /** @@ -114,20 +115,36 @@ public final class ConfigUpdate { = "android.os.action.UPDATE_CARRIER_ID_DB"; /** - * Broadcast intent action indicating that the updated emergency number database is available. - *

Extra: "VERSION" the numeric version of the new data. Devices should only install if the - * update version is newer than the current one. - *

Extra: "REQUIRED_HASH" the hash of the current update data. - *

Input: {@link android.content.Intent#getData} is URI of downloaded emergency number file. - * Devices should pick up the downloaded file and persist to the database - * {@code com.android.internal.telephony.emergency.EmergencyNumberTracker}. + * Update the emergency number database into the devices. + *

Extra: {@link #EXTRA_VERSION} the numeric version of the database. + *

Extra: {@link #EXTRA_REQUIRED_HASH} the hash of the database. + *

Input: {@link android.content.Intent#getData} the URI to download emergency number + * database. * * @hide */ @SystemApi + @RequiresPermission(android.Manifest.permission.UPDATE_CONFIG) public static final String ACTION_UPDATE_EMERGENCY_NUMBER_DB = "android.os.action.UPDATE_EMERGENCY_NUMBER_DB"; + /** + * An integer to indicate the numeric version of the new data. Devices should only install + * if the update version is newer than the current one. + * + * @hide + */ + @SystemApi + public static final String EXTRA_VERSION = "android.os.extra.VERSION"; + + /** + * A string to indicate the hash of the data. + * + * @hide + */ + @SystemApi + public static final String EXTRA_REQUIRED_HASH = "android.os.extra.REQUIRED_HASH"; + private ConfigUpdate() { } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java index 7892381ae19fb..48534f6c985a9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java @@ -577,7 +577,7 @@ public class MobileSignalController extends SignalController< } boolean isDataDisabled() { - return !mPhone.isDataConnectionEnabled(); + return !mPhone.isDataConnectionAllowed(); } @VisibleForTesting diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java index 264905483ddc3..698185fe51544 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java @@ -176,7 +176,7 @@ public class NetworkControllerBaseTest extends SysuiTestCase { protected void setupNetworkController() { // For now just pretend to be the data sim, so we can test that too. mSubId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID; - when(mMockTm.isDataConnectionEnabled()).thenReturn(true); + when(mMockTm.isDataConnectionAllowed()).thenReturn(true); setDefaultSubId(mSubId); setSubscriptions(mSubId); mMobileSignalController = mNetworkController.mMobileSignalControllers.get(mSubId); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java index 6b02ff01aafa8..bac1b8ca240c0 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java @@ -119,7 +119,7 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest { @Test public void testNoInternetIcon_withDefaultSub() { setupNetworkController(); - when(mMockTm.isDataConnectionEnabled()).thenReturn(false); + when(mMockTm.isDataConnectionAllowed()).thenReturn(false); setupDefaultSignal(); updateDataConnectionState(TelephonyManager.DATA_CONNECTED, 0); setConnectivityViaBroadcast(NetworkCapabilities.TRANSPORT_CELLULAR, false, false); @@ -133,7 +133,7 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest { @Test public void testDataDisabledIcon_withDefaultSub() { setupNetworkController(); - when(mMockTm.isDataConnectionEnabled()).thenReturn(false); + when(mMockTm.isDataConnectionAllowed()).thenReturn(false); setupDefaultSignal(); updateDataConnectionState(TelephonyManager.DATA_DISCONNECTED, 0); setConnectivityViaBroadcast(NetworkCapabilities.TRANSPORT_CELLULAR, false, false); @@ -147,7 +147,7 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest { @Test public void testNonDefaultSIM_showsFullSignal_connected() { setupNetworkController(); - when(mMockTm.isDataConnectionEnabled()).thenReturn(false); + when(mMockTm.isDataConnectionAllowed()).thenReturn(false); setupDefaultSignal(); setDefaultSubId(mSubId + 1); updateDataConnectionState(TelephonyManager.DATA_CONNECTED, 0); @@ -162,7 +162,7 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest { @Test public void testNonDefaultSIM_showsFullSignal_disconnected() { setupNetworkController(); - when(mMockTm.isDataConnectionEnabled()).thenReturn(false); + when(mMockTm.isDataConnectionAllowed()).thenReturn(false); setupDefaultSignal(); setDefaultSubId(mSubId + 1); updateDataConnectionState(TelephonyManager.DATA_DISCONNECTED, 0); @@ -177,7 +177,7 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest { @Test public void testDataDisabledIcon_UserNotSetup() { setupNetworkController(); - when(mMockTm.isDataConnectionEnabled()).thenReturn(false); + when(mMockTm.isDataConnectionAllowed()).thenReturn(false); setupDefaultSignal(); updateDataConnectionState(TelephonyManager.DATA_DISCONNECTED, 0); setConnectivityViaBroadcast(NetworkCapabilities.TRANSPORT_CELLULAR, false, false); @@ -192,7 +192,7 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest { @Test public void testAlwaysShowDataRatIcon() { setupDefaultSignal(); - when(mMockTm.isDataConnectionEnabled()).thenReturn(false); + when(mMockTm.isDataConnectionAllowed()).thenReturn(false); updateDataConnectionState(TelephonyManager.DATA_DISCONNECTED, TelephonyManager.NETWORK_TYPE_GSM); diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java index 57a47d3d78c5a..f6e63776f00e7 100644 --- a/telephony/java/android/telephony/CarrierConfigManager.java +++ b/telephony/java/android/telephony/CarrierConfigManager.java @@ -2362,17 +2362,16 @@ public class CarrierConfigManager { *

If a measure is not set, signal criteria reporting from modem will not be triggered and * not be used for calculating signal level. If multiple measures are set bit, the parameter * whose value is smallest is used to indicate the signal level. + *

    + *
  • RSRP = 1 << 0
  • + *
  • RSRQ = 1 << 1
  • + *
  • RSSNR = 1 << 2
  • + *
+ *

The value of this key must be bitwise OR of {@link CellSignalStrengthLte#USE_RSRP}, + * {@link CellSignalStrengthLte#USE_RSRQ}, {@link CellSignalStrengthLte#USE_RSSNR}. * - * RSRP = 1 << 0, - * RSRQ = 1 << 1, - * RSSNR = 1 << 2, - * - * The value of this key must be bitwise OR of {@link CellSignalStrengthLte#USE_RSRP}, - * {@link CellSignalStrengthLte#USE_RSRQ}, {@link CellSignalStrengthLte#USE_RSSNR}. - * - * For example, if both RSRP and RSRQ are used, the value of key is 3 (1 << 0 | 1 << 1). - * If the key is invalid or not configured, a default value (RSRP = 1 << 0) - * will apply. + *

For example, if both RSRP and RSRQ are used, the value of key is 3 (1 << 0 | 1 << 1). + * If the key is invalid or not configured, a default value (RSRP = 1 << 0) will apply. * * @hide */ @@ -2381,16 +2380,18 @@ public class CarrierConfigManager { /** * List of 4 customized 5G SS reference signal received power (SSRSRP) thresholds. - * + *

* Reference: 3GPP TS 38.215 - * + *

* 4 threshold integers must be within the boundaries [-140 dB, -44 dB], and the levels are: - * "NONE: [-140, threshold1]" - * "POOR: (threshold1, threshold2]" - * "MODERATE: (threshold2, threshold3]" - * "GOOD: (threshold3, threshold4]" - * "EXCELLENT: (threshold4, -44]" - * + *

    + *
  • "NONE: [-140, threshold1]"
  • + *
  • "POOR: (threshold1, threshold2]"
  • + *
  • "MODERATE: (threshold2, threshold3]"
  • + *
  • "GOOD: (threshold3, threshold4]"
  • + *
  • "EXCELLENT: (threshold4, -44]"
  • + *
+ *

* This key is considered invalid if the format is violated. If the key is invalid or * not configured, a default value set will apply. */ @@ -2399,16 +2400,18 @@ public class CarrierConfigManager { /** * List of 4 customized 5G SS reference signal received quality (SSRSRQ) thresholds. - * + *

* Reference: 3GPP TS 38.215 - * + *

* 4 threshold integers must be within the boundaries [-20 dB, -3 dB], and the levels are: - * "NONE: [-20, threshold1]" - * "POOR: (threshold1, threshold2]" - * "MODERATE: (threshold2, threshold3]" - * "GOOD: (threshold3, threshold4]" - * "EXCELLENT: (threshold4, -3]" - * + *

    + *
  • "NONE: [-20, threshold1]"
  • + *
  • "POOR: (threshold1, threshold2]"
  • + *
  • "MODERATE: (threshold2, threshold3]"
  • + *
  • "GOOD: (threshold3, threshold4]"
  • + *
  • "EXCELLENT: (threshold4, -3]"
  • + *
+ *

* This key is considered invalid if the format is violated. If the key is invalid or * not configured, a default value set will apply. */ @@ -2417,17 +2420,19 @@ public class CarrierConfigManager { /** * List of 4 customized 5G SS signal-to-noise and interference ratio (SSSINR) thresholds. - * + *

* Reference: 3GPP TS 38.215, * 3GPP TS 38.133 10.1.16.1 - * + *

* 4 threshold integers must be within the boundaries [-23 dB, 40 dB], and the levels are: - * "NONE: [-23, threshold1]" - * "POOR: (threshold1, threshold2]" - * "MODERATE: (threshold2, threshold3]" - * "GOOD: (threshold3, threshold4]" - * "EXCELLENT: (threshold4, 40]" - * + *

    + *
  • "NONE: [-23, threshold1]"
  • + *
  • "POOR: (threshold1, threshold2]"
  • + *
  • "MODERATE: (threshold2, threshold3]"
  • + *
  • "GOOD: (threshold3, threshold4]"
  • + *
  • "EXCELLENT: (threshold4, 40]"
  • + *
+ *

* This key is considered invalid if the format is violated. If the key is invalid or * not configured, a default value set will apply. */ @@ -2442,19 +2447,19 @@ public class CarrierConfigManager { *

If a measure is not set, signal criteria reporting from modem will not be triggered and * not be used for calculating signal level. If multiple measures are set bit, the parameter * whose value is smallest is used to indicate the signal level. - * - * SSRSRP = 1 << 0, - * SSRSRQ = 1 << 1, - * SSSINR = 1 << 2, - * + *

    + *
  • SSRSRP = 1 << 0
  • + *
  • SSRSRQ = 1 << 1
  • + *
  • SSSINR = 1 << 2
  • + *
* The value of this key must be bitwise OR of {@link CellSignalStrengthNr#USE_SSRSRP}, * {@link CellSignalStrengthNr#USE_SSRSRQ}, {@link CellSignalStrengthNr#USE_SSSINR}. * - * For example, if both SSRSRP and SSSINR are used, the value of key is 5 (1 << 0 | 1 << 2). + *

For example, if both SSRSRP and SSSINR are used, the value of key is 5 (1 << 0 | 1 << 2). * If the key is invalid or not configured, a default value (SSRSRP = 1 << 0) will apply. * - * Reference: 3GPP TS 38.215, - * 3GPP TS 38.133 10.1.16.1 + *

Reference: 3GPP TS 38.215, + * 3GPP TS 38.133 10.1.16.1 * * @hide */ diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index bfe9152212d5b..0ec598fca8157 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -8908,7 +8908,10 @@ public class TelephonyManager { } /** - * Shut down all the live radios over all the slot index. + * Shut down all the live radios over all the slot indexes. + * + *

To know when the radio has completed powering off, use + * {@link PhoneStateListener#LISTEN_SERVICE_STATE LISTEN_SERVICE_STATE}. * * @hide */ @@ -8921,7 +8924,8 @@ public class TelephonyManager { telephony.shutdownMobileRadios(); } } catch (RemoteException e) { - Log.e(TAG, "Error calling ITelephony#shutdownMobileRadios", e); + Log.e(TAG, "Error calling ITelephony#shutdownAllRadios", e); + e.rethrowAsRuntimeException(); } } @@ -8940,7 +8944,8 @@ public class TelephonyManager { return telephony.needMobileRadioShutdown(); } } catch (RemoteException e) { - Log.e(TAG, "Error calling ITelephony#needMobileRadioShutdown", e); + Log.e(TAG, "Error calling ITelephony#isAnyRadioPoweredOn", e); + e.rethrowAsRuntimeException(); } return false; } @@ -11109,21 +11114,21 @@ public class TelephonyManager { } /** - * Checks whether cellular data connection is enabled in the device. + * Checks whether cellular data connection is allowed in the device. * - * Whether cellular data connection is enabled, meaning upon request whether will try to setup - * metered data connection considering all factors below: - * 1) User turned on data setting {@link #isDataEnabled}. - * 2) Carrier allows data to be on. - * 3) Network policy. - * And possibly others. - * - * @return {@code true} if the overall data connection is capable; {@code false} if not. + *

Whether cellular data connection is allowed considers all factors below: + *

    + *
  • User turned on data setting {@link #isDataEnabled}.
  • + *
  • Carrier allows data to be on.
  • + *
  • Network policy.
  • + *
  • And possibly others.
  • + *
+ * @return {@code true} if the overall data connection is allowed; {@code false} if not. * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) - public boolean isDataConnectionEnabled() { + public boolean isDataConnectionAllowed() { boolean retVal = false; try { int subId = getSubId(SubscriptionManager.getDefaultDataSubscriptionId()); @@ -11131,8 +11136,9 @@ public class TelephonyManager { if (telephony != null) retVal = telephony.isDataEnabled(subId); } catch (RemoteException e) { - Log.e(TAG, "Error isDataConnectionEnabled", e); + Log.e(TAG, "Error isDataConnectionAllowed", e); } catch (NullPointerException e) { + return false; } return retVal; } @@ -11843,7 +11849,7 @@ public class TelephonyManager { } /** - * A test API to return the emergency number db version. + * Returns the emergency number database version. * *

Requires Permission: * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE READ_PRIVILEGED_PHONE_STATE} @@ -11852,6 +11858,7 @@ public class TelephonyManager { */ @TestApi @SystemApi + @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getEmergencyNumberDbVersion() { try { ITelephony telephony = getITelephony();