summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nathan Harold <nharold@google.com> 2019-05-18 00:25:42 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2019-05-18 00:25:42 +0000
commit06445094a9935b5be7569c2514a97a02a05c7494 (patch)
tree79fdea1dc34b4c12d91d5bd1c2f775b3ef5de261
parent909e72a9e4485e8bcc18ce1054da06464cdc0177 (diff)
parent0aca4313139fb707158f6017c6ad7f62af4ce5e6 (diff)
Merge "Use the SubId in the TM.getNetworkType if Valid"
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java34
1 files changed, 3 insertions, 31 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 57316466c3fd..d611da9e07c7 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -2412,21 +2412,7 @@ public class TelephonyManager {
* @return the NETWORK_TYPE_xxxx for current data connection.
*/
public @NetworkType int getNetworkType() {
- try {
- ITelephony telephony = getITelephony();
- if (telephony != null) {
- return telephony.getNetworkType();
- } else {
- // This can happen when the ITelephony interface is not up yet.
- return NETWORK_TYPE_UNKNOWN;
- }
- } catch(RemoteException ex) {
- // This shouldn't happen in the normal case
- return NETWORK_TYPE_UNKNOWN;
- } catch (NullPointerException ex) {
- // This could happen before phone restarts due to crashing
- return NETWORK_TYPE_UNKNOWN;
- }
+ return getDataNetworkType();
}
/**
@@ -2457,23 +2443,9 @@ public class TelephonyManager {
* @hide
*/
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
public int getNetworkType(int subId) {
- try {
- ITelephony telephony = getITelephony();
- if (telephony != null) {
- return telephony.getNetworkTypeForSubscriber(subId, getOpPackageName());
- } else {
- // This can happen when the ITelephony interface is not up yet.
- return NETWORK_TYPE_UNKNOWN;
- }
- } catch (RemoteException ex) {
- // This shouldn't happen in the normal case
- return NETWORK_TYPE_UNKNOWN;
- } catch (NullPointerException ex) {
- // This could happen before phone restarts due to crashing
- return NETWORK_TYPE_UNKNOWN;
- }
+ return getDataNetworkType(subId);
}
/**