diff options
Diffstat (limited to 'telecomm/java/android/telecom/Phone.java')
| -rw-r--r-- | telecomm/java/android/telecom/Phone.java | 66 |
1 files changed, 47 insertions, 19 deletions
diff --git a/telecomm/java/android/telecom/Phone.java b/telecomm/java/android/telecom/Phone.java index 6344181..8eb091b 100644 --- a/telecomm/java/android/telecom/Phone.java +++ b/telecomm/java/android/telecom/Phone.java @@ -28,9 +28,11 @@ import java.util.concurrent.CopyOnWriteArrayList; /** * A unified virtual device providing a means of voice (and other) communication on a device. * - * {@hide} + * @hide + * @deprecated Use {@link InCallService} directly instead of using this class. */ @SystemApi +@Deprecated public final class Phone { public abstract static class Listener { @@ -39,10 +41,21 @@ public final class Phone { * * @param phone The {@code Phone} calling this method. * @param audioState The new {@link AudioState}. + * + * @deprecated Use {@link #onCallAudioStateChanged(Phone, CallAudioState)} instead. */ + @Deprecated public void onAudioStateChanged(Phone phone, AudioState audioState) { } /** + * Called when the audio state changes. + * + * @param phone The {@code Phone} calling this method. + * @param callAudioState The new {@link CallAudioState}. + */ + public void onCallAudioStateChanged(Phone phone, CallAudioState callAudioState) { } + + /** * 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. @@ -98,18 +111,16 @@ public final class Phone { private final InCallAdapter mInCallAdapter; - private AudioState mAudioState; + private CallAudioState mCallAudioState; private final List<Listener> mListeners = new CopyOnWriteArrayList<>(); private boolean mCanAddCall = true; - /** {@hide} */ Phone(InCallAdapter adapter) { mInCallAdapter = adapter; } - /** {@hide} */ final void internalAddCall(ParcelableCall parcelableCall) { Call call = new Call(this, parcelableCall.getId(), mInCallAdapter); mCallByTelecomCallId.put(parcelableCall.getId(), call); @@ -119,14 +130,17 @@ public final class Phone { fireCallAdded(call); } - /** {@hide} */ final void internalRemoveCall(Call call) { mCallByTelecomCallId.remove(call.internalGetCallId()); mCalls.remove(call); + + InCallService.VideoCall videoCall = call.getVideoCall(); + if (videoCall != null) { + videoCall.destroy(); + } fireCallRemoved(call); } - /** {@hide} */ final void internalUpdateCall(ParcelableCall parcelableCall) { Call call = mCallByTelecomCallId.get(parcelableCall.getId()); if (call != null) { @@ -135,7 +149,6 @@ public final class Phone { } } - /** {@hide} */ final void internalSetPostDialWait(String telecomId, String remaining) { Call call = mCallByTelecomCallId.get(telecomId); if (call != null) { @@ -143,25 +156,21 @@ public final class Phone { } } - /** {@hide} */ - final void internalAudioStateChanged(AudioState audioState) { - if (!Objects.equals(mAudioState, audioState)) { - mAudioState = audioState; - fireAudioStateChanged(audioState); + final void internalCallAudioStateChanged(CallAudioState callAudioState) { + if (!Objects.equals(mCallAudioState, callAudioState)) { + mCallAudioState = callAudioState; + fireCallAudioStateChanged(callAudioState); } } - /** {@hide} */ final Call internalGetCallByTelecomId(String telecomId) { return mCallByTelecomCallId.get(telecomId); } - /** {@hide} */ final void internalBringToForeground(boolean showDialpad) { fireBringToForeground(showDialpad); } - /** {@hide} */ final void internalSetCanAddCall(boolean canAddCall) { if (mCanAddCall != canAddCall) { mCanAddCall = canAddCall; @@ -171,10 +180,13 @@ public final class Phone { /** * Called to destroy the phone and cleanup any lingering calls. - * @hide */ final void destroy() { for (Call call : mCalls) { + InCallService.VideoCall videoCall = call.getVideoCall(); + if (videoCall != null) { + videoCall.destroy(); + } if (call.getState() != Call.STATE_DISCONNECTED) { call.internalSetDisconnected(); } @@ -244,6 +256,8 @@ public final class Phone { * become active, and the touch screen and display will be turned off when the user's face * is detected to be in close proximity to the screen. This operation is a no-op on devices * that do not have a proximity sensor. + * + * @hide */ public final void setProximitySensorOn() { mInCallAdapter.turnProximitySensorOn(); @@ -257,6 +271,8 @@ public final class Phone { * @param screenOnImmediately If true, the screen will be turned on immediately if it was * previously off. Otherwise, the screen will only be turned on after the proximity sensor * is no longer triggered. + * + * @hide */ public final void setProximitySensorOff(boolean screenOnImmediately) { mInCallAdapter.turnProximitySensorOff(screenOnImmediately); @@ -266,9 +282,20 @@ public final class Phone { * Obtains the current phone call audio state of the {@code Phone}. * * @return An object encapsulating the audio state. + * @deprecated Use {@link #getCallAudioState()} instead. */ + @Deprecated public final AudioState getAudioState() { - return mAudioState; + return new AudioState(mCallAudioState); + } + + /** + * Obtains the current phone call audio state of the {@code Phone}. + * + * @return An object encapsulating the audio state. + */ + public final CallAudioState getCallAudioState() { + return mCallAudioState; } private void fireCallAdded(Call call) { @@ -283,9 +310,10 @@ public final class Phone { } } - private void fireAudioStateChanged(AudioState audioState) { + private void fireCallAudioStateChanged(CallAudioState audioState) { for (Listener listener : mListeners) { - listener.onAudioStateChanged(this, audioState); + listener.onCallAudioStateChanged(this, audioState); + listener.onAudioStateChanged(this, new AudioState(audioState)); } } |
