From 896a1e650cf69f8dea1ef588c0089aaaf3d12e08 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Fri, 3 Apr 2015 14:09:29 -0700 Subject: [PATCH] Protect against null ITelephony to fix crash. Bug: 20066803 Change-Id: I4336e979dab3a4b1b3d53078af572ff3f822377a --- .../android/telephony/TelephonyManager.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 6bc6de63ba67b..d8bb0d7f4af2a 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -3982,7 +3982,10 @@ public class TelephonyManager { */ public boolean canChangeDtmfToneLength() { try { - return getITelephony().canChangeDtmfToneLength(); + ITelephony telephony = getITelephony(); + if (telephony != null) { + return telephony.canChangeDtmfToneLength(); + } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#canChangeDtmfToneLength", e); } @@ -3996,7 +3999,10 @@ public class TelephonyManager { */ public boolean isWorldPhone() { try { - return getITelephony().isWorldPhone(); + ITelephony telephony = getITelephony(); + if (telephony != null) { + return telephony.isWorldPhone(); + } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#isWorldPhone", e); } @@ -4010,7 +4016,10 @@ public class TelephonyManager { */ public boolean isTtyModeSupported() { try { - return getITelephony().isTtyModeSupported(); + ITelephony telephony = getITelephony(); + if (telephony != null) { + return telephony.isTtyModeSupported(); + } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#isTtyModeSupported", e); } @@ -4025,7 +4034,10 @@ public class TelephonyManager { */ public boolean isHearingAidCompatibilitySupported() { try { - return getITelephony().isHearingAidCompatibilitySupported(); + ITelephony telephony = getITelephony(); + if (telephony != null) { + return telephony.isHearingAidCompatibilitySupported(); + } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#isHearingAidCompatibilitySupported", e); }