summaryrefslogtreecommitdiffstats
path: root/telecomm/java/android/telecom/InCallService.java
diff options
context:
space:
mode:
Diffstat (limited to 'telecomm/java/android/telecom/InCallService.java')
-rw-r--r--telecomm/java/android/telecom/InCallService.java184
1 files changed, 170 insertions, 14 deletions
diff --git a/telecomm/java/android/telecom/InCallService.java b/telecomm/java/android/telecom/InCallService.java
index 66072da..7cbc0fc 100644
--- a/telecomm/java/android/telecom/InCallService.java
+++ b/telecomm/java/android/telecom/InCallService.java
@@ -17,6 +17,7 @@
package android.telecom;
import android.annotation.SdkConstant;
+import android.annotation.SystemApi;
import android.app.Service;
import android.content.Intent;
import android.os.Handler;
@@ -30,6 +31,8 @@ import com.android.internal.telecom.IInCallAdapter;
import com.android.internal.telecom.IInCallService;
import java.lang.String;
+import java.util.Collections;
+import java.util.List;
/**
* This service is implemented by any app that wishes to provide the user-interface for managing
@@ -63,6 +66,7 @@ public abstract class InCallService extends Service {
switch (msg.what) {
case MSG_SET_IN_CALL_ADAPTER:
mPhone = new Phone(new InCallAdapter((IInCallAdapter) msg.obj));
+ mPhone.addListener(mPhoneListener);
onPhoneCreated(mPhone);
break;
case MSG_ADD_CALL:
@@ -144,6 +148,39 @@ public abstract class InCallService extends Service {
}
}
+ private Phone.Listener mPhoneListener = new Phone.Listener() {
+ /** ${inheritDoc} */
+ @Override
+ public void onAudioStateChanged(Phone phone, AudioState audioState) {
+ InCallService.this.onAudioStateChanged(audioState);
+ }
+
+ /** ${inheritDoc} */
+ @Override
+ public void onBringToForeground(Phone phone, boolean showDialpad) {
+ InCallService.this.onBringToForeground(showDialpad);
+ }
+
+ /** ${inheritDoc} */
+ @Override
+ public void onCallAdded(Phone phone, Call call) {
+ InCallService.this.onCallAdded(call);
+ }
+
+ /** ${inheritDoc} */
+ @Override
+ public void onCallRemoved(Phone phone, Call call) {
+ InCallService.this.onCallRemoved(call);
+ }
+
+ /** ${inheritDoc} */
+ @Override
+ public void onCanAddCallChanged(Phone phone, boolean canAddCall) {
+ InCallService.this.onCanAddCallChanged(canAddCall);
+ }
+
+ };
+
private Phone mPhone;
public InCallService() {
@@ -161,8 +198,14 @@ public abstract class InCallService extends Service {
mPhone = null;
oldPhone.destroy();
+ // destroy sets all the calls to disconnected if any live ones still exist. Therefore,
+ // it is important to remove the Listener *after* the call to destroy so that
+ // InCallService.on* callbacks are appropriately called.
+ oldPhone.removeListener(mPhoneListener);
+
onPhoneDestroyed(oldPhone);
}
+
return false;
}
@@ -172,19 +215,79 @@ public abstract class InCallService extends Service {
* @return The {@code Phone} object associated with this {@code InCallService}, or {@code null}
* if the {@code InCallService} is not in a state where it has an associated
* {@code Phone}.
+ * @hide
+ * @deprecated Use direct methods on InCallService instead of {@link Phone}.
*/
- public final Phone getPhone() {
+ @SystemApi
+ @Deprecated
+ public Phone getPhone() {
return mPhone;
}
/**
+ * Obtains the current list of {@code Call}s to be displayed by this in-call experience.
+ *
+ * @return A list of the relevant {@code Call}s.
+ */
+ public final List<Call> getCalls() {
+ return mPhone == null ? Collections.<Call>emptyList() : mPhone.getCalls();
+ }
+
+ /**
+ * Returns if the device can support additional calls.
+ *
+ * @return Whether the phone supports adding more calls.
+ */
+ public final boolean canAddCall() {
+ return mPhone == null ? false : mPhone.canAddCall();
+ }
+
+ /**
+ * Obtains the current phone call audio state.
+ *
+ * @return An object encapsulating the audio state. Returns null if the service is not
+ * fully initialized.
+ */
+ public final AudioState getAudioState() {
+ return mPhone == null ? null : mPhone.getAudioState();
+ }
+
+ /**
+ * Sets the microphone mute state. When this request is honored, there will be change to
+ * the {@link #getAudioState()}.
+ *
+ * @param state {@code true} if the microphone should be muted; {@code false} otherwise.
+ */
+ public final void setMuted(boolean state) {
+ if (mPhone != null) {
+ mPhone.setMuted(state);
+ }
+ }
+
+ /**
+ * Sets the audio route (speaker, bluetooth, etc...). When this request is honored, there will
+ * be change to the {@link #getAudioState()}.
+ *
+ * @param route The audio route to use.
+ */
+ public final void setAudioRoute(int route) {
+ if (mPhone != null) {
+ mPhone.setAudioRoute(route);
+ }
+ }
+
+ /**
* Invoked when the {@code Phone} has been created. This is a signal to the in-call experience
* to start displaying in-call information to the user. Each instance of {@code InCallService}
* will have only one {@code Phone}, and this method will be called exactly once in the lifetime
* of the {@code InCallService}.
*
* @param phone The {@code Phone} object associated with this {@code InCallService}.
+ * @hide
+ * @deprecated Use direct methods on InCallService instead of {@link Phone}.
*/
+ @SystemApi
+ @Deprecated
public void onPhoneCreated(Phone phone) {
}
@@ -195,22 +298,76 @@ public abstract class InCallService extends Service {
* call to {@link #onPhoneCreated(Phone)}.
*
* @param phone The {@code Phone} object associated with this {@code InCallService}.
+ * @hide
+ * @deprecated Use direct methods on InCallService instead of {@link Phone}.
*/
+ @SystemApi
+ @Deprecated
public void onPhoneDestroyed(Phone phone) {
}
/**
+ * Called when the audio state changes.
+ *
+ * @param audioState The new {@link AudioState}.
+ */
+ public void onAudioStateChanged(AudioState audioState) {
+ }
+
+ /**
+ * Called to bring the in-call screen to the foreground. The in-call experience should
+ * respond immediately by coming to the foreground to inform the user of the state of
+ * ongoing {@code Call}s.
+ *
+ * @param showDialpad If true, put up the dialpad when the screen is shown.
+ */
+ public void onBringToForeground(boolean showDialpad) {
+ }
+
+ /**
+ * Called when a {@code Call} has been added to this in-call session. The in-call user
+ * experience should add necessary state listeners to the specified {@code Call} and
+ * immediately start to show the user information about the existence
+ * and nature of this {@code Call}. Subsequent invocations of {@link #getCalls()} will
+ * include this {@code Call}.
+ *
+ * @param call A newly added {@code Call}.
+ */
+ public void onCallAdded(Call call) {
+ }
+
+ /**
+ * Called when a {@code Call} has been removed from this in-call session. The in-call user
+ * experience should remove any state listeners from the specified {@code Call} and
+ * immediately stop displaying any information about this {@code Call}.
+ * Subsequent invocations of {@link #getCalls()} will no longer include this {@code Call}.
+ *
+ * @param call A newly removed {@code Call}.
+ */
+ public void onCallRemoved(Call call) {
+ }
+
+ /**
+ * Called when the ability to add more calls changes. If the phone cannot
+ * support more calls then {@code canAddCall} is set to {@code false}. If it can, then it
+ * is set to {@code true}. This can be used to control the visibility of UI to add more calls.
+ *
+ * @param canAddCall Indicates whether an additional call can be added.
+ */
+ public void onCanAddCallChanged(boolean canAddCall) {
+ }
+
+ /**
* Class to invoke functionality related to video calls.
*/
public static abstract class VideoCall {
/**
- * Sets a listener to invoke callback methods in the InCallUI after performing video
- * telephony actions.
+ * Registers a callback to receive commands and state changes for video calls.
*
- * @param videoCallListener The call video client.
+ * @param callback The video call callback.
*/
- public abstract void setVideoCallListener(VideoCall.Listener videoCallListener);
+ public abstract void registerCallback(VideoCall.Callback callback);
/**
* Sets the camera to be used for video recording in a video call.
@@ -253,7 +410,7 @@ public abstract class InCallService extends Service {
/**
* Issues a request to modify the properties of the current session. The request is sent to
* the remote device where it it handled by
- * {@link VideoCall.Listener#onSessionModifyRequestReceived}.
+ * {@link VideoCall.Callback#onSessionModifyRequestReceived}.
* Some examples of session modification requests: upgrade call from audio to video,
* downgrade call from video to audio, pause video.
*
@@ -265,9 +422,9 @@ public abstract class InCallService extends Service {
* Provides a response to a request to change the current call session video
* properties.
* This is in response to a request the InCall UI has received via
- * {@link VideoCall.Listener#onSessionModifyRequestReceived}.
+ * {@link VideoCall.Callback#onSessionModifyRequestReceived}.
* The response is handled on the remove device by
- * {@link VideoCall.Listener#onSessionModifyResponseReceived}.
+ * {@link VideoCall.Callback#onSessionModifyResponseReceived}.
*
* @param responseProfile The response call video properties.
*/
@@ -276,14 +433,14 @@ public abstract class InCallService extends Service {
/**
* Issues a request to the video provider to retrieve the camera capabilities.
* Camera capabilities are reported back to the caller via
- * {@link VideoCall.Listener#onCameraCapabilitiesChanged(CameraCapabilities)}.
+ * {@link VideoCall.Callback#onCameraCapabilitiesChanged(CameraCapabilities)}.
*/
public abstract void requestCameraCapabilities();
/**
* Issues a request to the video telephony framework to retrieve the cumulative data usage for
* the current call. Data usage is reported back to the caller via
- * {@link VideoCall.Listener#onCallDataUsageChanged}.
+ * {@link VideoCall.Callback#onCallDataUsageChanged}.
*/
public abstract void requestCallDataUsage();
@@ -296,9 +453,9 @@ public abstract class InCallService extends Service {
public abstract void setPauseImage(String uri);
/**
- * Listener class which invokes callbacks after video call actions occur.
+ * Callback class which invokes callbacks after video call actions occur.
*/
- public static abstract class Listener {
+ public static abstract class Callback {
/**
* Called when a session modification request is received from the remote device.
* The remote request is sent via
@@ -373,8 +530,7 @@ public abstract class InCallService extends Service {
*
* @param cameraCapabilities The changed camera capabilities.
*/
- public abstract void onCameraCapabilitiesChanged(
- CameraCapabilities cameraCapabilities);
+ public abstract void onCameraCapabilitiesChanged(CameraCapabilities cameraCapabilities);
}
}
}