Update Telephony to use new Telecomm wrappers
Change-Id: I8a828a41d5e4c10e96bbe4eb36c3afc95d3e7beb
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 7e8648c..13ecedb 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -556,22 +556,22 @@
<!-- Telecomm integration -->
<service android:name="com.android.services.telephony.TelephonyCallServiceProvider">
<intent-filter>
- <action android:name="android.telecomm.ICallServiceProvider" />
+ <action android:name="android.telecomm.CallServiceProvider" />
</intent-filter>
</service>
<service android:name="com.android.services.telephony.GsmCallService">
<intent-filter>
- <action android:name="android.telecomm.ICallService" />
+ <action android:name="android.telecomm.CallService" />
</intent-filter>
</service>
<service android:name="com.android.services.telephony.CdmaCallService">
<intent-filter>
- <action android:name="android.telecomm.ICallService" />
+ <action android:name="android.telecomm.CallService" />
</intent-filter>
</service>
<service android:name="com.android.services.telephony.SipCallService">
<intent-filter>
- <action android:name="android.telecomm.ICallService" />
+ <action android:name="android.telecomm.CallService" />
</intent-filter>
</service>
</application>
diff --git a/src/com/android/services/telephony/BaseTelephonyCallService.java b/src/com/android/services/telephony/BaseTelephonyCallService.java
index a9051c5..7004fed 100644
--- a/src/com/android/services/telephony/BaseTelephonyCallService.java
+++ b/src/com/android/services/telephony/BaseTelephonyCallService.java
@@ -18,10 +18,9 @@
import android.net.Uri;
import android.os.Bundle;
-import android.os.RemoteException;
import android.telecomm.CallInfo;
import android.telecomm.CallService;
-import android.telecomm.ICallServiceAdapter;
+import android.telecomm.CallServiceAdapter;
import android.text.TextUtils;
import android.util.Log;
@@ -40,7 +39,7 @@
public abstract class BaseTelephonyCallService extends CallService {
private static final String TAG = "BaseTeleCallService";
- protected ICallServiceAdapter mCallServiceAdapter;
+ protected CallServiceAdapter mCallServiceAdapter;
/** Map of all call connections keyed by the call ID. */
private static HashMap<String, TelephonyCallConnection> sCallConnections =
@@ -58,7 +57,7 @@
/** {@inheritDoc} */
@Override
- public void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter) {
+ public void setCallServiceAdapter(CallServiceAdapter callServiceAdapter) {
mCallServiceAdapter = callServiceAdapter;
}
@@ -99,42 +98,38 @@
* Initiates the call, should be called by the subclass.
*/
protected void startCallWithPhone(Phone phone, CallInfo callInfo) {
- try {
- if (phone == null) {
- mCallServiceAdapter.handleFailedOutgoingCall(callInfo.getId(), "Phone is null");
- return;
- }
-
- Uri uri = Uri.parse(callInfo.getHandle());
- String number = null;
- if (uri != null) {
- number = uri.getSchemeSpecificPart();
- }
- if (TextUtils.isEmpty(number)) {
- mCallServiceAdapter.handleFailedOutgoingCall(callInfo.getId(),
- "Unable to parse number");
- return;
- }
-
- Connection connection;
- try {
- PhoneGlobals.getInstance().getCallModeler().setShouldDisableUpdates(true);
- connection = phone.dial(number);
- } catch (CallStateException e) {
- Log.e(TAG, "Call to Phone.dial failed with exception", e);
- mCallServiceAdapter.handleFailedOutgoingCall(callInfo.getId(), e.getMessage());
- if (sCallConnections.isEmpty()) {
- PhoneGlobals.getInstance().getCallModeler().setShouldDisableUpdates(false);
- }
- return;
- }
-
- TelephonyCallConnection callConnection =
- new TelephonyCallConnection(mCallServiceAdapter, callInfo.getId(), connection);
- sCallConnections.put(callInfo.getId(), callConnection);
- mCallServiceAdapter.handleSuccessfulOutgoingCall(callInfo.getId());
- } catch (RemoteException e) {
- Log.e(TAG, "Got RemoteException", e);
+ if (phone == null) {
+ mCallServiceAdapter.handleFailedOutgoingCall(callInfo.getId(), "Phone is null");
+ return;
}
+
+ Uri uri = Uri.parse(callInfo.getHandle());
+ String number = null;
+ if (uri != null) {
+ number = uri.getSchemeSpecificPart();
+ }
+ if (TextUtils.isEmpty(number)) {
+ mCallServiceAdapter.handleFailedOutgoingCall(callInfo.getId(),
+ "Unable to parse number");
+ return;
+ }
+
+ Connection connection;
+ try {
+ PhoneGlobals.getInstance().getCallModeler().setShouldDisableUpdates(true);
+ connection = phone.dial(number);
+ } catch (CallStateException e) {
+ Log.e(TAG, "Call to Phone.dial failed with exception", e);
+ mCallServiceAdapter.handleFailedOutgoingCall(callInfo.getId(), e.getMessage());
+ if (sCallConnections.isEmpty()) {
+ PhoneGlobals.getInstance().getCallModeler().setShouldDisableUpdates(false);
+ }
+ return;
+ }
+
+ TelephonyCallConnection callConnection =
+ new TelephonyCallConnection(mCallServiceAdapter, callInfo.getId(), connection);
+ sCallConnections.put(callInfo.getId(), callConnection);
+ mCallServiceAdapter.handleSuccessfulOutgoingCall(callInfo.getId());
}
}
diff --git a/src/com/android/services/telephony/CdmaCallService.java b/src/com/android/services/telephony/CdmaCallService.java
index 03fc2b7..123c71d 100644
--- a/src/com/android/services/telephony/CdmaCallService.java
+++ b/src/com/android/services/telephony/CdmaCallService.java
@@ -17,7 +17,6 @@
package com.android.services.telephony;
import android.content.Context;
-import android.os.RemoteException;
import android.telecomm.CallInfo;
import android.telephony.TelephonyManager;
import android.util.Log;
@@ -40,11 +39,7 @@
/** {@inheritDoc} */
@Override
public void isCompatibleWith(CallInfo callInfo) {
- try {
- mCallServiceAdapter.setCompatibleWith(callInfo.getId(), shouldSelect(this, callInfo));
- } catch (RemoteException e) {
- Log.e(TAG, "Call to setCompatibleWith failed with exception", e);
- }
+ mCallServiceAdapter.setIsCompatibleWith(callInfo.getId(), shouldSelect(this, callInfo));
}
/** {@inheritDoc} */
diff --git a/src/com/android/services/telephony/GsmCallService.java b/src/com/android/services/telephony/GsmCallService.java
index 5c31b52..8ca5e96 100644
--- a/src/com/android/services/telephony/GsmCallService.java
+++ b/src/com/android/services/telephony/GsmCallService.java
@@ -17,7 +17,6 @@
package com.android.services.telephony;
import android.content.Context;
-import android.os.RemoteException;
import android.telecomm.CallInfo;
import android.telephony.TelephonyManager;
import android.util.Log;
@@ -40,11 +39,7 @@
/** {@inheritDoc} */
@Override
public void isCompatibleWith(CallInfo callInfo) {
- try {
- mCallServiceAdapter.setCompatibleWith(callInfo.getId(), shouldSelect(this, callInfo));
- } catch (RemoteException e) {
- Log.e(TAG, "Call to setCompatibleWith failed with exception", e);
- }
+ mCallServiceAdapter.setIsCompatibleWith(callInfo.getId(), shouldSelect(this, callInfo));
}
/** {@inheritDoc} */
diff --git a/src/com/android/services/telephony/SipCallService.java b/src/com/android/services/telephony/SipCallService.java
index 37589fd..c5efe32 100644
--- a/src/com/android/services/telephony/SipCallService.java
+++ b/src/com/android/services/telephony/SipCallService.java
@@ -17,7 +17,6 @@
package com.android.services.telephony;
import android.content.Context;
-import android.os.RemoteException;
import android.net.sip.SipException;
import android.net.sip.SipManager;
import android.net.sip.SipProfile;
@@ -85,11 +84,7 @@
/** {@inheritDoc} */
@Override
public void isCompatibleWith(CallInfo callInfo) {
- try {
- mCallServiceAdapter.setCompatibleWith(callInfo.getId(), shouldSelect(this, callInfo));
- } catch (RemoteException e) {
- Log.e(TAG, "Call to setCompatibleWith failed with exception", e);
- }
+ mCallServiceAdapter.setIsCompatibleWith(callInfo.getId(), shouldSelect(this, callInfo));
}
/** {@inheritDoc} */
diff --git a/src/com/android/services/telephony/TelephonyCallConnection.java b/src/com/android/services/telephony/TelephonyCallConnection.java
index 3abeb14..2689e07 100644
--- a/src/com/android/services/telephony/TelephonyCallConnection.java
+++ b/src/com/android/services/telephony/TelephonyCallConnection.java
@@ -18,8 +18,7 @@
import android.os.Handler;
import android.os.Message;
-import android.os.RemoteException;
-import android.telecomm.ICallServiceAdapter;
+import android.telecomm.CallServiceAdapter;
import android.util.Log;
import com.android.internal.telephony.Call;
@@ -28,7 +27,7 @@
/**
* Manages a single phone call. Listens to the call's state changes and updates the
- * ICallServiceAdapter.
+ * CallServiceAdapter.
*/
class TelephonyCallConnection {
private static final String TAG = TelephonyCallConnection.class.getSimpleName();
@@ -37,12 +36,12 @@
private final String mCallId;
private final StateHandler mHandler = new StateHandler();
- private ICallServiceAdapter mCallServiceAdapter;
+ private CallServiceAdapter mCallServiceAdapter;
private Connection mConnection;
private Call.State mOldState = Call.State.IDLE;
- TelephonyCallConnection(ICallServiceAdapter callServiceAdapter, String callId,
+ TelephonyCallConnection(CallServiceAdapter callServiceAdapter, String callId,
Connection connection) {
mCallServiceAdapter = callServiceAdapter;
mCallId = callId;
@@ -80,35 +79,31 @@
}
mOldState = newState;
- try {
- switch (newState) {
- case IDLE:
- break;
- case ACTIVE:
- mCallServiceAdapter.setActive(mCallId);
- break;
- case HOLDING:
- break;
- case DIALING:
- mCallServiceAdapter.setDialing(mCallId);
- break;
- case ALERTING:
- mCallServiceAdapter.setDialing(mCallId);
- break;
- case INCOMING:
- // Incoming calls not implemented.
- break;
- case WAITING:
- break;
- case DISCONNECTED:
- mCallServiceAdapter.setDisconnected(mCallId);
- close();
- break;
- case DISCONNECTING:
- break;
- }
- } catch (RemoteException e) {
- Log.e(TAG, "Remote exception", e);
+ switch (newState) {
+ case IDLE:
+ break;
+ case ACTIVE:
+ mCallServiceAdapter.setActive(mCallId);
+ break;
+ case HOLDING:
+ break;
+ case DIALING:
+ mCallServiceAdapter.setDialing(mCallId);
+ break;
+ case ALERTING:
+ mCallServiceAdapter.setDialing(mCallId);
+ break;
+ case INCOMING:
+ // Incoming calls not implemented.
+ break;
+ case WAITING:
+ break;
+ case DISCONNECTED:
+ mCallServiceAdapter.setDisconnected(mCallId);
+ close();
+ break;
+ case DISCONNECTING:
+ break;
}
}
diff --git a/src/com/android/services/telephony/TelephonyCallServiceProvider.java b/src/com/android/services/telephony/TelephonyCallServiceProvider.java
index 9ff1401..5c3026b 100644
--- a/src/com/android/services/telephony/TelephonyCallServiceProvider.java
+++ b/src/com/android/services/telephony/TelephonyCallServiceProvider.java
@@ -17,10 +17,9 @@
package com.android.services.telephony;
import android.os.IBinder;
-import android.os.RemoteException;
import android.telecomm.CallServiceDescriptor;
+import android.telecomm.CallServiceLookupResponse;
import android.telecomm.CallServiceProvider;
-import android.telecomm.ICallServiceLookupResponse;
import android.util.Log;
import java.util.ArrayList;
@@ -33,7 +32,7 @@
/** {@inheritDoc} */
@Override
- public void lookupCallServices(ICallServiceLookupResponse response) {
+ public void lookupCallServices(CallServiceLookupResponse response) {
ArrayList<CallServiceDescriptor> descriptors = new ArrayList<CallServiceDescriptor>();
descriptors.add(CallServiceDescriptor.newBuilder(this)
.setCallService(GsmCallService.class)
@@ -48,10 +47,6 @@
.setNetworkType(CallServiceDescriptor.FLAG_WIFI |
CallServiceDescriptor.FLAG_MOBILE)
.build());
- try {
- response.setCallServiceDescriptors(descriptors);
- } catch (RemoteException e) {
- Log.e(TAG, "Call to setCallServices failed with exception", e);
- }
+ response.setCallServiceDescriptors(descriptors);
}
}