summaryrefslogtreecommitdiffstats
path: root/telecomm/java/android/telecom/InCallService.java
diff options
context:
space:
mode:
authorSantos Cordon <santoscordon@google.com>2015-04-15 11:05:16 -0700
committerSantos Cordon <santoscordon@google.com>2015-04-16 10:54:12 -0700
commita2492810dfb0cd290b5466e33d5bdc5be4fb330e (patch)
tree96cc501ea5881e4c13b4fa5aa2713e2103b35a45 /telecomm/java/android/telecom/InCallService.java
parent3f2631f526d0a0ac0b57ac9f6d241bcc7aeb5f5b (diff)
downloadframeworks_base-a2492810dfb0cd290b5466e33d5bdc5be4fb330e.zip
frameworks_base-a2492810dfb0cd290b5466e33d5bdc5be4fb330e.tar.gz
frameworks_base-a2492810dfb0cd290b5466e33d5bdc5be4fb330e.tar.bz2
Move Phone.java APIs into InCallService
This change is one step in the right direction of getting rid of Phone.java. Phone.java was deemed superfluous and this change moves the methods previously exposed in Phone.java into InCallService. This was done by having InCallService listen to Phone and pipe the calls as appropriate. However, state still lives in Phone and we eventually want to move that code into InCallService. That will be done in a later CL. Bug: 20160495 Change-Id: Id142431c253c1f24f260da42e8bedd1eb2ce448b
Diffstat (limited to 'telecomm/java/android/telecom/InCallService.java')
-rw-r--r--telecomm/java/android/telecom/InCallService.java155
1 files changed, 153 insertions, 2 deletions
diff --git a/telecomm/java/android/telecom/InCallService.java b/telecomm/java/android/telecom/InCallService.java
index 66072da..a17474a 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,75 @@ 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
*/
+ @SystemApi
public final 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
*/
+ @SystemApi
public void onPhoneCreated(Phone phone) {
}
@@ -195,11 +294,64 @@ public abstract class InCallService extends Service {
* call to {@link #onPhoneCreated(Phone)}.
*
* @param phone The {@code Phone} object associated with this {@code InCallService}.
+ * @hide
*/
+ @SystemApi
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 {
@@ -373,8 +525,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);
}
}
}