Add wrappers around telecomm interfaces
This CL adds wrappers for: CallServiceLookupResponse CallServiceAdapter IInCallAdapter IInCallService This CL also moves all the aidl files into com.android.internal.telecomm. Change-Id: I840f023bc545643e8bb719825e7bc78344ee46ee
This commit is contained in:
18
Android.mk
18
Android.mk
@@ -279,15 +279,15 @@ LOCAL_SRC_FILES += \
|
||||
media/java/android/media/session/IMediaSession.aidl \
|
||||
media/java/android/media/session/IMediaSessionCallback.aidl \
|
||||
media/java/android/media/session/IMediaSessionManager.aidl \
|
||||
telecomm/java/android/telecomm/ICallService.aidl \
|
||||
telecomm/java/android/telecomm/ICallServiceAdapter.aidl \
|
||||
telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl \
|
||||
telecomm/java/android/telecomm/ICallServiceProvider.aidl \
|
||||
telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl \
|
||||
telecomm/java/android/telecomm/ICallServiceSelector.aidl \
|
||||
telecomm/java/android/telecomm/ICallSwitchabilityResponse.aidl \
|
||||
telecomm/java/android/telecomm/IInCallAdapter.aidl \
|
||||
telecomm/java/android/telecomm/IInCallService.aidl \
|
||||
telecomm/java/com/android/internal/telecomm/ICallService.aidl \
|
||||
telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl \
|
||||
telecomm/java/com/android/internal/telecomm/ICallServiceLookupResponse.aidl \
|
||||
telecomm/java/com/android/internal/telecomm/ICallServiceProvider.aidl \
|
||||
telecomm/java/com/android/internal/telecomm/ICallServiceSelectionResponse.aidl \
|
||||
telecomm/java/com/android/internal/telecomm/ICallServiceSelector.aidl \
|
||||
telecomm/java/com/android/internal/telecomm/ICallSwitchabilityResponse.aidl \
|
||||
telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl \
|
||||
telecomm/java/com/android/internal/telecomm/IInCallService.aidl \
|
||||
telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \
|
||||
telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \
|
||||
telephony/java/com/android/internal/telephony/ITelephony.aidl \
|
||||
|
||||
@@ -24266,10 +24266,21 @@ package android.telecomm {
|
||||
method public abstract void isCompatibleWith(android.telecomm.CallInfo);
|
||||
method public final android.os.IBinder onBind(android.content.Intent);
|
||||
method public abstract void reject(java.lang.String);
|
||||
method public abstract void setCallServiceAdapter(android.telecomm.ICallServiceAdapter);
|
||||
method public abstract void setCallServiceAdapter(android.telecomm.CallServiceAdapter);
|
||||
method public abstract void setIncomingCallId(java.lang.String, android.os.Bundle);
|
||||
}
|
||||
|
||||
public final class CallServiceAdapter {
|
||||
method public void handleFailedOutgoingCall(java.lang.String, java.lang.String);
|
||||
method public void handleSuccessfulOutgoingCall(java.lang.String);
|
||||
method public void notifyIncomingCall(android.telecomm.CallInfo);
|
||||
method public void setActive(java.lang.String);
|
||||
method public void setDialing(java.lang.String);
|
||||
method public void setDisconnected(java.lang.String);
|
||||
method public void setIsCompatibleWith(java.lang.String, boolean);
|
||||
method public void setRinging(java.lang.String);
|
||||
}
|
||||
|
||||
public final class CallServiceDescriptor implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public java.lang.String getCallServiceId();
|
||||
@@ -24289,9 +24300,13 @@ package android.telecomm {
|
||||
method public android.telecomm.CallServiceDescriptor.Builder setNetworkType(int);
|
||||
}
|
||||
|
||||
public final class CallServiceLookupResponse {
|
||||
method public void setCallServiceDescriptors(java.util.List<android.telecomm.CallServiceDescriptor>);
|
||||
}
|
||||
|
||||
public abstract class CallServiceProvider extends android.app.Service {
|
||||
ctor protected CallServiceProvider();
|
||||
method public abstract void lookupCallServices(android.telecomm.ICallServiceLookupResponse);
|
||||
method public abstract void lookupCallServices(android.telecomm.CallServiceLookupResponse);
|
||||
method public android.os.IBinder onBind(android.content.Intent);
|
||||
}
|
||||
|
||||
@@ -24438,9 +24453,27 @@ package android.telecomm {
|
||||
method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException;
|
||||
}
|
||||
|
||||
public final class InCallAdapter {
|
||||
method public void answerCall(java.lang.String);
|
||||
method public void disconnectCall(java.lang.String);
|
||||
method public void rejectCall(java.lang.String);
|
||||
}
|
||||
|
||||
public abstract class InCallService extends android.app.Service {
|
||||
ctor protected InCallService();
|
||||
method protected abstract void addCall(android.telecomm.CallInfo);
|
||||
method public final android.os.IBinder onBind(android.content.Intent);
|
||||
method protected abstract void setActive(java.lang.String);
|
||||
method protected abstract void setDisconnected(java.lang.String);
|
||||
method protected abstract void setInCallAdapter(android.telecomm.InCallAdapter);
|
||||
}
|
||||
|
||||
public final class TelecommConstants {
|
||||
ctor public TelecommConstants();
|
||||
field public static final java.lang.String ACTION_INCOMING_CALL = "android.intent.action.INCOMING_CALL";
|
||||
field public static final java.lang.String CALL_SERVICE_ACTION;
|
||||
field public static final java.lang.String CALL_SERVICE_PROVIDER_ACTION;
|
||||
field public static final java.lang.String CALL_SERVICE_SELECTOR_ACTION;
|
||||
field public static final java.lang.String EXTRA_CALL_SERVICE_DESCRIPTOR = "android.intent.extra.CALL_SERVICE_DESCRIPTOR";
|
||||
field public static final java.lang.String EXTRA_INCOMING_CALL_EXTRAS = "android.intent.extra.INCOMING_CALL_EXTRAS";
|
||||
}
|
||||
|
||||
@@ -24,13 +24,15 @@ import android.os.IBinder;
|
||||
import android.os.Message;
|
||||
|
||||
import com.android.internal.os.SomeArgs;
|
||||
import com.android.internal.telecomm.ICallService;
|
||||
import com.android.internal.telecomm.ICallServiceAdapter;
|
||||
|
||||
/**
|
||||
* Base implementation of CallService which can be used to provide calls for the system
|
||||
* in-call UI. CallService is a one-way service from the framework's CallsManager to any app
|
||||
* that would like to provide calls managed by the default system in-call user interface.
|
||||
* When the service is bound by the framework, CallsManager will call setCallServiceAdapter
|
||||
* which will provide CallService with an instance of {@link ICallServiceAdapter} to be used
|
||||
* which will provide CallService with an instance of {@link CallServiceAdapter} to be used
|
||||
* for communicating back to CallsManager. Subsequently, more specific methods of the service
|
||||
* will be called to perform various call actions including making an outgoing call and
|
||||
* disconnected existing calls.
|
||||
@@ -52,7 +54,9 @@ public abstract class CallService extends Service {
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_SET_CALL_SERVICE_ADAPTER:
|
||||
setCallServiceAdapter((ICallServiceAdapter) msg.obj);
|
||||
CallServiceAdapter adapter =
|
||||
new CallServiceAdapter((ICallServiceAdapter) msg.obj);
|
||||
setCallServiceAdapter(adapter);
|
||||
break;
|
||||
case MSG_IS_COMPATIBLE_WITH:
|
||||
isCompatibleWith((CallInfo) msg.obj);
|
||||
@@ -177,18 +181,16 @@ public abstract class CallService extends Service {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an implementation of ICallServiceAdapter for adding new calls and communicating state
|
||||
* Sets an implementation of CallServiceAdapter for adding new calls and communicating state
|
||||
* changes of existing calls.
|
||||
* TODO(santoscordon): Should we not reference ICallServiceAdapter directly from here? Should we
|
||||
* wrap that in a wrapper like we do for CallService/ICallService?
|
||||
*
|
||||
* @param callServiceAdapter Adapter object for communicating call to CallsManager
|
||||
*/
|
||||
public abstract void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter);
|
||||
public abstract void setCallServiceAdapter(CallServiceAdapter callServiceAdapter);
|
||||
|
||||
/**
|
||||
* Determines if the CallService can place the specified call. Response is sent via
|
||||
* {@link ICallServiceAdapter#setCompatibleWith}. When responding, the correct call ID must be
|
||||
* {@link CallServiceAdapter#setCompatibleWith}. When responding, the correct call ID must be
|
||||
* specified. Only used in the context of outgoing calls and call switching (handoff).
|
||||
*
|
||||
* @param callInfo The details of the relevant call.
|
||||
@@ -200,7 +202,7 @@ public abstract class CallService extends Service {
|
||||
* SIP address, or some other kind of user ID. Note that the set of handle types is
|
||||
* dynamically extensible since call providers should be able to implement arbitrary
|
||||
* handle-calling systems. See {@link #isCompatibleWith}. It is expected that the
|
||||
* call service respond via {@link ICallServiceAdapter#handleSuccessfulOutgoingCall(String)}
|
||||
* call service respond via {@link CallServiceAdapter#handleSuccessfulOutgoingCall(String)}
|
||||
* if it can successfully make the call. Only used in the context of outgoing calls.
|
||||
*
|
||||
* @param callInfo The details of the relevant call.
|
||||
@@ -212,7 +214,7 @@ public abstract class CallService extends Service {
|
||||
* abort an attempt to place a call. Only ever be invoked after {@link #call} invocations.
|
||||
* After this is invoked, Telecomm does not expect any more updates about the call and will
|
||||
* actively ignore any such update. This is different from {@link #disconnect} where Telecomm
|
||||
* expects confirmation via ICallServiceAdapter.markCallAsDisconnected.
|
||||
* expects confirmation via CallServiceAdapter.markCallAsDisconnected.
|
||||
*
|
||||
* @param callId The identifier of the call to abort.
|
||||
*/
|
||||
@@ -222,7 +224,7 @@ public abstract class CallService extends Service {
|
||||
* Receives a new call ID to use with an incoming call. Invoked by Telecomm after it is notified
|
||||
* that this call service has a pending incoming call, see
|
||||
* {@link TelecommConstants#ACTION_INCOMING_CALL}. The call service must first give Telecomm
|
||||
* additional information about the call through {@link ICallServiceAdapter#handleIncomingCall}.
|
||||
* additional information about the call through {@link CallServiceAdapter#handleIncomingCall}.
|
||||
* Following that, the call service can update the call at will using the specified call ID.
|
||||
*
|
||||
* If a {@link Bundle} was passed (via {@link TelecommConstants#EXTRA_INCOMING_CALL_EXTRAS}) in
|
||||
|
||||
143
telecomm/java/android/telecomm/CallServiceAdapter.java
Normal file
143
telecomm/java/android/telecomm/CallServiceAdapter.java
Normal file
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.telecomm;
|
||||
|
||||
import android.os.RemoteException;
|
||||
|
||||
import com.android.internal.telecomm.ICallServiceAdapter;
|
||||
|
||||
/**
|
||||
* Provides methods for ICallService implementations to interact with the system phone app.
|
||||
* TODO(santoscordon): Need final public-facing comments in this file.
|
||||
*/
|
||||
public final class CallServiceAdapter {
|
||||
private final ICallServiceAdapter mAdapter;
|
||||
|
||||
/**
|
||||
* {@hide}
|
||||
*/
|
||||
public CallServiceAdapter(ICallServiceAdapter adapter) {
|
||||
mAdapter = adapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives confirmation of a call service's ability to place a call. This method is used in
|
||||
* response to {@link CallService#isCompatibleWith}.
|
||||
*
|
||||
* @param callId The identifier of the call for which compatibility is being received. This ID
|
||||
* should correspond to the ID given as part of the call information in
|
||||
* {@link CallService#isCompatibleWith}.
|
||||
* @param isCompatible True if the call service can place the call.
|
||||
*/
|
||||
public void setIsCompatibleWith(String callId, boolean isCompatible) {
|
||||
try {
|
||||
mAdapter.setIsCompatibleWith(callId, isCompatible);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides Telecomm with the details of an incoming call. An invocation of this method must
|
||||
* follow {@link CallService#setIncomingCallId} and use the call ID specified therein. Upon
|
||||
* the invocation of this method, Telecomm will bring up the incoming-call interface where the
|
||||
* user can elect to answer or reject a call.
|
||||
*
|
||||
* @param callInfo The details of the relevant call.
|
||||
*/
|
||||
public void notifyIncomingCall(CallInfo callInfo) {
|
||||
try {
|
||||
mAdapter.notifyIncomingCall(callInfo);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells Telecomm that an attempt to place the specified outgoing call succeeded.
|
||||
* TODO(santoscordon): Consider adding a CallState parameter in case this outgoing call is
|
||||
* somehow no longer in the DIALING state.
|
||||
*
|
||||
* @param callId The ID of the outgoing call.
|
||||
*/
|
||||
public void handleSuccessfulOutgoingCall(String callId) {
|
||||
try {
|
||||
mAdapter.handleSuccessfulOutgoingCall(callId);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells Telecomm that an attempt to place the specified outgoing call failed.
|
||||
*
|
||||
* @param callId The ID of the outgoing call.
|
||||
* @param errorMessage The error associated with the failed call attempt.
|
||||
*/
|
||||
public void handleFailedOutgoingCall(String callId, String errorMessage) {
|
||||
try {
|
||||
mAdapter.handleFailedOutgoingCall(callId, errorMessage);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a call's state to active (e.g., an ongoing call where two parties can actively
|
||||
* communicate).
|
||||
*
|
||||
* @param callId The unique ID of the call whose state is changing to active.
|
||||
*/
|
||||
public void setActive(String callId) {
|
||||
try {
|
||||
mAdapter.setActive(callId);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a call's state to ringing (e.g., an inbound ringing call).
|
||||
*
|
||||
* @param callId The unique ID of the call whose state is changing to ringing.
|
||||
*/
|
||||
public void setRinging(String callId) {
|
||||
try {
|
||||
mAdapter.setRinging(callId);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a call's state to dialing (e.g., dialing an outbound call).
|
||||
*
|
||||
* @param callId The unique ID of the call whose state is changing to dialing.
|
||||
*/
|
||||
public void setDialing(String callId) {
|
||||
try {
|
||||
mAdapter.setDialing(callId);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a call's state to disconnected.
|
||||
*
|
||||
* @param callId The unique ID of the call whose state is changing to disconnected.
|
||||
*/
|
||||
public void setDisconnected(String callId) {
|
||||
try {
|
||||
mAdapter.setDisconnected(callId);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.telecomm;
|
||||
|
||||
import android.os.RemoteException;
|
||||
|
||||
import com.android.internal.telecomm.ICallServiceLookupResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Used by {@link CallServiceProvider} to return a list of {@link CallServiceDescriptor}s.
|
||||
*/
|
||||
public final class CallServiceLookupResponse {
|
||||
private final ICallServiceLookupResponse mResponse;
|
||||
|
||||
/**
|
||||
* {@hide}
|
||||
*/
|
||||
public CallServiceLookupResponse(ICallServiceLookupResponse response) {
|
||||
mResponse = response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes the sorted list of preferred {@link CallServiceDescriptor}s back to Telecomm. Used
|
||||
* in the context of attempting to place a pending outgoing call.
|
||||
*
|
||||
* @param callServiceDescriptors The set of call-service descriptors from
|
||||
* {@link CallServiceProvider}.
|
||||
*/
|
||||
public void setCallServiceDescriptors(List<CallServiceDescriptor> callServiceDescriptors) {
|
||||
try {
|
||||
mResponse.setCallServiceDescriptors(callServiceDescriptors);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,8 +22,8 @@ import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Message;
|
||||
|
||||
import android.telecomm.ICallServiceProvider;
|
||||
import android.telecomm.ICallServiceLookupResponse;
|
||||
import com.android.internal.telecomm.ICallServiceLookupResponse;
|
||||
import com.android.internal.telecomm.ICallServiceProvider;
|
||||
|
||||
/**
|
||||
* Base implementation of {@link ICallServiceProvider} which extends {@link Service}. This class
|
||||
@@ -45,9 +45,9 @@ public abstract class CallServiceProvider extends Service {
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_LOOKUP_CALL_SERVICES:
|
||||
lookupCallServices((ICallServiceLookupResponse) msg.obj);
|
||||
break;
|
||||
default:
|
||||
CallServiceLookupResponse response =
|
||||
new CallServiceLookupResponse((ICallServiceLookupResponse) msg.obj);
|
||||
lookupCallServices(response);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -100,10 +100,10 @@ public abstract class CallServiceProvider extends Service {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiates the process to retrieve the list of {@link ICallService}s implemented by
|
||||
* Initiates the process to retrieve the list of {@link CallServiceDescriptor}s implemented by
|
||||
* this provider.
|
||||
*
|
||||
* @param response The response object through which the list of call services is sent.
|
||||
*/
|
||||
public abstract void lookupCallServices(ICallServiceLookupResponse response);
|
||||
public abstract void lookupCallServices(CallServiceLookupResponse response);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@ import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.os.SomeArgs;
|
||||
import com.android.internal.telecomm.ICallServiceSelector;
|
||||
import com.android.internal.telecomm.ICallServiceSelectionResponse;
|
||||
import com.android.internal.telecomm.ICallSwitchabilityResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -108,7 +111,7 @@ public abstract class CallServiceSelector extends Service {
|
||||
}
|
||||
};
|
||||
|
||||
/** Manages the binder calls so that the implementor does not need to deal it. */
|
||||
/** Manages the binder calls so that the implementor does not need to deal with it. */
|
||||
private final class CallServiceSelectorBinder extends ICallServiceSelector.Stub
|
||||
implements CallSwitchabilityResponse, CallServiceSelectionResponse {
|
||||
private ICallSwitchabilityResponse mSwitchabilityResponse;
|
||||
|
||||
81
telecomm/java/android/telecomm/InCallAdapter.java
Normal file
81
telecomm/java/android/telecomm/InCallAdapter.java
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.telecomm;
|
||||
|
||||
import android.os.RemoteException;
|
||||
|
||||
import com.android.internal.telecomm.IInCallAdapter;
|
||||
|
||||
/**
|
||||
* Receives commands from {@link InCallService} implementations which should be executed by
|
||||
* Telecomm. When Telecomm binds to a {@link InCallService}, an instance of this class is given to
|
||||
* the in-call service through which it can manipulate live (active, dialing, ringing) calls. When
|
||||
* the in-call service is notified of new calls ({@link InCallService#addCall}), it can use the
|
||||
* given call IDs to execute commands such as {@link #answerCall} for incoming calls or
|
||||
* {@link #disconnectCall} for active calls the user would like to end. Some commands are only
|
||||
* appropriate for calls in certain states; please consult each method for such limitations.
|
||||
* TODO(santoscordon): Needs more/better comments once the API is finalized.
|
||||
* TODO(santoscordon): Specify the adapter will stop functioning when there are no more calls.
|
||||
*/
|
||||
public final class InCallAdapter {
|
||||
private final IInCallAdapter mAdapter;
|
||||
|
||||
/**
|
||||
* {@hide}
|
||||
*/
|
||||
public InCallAdapter(IInCallAdapter adapter) {
|
||||
mAdapter = adapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instructs Telecomm to answer the specified call.
|
||||
*
|
||||
* @param callId The identifier of the call to answer.
|
||||
*/
|
||||
public void answerCall(String callId) {
|
||||
try {
|
||||
mAdapter.answerCall(callId);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instructs Telecomm to reject the specified call.
|
||||
* TODO(santoscordon): Add reject-with-text-message parameter when that feature
|
||||
* is ported over.
|
||||
*
|
||||
* @param callId The identifier of the call to reject.
|
||||
*/
|
||||
public void rejectCall(String callId) {
|
||||
try {
|
||||
mAdapter.rejectCall(callId);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instructs Telecomm to disconnect the specified call.
|
||||
*
|
||||
* @param callId The identifier of the call to disconnect.
|
||||
*/
|
||||
public void disconnectCall(String callId) {
|
||||
try {
|
||||
mAdapter.disconnectCall(callId);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
139
telecomm/java/android/telecomm/InCallService.java
Normal file
139
telecomm/java/android/telecomm/InCallService.java
Normal file
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.telecomm;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
|
||||
import com.android.internal.telecomm.IInCallAdapter;
|
||||
import com.android.internal.telecomm.IInCallService;
|
||||
|
||||
/**
|
||||
* This service is implemented by any app that wishes to provide the user-interface for managing
|
||||
* phone calls. Telecomm binds to this service while there exists a live (active or incoming)
|
||||
* call, and uses it to notify the in-call app of any live and and recently disconnected calls.
|
||||
* TODO(santoscordon): Needs more/better description of lifecycle once the interface is better
|
||||
* defined.
|
||||
* TODO(santoscordon): What happens if two or more apps on a given device implement this interface?
|
||||
*/
|
||||
public abstract class InCallService extends Service {
|
||||
private static final int MSG_SET_IN_CALL_ADAPTER = 1;
|
||||
private static final int MSG_ADD_CALL = 2;
|
||||
private static final int MSG_SET_ACTIVE = 3;
|
||||
private static final int MSG_SET_DISCONNECTED = 4;
|
||||
|
||||
/** Default Handler used to consolidate binder method calls onto a single thread. */
|
||||
private final Handler mHandler = new Handler(Looper.getMainLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_SET_IN_CALL_ADAPTER:
|
||||
InCallAdapter adapter = new InCallAdapter((IInCallAdapter) msg.obj);
|
||||
setInCallAdapter(adapter);
|
||||
break;
|
||||
case MSG_ADD_CALL:
|
||||
addCall((CallInfo) msg.obj);
|
||||
break;
|
||||
case MSG_SET_ACTIVE:
|
||||
setActive((String) msg.obj);
|
||||
break;
|
||||
case MSG_SET_DISCONNECTED:
|
||||
setDisconnected((String) msg.obj);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/** Manages the binder calls so that the implementor does not need to deal with it. */
|
||||
private final class InCallServiceBinder extends IInCallService.Stub {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setInCallAdapter(IInCallAdapter inCallAdapter) {
|
||||
mHandler.obtainMessage(MSG_SET_IN_CALL_ADAPTER, inCallAdapter).sendToTarget();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void addCall(CallInfo callInfo) {
|
||||
mHandler.obtainMessage(MSG_ADD_CALL, callInfo).sendToTarget();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setActive(String callId) {
|
||||
mHandler.obtainMessage(MSG_SET_ACTIVE, callId).sendToTarget();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setDisconnected(String callId) {
|
||||
mHandler.obtainMessage(MSG_SET_DISCONNECTED, callId).sendToTarget();
|
||||
}
|
||||
}
|
||||
|
||||
private final InCallServiceBinder mBinder;
|
||||
|
||||
protected InCallService() {
|
||||
mBinder = new InCallServiceBinder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IBinder onBind(Intent intent) {
|
||||
return mBinder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the in-call app an adapter object through which to send call-commands such as
|
||||
* answering and rejecting incoming calls, disconnecting active calls, and putting calls in
|
||||
* special states (mute, hold, etc).
|
||||
*
|
||||
* @param inCallAdapter Adapter through which an in-call app can send call-commands to Telecomm.
|
||||
*/
|
||||
protected abstract void setInCallAdapter(InCallAdapter inCallAdapter);
|
||||
|
||||
/**
|
||||
* Indicates to the in-call app that a new call has been created and an appropriate
|
||||
* user-interface should be built and shown to notify the user. Information about the call
|
||||
* including its current state is passed in through the callInfo object.
|
||||
*
|
||||
* @param callInfo Information about the new call.
|
||||
*/
|
||||
protected abstract void addCall(CallInfo callInfo);
|
||||
|
||||
/**
|
||||
* Indicates to the in-call app that a call has moved to the {@link CallState#ACTIVE} state.
|
||||
*
|
||||
* @param callId The identifier of the call that became active.
|
||||
*/
|
||||
protected abstract void setActive(String callId);
|
||||
|
||||
/**
|
||||
* Indicates to the in-call app that a call has been moved to the
|
||||
* {@link CallState#DISCONNECTED} and the user should be notified.
|
||||
* TODO(santoscordon): Needs disconnect-cause either as a numberical constant, string or both
|
||||
* depending on what is ultimately needed to support all scenarios.
|
||||
*
|
||||
* @param callId The identifier of the call that was disconnected.
|
||||
*/
|
||||
protected abstract void setDisconnected(String callId);
|
||||
}
|
||||
@@ -38,6 +38,21 @@ public final class TelecommConstants {
|
||||
*/
|
||||
public static final String ACTION_INCOMING_CALL = "android.intent.action.INCOMING_CALL";
|
||||
|
||||
/**
|
||||
* The service action used to bind to {@link CallServiceProvider} implementations.
|
||||
*/
|
||||
public static final String ACTION_CALL_SERVICE_PROVIDER = CallServiceProvider.class.getName();
|
||||
|
||||
/**
|
||||
* The service action used to bind to {@link CallService} implementations.
|
||||
*/
|
||||
public static final String ACTION_CALL_SERVICE = CallService.class.getName();
|
||||
|
||||
/**
|
||||
* The service action used to bind to {@link CallServiceSelector} implementations.
|
||||
*/
|
||||
public static final String ACTION_CALL_SERVICE_SELECTOR = CallServiceSelector.class.getName();
|
||||
|
||||
/**
|
||||
* Extra for {@link #ACTION_INCOMING_CALL} containing the {@link CallServiceDescriptor} that
|
||||
* describes the call service to use for the incoming call.
|
||||
|
||||
@@ -14,11 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.telecomm;
|
||||
package com.android.internal.telecomm;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.telecomm.CallInfo;
|
||||
import android.telecomm.ICallServiceAdapter;
|
||||
|
||||
import com.android.internal.telecomm.ICallServiceAdapter;
|
||||
|
||||
/**
|
||||
* Service interface for services which would like to provide calls to be
|
||||
@@ -31,6 +32,7 @@ import android.telecomm.ICallServiceAdapter;
|
||||
* 2) Prior to an outbound call to test if this call service is compatible with the outgoing call.
|
||||
*
|
||||
* TODO(santoscordon): Need final public-facing comments in this file.
|
||||
* {@hide}
|
||||
*/
|
||||
oneway interface ICallService {
|
||||
|
||||
@@ -14,38 +14,37 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.telecomm;
|
||||
package com.android.internal.telecomm;
|
||||
|
||||
import android.telecomm.CallInfo;
|
||||
|
||||
/**
|
||||
* Provides methods for ICallService implementations to interact with the system phone app.
|
||||
* TODO(santoscordon): Need final public-facing comments in this file.
|
||||
* {@hide}
|
||||
*/
|
||||
oneway interface ICallServiceAdapter {
|
||||
|
||||
/**
|
||||
* Receives confirmation of a call service's ability to place a call. This method is used in
|
||||
* response to {@link ICallService#isCompatibleWith}.
|
||||
* TODO(santoscordon): rename to setIsCompatibleWith().
|
||||
*
|
||||
* @param callId The identifier of the call for which compatibility is being received. This ID
|
||||
* should correspond to the ID given as part of the call information in
|
||||
* {@link ICallService#isCompatibleWith}.
|
||||
* @param isCompatible True if the call service can place the call.
|
||||
*/
|
||||
void setCompatibleWith(String callId, boolean isCompatible);
|
||||
void setIsCompatibleWith(String callId, boolean isCompatible);
|
||||
|
||||
/**
|
||||
* Provides Telecomm with the details of an incoming call. An invocation of this method must
|
||||
* follow {@link CallService#setIncomingCallId} and use the call ID specified therein. Upon
|
||||
* the invocation of this method, Telecomm will bring up the incoming-call interface where the
|
||||
* user can elect to answer or reject a call.
|
||||
* TODO(santoscordon): Consider renaming from handle* to notify*.
|
||||
*
|
||||
* @param callInfo The details of the relevant call.
|
||||
*/
|
||||
void handleIncomingCall(in CallInfo callInfo);
|
||||
void notifyIncomingCall(in CallInfo callInfo);
|
||||
|
||||
/**
|
||||
* Tells Telecomm that an attempt to place the specified outgoing call succeeded.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.telecomm;
|
||||
package com.android.internal.telecomm;
|
||||
|
||||
import android.os.IBinder;
|
||||
import android.telecomm.CallServiceDescriptor;
|
||||
@@ -22,6 +22,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Used by {@link ICallServiceProvider} to return a list of {@link CallServiceDescriptor}s.
|
||||
* {@hide}
|
||||
*/
|
||||
oneway interface ICallServiceLookupResponse {
|
||||
/**
|
||||
@@ -14,9 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.telecomm;
|
||||
package com.android.internal.telecomm;
|
||||
|
||||
import android.telecomm.ICallServiceLookupResponse;
|
||||
import android.telecomm.CallServiceDescriptor;
|
||||
|
||||
import com.android.internal.telecomm.ICallServiceLookupResponse;
|
||||
|
||||
/**
|
||||
* Interface for applications interested in providing call-service implementations. Only used in
|
||||
@@ -30,11 +32,12 @@ import android.telecomm.ICallServiceLookupResponse;
|
||||
* processed by the CallsManager and its helpers (potentially requesting input from the user) to
|
||||
* identify the best CallService. The user should obviously be notified upon zero candidates as
|
||||
* well as all (one or more) candidates failing to issue the call.
|
||||
* {@hide}
|
||||
*/
|
||||
oneway interface ICallServiceProvider {
|
||||
|
||||
/**
|
||||
* Initiates the process to retrieve the list of {@link ICallService}s implemented by
|
||||
* Initiates the process to retrieve the list of {@link CallServiceDescriptor}s implemented by
|
||||
* this provider.
|
||||
* TODO(santoscordon): Needs comments on how to populate the list within
|
||||
* ICallServiceLookupResponse and how to handle error conditions.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.telecomm;
|
||||
package com.android.internal.telecomm;
|
||||
|
||||
import android.os.IBinder;
|
||||
import android.telecomm.CallServiceDescriptor;
|
||||
@@ -23,6 +23,7 @@ import java.util.List;
|
||||
/**
|
||||
* Used by {@link ICallServiceSelector} to return the preferred list of {@link ICallService}
|
||||
* implementations with which to connect the corresponding outgoing call.
|
||||
* {@hide}
|
||||
*/
|
||||
oneway interface ICallServiceSelectionResponse {
|
||||
/**
|
||||
@@ -14,13 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.telecomm;
|
||||
package com.android.internal.telecomm;
|
||||
|
||||
import android.telecomm.CallInfo;
|
||||
import android.telecomm.CallServiceDescriptor;
|
||||
import android.telecomm.ICallService;
|
||||
import android.telecomm.ICallServiceSelectionResponse;
|
||||
import android.telecomm.ICallSwitchabilityResponse;
|
||||
|
||||
import com.android.internal.telecomm.ICallService;
|
||||
import com.android.internal.telecomm.ICallServiceSelectionResponse;
|
||||
import com.android.internal.telecomm.ICallSwitchabilityResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -61,6 +62,7 @@ import java.util.List;
|
||||
* all supported (either for a given call or globally across a given selector) , isSwitchable
|
||||
* below can return false blindly to suppress all "select" calls beyond the initial one (that
|
||||
* is used to establish outgoing calls).
|
||||
* {@hide}
|
||||
*/
|
||||
oneway interface ICallServiceSelector {
|
||||
|
||||
@@ -14,11 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.telecomm;
|
||||
package com.android.internal.telecomm;
|
||||
|
||||
/**
|
||||
* Used by {@link ICallServiceSelector}s to return whether or not the relevant
|
||||
* call is switchable.
|
||||
* {@hide}
|
||||
*/
|
||||
oneway interface ICallSwitchabilityResponse {
|
||||
/**
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.telecomm;
|
||||
package com.android.internal.telecomm;
|
||||
|
||||
/**
|
||||
* Receives commands from {@link IInCallService} implementations which should be executed by
|
||||
@@ -28,6 +28,7 @@ package android.telecomm;
|
||||
* TODO(santoscordon): Specify the adapter will stop functioning when there are no more calls.
|
||||
* TODO(santoscordon): Once we have proper "CallState" constant definitions, consider rewording
|
||||
* the javadoc to reference those states precisely.
|
||||
* {@hide}
|
||||
*/
|
||||
oneway interface IInCallAdapter {
|
||||
/**
|
||||
@@ -14,10 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.telecomm;
|
||||
package com.android.internal.telecomm;
|
||||
|
||||
import android.telecomm.CallInfo;
|
||||
import android.telecomm.IInCallAdapter;
|
||||
|
||||
import com.android.internal.telecomm.IInCallAdapter;
|
||||
|
||||
/**
|
||||
* This service is implemented by any app that wishes to provide the user-interface for managing
|
||||
@@ -25,7 +26,8 @@ import android.telecomm.IInCallAdapter;
|
||||
* call, and uses it to notify the in-call app of any live and and recently disconnected calls.
|
||||
* TODO(santoscordon): Needs more/better description of lifecycle once the interface is better
|
||||
* defined.
|
||||
* TODO(santoscordon): What happens if two or more apps on a given decide implement this interface?
|
||||
* TODO(santoscordon): What happens if two or more apps on a given device implement this interface?
|
||||
* {@hide}
|
||||
*/
|
||||
oneway interface IInCallService {
|
||||
|
||||
@@ -48,17 +50,16 @@ oneway interface IInCallService {
|
||||
void addCall(in CallInfo callInfo);
|
||||
|
||||
/**
|
||||
* Indicates to the in-call app that a call has moved to the active state.
|
||||
* TODO(santoscordon): link javadoc to "active" constant once CallState is defined.
|
||||
* Indicates to the in-call app that a call has moved to the
|
||||
* {@link android.telecomm.CallState#ACTIVE} state.
|
||||
*
|
||||
* @param callId The identifier of the call that became active.
|
||||
*/
|
||||
void setActive(String callId);
|
||||
|
||||
/**
|
||||
* Indicates to the in-call app that a call has been disconnected and the user should be
|
||||
* notified.
|
||||
* TODO(santoscordon): link javadoc to "disconnected" constant once CallState is defined.
|
||||
* Indicates to the in-call app that a call has been moved to the
|
||||
* {@link android.telecomm.CallState#DISCONNECTED} and the user should be notified.
|
||||
* TODO(santoscordon): Needs disconnect-cause either as a numberical constant, string or both
|
||||
* depending on what is ultimately needed to support all scenarios.
|
||||
*
|
||||
Reference in New Issue
Block a user