Adds check for connection before ringing.

Bug: 10458113
Change-Id: Ieb510831f320a944a539ad503184b97595c1111a
diff --git a/src/com/android/phone/CallNotifier.java b/src/com/android/phone/CallNotifier.java
index 0f5c6b5..3003290 100644
--- a/src/com/android/phone/CallNotifier.java
+++ b/src/com/android/phone/CallNotifier.java
@@ -658,18 +658,17 @@
             return;
         }
 
-        // Ring, either with the queried ringtone or default one.
-        if (VDBG) log("RINGING... (onCustomRingQueryComplete)");
-        mRinger.ring();
-
-        // ...and display the incoming call to the user:
-        if (DBG) log("- showing incoming call (custom ring query complete)...");
-
         // If the ringing call still does not have any connection anymore, do not send the
         // notification to the CallModeler.
         final Call ringingCall = mCM.getFirstActiveRingingCall();
 
         if (ringingCall != null && ringingCall.getLatestConnection() == c) {
+            // Ring, either with the queried ringtone or default one.
+            if (VDBG) log("RINGING... (onCustomRingQueryComplete)");
+            mRinger.ring();
+
+            // ...and display the incoming call to the user:
+            if (DBG) log("- showing incoming call (custom ring query complete)...");
             notifyCallModelerOfNewRingingCall(c);
         }
     }