Do not create incoming/disconnected calls on update.
This change fixes two things:
1. onIncoming will always get called for incoming calls, but sometimes
so does onUpdate. This caused too many updates since we ALWAYS send the
onIncoming (we need to). The solution is to not create incoming calls
on an update any more. After this change, onUpdate will only handle
updates to incoming calls, not the creation of them.
2. Basically, the same thing happens for disconnect calls. Some
disconnect updates come after we've disconnected and in those cases,
there is no need to recreate the objects since we've already sent a
disconnect update for the call.
bug:10571325
Change-Id: Ifa8eefd197161f90d60d4a55337a6a285e85e3bb
diff --git a/src/com/android/phone/CallHandlerServiceProxy.java b/src/com/android/phone/CallHandlerServiceProxy.java
index a57ac5b..adf54c2 100644
--- a/src/com/android/phone/CallHandlerServiceProxy.java
+++ b/src/com/android/phone/CallHandlerServiceProxy.java
@@ -44,7 +44,7 @@
implements CallModeler.Listener, AudioModeListener {
private static final String TAG = CallHandlerServiceProxy.class.getSimpleName();
- private static final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 0) && (SystemProperties.getInt(
+ private static final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 1) && (SystemProperties.getInt(
"ro.debuggable", 0) == 1);
public static final int RETRY_DELAY_MILLIS = 2000;
@@ -209,10 +209,6 @@
Log.i(TAG, "Updating with new audio mode: " + AudioMode.toString(newMode) +
" with mute " + muted);
- if (DBG) {
- Log.d(TAG, "onSupportAudioModeChange");
- }
-
mCallHandlerServiceGuarded.onAudioModeChange(newMode, muted);
} catch (Exception e) {
Log.e(TAG, "Remote exception handling onAudioModeChange", e);
diff --git a/src/com/android/phone/CallModeler.java b/src/com/android/phone/CallModeler.java
index 9c7b9dd..d8c11d6 100644
--- a/src/com/android/phone/CallModeler.java
+++ b/src/com/android/phone/CallModeler.java
@@ -241,8 +241,10 @@
final List<Call> updatedCalls = Lists.newArrayList();
doUpdate(false, updatedCalls);
- for (int i = 0; i < mListeners.size(); ++i) {
- mListeners.get(i).onUpdate(updatedCalls);
+ if (updatedCalls.size() > 0) {
+ for (int i = 0; i < mListeners.size(); ++i) {
+ mListeners.get(i).onUpdate(updatedCalls);
+ }
}
}
@@ -262,14 +264,23 @@
for (com.android.internal.telephony.Call telephonyCall : telephonyCalls) {
for (Connection connection : telephonyCall.getConnections()) {
- // new connections return a Call with INVALID state, which does not translate to
+ // We do not create incoming or disconnected calls on update. Those are created
+ // from the associated onNewRingingConnection and onDisconnected which do this
+ // process on their own and slightly differently.
+ boolean create = connection.getState().isAlive() &&
+ !connection.getState().isRinging();
+
+ // New connections return a Call with INVALID state, which does not translate to
// a state in the internal.telephony.Call object. This ensures that staleness
// check below fails and we always add the item to the update list if it is new.
- final Call call = getCallFromMap(mCallMap, connection, true);
+ final Call call = getCallFromMap(mCallMap, connection, create);
+
+ if (call == null) {
+ continue;
+ }
boolean changed = updateCallFromConnection(call, connection, false);
- Log.i(TAG, "doUpdate: " + call);
if (fullUpdate || changed) {
out.add(call);
}