Disable old Telephony updates when using PSTN Telecomm
This is a temporary workaround to allow PSTN Telecomm call services
and PSTN Telephony to co-exist. When a Telecomm PSTN call
is live we disable PSTN Telephony updates.
This prevents the old Telephony code from reacting to things like
incoming rings.
Change-Id: Ic283bed28005f534d337fefb47da445f2dc22c12
diff --git a/src/com/android/phone/CallModeler.java b/src/com/android/phone/CallModeler.java
index 3e37f29..5258f88 100644
--- a/src/com/android/phone/CallModeler.java
+++ b/src/com/android/phone/CallModeler.java
@@ -95,6 +95,8 @@
private final ArrayList<Listener> mListeners = new ArrayList<Listener>();
private Connection mCdmaIncomingConnection;
private Connection mCdmaOutgoingConnection;
+ // TODO(sail): Temporary flag to disable sending telephony updates when Telecomm is being used.
+ private boolean mShouldDisableUpdates;
public CallModeler(CallStateMonitor callStateMonitor, CallManager callManager,
CallGatewayManager callGatewayManager) {
@@ -105,6 +107,12 @@
mCallStateMonitor.addListener(this);
}
+ public void setShouldDisableUpdates(boolean shouldDisableUpdates) {
+ Log.i(TAG, "setShouldDisableUpdates " + mShouldDisableUpdates + " -> " +
+ shouldDisableUpdates);
+ mShouldDisableUpdates = shouldDisableUpdates;
+ }
+
@Override
public void handleMessage(Message msg) {
switch(msg.what) {
@@ -271,7 +279,7 @@
final Call call = getCallFromMap(mCallMap, c, false);
if (call == null) {
Log.i(TAG, "Call no longer exists. Skipping onPostDialWait().");
- } else {
+ } else if (!mShouldDisableUpdates) {
for (Listener mListener : mListeners) {
mListener.onPostDialAction(state, call.getCallId(),
c.getRemainingPostDialString(), ch);
@@ -281,8 +289,10 @@
default:
// This is primarily to cause the DTMFTonePlayer to play local tones.
// Other listeners simply perform no-ops.
- for (Listener mListener : mListeners) {
- mListener.onPostDialAction(state, 0, "", ch);
+ if (!mShouldDisableUpdates) {
+ for (Listener mListener : mListeners) {
+ mListener.onPostDialAction(state, 0, "", ch);
+ }
}
break;
}
@@ -296,8 +306,10 @@
if (call != null) {
updateCallFromConnection(call, conn, false);
- for (int i = 0; i < mListeners.size(); ++i) {
- mListeners.get(i).onIncoming(call);
+ if (!mShouldDisableUpdates) {
+ for (int i = 0; i < mListeners.size(); ++i) {
+ mListeners.get(i).onIncoming(call);
+ }
}
}
@@ -314,8 +326,10 @@
updateCallFromConnection(call, conn, false);
- for (int i = 0; i < mListeners.size(); ++i) {
- mListeners.get(i).onDisconnect(call);
+ if (!mShouldDisableUpdates) {
+ for (int i = 0; i < mListeners.size(); ++i) {
+ mListeners.get(i).onDisconnect(call);
+ }
}
// If it was a conferenced call, we need to run the entire update
@@ -339,7 +353,7 @@
final List<Call> updatedCalls = Lists.newArrayList();
doUpdate(false, updatedCalls);
- if (updatedCalls.size() > 0) {
+ if (updatedCalls.size() > 0 && !mShouldDisableUpdates) {
for (int i = 0; i < mListeners.size(); ++i) {
mListeners.get(i).onUpdate(updatedCalls);
}
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index 2059b64..d7b109d 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -600,7 +600,7 @@
/**
* Returns the singleton instance of the PhoneApp.
*/
- static PhoneGlobals getInstance() {
+ public static PhoneGlobals getInstance() {
if (sMe == null) {
throw new IllegalStateException("No PhoneGlobals here!");
}
@@ -642,7 +642,7 @@
return audioRouter;
}
- /* package */ CallModeler getCallModeler() {
+ public CallModeler getCallModeler() {
return callModeler;
}