diff options
Diffstat (limited to 'telecomm/java')
31 files changed, 1370 insertions, 398 deletions
diff --git a/telecomm/java/android/telecom/AudioState.java b/telecomm/java/android/telecom/AudioState.java index 9c03319..465c5f4 100644 --- a/telecomm/java/android/telecom/AudioState.java +++ b/telecomm/java/android/telecom/AudioState.java @@ -16,7 +16,6 @@ package android.telecom; -import android.annotation.SystemApi; import android.os.Parcel; import android.os.Parcelable; @@ -25,9 +24,7 @@ import java.util.Locale; /** * Encapsulates the telecom audio state, including the current audio routing, supported audio * routing and mute. - * @hide */ -@SystemApi public final class AudioState implements Parcelable { /** Direct the audio stream through the device's earpiece. */ public static final int ROUTE_EARPIECE = 0x00000001; @@ -47,21 +44,13 @@ public final class AudioState implements Parcelable { */ public static final int ROUTE_WIRED_OR_EARPIECE = ROUTE_EARPIECE | ROUTE_WIRED_HEADSET; - /** Bit mask of all possible audio routes. - * - * @hide - */ - public static final int ROUTE_ALL = ROUTE_EARPIECE | ROUTE_BLUETOOTH | ROUTE_WIRED_HEADSET | + /** Bit mask of all possible audio routes. */ + private static final int ROUTE_ALL = ROUTE_EARPIECE | ROUTE_BLUETOOTH | ROUTE_WIRED_HEADSET | ROUTE_SPEAKER; - /** Note: Deprecated, please do not use if possible. */ - @SystemApi public final boolean isMuted; - - /** Note: Deprecated, please do not use if possible. */ - @SystemApi public final int route; - - /** Note: Deprecated, please do not use if possible. */ - @SystemApi public final int supportedRouteMask; + private final boolean isMuted; + private final int route; + private final int supportedRouteMask; public AudioState(boolean muted, int route, int supportedRouteMask) { this.isMuted = muted; @@ -97,7 +86,6 @@ public final class AudioState implements Parcelable { audioRouteToString(supportedRouteMask)); } - /** @hide */ public static String audioRouteToString(int route) { if (route == 0 || (route & ~ROUTE_ALL) != 0x0) { return "UNKNOWN"; diff --git a/telecomm/java/android/telecom/AuthenticatorService.java b/telecomm/java/android/telecom/AuthenticatorService.java new file mode 100644 index 0000000..1e43c71 --- /dev/null +++ b/telecomm/java/android/telecom/AuthenticatorService.java @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2015 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.telecom; +import android.accounts.AbstractAccountAuthenticator; +import android.accounts.Account; +import android.accounts.AccountAuthenticatorResponse; +import android.accounts.NetworkErrorException; +import android.app.Service; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.os.IBinder; + +/** + * A generic stub account authenticator service often used for sync adapters that do not directly + * involve accounts. + * + * @hide + */ +public class AuthenticatorService extends Service { + private static Authenticator mAuthenticator; + + @Override + public void onCreate() { + mAuthenticator = new Authenticator(this); + } + + @Override + public IBinder onBind(Intent intent) { + return mAuthenticator.getIBinder(); + } + + /** + * Stub account authenticator. All methods either return null or throw an exception. + */ + public class Authenticator extends AbstractAccountAuthenticator { + public Authenticator(Context context) { + super(context); + } + + @Override + public Bundle editProperties(AccountAuthenticatorResponse accountAuthenticatorResponse, + String s) { + throw new UnsupportedOperationException(); + } + + @Override + public Bundle addAccount(AccountAuthenticatorResponse accountAuthenticatorResponse, + String s, String s2, String[] strings, Bundle bundle) + throws NetworkErrorException { + return null; + } + + @Override + public Bundle confirmCredentials(AccountAuthenticatorResponse accountAuthenticatorResponse, + Account account, Bundle bundle) + throws NetworkErrorException { + return null; + } + + @Override + public Bundle getAuthToken(AccountAuthenticatorResponse accountAuthenticatorResponse, + Account account, String s, Bundle bundle) + throws NetworkErrorException { + throw new UnsupportedOperationException(); + } + + @Override + public String getAuthTokenLabel(String s) { + throw new UnsupportedOperationException(); + } + + @Override + public Bundle updateCredentials(AccountAuthenticatorResponse accountAuthenticatorResponse, + Account account, String s, Bundle bundle) + throws NetworkErrorException { + throw new UnsupportedOperationException(); + } + + @Override + public Bundle hasFeatures(AccountAuthenticatorResponse accountAuthenticatorResponse, + Account account, String[] strings) + throws NetworkErrorException { + throw new UnsupportedOperationException(); + } + } +} diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java index d8a14ef..bbd5e30 100644 --- a/telecomm/java/android/telecom/Call.java +++ b/telecomm/java/android/telecom/Call.java @@ -30,10 +30,7 @@ import java.util.concurrent.CopyOnWriteArrayList; /** * Represents an ongoing phone call that the in-call app should present to the user. - * - * {@hide} */ -@SystemApi public final class Call { /** * The state of a {@code Call} when newly created. @@ -91,8 +88,6 @@ public final class Call { * The key to retrieve the optional {@code PhoneAccount}s Telecom can bundle with its Call * extras. Used to pass the phone accounts to display on the front end to the user in order to * select phone accounts to (for example) place a call. - * - * @hide */ public static final String AVAILABLE_PHONE_ACCOUNTS = "selectPhoneAccountAccounts"; @@ -141,28 +136,36 @@ public final class Call { public static final int CAPABILITY_MANAGE_CONFERENCE = 0x00000080; /** - * Local device supports video telephony. - * @hide + * Local device supports receiving video. */ - public static final int CAPABILITY_SUPPORTS_VT_LOCAL = 0x00000100; + public static final int CAPABILITY_SUPPORTS_VT_LOCAL_RX = 0x00000100; /** - * Remote device supports video telephony. - * @hide + * Local device supports transmitting video. */ - public static final int CAPABILITY_SUPPORTS_VT_REMOTE = 0x00000200; + public static final int CAPABILITY_SUPPORTS_VT_LOCAL_TX = 0x00000200; /** - * Call is using high definition audio. - * @hide + * Local device supports bidirectional video calling. */ - public static final int CAPABILITY_HIGH_DEF_AUDIO = 0x00000400; + public static final int CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL = + CAPABILITY_SUPPORTS_VT_LOCAL_RX | CAPABILITY_SUPPORTS_VT_LOCAL_TX; /** - * Call is using voice over WIFI. - * @hide + * Remote device supports receiving video. */ - public static final int CAPABILITY_VoWIFI = 0x00000800; + public static final int CAPABILITY_SUPPORTS_VT_REMOTE_RX = 0x00000400; + + /** + * Remote device supports transmitting video. + */ + public static final int CAPABILITY_SUPPORTS_VT_REMOTE_TX = 0x00000800; + + /** + * Remote device supports bidirectional video calling. + */ + public static final int CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL = + CAPABILITY_SUPPORTS_VT_REMOTE_RX | CAPABILITY_SUPPORTS_VT_REMOTE_TX; /** * Call is able to be separated from its parent {@code Conference}, if any. @@ -173,20 +176,49 @@ public final class Call { * Call is able to be individually disconnected when in a {@code Conference}. */ public static final int CAPABILITY_DISCONNECT_FROM_CONFERENCE = 0x00002000; - + /** * Whether the call is a generic conference, where we do not know the precise state of * participants in the conference (eg. on CDMA). - * - * @hide */ public static final int CAPABILITY_GENERIC_CONFERENCE = 0x00004000; /** + * Call is using high definition audio. + */ + public static final int CAPABILITY_HIGH_DEF_AUDIO = 0x00008000; + + /** + * Call is using WIFI. + */ + public static final int CAPABILITY_WIFI = 0x00010000; + + /** + * Indicates that the current device callback number should be shown. + */ + public static final int CAPABILITY_SHOW_CALLBACK_NUMBER = 0x00020000; + + /** * Speed up audio setup for MT call. * @hide */ - public static final int CAPABILITY_SPEED_UP_MT_AUDIO = 0x00008000; + public static final int CAPABILITY_SPEED_UP_MT_AUDIO = 0x00040000; + + /** + * Call can be upgraded to a video call. + * @hide + */ + public static final int CAPABILITY_CAN_UPGRADE_TO_VIDEO = 0x00080000; + + /** + * For video calls, indicates whether the outgoing video for the call can be paused using + * the {@link android.telecom.VideoProfile.VideoState#PAUSED} VideoState. + */ + public static final int CAPABILITY_CAN_PAUSE_VIDEO = 0x00100000; + + //****************************************************************************************** + // Next CAPABILITY value: 0x00200000 + //****************************************************************************************** private final Uri mHandle; private final int mHandlePresentation; @@ -208,7 +240,6 @@ public final class Call { * @param capabilities A bit field of capabilities. * @param capability The capability to check capabilities for. * @return Whether the specified capability is supported. - * @hide */ public static boolean can(int capabilities, int capability) { return (capabilities & capability) != 0; @@ -219,7 +250,6 @@ public final class Call { * * @param capability The capability to check capabilities for. * @return Whether the specified capability is supported. - * @hide */ public boolean can(int capability) { return can(mCallCapabilities, capability); @@ -255,23 +285,44 @@ public final class Call { if (can(capabilities, CAPABILITY_MANAGE_CONFERENCE)) { builder.append(" CAPABILITY_MANAGE_CONFERENCE"); } - if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL)) { - builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL"); + if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_RX)) { + builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL_RX"); + } + if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_TX)) { + builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL_TX"); + } + if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL)) { + builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL"); + } + if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_RX)) { + builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_RX"); + } + if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_TX)) { + builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_TX"); } - if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE)) { - builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE"); + if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL)) { + builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL"); } if (can(capabilities, CAPABILITY_HIGH_DEF_AUDIO)) { builder.append(" CAPABILITY_HIGH_DEF_AUDIO"); } - if (can(capabilities, CAPABILITY_VoWIFI)) { - builder.append(" CAPABILITY_VoWIFI"); + if (can(capabilities, CAPABILITY_WIFI)) { + builder.append(" CAPABILITY_WIFI"); } if (can(capabilities, CAPABILITY_GENERIC_CONFERENCE)) { builder.append(" CAPABILITY_GENERIC_CONFERENCE"); } + if (can(capabilities, CAPABILITY_SHOW_CALLBACK_NUMBER)) { + builder.append(" CAPABILITY_SHOW_CALLBACK_NUMBER"); + } if (can(capabilities, CAPABILITY_SPEED_UP_MT_AUDIO)) { - builder.append(" CAPABILITY_SPEED_UP_IMS_MT_AUDIO"); + builder.append(" CAPABILITY_SPEED_UP_MT_AUDIO"); + } + if (can(capabilities, CAPABILITY_CAN_UPGRADE_TO_VIDEO)) { + builder.append(" CAPABILITY_CAN_UPGRADE_TO_VIDEO"); + } + if (can(capabilities, CAPABILITY_CAN_PAUSE_VIDEO)) { + builder.append(" CAPABILITY_CAN_PAUSE_VIDEO"); } builder.append("]"); return builder.toString(); @@ -345,7 +396,7 @@ public final class Call { * periodically, but user interfaces should not rely on this to display any "call time * clock". */ - public long getConnectTimeMillis() { + public final long getConnectTimeMillis() { return mConnectTimeMillis; } @@ -450,7 +501,7 @@ public final class Call { } } - public static abstract class Listener { + public static abstract class Callback { /** * Invoked when the state of this {@code Call} has changed. See {@link #getState()}. * @@ -509,7 +560,6 @@ public final class Call { * * @param call The {@code Call} invoking this method. * @param videoCall The {@code Call.VideoCall} associated with the {@code Call}. - * @hide */ public void onVideoCallChanged(Call call, InCallService.VideoCall videoCall) {} @@ -535,13 +585,21 @@ public final class Call { public void onConferenceableCallsChanged(Call call, List<Call> conferenceableCalls) {} } + /** + * @deprecated Use {@code Call.Callback} instead. + * @hide + */ + @Deprecated + @SystemApi + public static abstract class Listener extends Callback { } + private final Phone mPhone; private final String mTelecomCallId; private final InCallAdapter mInCallAdapter; private final List<String> mChildrenIds = new ArrayList<>(); private final List<Call> mChildren = new ArrayList<>(); private final List<Call> mUnmodifiableChildren = Collections.unmodifiableList(mChildren); - private final List<Listener> mListeners = new CopyOnWriteArrayList<>(); + private final List<Callback> mCallbacks = new CopyOnWriteArrayList<>(); private final List<Call> mConferenceableCalls = new ArrayList<>(); private final List<Call> mUnmodifiableConferenceableCalls = Collections.unmodifiableList(mConferenceableCalls); @@ -636,8 +694,8 @@ public final class Call { * {@code Call} will temporarily pause playing the tones for a pre-defined period of time. * * If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_WAIT} symbol, this - * {@code Call} will pause playing the tones and notify listeners via - * {@link Listener#onPostDialWait(Call, String)}. At this point, the in-call app + * {@code Call} will pause playing the tones and notify callbacks via + * {@link Callback#onPostDialWait(Call, String)}. At this point, the in-call app * should display to the user an indication of this state and an affordance to continue * the postdial sequence. When the user decides to continue the postdial sequence, the in-call * app should invoke the {@link #postDialContinue(boolean)} method. @@ -762,7 +820,6 @@ public final class Call { * Obtains an object that can be used to display video from this {@code Call}. * * @return An {@code Call.VideoCall}. - * @hide */ public InCallService.VideoCall getVideoCall() { return mVideoCall; @@ -779,25 +836,52 @@ public final class Call { } /** + * Registers a callback to this {@code Call}. + * + * @param callback A {@code Callback}. + */ + public void registerCallback(Callback callback) { + mCallbacks.add(callback); + } + + /** + * Unregisters a callback from this {@code Call}. + * + * @param callback A {@code Callback}. + */ + public void unregisterCallback(Callback callback) { + if (callback != null) { + mCallbacks.remove(callback); + } + } + + /** * Adds a listener to this {@code Call}. * * @param listener A {@code Listener}. + * @deprecated Use {@link #registerCallback} instead. + * @hide */ + @Deprecated + @SystemApi public void addListener(Listener listener) { - mListeners.add(listener); + registerCallback(listener); } /** * Removes a listener from this {@code Call}. * * @param listener A {@code Listener}. + * @deprecated Use {@link #unregisterCallback} instead. + * @hide */ + @Deprecated + @SystemApi public void removeListener(Listener listener) { - if (listener != null) { - mListeners.remove(listener); - } + unregisterCallback(listener); } + /** {@hide} */ Call(Phone phone, String telecomCallId, InCallAdapter inCallAdapter) { mPhone = phone; @@ -928,56 +1012,56 @@ public final class Call { } private void fireStateChanged(int newState) { - for (Listener listener : mListeners) { - listener.onStateChanged(this, newState); + for (Callback callback : mCallbacks) { + callback.onStateChanged(this, newState); } } private void fireParentChanged(Call newParent) { - for (Listener listener : mListeners) { - listener.onParentChanged(this, newParent); + for (Callback callback : mCallbacks) { + callback.onParentChanged(this, newParent); } } private void fireChildrenChanged(List<Call> children) { - for (Listener listener : mListeners) { - listener.onChildrenChanged(this, children); + for (Callback callback : mCallbacks) { + callback.onChildrenChanged(this, children); } } private void fireDetailsChanged(Details details) { - for (Listener listener : mListeners) { - listener.onDetailsChanged(this, details); + for (Callback callback : mCallbacks) { + callback.onDetailsChanged(this, details); } } private void fireCannedTextResponsesLoaded(List<String> cannedTextResponses) { - for (Listener listener : mListeners) { - listener.onCannedTextResponsesLoaded(this, cannedTextResponses); + for (Callback callback : mCallbacks) { + callback.onCannedTextResponsesLoaded(this, cannedTextResponses); } } private void fireVideoCallChanged(InCallService.VideoCall videoCall) { - for (Listener listener : mListeners) { - listener.onVideoCallChanged(this, videoCall); + for (Callback callback : mCallbacks) { + callback.onVideoCallChanged(this, videoCall); } } private void firePostDialWait(String remainingPostDialSequence) { - for (Listener listener : mListeners) { - listener.onPostDialWait(this, remainingPostDialSequence); + for (Callback callback : mCallbacks) { + callback.onPostDialWait(this, remainingPostDialSequence); } } private void fireCallDestroyed() { - for (Listener listener : mListeners) { - listener.onCallDestroyed(this); + for (Callback callback : mCallbacks) { + callback.onCallDestroyed(this); } } private void fireConferenceableCallsChanged() { - for (Listener listener : mListeners) { - listener.onConferenceableCallsChanged(this, mUnmodifiableConferenceableCalls); + for (Callback callback : mCallbacks) { + callback.onConferenceableCallsChanged(this, mUnmodifiableConferenceableCalls); } } diff --git a/telecomm/java/android/telecom/CallProperties.java b/telecomm/java/android/telecom/CallProperties.java index b1b82e2..1721a392e 100644 --- a/telecomm/java/android/telecom/CallProperties.java +++ b/telecomm/java/android/telecom/CallProperties.java @@ -18,7 +18,6 @@ package android.telecom; /** * Defines properties of a phone call which may be affected by changes to the call. - * @hide */ public class CallProperties { /** Call is currently in a conference call. */ diff --git a/telecomm/java/android/telecom/CallState.java b/telecomm/java/android/telecom/CallState.java index bd9223a..5584226 100644 --- a/telecomm/java/android/telecom/CallState.java +++ b/telecomm/java/android/telecom/CallState.java @@ -16,17 +16,12 @@ package android.telecom; -import android.annotation.SystemApi; - /** * Defines call-state constants of the different states in which a call can exist. Although states * have the notion of normal transitions, due to the volatile nature of telephony systems, code * that uses these states should be resilient to unexpected state changes outside of what is * considered traditional. - * - * {@hide} */ -@SystemApi public final class CallState { private CallState() {} diff --git a/telecomm/java/android/telecom/CameraCapabilities.java b/telecomm/java/android/telecom/CameraCapabilities.java index f968c13..6242956 100644 --- a/telecomm/java/android/telecom/CameraCapabilities.java +++ b/telecomm/java/android/telecom/CameraCapabilities.java @@ -21,43 +21,54 @@ import android.os.Parcelable; /** * Represents the camera capabilities important to a Video Telephony provider. - * @hide */ public final class CameraCapabilities implements Parcelable { /** - * Whether the camera supports zoom. + * The width of the camera video in pixels. */ - private final boolean mZoomSupported; + private final int mWidth; /** - * The maximum zoom supported by the camera. + * The height of the camera video in pixels. */ - private final float mMaxZoom; + private final int mHeight; /** - * The width of the camera video in pixels. + * Whether the camera supports zoom. */ - private final int mWidth; + private final boolean mZoomSupported; /** - * The height of the camera video in pixels. + * The maximum zoom supported by the camera. */ - private final int mHeight; + private final float mMaxZoom; /** * Create a call camera capabilities instance. * - * @param zoomSupported True when camera supports zoom. - * @param maxZoom Maximum zoom supported by camera. * @param width The width of the camera video (in pixels). * @param height The height of the camera video (in pixels). */ - public CameraCapabilities(boolean zoomSupported, float maxZoom, int width, int height) { - mZoomSupported = zoomSupported; - mMaxZoom = maxZoom; + public CameraCapabilities(int width, int height) { + this(width, height, false, 1.0f); + } + + /** + * Create a call camera capabilities instance that optionally + * supports zoom. + * + * @param width The width of the camera video (in pixels). + * @param height The height of the camera video (in pixels). + * @param zoomSupported True when camera supports zoom. + * @param maxZoom Maximum zoom supported by camera. + * @hide + */ + public CameraCapabilities(int width, int height, boolean zoomSupported, float maxZoom) { mWidth = width; mHeight = height; + mZoomSupported = zoomSupported; + mMaxZoom = maxZoom; } /** @@ -73,12 +84,12 @@ public final class CameraCapabilities implements Parcelable { */ @Override public CameraCapabilities createFromParcel(Parcel source) { - boolean supportsZoom = source.readByte() != 0; - float maxZoom = source.readFloat(); int width = source.readInt(); int height = source.readInt(); + boolean supportsZoom = source.readByte() != 0; + float maxZoom = source.readFloat(); - return new CameraCapabilities(supportsZoom, maxZoom, width, height); + return new CameraCapabilities(width, height, supportsZoom, maxZoom); } @Override @@ -108,37 +119,39 @@ public final class CameraCapabilities implements Parcelable { */ @Override public void writeToParcel(Parcel dest, int flags) { - dest.writeByte((byte) (isZoomSupported() ? 1 : 0)); - dest.writeFloat(getMaxZoom()); dest.writeInt(getWidth()); dest.writeInt(getHeight()); + dest.writeByte((byte) (isZoomSupported() ? 1 : 0)); + dest.writeFloat(getMaxZoom()); } /** - * Whether the camera supports zoom. + * The width of the camera video in pixels. */ - public boolean isZoomSupported() { - return mZoomSupported; + public int getWidth() { + return mWidth; } /** - * The maximum zoom supported by the camera. + * The height of the camera video in pixels. */ - public float getMaxZoom() { - return mMaxZoom; + public int getHeight() { + return mHeight; } /** - * The width of the camera video in pixels. + * Whether the camera supports zoom. + * @hide */ - public int getWidth() { - return mWidth; + public boolean isZoomSupported() { + return mZoomSupported; } /** - * The height of the camera video in pixels. + * The maximum zoom supported by the camera. + * @hide */ - public int getHeight() { - return mHeight; + public float getMaxZoom() { + return mMaxZoom; } } diff --git a/telecomm/java/android/telecom/Conference.java b/telecomm/java/android/telecom/Conference.java index 33bbb29..bab60fe 100644 --- a/telecomm/java/android/telecom/Conference.java +++ b/telecomm/java/android/telecom/Conference.java @@ -16,27 +16,26 @@ package android.telecom; -import android.annotation.SystemApi; +import android.telecom.Connection.VideoProvider; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArraySet; /** * Represents a conference call which can contain any number of {@link Connection} objects. - * @hide */ -@SystemApi -public abstract class Conference implements IConferenceable { +public abstract class Conference implements Conferenceable { /** * Used to indicate that the conference connection time is not specified. If not specified, * Telecom will set the connect time. */ - public static long CONNECT_TIME_NOT_SPECIFIED = 0; + public static final long CONNECT_TIME_NOT_SPECIFIED = 0; /** @hide */ public abstract static class Listener { @@ -49,6 +48,8 @@ public abstract class Conference implements IConferenceable { public void onDestroyed(Conference conference) {} public void onConnectionCapabilitiesChanged( Conference conference, int connectionCapabilities) {} + public void onVideoStateChanged(Conference c, int videoState) { } + public void onVideoProviderChanged(Conference c, Connection.VideoProvider videoProvider) {} } private final Set<Listener> mListeners = new CopyOnWriteArraySet<>(); @@ -59,7 +60,7 @@ public abstract class Conference implements IConferenceable { private final List<Connection> mUnmodifiableConferenceableConnections = Collections.unmodifiableList(mConferenceableConnections); - protected PhoneAccountHandle mPhoneAccount; + private PhoneAccountHandle mPhoneAccount; private AudioState mAudioState; private int mState = Connection.STATE_NEW; private DisconnectCause mDisconnectCause; @@ -112,11 +113,6 @@ public abstract class Conference implements IConferenceable { return mState; } - /** @hide */ - @Deprecated public final int getCapabilities() { - return getConnectionCapabilities(); - } - /** * Returns the capabilities of a conference. See {@code CAPABILITY_*} constants in class * {@link Connection} for valid values. @@ -180,6 +176,22 @@ public abstract class Conference implements IConferenceable { } /** + * Returns VideoProvider of the primary call. This can be null. + * @hide + */ + public VideoProvider getVideoProvider() { + return null; + } + + /** + * Returns video state of the primary call. + * @hide + */ + public int getVideoState() { + return VideoProfile.VideoState.AUDIO_ONLY; + } + + /** * Invoked when the Conference and all it's {@link Connection}s should be disconnected. */ public void onDisconnect() {} @@ -281,11 +293,6 @@ public abstract class Conference implements IConferenceable { return mDisconnectCause; } - /** @hide */ - @Deprecated public final void setCapabilities(int connectionCapabilities) { - setConnectionCapabilities(connectionCapabilities); - } - /** * Sets the capabilities of a conference. See {@code CAPABILITY_*} constants of class * {@link Connection} for valid values. @@ -309,6 +316,7 @@ public abstract class Conference implements IConferenceable { * @return True if the connection was successfully added. */ public final boolean addConnection(Connection connection) { + Log.d(this, "Connection=%s, connection=", connection); if (connection != null && !mChildConnections.contains(connection)) { if (connection.setConference(this)) { mChildConnections.add(connection); @@ -355,6 +363,38 @@ public abstract class Conference implements IConferenceable { fireOnConferenceableConnectionsChanged(); } + /** + * Set the video state for the conference. + * Valid values: {@link VideoProfile.VideoState#AUDIO_ONLY}, + * {@link VideoProfile.VideoState#BIDIRECTIONAL}, + * {@link VideoProfile.VideoState#TX_ENABLED}, + * {@link VideoProfile.VideoState#RX_ENABLED}. + * + * @param videoState The new video state. + * @hide + */ + public final void setVideoState(Connection c, int videoState) { + Log.d(this, "setVideoState Conference: %s Connection: %s VideoState: %s", + this, c, videoState); + for (Listener l : mListeners) { + l.onVideoStateChanged(this, videoState); + } + } + + /** + * Sets the video connection provider. + * + * @param videoProvider The video provider. + * @hide + */ + public final void setVideoProvider(Connection c, Connection.VideoProvider videoProvider) { + Log.d(this, "setVideoProvider Conference: %s Connection: %s VideoState: %s", + this, c, videoProvider); + for (Listener l : mListeners) { + l.onVideoProviderChanged(this, videoProvider); + } + } + private final void fireOnConferenceableConnectionsChanged() { for (Listener l : mListeners) { l.onConferenceableConnectionsChanged(this, getConferenceableConnections()); @@ -444,7 +484,7 @@ public abstract class Conference implements IConferenceable { * * @return The time the {@code Conference} has been connected. */ - public long getConnectTimeMillis() { + public final long getConnectTimeMillis() { return mConnectTimeMillis; } @@ -484,4 +524,15 @@ public abstract class Conference implements IConferenceable { } mConferenceableConnections.clear(); } + + @Override + public String toString() { + return String.format(Locale.US, + "[State: %s,Capabilites: %s, VideoState: %s, VideoProvider: %s, ThisObject %s]", + Connection.stateToString(mState), + Call.Details.capabilitiesToString(mConnectionCapabilities), + getVideoState(), + getVideoProvider(), + super.toString()); + } } diff --git a/telecomm/java/android/telecom/Conferenceable.java b/telecomm/java/android/telecom/Conferenceable.java new file mode 100644 index 0000000..5c4cbc5 --- /dev/null +++ b/telecomm/java/android/telecom/Conferenceable.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2015 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.telecom; + +/** + * Interface used to identify entities with which another entity can participate in a conference + * call with. The {@link ConnectionService} implementation will only recognize + * {@link Conferenceable}s which are {@link Connection}s or {@link Conference}s. + */ +public interface Conferenceable { + +} diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java index 00a4136..e79584f 100644 --- a/telecomm/java/android/telecom/Connection.java +++ b/telecomm/java/android/telecom/Connection.java @@ -19,7 +19,6 @@ package android.telecom; import com.android.internal.telecom.IVideoCallback; import com.android.internal.telecom.IVideoProvider; -import android.annotation.SystemApi; import android.net.Uri; import android.os.Handler; import android.os.IBinder; @@ -44,10 +43,8 @@ import java.util.concurrent.ConcurrentHashMap; * Implementations are then responsible for updating the state of the {@code Connection}, and * must call {@link #destroy()} to signal to the framework that the {@code Connection} is no * longer used and associated resources may be recovered. - * @hide */ -@SystemApi -public abstract class Connection implements IConferenceable { +public abstract class Connection implements Conferenceable { public static final int STATE_INITIALIZING = 0; @@ -106,28 +103,42 @@ public abstract class Connection implements IConferenceable { public static final int CAPABILITY_MANAGE_CONFERENCE = 0x00000080; /** - * Local device supports video telephony. + * Local device supports receiving video. * @hide */ - public static final int CAPABILITY_SUPPORTS_VT_LOCAL = 0x00000100; + public static final int CAPABILITY_SUPPORTS_VT_LOCAL_RX = 0x00000100; /** - * Remote device supports video telephony. + * Local device supports transmitting video. * @hide */ - public static final int CAPABILITY_SUPPORTS_VT_REMOTE = 0x00000200; + public static final int CAPABILITY_SUPPORTS_VT_LOCAL_TX = 0x00000200; /** - * Connection is using high definition audio. + * Local device supports bidirectional video calling. + * @hide + */ + public static final int CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL = + CAPABILITY_SUPPORTS_VT_LOCAL_RX | CAPABILITY_SUPPORTS_VT_LOCAL_TX; + + /** + * Remote device supports receiving video. + * @hide + */ + public static final int CAPABILITY_SUPPORTS_VT_REMOTE_RX = 0x00000400; + + /** + * Remote device supports transmitting video. * @hide */ - public static final int CAPABILITY_HIGH_DEF_AUDIO = 0x00000400; + public static final int CAPABILITY_SUPPORTS_VT_REMOTE_TX = 0x00000800; /** - * Connection is using voice over WIFI. + * Remote device supports bidirectional video calling. * @hide */ - public static final int CAPABILITY_VoWIFI = 0x00000800; + public static final int CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL = + CAPABILITY_SUPPORTS_VT_REMOTE_RX | CAPABILITY_SUPPORTS_VT_REMOTE_TX; /** * Connection is able to be separated from its parent {@code Conference}, if any. @@ -148,10 +159,46 @@ public abstract class Connection implements IConferenceable { public static final int CAPABILITY_GENERIC_CONFERENCE = 0x00004000; /** + * Connection is using high definition audio. + * @hide + */ + public static final int CAPABILITY_HIGH_DEF_AUDIO = 0x00008000; + + /** + * Connection is using WIFI. + * @hide + */ + public static final int CAPABILITY_WIFI = 0x00010000; + + /** + * Indicates that the current device callback number should be shown. + * + * @hide + */ + public static final int CAPABILITY_SHOW_CALLBACK_NUMBER = 0x00020000; + + /** * Speed up audio setup for MT call. * @hide - */ - public static final int CAPABILITY_SPEED_UP_MT_AUDIO = 0x00008000; + */ + public static final int CAPABILITY_SPEED_UP_MT_AUDIO = 0x00040000; + + /** + * Call can be upgraded to a video call. + * @hide + */ + public static final int CAPABILITY_CAN_UPGRADE_TO_VIDEO = 0x00080000; + + /** + * For video calls, indicates whether the outgoing video for the call can be paused using + * the {@link android.telecom.VideoProfile.VideoState#PAUSED} VideoState. + * @hide + */ + public static final int CAPABILITY_CAN_PAUSE_VIDEO = 0x00100000; + + //********************************************************************************************** + // Next CAPABILITY value: 0x00200000 + //********************************************************************************************** // Flag controlling whether PII is emitted into the logs private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG); @@ -224,23 +271,44 @@ public abstract class Connection implements IConferenceable { if (can(capabilities, CAPABILITY_MANAGE_CONFERENCE)) { builder.append(" CAPABILITY_MANAGE_CONFERENCE"); } - if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL)) { - builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL"); + if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_RX)) { + builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL_RX"); + } + if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_TX)) { + builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL_TX"); + } + if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL)) { + builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL"); } - if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE)) { - builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE"); + if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_RX)) { + builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_RX"); + } + if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_TX)) { + builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_TX"); + } + if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL)) { + builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL"); } if (can(capabilities, CAPABILITY_HIGH_DEF_AUDIO)) { builder.append(" CAPABILITY_HIGH_DEF_AUDIO"); } - if (can(capabilities, CAPABILITY_VoWIFI)) { - builder.append(" CAPABILITY_VoWIFI"); + if (can(capabilities, CAPABILITY_WIFI)) { + builder.append(" CAPABILITY_WIFI"); } if (can(capabilities, CAPABILITY_GENERIC_CONFERENCE)) { builder.append(" CAPABILITY_GENERIC_CONFERENCE"); } + if (can(capabilities, CAPABILITY_SHOW_CALLBACK_NUMBER)) { + builder.append(" CAPABILITY_SHOW_CALLBACK_NUMBER"); + } if (can(capabilities, CAPABILITY_SPEED_UP_MT_AUDIO)) { - builder.append(" CAPABILITY_SPEED_UP_IMS_MT_AUDIO"); + builder.append(" CAPABILITY_SPEED_UP_MT_AUDIO"); + } + if (can(capabilities, CAPABILITY_CAN_UPGRADE_TO_VIDEO)) { + builder.append(" CAPABILITY_CAN_UPGRADE_TO_VIDEO"); + } + if (can(capabilities, CAPABILITY_CAN_PAUSE_VIDEO)) { + builder.append(" CAPABILITY_CAN_PAUSE_VIDEO"); } builder.append("]"); return builder.toString(); @@ -264,7 +332,7 @@ public abstract class Connection implements IConferenceable { public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {} public void onStatusHintsChanged(Connection c, StatusHints statusHints) {} public void onConferenceablesChanged( - Connection c, List<IConferenceable> conferenceables) {} + Connection c, List<Conferenceable> conferenceables) {} public void onConferenceChanged(Connection c, Conference conference) {} /** @hide */ public void onConferenceParticipantsChanged(Connection c, @@ -272,7 +340,6 @@ public abstract class Connection implements IConferenceable { public void onConferenceStarted() {} } - /** @hide */ public static abstract class VideoProvider { /** @@ -325,6 +392,16 @@ public abstract class Connection implements IConferenceable { */ public static final int SESSION_MODIFY_REQUEST_INVALID = 3; + /** + * Session modify request timed out. + */ + public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4; + + /** + * Session modify request rejected by remote UE. + */ + public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5; + private static final int MSG_SET_VIDEO_CALLBACK = 1; private static final int MSG_SET_CAMERA = 2; private static final int MSG_SET_PREVIEW_SURFACE = 3; @@ -410,7 +487,8 @@ public abstract class Connection implements IConferenceable { } public void setDeviceOrientation(int rotation) { - mMessageHandler.obtainMessage(MSG_SET_DEVICE_ORIENTATION, rotation).sendToTarget(); + mMessageHandler.obtainMessage( + MSG_SET_DEVICE_ORIENTATION, rotation, 0).sendToTarget(); } public void setZoom(float value) { @@ -604,7 +682,7 @@ public abstract class Connection implements IConferenceable { * * @param dataUsage The updated data usage. */ - public void changeCallDataUsage(int dataUsage) { + public void changeCallDataUsage(long dataUsage) { if (mVideoCallback != null) { try { mVideoCallback.changeCallDataUsage(dataUsage); @@ -626,6 +704,20 @@ public abstract class Connection implements IConferenceable { } } } + + /** + * Invokes callback method defined in In-Call UI. + * + * @param videoQuality The updated video quality. + */ + public void changeVideoQuality(int videoQuality) { + if (mVideoCallback != null) { + try { + mVideoCallback.changeVideoQuality(videoQuality); + } catch (RemoteException ignored) { + } + } + } } private final Listener mConnectionDeathListener = new Listener() { @@ -653,8 +745,8 @@ public abstract class Connection implements IConferenceable { */ private final Set<Listener> mListeners = Collections.newSetFromMap( new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1)); - private final List<IConferenceable> mConferenceables = new ArrayList<>(); - private final List<IConferenceable> mUnmodifiableConferenceables = + private final List<Conferenceable> mConferenceables = new ArrayList<>(); + private final List<Conferenceable> mUnmodifiableConferenceables = Collections.unmodifiableList(mConferenceables); private int mState = STATE_NEW; @@ -849,11 +941,6 @@ public abstract class Connection implements IConferenceable { return mConnectionCapabilities; } - /** @hide */ - @SystemApi @Deprecated public final int getCallCapabilities() { - return getConnectionCapabilities(); - } - /** * Sets the value of the {@link #getAddress()} property. * @@ -970,7 +1057,6 @@ public abstract class Connection implements IConferenceable { } } - /** @hide */ public final VideoProvider getVideoProvider() { return mVideoProvider; } @@ -1011,14 +1097,11 @@ public abstract class Connection implements IConferenceable { /** * Informs listeners that this {@code Connection} has processed a character in the post-dial * started state. This is done when (a) the {@code Connection} is issuing a DTMF sequence; - * (b) it has encountered a "wait" character; and (c) it wishes to signal Telecom to play - * the corresponding DTMF tone locally. + * and (b) it wishes to signal Telecom to play the corresponding DTMF tone locally. * * @param nextChar The DTMF character that was just processed by the {@code Connection}. - * - * @hide */ - public final void setNextPostDialWaitChar(char nextChar) { + public final void setNextPostDialChar(char nextChar) { checkImmutable(); for (Listener l : mListeners) { l.onPostDialChar(this, nextChar); @@ -1041,11 +1124,6 @@ public abstract class Connection implements IConferenceable { } } - /** @hide */ - @SystemApi @Deprecated public final void setCallCapabilities(int connectionCapabilities) { - setConnectionCapabilities(connectionCapabilities); - } - /** * Sets the connection's capabilities as a bit mask of the {@code CAPABILITY_*} constants. * @@ -1121,9 +1199,9 @@ public abstract class Connection implements IConferenceable { * * @param conferenceables The conferenceables. */ - public final void setConferenceables(List<IConferenceable> conferenceables) { + public final void setConferenceables(List<Conferenceable> conferenceables) { clearConferenceableList(); - for (IConferenceable c : conferenceables) { + for (Conferenceable c : conferenceables) { // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a // small amount of items here. if (!mConferenceables.contains(c)) { @@ -1143,7 +1221,7 @@ public abstract class Connection implements IConferenceable { /** * Returns the connections or conferences with which this connection can be conferenced. */ - public final List<IConferenceable> getConferenceables() { + public final List<Conferenceable> getConferenceables() { return mUnmodifiableConferenceables; } @@ -1408,7 +1486,7 @@ public abstract class Connection implements IConferenceable { } private final void clearConferenceableList() { - for (IConferenceable c : mConferenceables) { + for (Conferenceable c : mConferenceables) { if (c instanceof Connection) { Connection connection = (Connection) c; connection.removeConnectionListener(mConnectionDeathListener); @@ -1435,6 +1513,7 @@ public abstract class Connection implements IConferenceable { /** * Notifies listeners that a conference call has been started. + * @hide */ protected void notifyConferenceStarted() { for (Listener l : mListeners) { diff --git a/telecomm/java/android/telecom/ConnectionRequest.java b/telecomm/java/android/telecom/ConnectionRequest.java index f691c17..71b481b 100644 --- a/telecomm/java/android/telecom/ConnectionRequest.java +++ b/telecomm/java/android/telecom/ConnectionRequest.java @@ -16,7 +16,6 @@ package android.telecom; -import android.annotation.SystemApi; import android.net.Uri; import android.os.Bundle; import android.os.Parcel; @@ -25,9 +24,7 @@ import android.os.Parcelable; /** * Simple data container encapsulating a request to some entity to * create a new {@link Connection}. - * @hide */ -@SystemApi public final class ConnectionRequest implements Parcelable { // TODO: Token to limit recursive invocations diff --git a/telecomm/java/android/telecom/ConnectionService.java b/telecomm/java/android/telecom/ConnectionService.java index dfdc3e1..9812815 100644 --- a/telecomm/java/android/telecom/ConnectionService.java +++ b/telecomm/java/android/telecom/ConnectionService.java @@ -17,7 +17,6 @@ package android.telecom; import android.annotation.SdkConstant; -import android.annotation.SystemApi; import android.app.Service; import android.content.ComponentName; import android.content.Intent; @@ -72,9 +71,7 @@ import java.util.concurrent.ConcurrentHashMap; * receives call-commands such as answer, reject, hold and disconnect. * <p> * When there are no more live calls, telecom will unbind from the {@code ConnectionService}. - * @hide */ -@SystemApi public abstract class ConnectionService extends Service { /** * The {@link Intent} that must be declared as handled by the service. @@ -415,6 +412,21 @@ public abstract class ConnectionService extends Service { Connection.capabilitiesToString(connectionCapabilities)); mAdapter.setConnectionCapabilities(id, connectionCapabilities); } + + @Override + public void onVideoStateChanged(Conference c, int videoState) { + String id = mIdByConference.get(c); + Log.d(this, "onVideoStateChanged set video state %d", videoState); + mAdapter.setVideoState(id, videoState); + } + + @Override + public void onVideoProviderChanged(Conference c, Connection.VideoProvider videoProvider) { + String id = mIdByConference.get(c); + Log.d(this, "onVideoProviderChanged: Connection: %s, VideoProvider: %s", c, + videoProvider); + mAdapter.setVideoProvider(id, videoProvider); + } }; private final Connection.Listener mConnectionListener = new Connection.Listener() { @@ -508,6 +520,8 @@ public abstract class ConnectionService extends Service { @Override public void onVideoProviderChanged(Connection c, Connection.VideoProvider videoProvider) { String id = mIdByConnection.get(c); + Log.d(this, "onVideoProviderChanged: Connection: %s, VideoProvider: %s", c, + videoProvider); mAdapter.setVideoProvider(id, videoProvider); } @@ -525,7 +539,7 @@ public abstract class ConnectionService extends Service { @Override public void onConferenceablesChanged( - Connection connection, List<IConferenceable> conferenceables) { + Connection connection, List<Conferenceable> conferenceables) { mAdapter.setConferenceableConnections( mIdByConnection.get(connection), createIdList(conferenceables)); @@ -871,6 +885,8 @@ public abstract class ConnectionService extends Service { * @param conference The new conference object. */ public final void addConference(Conference conference) { + Log.d(this, "addConference: conference=%s", conference); + String id = addConferenceInternal(conference); if (id != null) { List<String> connectionIds = new ArrayList<>(2); @@ -884,8 +900,14 @@ public abstract class ConnectionService extends Service { conference.getState(), conference.getConnectionCapabilities(), connectionIds, - conference.getConnectTimeMillis()); + conference.getVideoProvider() == null ? + null : conference.getVideoProvider().getInterface(), + conference.getVideoState(), + conference.getConnectTimeMillis() + ); mAdapter.addConferenceCall(id, parcelableConference); + mAdapter.setVideoProvider(id, conference.getVideoProvider()); + mAdapter.setVideoState(id, conference.getVideoState()); // Go through any child calls and set the parent. for (Connection connection : conference.getConnections()) { @@ -1146,14 +1168,14 @@ public abstract class ConnectionService extends Service { /** * Builds a list of {@link Connection} and {@link Conference} IDs based on the list of - * {@link IConferenceable}s passed in. + * {@link Conferenceable}s passed in. * - * @param conferenceables The {@link IConferenceable} connections and conferences. + * @param conferenceables The {@link Conferenceable} connections and conferences. * @return List of string conference and call Ids. */ - private List<String> createIdList(List<IConferenceable> conferenceables) { + private List<String> createIdList(List<Conferenceable> conferenceables) { List<String> ids = new ArrayList<>(); - for (IConferenceable c : conferenceables) { + for (Conferenceable c : conferenceables) { // Only allow Connection and Conference conferenceables. if (c instanceof Connection) { Connection connection = (Connection) c; diff --git a/telecomm/java/android/telecom/DefaultDialerManager.java b/telecomm/java/android/telecom/DefaultDialerManager.java new file mode 100644 index 0000000..eef72fb --- /dev/null +++ b/telecomm/java/android/telecom/DefaultDialerManager.java @@ -0,0 +1,174 @@ +/* + * Copyright (C) 2015 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.telecom; + +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.pm.ActivityInfo; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.provider.Settings; +import android.text.TextUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * Class for managing the default dialer application that will receive incoming calls, and be + * allowed to make emergency outgoing calls. + * + * @hide + */ +public class DefaultDialerManager { + private static final String TAG = "DefaultDialerManager"; + + /** + * Sets the specified package name as the default dialer application. The caller of this method + * needs to have permission to write to secure settings. + * + * @hide + * */ + public static void setDefaultPhoneApplication(Context context, String packageName) { + // Get old package name + String oldPackageName = Settings.Secure.getString(context.getContentResolver(), + Settings.Secure.DIALER_DEFAULT_APPLICATION); + + if (packageName != null && oldPackageName != null && packageName.equals(oldPackageName)) { + // No change + return; + } + + // Only make the change if the new package belongs to a valid phone application + List<ComponentName> componentNames = getInstalledDialerApplications(context); + final ComponentName foundComponent = getComponentName(componentNames, packageName); + + if (foundComponent != null) { + // Update the secure setting. + Settings.Secure.putString(context.getContentResolver(), + Settings.Secure.DIALER_DEFAULT_APPLICATION, foundComponent.getPackageName()); + } + } + + /** + * Returns the installed dialer application that will be used to receive incoming calls, and is + * allowed to make emergency calls. + * + * The application will be returned in order of preference: + * 1) User selected phone application (if still installed) + * 2) Pre-installed system dialer (if not disabled) + * 3) Null + * + * @hide + * */ + public static ComponentName getDefaultDialerApplication(Context context) { + String defaultPackageName = Settings.Secure.getString(context.getContentResolver(), + Settings.Secure.DIALER_DEFAULT_APPLICATION); + + final List<ComponentName> componentNames = getInstalledDialerApplications(context); + if (!TextUtils.isEmpty(defaultPackageName)) { + final ComponentName defaultDialer = + getComponentName(componentNames, defaultPackageName); + if (defaultDialer != null) { + return defaultDialer; + } + } + + // No user-set dialer found, fallback to system dialer + ComponentName systemDialer = getTelecomManager(context).getDefaultPhoneApp(); + + if (systemDialer == null) { + // No system dialer configured at build time + return null; + } + + // Verify that the system dialer has not been disabled. + return getComponentName(componentNames, systemDialer.getPackageName()); + } + + /** + * Returns a list of installed and available dialer applications. + * + * In order to appear in the list, a dialer application must implement an intent-filter with + * the DIAL intent for the following schemes: + * + * 1) Empty scheme + * 2) tel Uri scheme + * + * @hide + **/ + public static List<ComponentName> getInstalledDialerApplications(Context context) { + PackageManager packageManager = context.getPackageManager(); + + // Get the list of apps registered for the DIAL intent with empty scheme + Intent intent = new Intent(Intent.ACTION_DIAL); + List<ResolveInfo> resolveInfoList = packageManager.queryIntentActivities(intent, 0); + + List<ComponentName> componentNames = new ArrayList<ComponentName> (); + + for (ResolveInfo resolveInfo : resolveInfoList) { + final ActivityInfo activityInfo = resolveInfo.activityInfo; + if (activityInfo == null) { + continue; + } + final ComponentName componentName = + new ComponentName(activityInfo.packageName, activityInfo.name); + componentNames.add(componentName); + } + + // TODO: Filter for apps that don't handle DIAL intent with tel scheme + return componentNames; + } + + /** + * Returns the {@link ComponentName} for the installed dialer application for a given package + * name. + * + * @param context A valid context. + * @param packageName to retrieve the {@link ComponentName} for. + * + * @return The {@link ComponentName} for the installed dialer application corresponding to the + * package name, or null if none is found. + * + * @hide + */ + public static ComponentName getDialerApplicationForPackageName(Context context, + String packageName) { + return getComponentName(getInstalledDialerApplications(context), packageName); + } + + /** + * Returns the component from a list of application components that corresponds to the package + * name. + * + * @param componentNames A list of component names + * @param packageName The package name to look for + * @return The {@link ComponentName} that matches the provided packageName, or null if not + * found. + */ + private static ComponentName getComponentName(List<ComponentName> componentNames, + String packageName) { + for (ComponentName componentName : componentNames) { + if (TextUtils.equals(packageName, componentName.getPackageName())) { + return componentName; + } + } + return null; + } + + private static TelecomManager getTelecomManager(Context context) { + return (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); + } +} diff --git a/telecomm/java/android/telecom/DisconnectCause.java b/telecomm/java/android/telecom/DisconnectCause.java index 130d676..73bcd0c 100644 --- a/telecomm/java/android/telecom/DisconnectCause.java +++ b/telecomm/java/android/telecom/DisconnectCause.java @@ -16,7 +16,6 @@ package android.telecom; -import android.annotation.SystemApi; import android.os.Parcel; import android.os.Parcelable; import android.media.ToneGenerator; @@ -30,9 +29,7 @@ import java.util.Objects; * user. It is the responsibility of the {@link ConnectionService} to provide localized versions of * the label and description. It also may contain a reason for the disconnect, which is intended for * logging and not for display to the user. - * @hide */ -@SystemApi public final class DisconnectCause implements Parcelable { /** Disconnected because of an unknown or unspecified reason. */ diff --git a/telecomm/java/android/telecom/GatewayInfo.java b/telecomm/java/android/telecom/GatewayInfo.java index 5b8e4ab..928570e 100644 --- a/telecomm/java/android/telecom/GatewayInfo.java +++ b/telecomm/java/android/telecom/GatewayInfo.java @@ -16,7 +16,6 @@ package android.telecom; -import android.annotation.SystemApi; import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; @@ -34,17 +33,13 @@ import android.text.TextUtils; * <li> Call the appropriate gateway address. * <li> Display information about how the call is being routed to the user. * </ol> - * @hide */ -@SystemApi public class GatewayInfo implements Parcelable { private final String mGatewayProviderPackageName; private final Uri mGatewayAddress; private final Uri mOriginalAddress; - /** @hide */ - @SystemApi public GatewayInfo(String packageName, Uri gatewayUri, Uri originalAddress) { mGatewayProviderPackageName = packageName; mGatewayAddress = gatewayUri; diff --git a/telecomm/java/android/telecom/IConferenceable.java b/telecomm/java/android/telecom/IConferenceable.java index 095d7cb..a664baa 100644 --- a/telecomm/java/android/telecom/IConferenceable.java +++ b/telecomm/java/android/telecom/IConferenceable.java @@ -16,16 +16,13 @@ package android.telecom; -import android.annotation.SystemApi; - /** * Interface used to identify entities with which another entity can participate in a conference * call with. The {@link ConnectionService} implementation will only recognize - * {@link IConferenceable}s which are {@link Connection}s or {@link Conference}s. - * + * {@link Conferenceable}s which are {@link Connection}s or {@link Conference}s. + * <p> + * @deprecated use {@link Conferenceable} instead. * @hide */ -@SystemApi -public interface IConferenceable { - +public interface IConferenceable extends Conferenceable { } diff --git a/telecomm/java/android/telecom/InCallService.java b/telecomm/java/android/telecom/InCallService.java index a85e84d..7cbc0fc 100644 --- a/telecomm/java/android/telecom/InCallService.java +++ b/telecomm/java/android/telecom/InCallService.java @@ -16,8 +16,8 @@ package android.telecom; -import android.annotation.SystemApi; import android.annotation.SdkConstant; +import android.annotation.SystemApi; import android.app.Service; import android.content.Intent; import android.os.Handler; @@ -31,15 +31,14 @@ 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 * phone calls. Telecom 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. - * - * {@hide} */ -@SystemApi public abstract class InCallService extends Service { /** @@ -67,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: @@ -148,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() { @@ -165,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; } @@ -176,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}. */ + @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) { } @@ -199,23 +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. - * @hide */ 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. @@ -258,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. * @@ -270,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. */ @@ -281,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(); @@ -301,10 +453,9 @@ public abstract class InCallService extends Service { public abstract void setPauseImage(String uri); /** - * Listener class which invokes callbacks after video call actions occur. - * @hide + * 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 @@ -361,19 +512,25 @@ public abstract class InCallService extends Service { public abstract void onPeerDimensionsChanged(int width, int height); /** + * Handles a change to the video quality. + * + * @param videoQuality The updated peer video quality. + */ + public abstract void onVideoQualityChanged(int videoQuality); + + /** * Handles an update to the total data used for the current session. * * @param dataUsage The updated data usage. */ - public abstract void onCallDataUsageChanged(int dataUsage); + public abstract void onCallDataUsageChanged(long dataUsage); /** * Handles a change in camera capabilities. * * @param cameraCapabilities The changed camera capabilities. */ - public abstract void onCameraCapabilitiesChanged( - CameraCapabilities cameraCapabilities); + public abstract void onCameraCapabilitiesChanged(CameraCapabilities cameraCapabilities); } } } diff --git a/telecomm/java/android/telecom/ParcelableConference.java b/telecomm/java/android/telecom/ParcelableConference.java index dcc2713..ab82549 100644 --- a/telecomm/java/android/telecom/ParcelableConference.java +++ b/telecomm/java/android/telecom/ParcelableConference.java @@ -22,6 +22,8 @@ import android.os.Parcelable; import java.util.ArrayList; import java.util.List; +import com.android.internal.telecom.IVideoProvider; + /** * A parcelable representation of a conference connection. * @hide @@ -33,17 +35,23 @@ public final class ParcelableConference implements Parcelable { private int mConnectionCapabilities; private List<String> mConnectionIds; private long mConnectTimeMillis; + private final IVideoProvider mVideoProvider; + private final int mVideoState; public ParcelableConference( PhoneAccountHandle phoneAccount, int state, int connectionCapabilities, - List<String> connectionIds) { + List<String> connectionIds, + IVideoProvider videoProvider, + int videoState) { mPhoneAccount = phoneAccount; mState = state; mConnectionCapabilities = connectionCapabilities; mConnectionIds = connectionIds; mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED; + mVideoProvider = videoProvider; + mVideoState = videoState; } public ParcelableConference( @@ -51,8 +59,10 @@ public final class ParcelableConference implements Parcelable { int state, int connectionCapabilities, List<String> connectionIds, + IVideoProvider videoProvider, + int videoState, long connectTimeMillis) { - this(phoneAccount, state, connectionCapabilities, connectionIds); + this(phoneAccount, state, connectionCapabilities, connectionIds, videoProvider, videoState); mConnectTimeMillis = connectTimeMillis; } @@ -69,6 +79,10 @@ public final class ParcelableConference implements Parcelable { .append(mConnectTimeMillis) .append(", children: ") .append(mConnectionIds) + .append(", VideoState: ") + .append(mVideoState) + .append(", VideoProvider: ") + .append(mVideoProvider) .toString(); } @@ -91,6 +105,13 @@ public final class ParcelableConference implements Parcelable { public long getConnectTimeMillis() { return mConnectTimeMillis; } + public IVideoProvider getVideoProvider() { + return mVideoProvider; + } + + public int getVideoState() { + return mVideoState; + } public static final Parcelable.Creator<ParcelableConference> CREATOR = new Parcelable.Creator<ParcelableConference> () { @@ -104,8 +125,12 @@ public final class ParcelableConference implements Parcelable { source.readList(connectionIds, classLoader); long connectTimeMillis = source.readLong(); + IVideoProvider videoCallProvider = + IVideoProvider.Stub.asInterface(source.readStrongBinder()); + int videoState = source.readInt(); + return new ParcelableConference(phoneAccount, state, capabilities, connectionIds, - connectTimeMillis); + videoCallProvider, videoState); } @Override @@ -128,5 +153,8 @@ public final class ParcelableConference implements Parcelable { destination.writeInt(mConnectionCapabilities); destination.writeList(mConnectionIds); destination.writeLong(mConnectTimeMillis); + destination.writeStrongBinder( + mVideoProvider != null ? mVideoProvider.asBinder() : null); + destination.writeInt(mVideoState); } } diff --git a/telecomm/java/android/telecom/Phone.java b/telecomm/java/android/telecom/Phone.java index 6344181..c1c1129 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 { @@ -104,12 +106,10 @@ public final class Phone { 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 +119,12 @@ public final class Phone { fireCallAdded(call); } - /** {@hide} */ final void internalRemoveCall(Call call) { mCallByTelecomCallId.remove(call.internalGetCallId()); mCalls.remove(call); fireCallRemoved(call); } - /** {@hide} */ final void internalUpdateCall(ParcelableCall parcelableCall) { Call call = mCallByTelecomCallId.get(parcelableCall.getId()); if (call != null) { @@ -135,7 +133,6 @@ public final class Phone { } } - /** {@hide} */ final void internalSetPostDialWait(String telecomId, String remaining) { Call call = mCallByTelecomCallId.get(telecomId); if (call != null) { @@ -143,7 +140,6 @@ public final class Phone { } } - /** {@hide} */ final void internalAudioStateChanged(AudioState audioState) { if (!Objects.equals(mAudioState, audioState)) { mAudioState = audioState; @@ -151,17 +147,14 @@ public final class Phone { } } - /** {@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,7 +164,6 @@ public final class Phone { /** * Called to destroy the phone and cleanup any lingering calls. - * @hide */ final void destroy() { for (Call call : mCalls) { @@ -244,6 +236,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 +251,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); diff --git a/telecomm/java/android/telecom/PhoneAccount.java b/telecomm/java/android/telecom/PhoneAccount.java index 052a481..bab460d 100644 --- a/telecomm/java/android/telecom/PhoneAccount.java +++ b/telecomm/java/android/telecom/PhoneAccount.java @@ -40,15 +40,13 @@ import java.util.MissingResourceException; /** * Represents a distinct method to place or receive a phone call. Apps which can place calls and * want those calls to be integrated into the dialer and in-call UI should build an instance of - * this class and register it with the system using {@link TelecomManager#registerPhoneAccount}. + * this class and register it with the system using {@link TelecomManager}. * <p> * {@link TelecomManager} uses registered {@link PhoneAccount}s to present the user with * alternative options when placing a phone call. When building a {@link PhoneAccount}, the app - * should supply a valid {@link PhoneAccountHandle} that references the {@link ConnectionService} + * should supply a valid {@link PhoneAccountHandle} that references the connection service * implementation Telecom will use to interact with the app. - * @hide */ -@SystemApi public class PhoneAccount implements Parcelable { /** @@ -74,7 +72,6 @@ public class PhoneAccount implements Parcelable { * <p> * See {@link #getCapabilities} * <p> - * {@hide} */ public static final int CAPABILITY_CALL_PROVIDER = 0x2; @@ -92,7 +89,6 @@ public class PhoneAccount implements Parcelable { * Flag indicating that this {@code PhoneAccount} is capable of placing video calls. * <p> * See {@link #getCapabilities} - * @hide */ public static final int CAPABILITY_VIDEO_CALLING = 0x8; @@ -111,6 +107,7 @@ public class PhoneAccount implements Parcelable { * See {@link #getCapabilities} * @hide */ + @SystemApi public static final int CAPABILITY_MULTI_USER = 0x20; /** @@ -202,12 +199,6 @@ public class PhoneAccount implements Parcelable { mSupportedUriSchemes.addAll(phoneAccount.getSupportedUriSchemes()); } - /** @hide */ - public Builder setAccountHandle(PhoneAccountHandle accountHandle) { - mAccountHandle = accountHandle; - return this; - } - /** * Sets the address. See {@link PhoneAccount#getAddress}. * @@ -331,7 +322,6 @@ public class PhoneAccount implements Parcelable { * * @param uriScheme The URI scheme. * @return The builder. - * @hide */ public Builder addSupportedUriScheme(String uriScheme) { if (!TextUtils.isEmpty(uriScheme) && !mSupportedUriSchemes.contains(uriScheme)) { @@ -421,7 +411,6 @@ public class PhoneAccount implements Parcelable { * Returns a builder initialized with the current {@link PhoneAccount} instance. * * @return The builder. - * @hide */ public Builder toBuilder() { return new Builder(this); } diff --git a/telecomm/java/android/telecom/PhoneAccountHandle.java b/telecomm/java/android/telecom/PhoneAccountHandle.java index 97af41a..60917b2 100644 --- a/telecomm/java/android/telecom/PhoneAccountHandle.java +++ b/telecomm/java/android/telecom/PhoneAccountHandle.java @@ -16,7 +16,6 @@ package android.telecom; -import android.annotation.SystemApi; import android.content.ComponentName; import android.os.Parcel; import android.os.Parcelable; @@ -29,16 +28,13 @@ import java.util.Objects; * The unique identifier for a {@link PhoneAccount}. A {@code PhoneAccountHandle} is made of two * parts: * <ul> - * <li>The component name of the associated {@link ConnectionService}.</li> + * <li>The component name of the associated connection service.</li> * <li>A string identifier that is unique across {@code PhoneAccountHandle}s with the same * component name.</li> * </ul> * - * See {@link PhoneAccount}, - * {@link TelecomManager#registerPhoneAccount TelecomManager.registerPhoneAccount}. - * @hide + * See {@link PhoneAccount}, {@link TelecomManager}. */ -@SystemApi public class PhoneAccountHandle implements Parcelable { private final ComponentName mComponentName; private final String mId; @@ -50,7 +46,6 @@ public class PhoneAccountHandle implements Parcelable { this(componentName, id, Process.myUserHandle()); } - /** @hide */ public PhoneAccountHandle( ComponentName componentName, String id, @@ -61,8 +56,8 @@ public class PhoneAccountHandle implements Parcelable { } /** - * The {@code ComponentName} of the {@link android.telecom.ConnectionService} which is - * responsible for making phone calls using this {@code PhoneAccountHandle}. + * The {@code ComponentName} of the connection service which is responsible for making phone + * calls using this {@code PhoneAccountHandle}. * * @return A suitable {@code ComponentName}. */ @@ -72,9 +67,9 @@ public class PhoneAccountHandle implements Parcelable { /** * A string that uniquely distinguishes this particular {@code PhoneAccountHandle} from all the - * others supported by the {@link ConnectionService} that created it. + * others supported by the connection service that created it. * <p> - * A {@code ConnectionService} must select identifiers that are stable for the lifetime of + * A connection service must select identifiers that are stable for the lifetime of * their users' relationship with their service, across many Android devices. For example, a * good set of identifiers might be the email addresses with which with users registered for * their accounts with a particular service. Depending on how a service chooses to operate, @@ -82,6 +77,9 @@ public class PhoneAccountHandle implements Parcelable { * ({@code 0}, {@code 1}, {@code 2}, ...) that are generated locally on each phone and could * collide with values generated on other phones or after a data wipe of a given phone. * + * Important: A non-unique identifier could cause non-deterministic call-log backup/restore + * behavior. + * * @return A service-specific unique identifier for this {@code PhoneAccountHandle}. */ public String getId() { @@ -90,7 +88,6 @@ public class PhoneAccountHandle implements Parcelable { /** * @return the {@link UserHandle} to use when connecting to this PhoneAccount. - * @hide */ public UserHandle getUserHandle() { return mUserHandle; diff --git a/telecomm/java/android/telecom/RemoteConference.java b/telecomm/java/android/telecom/RemoteConference.java index a8879ae..fba3ee3 100644 --- a/telecomm/java/android/telecom/RemoteConference.java +++ b/telecomm/java/android/telecom/RemoteConference.java @@ -18,7 +18,6 @@ package android.telecom; import com.android.internal.telecom.IConnectionService; -import android.annotation.SystemApi; import android.os.RemoteException; import java.util.ArrayList; @@ -30,9 +29,7 @@ import java.util.concurrent.CopyOnWriteArraySet; /** * Represents a conference call which can contain any number of {@link Connection} objects. - * @hide */ -@SystemApi public final class RemoteConference { public abstract static class Callback { @@ -164,11 +161,6 @@ public final class RemoteConference { return mState; } - /** @hide */ - @Deprecated public final int getCallCapabilities() { - return getConnectionCapabilities(); - } - public final int getConnectionCapabilities() { return mConnectionCapabilities; } diff --git a/telecomm/java/android/telecom/RemoteConnection.java b/telecomm/java/android/telecom/RemoteConnection.java index 486691f..4c423f2 100644 --- a/telecomm/java/android/telecom/RemoteConnection.java +++ b/telecomm/java/android/telecom/RemoteConnection.java @@ -20,7 +20,6 @@ import com.android.internal.telecom.IConnectionService; import com.android.internal.telecom.IVideoCallback; import com.android.internal.telecom.IVideoProvider; -import android.annotation.SystemApi; import android.net.Uri; import android.os.IBinder; import android.os.RemoteException; @@ -38,9 +37,7 @@ import java.util.concurrent.ConcurrentHashMap; * * @see ConnectionService#createRemoteOutgoingConnection(PhoneAccountHandle, ConnectionRequest) * @see ConnectionService#createRemoteIncomingConnection(PhoneAccountHandle, ConnectionRequest) - * @hide */ -@SystemApi public final class RemoteConnection { public static abstract class Callback { @@ -73,11 +70,6 @@ public final class RemoteConnection { */ public void onRingbackRequested(RemoteConnection connection, boolean ringback) {} - /** @hide */ - @Deprecated public void onCallCapabilitiesChanged( - RemoteConnection connection, - int callCapabilities) {} - /** * Indicates that the call capabilities of this {@code RemoteConnection} have changed. * See {@link #getConnectionCapabilities()}. @@ -223,11 +215,13 @@ public final class RemoteConnection { public void onPeerDimensionsChanged(VideoProvider videoProvider, int width, int height) {} - public void onCallDataUsageChanged(VideoProvider videoProvider, int dataUsage) {} + public void onCallDataUsageChanged(VideoProvider videoProvider, long dataUsage) {} public void onCameraCapabilitiesChanged( VideoProvider videoProvider, CameraCapabilities cameraCapabilities) {} + + public void onVideoQualityChanged(VideoProvider videoProvider, int videoQuality) {} } private final IVideoCallback mVideoCallbackDelegate = new IVideoCallback() { @@ -265,7 +259,7 @@ public final class RemoteConnection { } @Override - public void changeCallDataUsage(int dataUsage) { + public void changeCallDataUsage(long dataUsage) { for (Listener l : mListeners) { l.onCallDataUsageChanged(VideoProvider.this, dataUsage); } @@ -279,6 +273,13 @@ public final class RemoteConnection { } @Override + public void changeVideoQuality(int videoQuality) { + for (Listener l : mListeners) { + l.onVideoQualityChanged(VideoProvider.this, videoQuality); + } + } + + @Override public IBinder asBinder() { return null; } @@ -584,7 +585,6 @@ public final class RemoteConnection { /** * Obtains the video provider of this {@code RemoteConnection}. - * * @return The video provider associated with this {@code RemoteConnection}. * @hide */ @@ -842,7 +842,6 @@ public final class RemoteConnection { mConnectionCapabilities = connectionCapabilities; for (Callback c : mCallbacks) { c.onConnectionCapabilitiesChanged(this, connectionCapabilities); - c.onCallCapabilitiesChanged(this, connectionCapabilities); } } diff --git a/telecomm/java/android/telecom/RemoteConnectionService.java b/telecomm/java/android/telecom/RemoteConnectionService.java index 43a92cb..a9b725b 100644 --- a/telecomm/java/android/telecom/RemoteConnectionService.java +++ b/telecomm/java/android/telecom/RemoteConnectionService.java @@ -60,11 +60,16 @@ final class RemoteConnectionService { mPendingConnections.remove(connection); // Unconditionally initialize the connection ... connection.setConnectionCapabilities(parcel.getConnectionCapabilities()); - connection.setAddress( - parcel.getHandle(), parcel.getHandlePresentation()); - connection.setCallerDisplayName( - parcel.getCallerDisplayName(), - parcel.getCallerDisplayNamePresentation()); + if (parcel.getHandle() != null + || parcel.getState() != Connection.STATE_DISCONNECTED) { + connection.setAddress(parcel.getHandle(), parcel.getHandlePresentation()); + } + if (parcel.getCallerDisplayName() != null + || parcel.getState() != Connection.STATE_DISCONNECTED) { + connection.setCallerDisplayName( + parcel.getCallerDisplayName(), + parcel.getCallerDisplayNamePresentation()); + } // Set state after handle so that the client can identify the connection. if (parcel.getState() == Connection.STATE_DISCONNECTED) { connection.setDisconnected(parcel.getDisconnectCause()); diff --git a/telecomm/java/android/telecom/StatusHints.java b/telecomm/java/android/telecom/StatusHints.java index dd3a639..a32eae7 100644 --- a/telecomm/java/android/telecom/StatusHints.java +++ b/telecomm/java/android/telecom/StatusHints.java @@ -16,7 +16,6 @@ package android.telecom; -import android.annotation.SystemApi; import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; @@ -30,9 +29,7 @@ import java.util.Objects; /** * Contains status label and icon displayed in the in-call UI. - * @hide */ -@SystemApi public final class StatusHints implements Parcelable { private final ComponentName mPackageName; diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index 1a6b292..a72172c 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -55,8 +55,6 @@ public class TelecomManager { * Input: get*Extra field {@link #EXTRA_PHONE_ACCOUNT_HANDLE} contains the component name of the * {@link android.telecom.ConnectionService} that Telecom should bind to. Telecom will then * ask the connection service for more information about the call prior to showing any UI. - * - * @hide */ public static final String ACTION_INCOMING_CALL = "android.telecom.action.INCOMING_CALL"; @@ -77,21 +75,40 @@ public class TelecomManager { "android.telecom.action.CONNECTION_SERVICE_CONFIGURE"; /** + * The {@link android.content.Intent} action used to show the call accessibility settings page. + */ + public static final String ACTION_SHOW_CALL_ACCESSIBILITY_SETTINGS = + "android.telecom.action.SHOW_CALL_ACCESSIBILITY_SETTINGS"; + + /** * The {@link android.content.Intent} action used to show the call settings page. */ public static final String ACTION_SHOW_CALL_SETTINGS = "android.telecom.action.SHOW_CALL_SETTINGS"; /** + * The {@link android.content.Intent} action used to show the respond via SMS settings page. + */ + public static final String ACTION_SHOW_RESPOND_VIA_SMS_SETTINGS = + "android.telecom.action.SHOW_RESPOND_VIA_SMS_SETTINGS"; + + /** * The {@link android.content.Intent} action used to show the settings page used to configure * {@link PhoneAccount} preferences. - * @hide */ - @SystemApi public static final String ACTION_CHANGE_PHONE_ACCOUNTS = "android.telecom.action.CHANGE_PHONE_ACCOUNTS"; /** + * The {@link android.content.Intent} action used indicate that a new phone account was + * just registered. + * @hide + */ + @SystemApi + public static final String ACTION_PHONE_ACCOUNT_REGISTERED = + "android.telecom.action.PHONE_ACCOUNT_REGISTERED"; + + /** * Optional extra for {@link android.content.Intent#ACTION_CALL} containing a boolean that * determines whether the speakerphone should be automatically turned on for an outgoing call. */ @@ -106,7 +123,6 @@ public class TelecomManager { * {@link VideoProfile.VideoState#BIDIRECTIONAL}, * {@link VideoProfile.VideoState#RX_ENABLED}, * {@link VideoProfile.VideoState#TX_ENABLED}. - * @hide */ public static final String EXTRA_START_CALL_WITH_VIDEO_STATE = "android.telecom.extra.START_CALL_WITH_VIDEO_STATE"; @@ -117,9 +133,7 @@ public class TelecomManager { * {@link PhoneAccountHandle} to use when making the call. * <p class="note"> * Retrieve with {@link android.content.Intent#getParcelableExtra(String)}. - * @hide */ - @SystemApi public static final String EXTRA_PHONE_ACCOUNT_HANDLE = "android.telecom.extra.PHONE_ACCOUNT_HANDLE"; @@ -127,10 +141,7 @@ public class TelecomManager { * Optional extra for {@link #ACTION_INCOMING_CALL} containing a {@link Bundle} which contains * metadata about the call. This {@link Bundle} will be returned to the * {@link ConnectionService}. - * - * @hide */ - @SystemApi public static final String EXTRA_INCOMING_CALL_EXTRAS = "android.telecom.extra.INCOMING_CALL_EXTRAS"; @@ -139,10 +150,7 @@ public class TelecomManager { * {@link android.content.Intent#ACTION_DIAL} {@code Intent} containing a {@link Bundle} * which contains metadata about the call. This {@link Bundle} will be saved into * {@code Call.Details}. - * - * @hide */ - @SystemApi public static final String EXTRA_OUTGOING_CALL_EXTRAS = "android.telecom.extra.OUTGOING_CALL_EXTRAS"; @@ -206,9 +214,7 @@ public class TelecomManager { * {@link ConnectionService}s which interact with {@link RemoteConnection}s should only populate * this if the {@link android.telephony.TelephonyManager#getLine1Number()} value, as that is the * user's expected caller ID. - * @hide */ - @SystemApi public static final String EXTRA_CALL_BACK_NUMBER = "android.telecom.extra.CALL_BACK_NUMBER"; /** @@ -349,13 +355,12 @@ public class TelecomManager { * @param uriScheme The URI scheme. * @return The {@link PhoneAccountHandle} corresponding to the user-chosen default for outgoing * phone calls for a specified URI scheme. - * @hide */ - @SystemApi public PhoneAccountHandle getDefaultOutgoingPhoneAccount(String uriScheme) { try { if (isServiceConnected()) { - return getTelecomService().getDefaultOutgoingPhoneAccount(uriScheme); + return getTelecomService().getDefaultOutgoingPhoneAccount(uriScheme, + mContext.getOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelecomService#getDefaultOutgoingPhoneAccount", e); @@ -404,7 +409,6 @@ public class TelecomManager { * {@code null}, indicating that there currently exists no user-chosen default * {@code PhoneAccount}. * @return The phone account handle of the current sim call manager. - * @hide */ public PhoneAccountHandle getSimCallManager() { try { @@ -440,7 +444,7 @@ public class TelecomManager { public List<PhoneAccountHandle> getSimCallManagers() { try { if (isServiceConnected()) { - return getTelecomService().getSimCallManagers(); + return getTelecomService().getSimCallManagers(mContext.getOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelecomService#getSimCallManagers"); @@ -488,7 +492,8 @@ public class TelecomManager { public List<PhoneAccountHandle> getPhoneAccountsSupportingScheme(String uriScheme) { try { if (isServiceConnected()) { - return getTelecomService().getPhoneAccountsSupportingScheme(uriScheme); + return getTelecomService().getPhoneAccountsSupportingScheme(uriScheme, + mContext.getOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelecomService#getPhoneAccountsSupportingScheme", e); @@ -504,12 +509,11 @@ public class TelecomManager { * @see #EXTRA_PHONE_ACCOUNT_HANDLE * @return A list of {@code PhoneAccountHandle} objects. * - * @hide */ public List<PhoneAccountHandle> getCallCapablePhoneAccounts() { try { if (isServiceConnected()) { - return getTelecomService().getCallCapablePhoneAccounts(); + return getTelecomService().getCallCapablePhoneAccounts(mContext.getOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelecomService#getCallCapablePhoneAccounts", e); @@ -518,19 +522,6 @@ public class TelecomManager { } /** - * Determine whether the device has more than one account registered that can make and receive - * phone calls. - * - * @return {@code true} if the device has more than one account registered and {@code false} - * otherwise. - * @hide - */ - @SystemApi - public boolean hasMultipleCallCapableAccounts() { - return getCallCapablePhoneAccounts().size() > 1; - } - - /** * Returns a list of all {@link PhoneAccount}s registered for the calling package. * * @return A list of {@code PhoneAccountHandle} objects. @@ -554,9 +545,7 @@ public class TelecomManager { * * @param account The {@link PhoneAccountHandle}. * @return The {@link PhoneAccount} object. - * @hide */ - @SystemApi public PhoneAccount getPhoneAccount(PhoneAccountHandle account) { try { if (isServiceConnected()) { @@ -635,10 +624,7 @@ public class TelecomManager { * {@link PhoneAccountHandle#getComponentName()} does not match the package name of the app. * * @param account The complete {@link PhoneAccount}. - * - * @hide */ - @SystemApi public void registerPhoneAccount(PhoneAccount account) { try { if (isServiceConnected()) { @@ -653,9 +639,7 @@ public class TelecomManager { * Remove a {@link PhoneAccount} registration from the system. * * @param accountHandle A {@link PhoneAccountHandle} for the {@link PhoneAccount} to unregister. - * @hide */ - @SystemApi public void unregisterPhoneAccount(PhoneAccountHandle accountHandle) { try { if (isServiceConnected()) { @@ -671,6 +655,15 @@ public class TelecomManager { * @hide */ @SystemApi + public void clearPhoneAccounts() { + clearAccounts(); + } + /** + * Remove all Accounts that belong to the calling package from the system. + * @deprecated Use {@link #clearPhoneAccounts()} instead. + * @hide + */ + @SystemApi public void clearAccounts() { try { if (isServiceConnected()) { @@ -716,14 +709,12 @@ public class TelecomManager { * * @param accountHandle The handle for the account to check the voicemail number against * @param number The number to look up. - * - * @hide */ - @SystemApi public boolean isVoiceMailNumber(PhoneAccountHandle accountHandle, String number) { try { if (isServiceConnected()) { - return getTelecomService().isVoiceMailNumber(accountHandle, number); + return getTelecomService().isVoiceMailNumber(accountHandle, number, + mContext.getOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "RemoteException calling ITelecomService#isVoiceMailNumber.", e); @@ -732,23 +723,22 @@ public class TelecomManager { } /** - * Return whether a given phone account has a voicemail number configured. + * Return the voicemail number for a given phone account. * - * @param accountHandle The handle for the account to check for a voicemail number. - * @return {@code true} If the given phone account has a voicemail number. - * - * @hide + * @param accountHandle The handle for the phone account. + * @return The voicemail number for the phone account, and {@code null} if one has not been + * configured. */ - @SystemApi - public boolean hasVoiceMailNumber(PhoneAccountHandle accountHandle) { + public String getVoiceMailNumber(PhoneAccountHandle accountHandle) { try { if (isServiceConnected()) { - return getTelecomService().hasVoiceMailNumber(accountHandle); + return getTelecomService().getVoiceMailNumber(accountHandle, + mContext.getOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "RemoteException calling ITelecomService#hasVoiceMailNumber.", e); } - return false; + return null; } /** @@ -756,14 +746,12 @@ public class TelecomManager { * * @param accountHandle The handle for the account retrieve a number for. * @return A string representation of the line 1 phone number. - * - * @hide */ - @SystemApi public String getLine1Number(PhoneAccountHandle accountHandle) { try { if (isServiceConnected()) { - return getTelecomService().getLine1Number(accountHandle); + return getTelecomService().getLine1Number(accountHandle, + mContext.getOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "RemoteException calling ITelecomService#getLine1Number.", e); @@ -781,7 +769,7 @@ public class TelecomManager { public boolean isInCall() { try { if (isServiceConnected()) { - return getTelecomService().isInCall(); + return getTelecomService().isInCall(mContext.getOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "RemoteException calling isInCall().", e); @@ -823,7 +811,7 @@ public class TelecomManager { public boolean isRinging() { try { if (isServiceConnected()) { - return getTelecomService().isRinging(); + return getTelecomService().isRinging(mContext.getOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "RemoteException attempting to get ringing state of phone app.", e); @@ -869,10 +857,7 @@ public class TelecomManager { /** * Silences the ringer if a ringing call exists. - * - * @hide */ - @SystemApi public void silenceRinger() { try { if (isServiceConnected()) { @@ -892,7 +877,7 @@ public class TelecomManager { public boolean isTtySupported() { try { if (isServiceConnected()) { - return getTelecomService().isTtySupported(); + return getTelecomService().isTtySupported(mContext.getOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "RemoteException attempting to get TTY supported state.", e); @@ -913,7 +898,7 @@ public class TelecomManager { public int getCurrentTtyMode() { try { if (isServiceConnected()) { - return getTelecomService().getCurrentTtyMode(); + return getTelecomService().getCurrentTtyMode(mContext.getOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "RemoteException attempting to get the current TTY mode.", e); @@ -933,9 +918,7 @@ public class TelecomManager { * {@link #registerPhoneAccount}. * @param extras A bundle that will be passed through to * {@link ConnectionService#onCreateIncomingConnection}. - * @hide */ - @SystemApi public void addNewIncomingCall(PhoneAccountHandle phoneAccount, Bundle extras) { try { if (isServiceConnected()) { @@ -1005,10 +988,8 @@ public class TelecomManager { * @param accountHandle The handle for the account the MMI code should apply to. * @param dialString The digits to dial. * @return True if the digits were processed as an MMI code, false otherwise. - * @hide */ - @SystemApi - public boolean handleMmi(PhoneAccountHandle accountHandle, String dialString) { + public boolean handleMmi(String dialString, PhoneAccountHandle accountHandle) { ITelecomService service = getTelecomService(); if (service != null) { try { @@ -1025,9 +1006,7 @@ public class TelecomManager { * {@code null} to return a URI which will use the default account. * @return The URI (with the content:// scheme) specific to the specified {@link PhoneAccount} * for the the content retrieve. - * @hide */ - @SystemApi public Uri getAdnUriForPhoneAccount(PhoneAccountHandle accountHandle) { ITelecomService service = getTelecomService(); if (service != null && accountHandle != null) { @@ -1071,7 +1050,7 @@ public class TelecomManager { ITelecomService service = getTelecomService(); if (service != null) { try { - service.showInCallScreen(showDialpad); + service.showInCallScreen(showDialpad, mContext.getOpPackageName()); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelecomService#showCallScreen", e); } diff --git a/telecomm/java/android/telecom/VideoCallImpl.java b/telecomm/java/android/telecom/VideoCallImpl.java index 925058e..7bef688 100644 --- a/telecomm/java/android/telecom/VideoCallImpl.java +++ b/telecomm/java/android/telecom/VideoCallImpl.java @@ -42,10 +42,11 @@ public class VideoCallImpl extends VideoCall { private static final int MSG_CHANGE_PEER_DIMENSIONS = 4; private static final int MSG_CHANGE_CALL_DATA_USAGE = 5; private static final int MSG_CHANGE_CAMERA_CAPABILITIES = 6; + private static final int MSG_CHANGE_VIDEO_QUALITY = 7; private final IVideoProvider mVideoProvider; private final VideoCallListenerBinder mBinder; - private VideoCall.Listener mVideoCallListener; + private VideoCall.Callback mCallback; private IBinder.DeathRecipient mDeathRecipient = new IBinder.DeathRecipient() { @Override @@ -88,7 +89,12 @@ public class VideoCallImpl extends VideoCall { } @Override - public void changeCallDataUsage(int dataUsage) { + public void changeVideoQuality(int videoQuality) { + mHandler.obtainMessage(MSG_CHANGE_VIDEO_QUALITY, videoQuality, 0).sendToTarget(); + } + + @Override + public void changeCallDataUsage(long dataUsage) { mHandler.obtainMessage(MSG_CHANGE_CALL_DATA_USAGE, dataUsage).sendToTarget(); } @@ -103,14 +109,14 @@ public class VideoCallImpl extends VideoCall { private final Handler mHandler = new Handler(Looper.getMainLooper()) { @Override public void handleMessage(Message msg) { - if (mVideoCallListener == null) { + if (mCallback == null) { return; } SomeArgs args; switch (msg.what) { case MSG_RECEIVE_SESSION_MODIFY_REQUEST: - mVideoCallListener.onSessionModifyRequestReceived((VideoProfile) msg.obj); + mCallback.onSessionModifyRequestReceived((VideoProfile) msg.obj); break; case MSG_RECEIVE_SESSION_MODIFY_RESPONSE: args = (SomeArgs) msg.obj; @@ -119,32 +125,35 @@ public class VideoCallImpl extends VideoCall { VideoProfile requestProfile = (VideoProfile) args.arg2; VideoProfile responseProfile = (VideoProfile) args.arg3; - mVideoCallListener.onSessionModifyResponseReceived( + mCallback.onSessionModifyResponseReceived( status, requestProfile, responseProfile); } finally { args.recycle(); } break; case MSG_HANDLE_CALL_SESSION_EVENT: - mVideoCallListener.onCallSessionEvent((int) msg.obj); + mCallback.onCallSessionEvent((int) msg.obj); break; case MSG_CHANGE_PEER_DIMENSIONS: args = (SomeArgs) msg.obj; try { int width = (int) args.arg1; int height = (int) args.arg2; - mVideoCallListener.onPeerDimensionsChanged(width, height); + mCallback.onPeerDimensionsChanged(width, height); } finally { args.recycle(); } break; case MSG_CHANGE_CALL_DATA_USAGE: - mVideoCallListener.onCallDataUsageChanged(msg.arg1); + mCallback.onCallDataUsageChanged((long) msg.obj); break; case MSG_CHANGE_CAMERA_CAPABILITIES: - mVideoCallListener.onCameraCapabilitiesChanged( + mCallback.onCameraCapabilitiesChanged( (CameraCapabilities) msg.obj); break; + case MSG_CHANGE_VIDEO_QUALITY: + mCallback.onVideoQualityChanged(msg.arg1); + break; default: break; } @@ -161,8 +170,8 @@ public class VideoCallImpl extends VideoCall { } /** {@inheritDoc} */ - public void setVideoCallListener(VideoCall.Listener videoCallListener) { - mVideoCallListener = videoCallListener; + public void registerCallback(VideoCall.Callback callback) { + mCallback = callback; } /** {@inheritDoc} */ @@ -244,4 +253,4 @@ public class VideoCallImpl extends VideoCall { } catch (RemoteException e) { } } -}
\ No newline at end of file +} diff --git a/telecomm/java/android/telecom/VideoCallbackServant.java b/telecomm/java/android/telecom/VideoCallbackServant.java index d0e3f22..1123621 100644 --- a/telecomm/java/android/telecom/VideoCallbackServant.java +++ b/telecomm/java/android/telecom/VideoCallbackServant.java @@ -38,6 +38,7 @@ final class VideoCallbackServant { private static final int MSG_CHANGE_PEER_DIMENSIONS = 3; private static final int MSG_CHANGE_CALL_DATA_USAGE = 4; private static final int MSG_CHANGE_CAMERA_CAPABILITIES = 5; + private static final int MSG_CHANGE_VIDEO_QUALITY = 6; private final IVideoCallback mDelegate; @@ -90,7 +91,7 @@ final class VideoCallbackServant { case MSG_CHANGE_CALL_DATA_USAGE: { SomeArgs args = (SomeArgs) msg.obj; try { - mDelegate.changeCallDataUsage(args.argi1); + mDelegate.changeCallDataUsage((long) args.arg1); } finally { args.recycle(); } @@ -100,6 +101,10 @@ final class VideoCallbackServant { mDelegate.changeCameraCapabilities((CameraCapabilities) msg.obj); break; } + case MSG_CHANGE_VIDEO_QUALITY: { + mDelegate.changeVideoQuality(msg.arg1); + break; + } } } }; @@ -136,9 +141,9 @@ final class VideoCallbackServant { } @Override - public void changeCallDataUsage(int dataUsage) throws RemoteException { + public void changeCallDataUsage(long dataUsage) throws RemoteException { SomeArgs args = SomeArgs.obtain(); - args.argi1 = dataUsage; + args.arg1 = dataUsage; mHandler.obtainMessage(MSG_CHANGE_CALL_DATA_USAGE, args).sendToTarget(); } @@ -148,6 +153,11 @@ final class VideoCallbackServant { mHandler.obtainMessage(MSG_CHANGE_CAMERA_CAPABILITIES, cameraCapabilities) .sendToTarget(); } + + @Override + public void changeVideoQuality(int videoQuality) throws RemoteException { + mHandler.obtainMessage(MSG_CHANGE_VIDEO_QUALITY, videoQuality, 0).sendToTarget(); + } }; public VideoCallbackServant(IVideoCallback delegate) { diff --git a/telecomm/java/android/telecom/VideoProfile.java b/telecomm/java/android/telecom/VideoProfile.java index f5cb054..2fd438a 100644 --- a/telecomm/java/android/telecom/VideoProfile.java +++ b/telecomm/java/android/telecom/VideoProfile.java @@ -21,11 +21,14 @@ import android.os.Parcelable; /** * Represents attributes of video calls. - * - * {@hide} */ public class VideoProfile implements Parcelable { /** + * "Unknown" video quality. + * @hide + */ + public static final int QUALITY_UNKNOWN = 0; + /** * "High" video quality. */ public static final int QUALITY_HIGH = 1; @@ -181,6 +184,17 @@ public class VideoProfile implements Parcelable { } /** + * Whether the video state is any of the video type + * @param videoState The video state. + * @hide + * @return Returns true if the video state TX or RX or Bidirectional + */ + public static boolean isVideo(int videoState) { + return hasState(videoState, TX_ENABLED) || hasState(videoState, RX_ENABLED) + || hasState(videoState, BIDIRECTIONAL); + } + + /** * Whether the video transmission is enabled. * @param videoState The video state. * @return Returns true if the video transmission is enabled. diff --git a/telecomm/java/android/telecom/Voicemail.java b/telecomm/java/android/telecom/Voicemail.java new file mode 100644 index 0000000..f5b8052 --- /dev/null +++ b/telecomm/java/android/telecom/Voicemail.java @@ -0,0 +1,278 @@ +/* + * Copyright (C) 2015 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.telecom; + +import android.net.Uri; +import android.os.Parcel; +import android.os.Parcelable; + +/** + * Represents a single voicemail stored in the voicemail content provider. + * + * @hide + */ +public class Voicemail implements Parcelable { + private final Long mTimestamp; + private final String mNumber; + private final Long mId; + private final Long mDuration; + private final String mSource; + private final String mProviderData; + private final Uri mUri; + private final Boolean mIsRead; + private final Boolean mHasContent; + + private Voicemail(Long timestamp, String number, Long id, Long duration, String source, + String providerData, Uri uri, Boolean isRead, Boolean hasContent) { + mTimestamp = timestamp; + mNumber = number; + mId = id; + mDuration = duration; + mSource = source; + mProviderData = providerData; + mUri = uri; + mIsRead = isRead; + mHasContent = hasContent; + } + + /** + * Create a {@link Builder} for a new {@link Voicemail} to be inserted. + * <p> + * The number and the timestamp are mandatory for insertion. + */ + public static Builder createForInsertion(long timestamp, String number) { + return new Builder().setNumber(number).setTimestamp(timestamp); + } + + /** + * Create a {@link Builder} for a {@link Voicemail} to be updated (or deleted). + * <p> + * The id and source data fields are mandatory for update - id is necessary for updating the + * database and source data is necessary for updating the server. + */ + public static Builder createForUpdate(long id, String sourceData) { + return new Builder().setId(id).setSourceData(sourceData); + } + + /** + * Builder pattern for creating a {@link Voicemail}. The builder must be created with the + * {@link #createForInsertion(long, String)} method. + * <p> + * This class is <b>not thread safe</b> + */ + public static class Builder { + private Long mBuilderTimestamp; + private String mBuilderNumber; + private Long mBuilderId; + private Long mBuilderDuration; + private String mBuilderSourcePackage; + private String mBuilderSourceData; + private Uri mBuilderUri; + private Boolean mBuilderIsRead; + private boolean mBuilderHasContent; + + /** You should use the correct factory method to construct a builder. */ + private Builder() { + } + + public Builder setNumber(String number) { + mBuilderNumber = number; + return this; + } + + public Builder setTimestamp(long timestamp) { + mBuilderTimestamp = timestamp; + return this; + } + + public Builder setId(long id) { + mBuilderId = id; + return this; + } + + public Builder setDuration(long duration) { + mBuilderDuration = duration; + return this; + } + + public Builder setSourcePackage(String sourcePackage) { + mBuilderSourcePackage = sourcePackage; + return this; + } + + public Builder setSourceData(String sourceData) { + mBuilderSourceData = sourceData; + return this; + } + + public Builder setUri(Uri uri) { + mBuilderUri = uri; + return this; + } + + public Builder setIsRead(boolean isRead) { + mBuilderIsRead = isRead; + return this; + } + + public Builder setHasContent(boolean hasContent) { + mBuilderHasContent = hasContent; + return this; + } + + public Voicemail build() { + mBuilderId = mBuilderId == null ? -1 : mBuilderId; + mBuilderTimestamp = mBuilderTimestamp == null ? 0 : mBuilderTimestamp; + mBuilderDuration = mBuilderDuration == null ? 0: mBuilderDuration; + mBuilderIsRead = mBuilderIsRead == null ? false : mBuilderIsRead; + return new Voicemail(mBuilderTimestamp, mBuilderNumber, mBuilderId, mBuilderDuration, + mBuilderSourcePackage, mBuilderSourceData, mBuilderUri, mBuilderIsRead, + mBuilderHasContent); + } + } + + /** + * The identifier of the voicemail in the content provider. + * <p> + * This may be missing in the case of a new {@link Voicemail} that we plan to insert into the + * content provider, since until it has been inserted we don't know what id it should have. If + * none is specified, we return -1. + */ + public long getId() { + return mId; + } + + /** The number of the person leaving the voicemail, empty string if unknown, null if not set. */ + public String getNumber() { + return mNumber; + } + + /** The timestamp the voicemail was received, in millis since the epoch, zero if not set. */ + public long getTimestampMillis() { + return mTimestamp; + } + + /** Gets the duration of the voicemail in millis, or zero if the field is not set. */ + public long getDuration() { + return mDuration; + } + + /** + * Returns the package name of the source that added this voicemail, or null if this field is + * not set. + */ + public String getSourcePackage() { + return mSource; + } + + /** + * Returns the application-specific data type stored with the voicemail, or null if this field + * is not set. + * <p> + * Source data is typically used as an identifier to uniquely identify the voicemail against + * the voicemail server. This is likely to be something like the IMAP UID, or some other + * server-generated identifying string. + */ + public String getSourceData() { + return mProviderData; + } + + /** + * Gets the Uri that can be used to refer to this voicemail, and to make it play. + * <p> + * Returns null if we don't know the Uri. + */ + public Uri getUri() { + return mUri; + } + + /** + * Tells us if the voicemail message has been marked as read. + * <p> + * Always returns false if this field has not been set, i.e. if hasRead() returns false. + */ + public boolean isRead() { + return mIsRead; + } + + /** + * Tells us if there is content stored at the Uri. + */ + public boolean hasContent() { + return mHasContent; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeLong(mTimestamp); + dest.writeCharSequence(mNumber); + dest.writeLong(mId); + dest.writeLong(mDuration); + dest.writeCharSequence(mSource); + dest.writeCharSequence(mProviderData); + if (mUri == null) { + dest.writeInt(0); + } else { + dest.writeInt(1); + mUri.writeToParcel(dest, flags); + } + if (mIsRead) { + dest.writeInt(1); + } else { + dest.writeInt(0); + } + if (mHasContent) { + dest.writeInt(1); + } else { + dest.writeInt(0); + } + } + + public static final Creator<Voicemail> CREATOR + = new Creator<Voicemail>() { + @Override + public Voicemail createFromParcel(Parcel in) { + return new Voicemail(in); + } + + @Override + public Voicemail[] newArray(int size) { + return new Voicemail[size]; + } + }; + + private Voicemail(Parcel in) { + mTimestamp = in.readLong(); + mNumber = (String) in.readCharSequence(); + mId = in.readLong(); + mDuration = in.readLong(); + mSource = (String) in.readCharSequence(); + mProviderData = (String) in.readCharSequence(); + if (in.readInt() > 0) { + mUri = Uri.CREATOR.createFromParcel(in); + } else { + mUri = null; + } + mIsRead = in.readInt() > 0 ? true : false; + mHasContent = in.readInt() > 0 ? true : false; + } +} diff --git a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl index d2030f2..727fd4b 100644 --- a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl +++ b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl @@ -33,12 +33,12 @@ interface ITelecomService { * * @param showDialpad if true, make the dialpad visible initially. */ - void showInCallScreen(boolean showDialpad); + void showInCallScreen(boolean showDialpad, String callingPackage); /** * @see TelecomServiceImpl#getDefaultOutgoingPhoneAccount */ - PhoneAccountHandle getDefaultOutgoingPhoneAccount(in String uriScheme); + PhoneAccountHandle getDefaultOutgoingPhoneAccount(in String uriScheme, String callingPackage); /** * @see TelecomServiceImpl#getUserSelectedOutgoingPhoneAccount @@ -53,12 +53,13 @@ interface ITelecomService { /** * @see TelecomServiceImpl#getCallCapablePhoneAccounts */ - List<PhoneAccountHandle> getCallCapablePhoneAccounts(); + List<PhoneAccountHandle> getCallCapablePhoneAccounts(String callingPackage); /** * @see TelecomManager#getPhoneAccountsSupportingScheme */ - List<PhoneAccountHandle> getPhoneAccountsSupportingScheme(in String uriScheme); + List<PhoneAccountHandle> getPhoneAccountsSupportingScheme(in String uriScheme, + String callingPackage); /** * @see TelecomManager#getPhoneAccountsForPackage @@ -98,7 +99,7 @@ interface ITelecomService { /** * @see TelecomServiceImpl#getSimCallManagers */ - List<PhoneAccountHandle> getSimCallManagers(); + List<PhoneAccountHandle> getSimCallManagers(String callingPackage); /** * @see TelecomServiceImpl#registerPhoneAccount @@ -118,17 +119,18 @@ interface ITelecomService { /** * @see TelecomServiceImpl#isVoiceMailNumber */ - boolean isVoiceMailNumber(in PhoneAccountHandle accountHandle, String number); + boolean isVoiceMailNumber(in PhoneAccountHandle accountHandle, String number, + String callingPackage); /** - * @see TelecomServiceImpl#hasVoiceMailNumber + * @see TelecomServiceImpl#getVoiceMailNumber */ - boolean hasVoiceMailNumber(in PhoneAccountHandle accountHandle); + String getVoiceMailNumber(in PhoneAccountHandle accountHandle, String callingPackage); /** * @see TelecomServiceImpl#getLine1Number */ - String getLine1Number(in PhoneAccountHandle accountHandle); + String getLine1Number(in PhoneAccountHandle accountHandle, String callingPackage); /** * @see TelecomServiceImpl#getDefaultPhoneApp @@ -147,12 +149,12 @@ interface ITelecomService { /** * @see TelecomServiceImpl#isInCall */ - boolean isInCall(); + boolean isInCall(String callingPackage); /** * @see TelecomServiceImpl#isRinging */ - boolean isRinging(); + boolean isRinging(String callingPackage); /** * @see TelecomServiceImpl#getCallState @@ -192,12 +194,12 @@ interface ITelecomService { /** * @see TelecomServiceImpl#isTtySupported */ - boolean isTtySupported(); + boolean isTtySupported(String callingPackage); /** * @see TelecomServiceImpl#getCurrentTtyMode */ - int getCurrentTtyMode(); + int getCurrentTtyMode(String callingPackage); /** * @see TelecomServiceImpl#addNewIncomingCall diff --git a/telecomm/java/com/android/internal/telecom/IVideoCallback.aidl b/telecomm/java/com/android/internal/telecom/IVideoCallback.aidl index f758b60..59f8f0c 100644 --- a/telecomm/java/com/android/internal/telecom/IVideoCallback.aidl +++ b/telecomm/java/com/android/internal/telecom/IVideoCallback.aidl @@ -39,7 +39,9 @@ oneway interface IVideoCallback { void changePeerDimensions(int width, int height); - void changeCallDataUsage(int dataUsage); + void changeCallDataUsage(long dataUsage); void changeCameraCapabilities(in CameraCapabilities cameraCapabilities); + + void changeVideoQuality(int videoQuality); } |
