Phone process crashes during the stability test.

[Description]
During a stability test, a NPE was thrown during a call.

[Root cause]
The method Connection.getAddress() might return null.

[Solution]
Add safe check before using Connection.getAddress().

Fixes: 145146245
Test: Run Telephony unit tests
Change-Id: Ia576bc0958811c8b38697869c594c70b0be0c2f3
diff --git a/src/com/android/services/telephony/CdmaConnection.java b/src/com/android/services/telephony/CdmaConnection.java
index bd015e3..36618c5 100644
--- a/src/com/android/services/telephony/CdmaConnection.java
+++ b/src/com/android/services/telephony/CdmaConnection.java
@@ -288,9 +288,8 @@
 
     private boolean isEmergency() {
         Phone phone = getPhone();
-        return phone != null &&
-                PhoneNumberUtils.isLocalEmergencyNumber(
-                    phone.getContext(), getAddress().getSchemeSpecificPart());
+        return phone != null && getAddress() != null && PhoneNumberUtils.isLocalEmergencyNumber(
+                phone.getContext(), getAddress().getSchemeSpecificPart());
     }
 
     /**
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 0b60e37..16e10cf 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -1639,7 +1639,10 @@
 
     private void placeOutgoingConnection(
             TelephonyConnection connection, Phone phone, int videoState, Bundle extras) {
-        String number = connection.getAddress().getSchemeSpecificPart();
+
+        String number = (connection.getAddress() != null)
+                ? connection.getAddress().getSchemeSpecificPart()
+                : "";
 
         com.android.internal.telephony.Connection originalConnection = null;
         try {