From f36fee3cf764838aa8b1f59142e82049e4cbacb1 Mon Sep 17 00:00:00 2001 From: Nathan Harold Date: Thu, 16 May 2019 19:39:12 -0700 Subject: [PATCH] Use the SubId in the TM.getNetworkType if Valid If the TM instance has a specific subid that was added using TM.createForSubscriptionId(), honor that subId in getNetworkType(). Bug: 132466954 Test: compilation + manual Merged-In: Ice4f673750ab3b374644750113e5b9b2a4f5ba63 Change-Id: Ice4f673750ab3b374644750113e5b9b2a4f5ba63 (cherry picked from commit 0aca4313139fb707158f6017c6ad7f62af4ce5e6) --- .../android/telephony/TelephonyManager.java | 34 ++----------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index dab1e6f4abde2..b722b79240dd8 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -2446,21 +2446,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(); } /** @@ -2491,23 +2477,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); } /**