diff options
| author | 2018-02-26 21:11:40 -0800 | |
|---|---|---|
| committer | 2018-02-27 15:30:09 -0800 | |
| commit | 331965e5d6f753cd061303607cdfbe9dff4be896 (patch) | |
| tree | 3b601345857d184bf532d8457af3ca19b18fd1f5 | |
| parent | f3f5c320f169e9b0856d39715f3d64218f409cbf (diff) | |
Don't throw exception if phone process is dead for carrier ID APIs
Bug: 73772776
Test: Build
Change-Id: I81638f52d5d8ccf1005878ba4f3967e07169284b
| -rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index cdc1ba99b6f4..e0cc6e1dd495 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -7183,18 +7183,16 @@ public class TelephonyManager { * * @return Carrier id of the current subscription. Return {@link #UNKNOWN_CARRIER_ID} if the * subscription is unavailable or the carrier cannot be identified. - * @throws IllegalStateException if telephony service is unavailable. */ public int getAndroidCarrierIdForSubscription() { try { ITelephony service = getITelephony(); - return service.getSubscriptionCarrierId(getSubId()); + if (service != null) { + return service.getSubscriptionCarrierId(getSubId()); + } } catch (RemoteException ex) { // This could happen if binder process crashes. ex.rethrowAsRuntimeException(); - } catch (NullPointerException ex) { - // This could happen before phone restarts due to crashing. - throw new IllegalStateException("Telephony service unavailable"); } return UNKNOWN_CARRIER_ID; } @@ -7210,18 +7208,16 @@ public class TelephonyManager { * * @return Carrier name of the current subscription. Return {@code null} if the subscription is * unavailable or the carrier cannot be identified. - * @throws IllegalStateException if telephony service is unavailable. */ public CharSequence getAndroidCarrierNameForSubscription() { try { ITelephony service = getITelephony(); - return service.getSubscriptionCarrierName(getSubId()); + if (service != null) { + return service.getSubscriptionCarrierName(getSubId()); + } } catch (RemoteException ex) { // This could happen if binder process crashes. ex.rethrowAsRuntimeException(); - } catch (NullPointerException ex) { - // This could happen before phone restarts due to crashing. - throw new IllegalStateException("Telephony service unavailable"); } return null; } |