Hang up all calls if the UI crashes.
bug:10823938
Change-Id: I417b4f4e1351efd65de65edaedd778115e605cd1
diff --git a/src/com/android/phone/CallHandlerServiceProxy.java b/src/com/android/phone/CallHandlerServiceProxy.java
index 1b05214..18b77ef 100644
--- a/src/com/android/phone/CallHandlerServiceProxy.java
+++ b/src/com/android/phone/CallHandlerServiceProxy.java
@@ -297,7 +297,8 @@
// always have an in call ui.
unbind();
- // TODO(klp): hang up all calls.
+ // We were disconnected from the UI. End all calls.
+ PhoneUtils.hangupAllCalls(PhoneGlobals.getInstance().getCallManager());
}
}
}
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index 6744d33..5474a62 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -651,6 +651,10 @@
return callModeler;
}
+ /* package */ CallManager getCallManager() {
+ return mCM;
+ }
+
/**
* Returns an Intent that can be used to go to the "Call log"
* UI (aka CallLogActivity) in the Contacts app.
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index 97be90b..e4c9a72 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -326,6 +326,28 @@
}
/**
+ * Hangs up all active calls.
+ */
+ static void hangupAllCalls(CallManager cm) {
+ final Call ringing = cm.getFirstActiveRingingCall();
+ final Call fg = cm.getActiveFgCall();
+ final Call bg = cm.getFirstActiveBgCall();
+
+ // We go in reverse order, BG->FG->RINGING because hanging up a ringing call or an active
+ // call can move a bg call to a fg call which would force us to loop over each call
+ // several times. This ordering works best to ensure we dont have any more calls.
+ if (bg != null && !bg.isIdle()) {
+ hangup(bg);
+ }
+ if (fg != null && !fg.isIdle()) {
+ hangup(fg);
+ }
+ if (ringing != null && !ringing.isIdle()) {
+ hangupRingingCall(fg);
+ }
+ }
+
+ /**
* Smart "hang up" helper method which hangs up exactly one connection,
* based on the current Phone state, as follows:
* <ul>