Merge "Add onDisconnect callback in root radio connection class."
diff --git a/src/java/com/android/internal/telephony/Connection.java b/src/java/com/android/internal/telephony/Connection.java
index 8c54a31..973fea8 100644
--- a/src/java/com/android/internal/telephony/Connection.java
+++ b/src/java/com/android/internal/telephony/Connection.java
@@ -104,6 +104,7 @@
         public void onConnectionEvent(String event, Bundle extras);
         public void onRttModifyRequestReceived();
         public void onRttModifyResponseReceived(int status);
+        public void onDisconnect(int cause);
     }
 
     /**
@@ -143,6 +144,8 @@
         public void onRttModifyRequestReceived() {}
         @Override
         public void onRttModifyResponseReceived(int status) {}
+        @Override
+        public void onDisconnect(int cause) {}
     }
 
     public static final int AUDIO_QUALITY_STANDARD = 1;
@@ -1055,6 +1058,18 @@
     }
 
     /**
+     * Notify interested parties that this connection disconnected.
+     * {@code TelephonyConnection}, for example, uses this.
+     * @param reason the disconnect code, per {@link DisconnectCause}.
+     */
+    protected void notifyDisconnect(int reason) {
+        Rlog.i(TAG, "notifyDisconnect: callId=" + getTelecomCallId() + ", reason=" + reason);
+        for (Listener l : mListeners) {
+            l.onDisconnect(reason);
+        }
+    }
+
+    /**
      *
      */
     public int getPhoneType() {
diff --git a/src/java/com/android/internal/telephony/GsmCdmaConnection.java b/src/java/com/android/internal/telephony/GsmCdmaConnection.java
index 0c8dea2..a8d79cf 100644
--- a/src/java/com/android/internal/telephony/GsmCdmaConnection.java
+++ b/src/java/com/android/internal/telephony/GsmCdmaConnection.java
@@ -583,6 +583,7 @@
             if (DBG) Rlog.d(LOG_TAG, "onDisconnect: cause=" + cause);
 
             mOwner.getPhone().notifyDisconnect(this);
+            notifyDisconnect(cause);
 
             if (mParent != null) {
                 changed = mParent.connectionDisconnected(this);
diff --git a/src/java/com/android/internal/telephony/imsphone/ImsPhoneConnection.java b/src/java/com/android/internal/telephony/imsphone/ImsPhoneConnection.java
index 3c3c192..5a490ae 100644
--- a/src/java/com/android/internal/telephony/imsphone/ImsPhoneConnection.java
+++ b/src/java/com/android/internal/telephony/imsphone/ImsPhoneConnection.java
@@ -428,6 +428,7 @@
             mDisconnected = true;
 
             mOwner.mPhone.notifyDisconnect(this);
+            notifyDisconnect(mCause);
 
             if (mParent != null) {
                 changed = mParent.connectionDisconnected(this);