summaryrefslogtreecommitdiffstats
path: root/telecomm/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'telecomm/java/android')
-rw-r--r--telecomm/java/android/telecom/AudioState.java10
-rw-r--r--telecomm/java/android/telecom/Conference.java17
-rw-r--r--telecomm/java/android/telecom/ConferenceParticipant.aidl22
-rw-r--r--telecomm/java/android/telecom/ConferenceParticipant.java158
-rw-r--r--telecomm/java/android/telecom/Connection.java31
-rw-r--r--telecomm/java/android/telecom/ConnectionRequest.java3
-rw-r--r--telecomm/java/android/telecom/ConnectionService.java60
-rw-r--r--telecomm/java/android/telecom/ConnectionServiceAdapter.java16
-rw-r--r--telecomm/java/android/telecom/ConnectionServiceAdapterServant.java20
-rw-r--r--telecomm/java/android/telecom/DisconnectCause.java11
-rw-r--r--telecomm/java/android/telecom/GatewayInfo.java32
-rw-r--r--telecomm/java/android/telecom/PhoneAccount.java199
-rw-r--r--telecomm/java/android/telecom/PhoneAccountHandle.java18
-rw-r--r--telecomm/java/android/telecom/PhoneCapabilities.java77
-rw-r--r--telecomm/java/android/telecom/RemoteConference.java3
-rw-r--r--telecomm/java/android/telecom/RemoteConnection.java28
-rw-r--r--telecomm/java/android/telecom/RemoteConnectionService.java12
-rw-r--r--telecomm/java/android/telecom/StatusHints.java3
-rw-r--r--telecomm/java/android/telecom/TelecomManager.java88
19 files changed, 675 insertions, 133 deletions
diff --git a/telecomm/java/android/telecom/AudioState.java b/telecomm/java/android/telecom/AudioState.java
index fc2fff4..43da38f 100644
--- a/telecomm/java/android/telecom/AudioState.java
+++ b/telecomm/java/android/telecom/AudioState.java
@@ -16,17 +16,15 @@
package android.telecom;
-import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.Locale;
/**
- * Encapsulates all audio states during a call.
- * @hide
+ * Encapsulates the telecom audio state, including the current audio routing, supported audio
+ * routing and mute.
*/
-@SystemApi
public final class AudioState implements Parcelable {
/** Direct the audio stream through the device's earpiece. */
public static final int ROUTE_EARPIECE = 0x00000001;
@@ -56,10 +54,10 @@ public final class AudioState implements Parcelable {
/** True if the call is muted, false otherwise. */
public final boolean isMuted;
- /** The route to use for the audio stream. */
+ /** The current audio route being used. */
public final int route;
- /** Bit vector of all routes supported by this call. */
+ /** Bit mask of all routes supported by this call. */
public final int supportedRouteMask;
public AudioState(boolean isMuted, int route, int supportedRouteMask) {
diff --git a/telecomm/java/android/telecom/Conference.java b/telecomm/java/android/telecom/Conference.java
index b7b98bf..003d5cd 100644
--- a/telecomm/java/android/telecom/Conference.java
+++ b/telecomm/java/android/telecom/Conference.java
@@ -16,8 +16,6 @@
package android.telecom;
-import android.annotation.SystemApi;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -27,9 +25,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
/**
* Represents a conference call which can contain any number of {@link Connection} objects.
- * @hide
*/
-@SystemApi
public abstract class Conference {
/** @hide */
@@ -338,6 +334,19 @@ public abstract class Conference {
}
/**
+ * Retrieves the primary connection associated with the conference. The primary connection is
+ * the connection from which the conference will retrieve its current state.
+ *
+ * @return The primary connection.
+ */
+ public Connection getPrimaryConnection() {
+ if (mUnmodifiableChildConnections == null || mUnmodifiableChildConnections.isEmpty()) {
+ return null;
+ }
+ return mUnmodifiableChildConnections.get(0);
+ }
+
+ /**
* Inform this Conference that the state of its audio output has been changed externally.
*
* @param state The new audio state.
diff --git a/telecomm/java/android/telecom/ConferenceParticipant.aidl b/telecomm/java/android/telecom/ConferenceParticipant.aidl
new file mode 100644
index 0000000..020c923
--- /dev/null
+++ b/telecomm/java/android/telecom/ConferenceParticipant.aidl
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package android.telecom;
+
+/**
+ * {@hide}
+ */
+parcelable ConferenceParticipant;
diff --git a/telecomm/java/android/telecom/ConferenceParticipant.java b/telecomm/java/android/telecom/ConferenceParticipant.java
new file mode 100644
index 0000000..db0f151
--- /dev/null
+++ b/telecomm/java/android/telecom/ConferenceParticipant.java
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package android.telecom;
+
+import android.net.Uri;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * Parcelable representation of a participant's state in a conference call.
+ * @hide
+ */
+public class ConferenceParticipant implements Parcelable {
+
+ /**
+ * The conference participant's handle (e.g., phone number).
+ */
+ private final Uri mHandle;
+
+ /**
+ * The display name for the participant.
+ */
+ private final String mDisplayName;
+
+ /**
+ * The endpoint Uri which uniquely identifies this conference participant. E.g. for an IMS
+ * conference call, this is the endpoint URI for the participant on the IMS conference server.
+ */
+ private final Uri mEndpoint;
+
+ /**
+ * The state of the participant in the conference.
+ *
+ * @see android.telecom.Connection
+ */
+ private final int mState;
+
+ /**
+ * Creates an instance of {@code ConferenceParticipant}.
+ *
+ * @param handle The conference participant's handle (e.g., phone number).
+ * @param displayName The display name for the participant.
+ * @param endpoint The enpoint Uri which uniquely identifies this conference participant.
+ * @param state The state of the participant in the conference.
+ */
+ public ConferenceParticipant(Uri handle, String displayName, Uri endpoint, int state) {
+ mHandle = handle;
+ mDisplayName = displayName;
+ mEndpoint = endpoint;
+ mState = state;
+ }
+
+ /**
+ * Responsible for creating {@code ConferenceParticipant} objects for deserialized Parcels.
+ */
+ public static final Parcelable.Creator<ConferenceParticipant> CREATOR =
+ new Parcelable.Creator<ConferenceParticipant>() {
+
+ @Override
+ public ConferenceParticipant createFromParcel(Parcel source) {
+ ClassLoader classLoader = ParcelableCall.class.getClassLoader();
+ Uri handle = source.readParcelable(classLoader);
+ String displayName = source.readString();
+ Uri endpoint = source.readParcelable(classLoader);
+ int state = source.readInt();
+ return new ConferenceParticipant(handle, displayName, endpoint, state);
+ }
+
+ @Override
+ public ConferenceParticipant[] newArray(int size) {
+ return new ConferenceParticipant[size];
+ }
+ };
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /**
+ * Writes the {@code ConferenceParticipant} to a parcel.
+ *
+ * @param dest The Parcel in which the object should be written.
+ * @param flags Additional flags about how the object should be written.
+ */
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeParcelable(mHandle, 0);
+ dest.writeString(mDisplayName);
+ dest.writeParcelable(mEndpoint, 0);
+ dest.writeInt(mState);
+ }
+
+ /**
+ * Builds a string representation of this instance.
+ *
+ * @return String representing the conference participant.
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("[ConferenceParticipant Handle: ");
+ sb.append(mHandle);
+ sb.append(" DisplayName: ");
+ sb.append(mDisplayName);
+ sb.append(" Endpoint: ");
+ sb.append(mEndpoint);
+ sb.append(" State: ");
+ sb.append(mState);
+ sb.append("]");
+ return sb.toString();
+ }
+
+ /**
+ * The conference participant's handle (e.g., phone number).
+ */
+ public Uri getHandle() {
+ return mHandle;
+ }
+
+ /**
+ * The display name for the participant.
+ */
+ public String getDisplayName() {
+ return mDisplayName;
+ }
+
+ /**
+ * The enpoint Uri which uniquely identifies this conference participant. E.g. for an IMS
+ * conference call, this is the endpoint URI for the participant on the IMS conference server.
+ */
+ public Uri getEndpoint() {
+ return mEndpoint;
+ }
+
+ /**
+ * The state of the participant in the conference.
+ *
+ * @see android.telecom.Connection
+ */
+ public int getState() {
+ return mState;
+ }
+}
diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java
index 4c1f75f..9bdbba8 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,9 +43,7 @@ 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 {
public static final int STATE_INITIALIZING = 0;
@@ -85,6 +82,9 @@ public abstract class Connection {
public void onConferenceableConnectionsChanged(
Connection c, List<Connection> conferenceableConnections) {}
public void onConferenceChanged(Connection c, Conference conference) {}
+ /** @hide */
+ public void onConferenceParticipantChanged(Connection c, ConferenceParticipant participant)
+ {}
}
/** @hide */
@@ -876,7 +876,7 @@ public abstract class Connection {
return mUnmodifiableConferenceableConnections;
}
- /**
+ /*
* @hide
*/
public final void setConnectionService(ConnectionService connectionService) {
@@ -921,6 +921,7 @@ public abstract class Connection {
mConference = conference;
if (mConnectionService != null && mConnectionService.containsConference(conference)) {
fireConferenceChanged();
+ onConferenceChanged();
}
return true;
}
@@ -936,6 +937,7 @@ public abstract class Connection {
Log.d(this, "Conference reset");
mConference = null;
fireConferenceChanged();
+ onConferenceChanged();
}
}
@@ -1020,14 +1022,9 @@ public abstract class Connection {
public void onPostDialContinue(boolean proceed) {}
/**
- * Merge this connection and the specified connection into a conference call. Once the
- * connections are merged, the calls should be added to the an existing or new
- * {@code Conference} instance. For new {@code Conference} instances, use
- * {@code ConnectionService#addConference}.
- *
- * @param otherConnection The connection with which this connection should be conferenced.
+ * Notifies this Connection that the conference which is set on it has changed.
*/
- public void onConferenceWith(Connection otherConnection) {}
+ public void onConferenceChanged() {}
static String toLogSafePhoneNumber(String number) {
// For unknown number, log empty string.
@@ -1123,4 +1120,16 @@ public abstract class Connection {
}
mConferenceableConnections.clear();
}
+
+ /**
+ * Notifies listeners of a change to a conference participant.
+ *
+ * @param conferenceParticipant The participant.
+ * @hide
+ */
+ protected final void updateConferenceParticipant(ConferenceParticipant conferenceParticipant) {
+ for (Listener l : mListeners) {
+ l.onConferenceParticipantChanged(this, conferenceParticipant);
+ }
+ }
}
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 6eee99d..6e41c33 100644
--- a/telecomm/java/android/telecom/ConnectionService.java
+++ b/telecomm/java/android/telecom/ConnectionService.java
@@ -16,7 +16,6 @@
package android.telecom;
-import android.annotation.SystemApi;
import android.annotation.SdkConstant;
import android.app.Service;
import android.content.ComponentName;
@@ -43,9 +42,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* A {@link android.app.Service} that provides telephone connections to processes running on an
* Android device.
- * @hide
*/
-@SystemApi
public abstract class ConnectionService extends Service {
/**
* The {@link Intent} that must be declared as handled by the service.
@@ -825,6 +822,40 @@ public abstract class ConnectionService extends Service {
}
/**
+ * Adds a connection created by the {@link ConnectionService} and informs telecom of the new
+ * connection.
+ *
+ * @param phoneAccountHandle The phone account handle for the connection.
+ * @param connection The connection to add.
+ */
+ public final void addExistingConnection(PhoneAccountHandle phoneAccountHandle,
+ Connection connection) {
+
+ String id = addExistingConnectionInternal(connection);
+ if (id != null) {
+ List<String> emptyList = new ArrayList<>(0);
+
+ ParcelableConnection parcelableConnection = new ParcelableConnection(
+ phoneAccountHandle,
+ connection.getState(),
+ connection.getCallCapabilities(),
+ connection.getAddress(),
+ connection.getAddressPresentation(),
+ connection.getCallerDisplayName(),
+ connection.getCallerDisplayNamePresentation(),
+ connection.getVideoProvider() == null ?
+ null : connection.getVideoProvider().getInterface(),
+ connection.getVideoState(),
+ connection.isRingbackRequested(),
+ connection.getAudioModeIsVoip(),
+ connection.getStatusHints(),
+ connection.getDisconnectCause(),
+ emptyList);
+ mAdapter.addExistingConnection(id, parcelableConnection);
+ }
+ }
+
+ /**
* Returns all the active {@code Connection}s for which this {@code ConnectionService}
* has taken responsibility.
*
@@ -909,6 +940,12 @@ public abstract class ConnectionService extends Service {
public void onRemoteConferenceAdded(RemoteConference conference) {}
/**
+ * Called when an existing connection is added remotely.
+ * @param connection The existing connection which was added.
+ */
+ public void onRemoteExistingConnectionAdded(RemoteConnection connection) {}
+
+ /**
* @hide
*/
public boolean containsConference(Conference conference) {
@@ -920,6 +957,11 @@ public abstract class ConnectionService extends Service {
onRemoteConferenceAdded(remoteConference);
}
+ /** {@hide} */
+ void addRemoteExistingConnection(RemoteConnection remoteConnection) {
+ onRemoteExistingConnectionAdded(remoteConnection);
+ }
+
private void onAccountsInitialized() {
mAreAccountsInitialized = true;
for (Runnable r : mPreInitializationConnectionRequests) {
@@ -928,6 +970,18 @@ public abstract class ConnectionService extends Service {
mPreInitializationConnectionRequests.clear();
}
+ /**
+ * Adds an existing connection to the list of connections, identified by a new UUID.
+ *
+ * @param connection The connection.
+ * @return The UUID of the connection (e.g. the call-id).
+ */
+ private String addExistingConnectionInternal(Connection connection) {
+ String id = UUID.randomUUID().toString();
+ addConnection(id, connection);
+ return id;
+ }
+
private void addConnection(String callId, Connection connection) {
mConnectionById.put(callId, connection);
mIdByConnection.put(connection, callId);
diff --git a/telecomm/java/android/telecom/ConnectionServiceAdapter.java b/telecomm/java/android/telecom/ConnectionServiceAdapter.java
index c676172..e67af8c 100644
--- a/telecomm/java/android/telecom/ConnectionServiceAdapter.java
+++ b/telecomm/java/android/telecom/ConnectionServiceAdapter.java
@@ -344,4 +344,20 @@ final class ConnectionServiceAdapter implements DeathRecipient {
}
}
}
+
+ /**
+ * Informs telecom of an existing connection which was added by the {@link ConnectionService}.
+ *
+ * @param callId The unique ID of the call being added.
+ * @param connection The connection.
+ */
+ void addExistingConnection(String callId, ParcelableConnection connection) {
+ Log.v(this, "addExistingConnection: %s", callId);
+ for (IConnectionServiceAdapter adapter : mAdapters) {
+ try {
+ adapter.addExistingConnection(callId, connection);
+ } catch (RemoteException ignored) {
+ }
+ }
+ }
}
diff --git a/telecomm/java/android/telecom/ConnectionServiceAdapterServant.java b/telecomm/java/android/telecom/ConnectionServiceAdapterServant.java
index 217dbc3..519a400 100644
--- a/telecomm/java/android/telecom/ConnectionServiceAdapterServant.java
+++ b/telecomm/java/android/telecom/ConnectionServiceAdapterServant.java
@@ -57,6 +57,7 @@ final class ConnectionServiceAdapterServant {
private static final int MSG_SET_ADDRESS = 18;
private static final int MSG_SET_CALLER_DISPLAY_NAME = 19;
private static final int MSG_SET_CONFERENCEABLE_CONNECTIONS = 20;
+ private static final int MSG_ADD_EXISTING_CONNECTION = 21;
private final IConnectionServiceAdapter mDelegate;
@@ -199,6 +200,16 @@ final class ConnectionServiceAdapterServant {
}
break;
}
+ case MSG_ADD_EXISTING_CONNECTION: {
+ SomeArgs args = (SomeArgs) msg.obj;
+ try {
+ mDelegate.addExistingConnection(
+ (String) args.arg1, (ParcelableConnection) args.arg2);
+ } finally {
+ args.recycle();
+ }
+ break;
+ }
}
}
};
@@ -345,6 +356,15 @@ final class ConnectionServiceAdapterServant {
args.arg2 = conferenceableConnectionIds;
mHandler.obtainMessage(MSG_SET_CONFERENCEABLE_CONNECTIONS, args).sendToTarget();
}
+
+ @Override
+ public final void addExistingConnection(
+ String connectionId, ParcelableConnection connection) {
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = connectionId;
+ args.arg2 = connection;
+ mHandler.obtainMessage(MSG_ADD_EXISTING_CONNECTION, args).sendToTarget();
+ }
};
public ConnectionServiceAdapterServant(IConnectionServiceAdapter delegate) {
diff --git a/telecomm/java/android/telecom/DisconnectCause.java b/telecomm/java/android/telecom/DisconnectCause.java
index 52c1284..206046d 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;
@@ -26,12 +25,11 @@ import java.util.Objects;
/**
* Describes the cause of a disconnected call. This always includes a code describing the generic
- * cause of the disconnect. Optionally, it may include a localized label and/or localized description
- * to display to the user which is provided by the {@link ConnectionService}. It also may contain a
- * reason for the the disconnect, which is intended for logging and not for display to the user.
- * @hide
+ * cause of the disconnect. Optionally, it may include a label and/or description to display to the
+ * 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.
*/
-@SystemApi
public final class DisconnectCause implements Parcelable {
/** Disconnected because of an unknown or unspecified reason. */
@@ -88,6 +86,7 @@ public final class DisconnectCause implements Parcelable {
/**
* Creates a new DisconnectCause.
+ *
* @param label The localized label to show to the user to explain the disconnect.
* @param code The code for the disconnect cause.
* @param description The localized description to show to the user to explain the disconnect.
diff --git a/telecomm/java/android/telecom/GatewayInfo.java b/telecomm/java/android/telecom/GatewayInfo.java
index 3efab0f..7105602 100644
--- a/telecomm/java/android/telecom/GatewayInfo.java
+++ b/telecomm/java/android/telecom/GatewayInfo.java
@@ -23,16 +23,18 @@ import android.os.Parcelable;
import android.text.TextUtils;
/**
- * When calls are made, they may contain gateway information for services which route phone calls
- * through their own service/numbers. The data consists of a number to call and the package name of
- * the service. This data is used in two ways:
+ * Encapsulated gateway address information for outgoing call. When calls are made, the system
+ * provides a facility to specify two addresses for the call: one to display as the address being
+ * dialed and a separate (gateway) address to actually dial. Telecom provides this information to
+ * {@link ConnectionService}s when placing the call as an instance of {@code GatewayInfo}.
+ * <p>
+ * The data consists of an address to call, an address to display and the package name of the
+ * service. This data is used in two ways:
* <ol>
- * <li> Call the appropriate routing number
- * <li> Display information about how the call is being routed to the user
+ * <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;
@@ -48,31 +50,39 @@ public class GatewayInfo implements Parcelable {
}
/**
- * Package name of the gateway provider service. used to place the call with.
+ * Package name of the gateway provider service that provided the gateway information.
+ * This can be used to identify the gateway address source and to load an appropriate icon when
+ * displaying gateway information in the in-call UI.
*/
public String getGatewayProviderPackageName() {
return mGatewayProviderPackageName;
}
/**
- * Gateway provider address to use when actually placing the call.
+ * Returns the gateway address to dial when placing the call.
*/
public Uri getGatewayAddress() {
return mGatewayAddress;
}
/**
- * The actual call address that the user is trying to connect to via the gateway.
+ * Returns the address that the user is trying to connect to via the gateway.
*/
public Uri getOriginalAddress() {
return mOriginalAddress;
}
+ /**
+ * Indicates whether this {@code GatewayInfo} instance contains any data. A returned value of
+ * false indicates that no gateway number is being used for the call.
+ */
public boolean isEmpty() {
return TextUtils.isEmpty(mGatewayProviderPackageName) || mGatewayAddress == null;
}
- /** Implement the Parcelable interface */
+ /**
+ * The Parcelable interface.
+ * */
public static final Parcelable.Creator<GatewayInfo> CREATOR =
new Parcelable.Creator<GatewayInfo> () {
diff --git a/telecomm/java/android/telecom/PhoneAccount.java b/telecomm/java/android/telecom/PhoneAccount.java
index 67b6328..3fc1d3d 100644
--- a/telecomm/java/android/telecom/PhoneAccount.java
+++ b/telecomm/java/android/telecom/PhoneAccount.java
@@ -16,10 +16,14 @@
package android.telecom;
-import android.annotation.SystemApi;
+import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources.NotFoundException;
+import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Parcel;
@@ -33,11 +37,15 @@ import java.util.List;
import java.util.MissingResourceException;
/**
- * Describes a distinct account, line of service or call placement method that the system
- * can use to place phone calls.
- * @hide
+ * 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}.
+ * <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}
+ * implementation Telecom will use to interact with the app.
*/
-@SystemApi
public class PhoneAccount implements Parcelable {
/**
@@ -59,7 +67,7 @@ public class PhoneAccount implements Parcelable {
* traditional SIM-based telephony calls. This account will be treated as a distinct method
* for placing calls alongside the traditional SIM-based telephony stack. This flag is
* distinct from {@link #CAPABILITY_CONNECTION_MANAGER} in that it is not allowed to manage
- * calls from or use the built-in telephony stack to place its calls.
+ * or place calls from the built-in telephony stack.
* <p>
* See {@link #getCapabilities}
* <p>
@@ -118,22 +126,32 @@ public class PhoneAccount implements Parcelable {
private final Uri mSubscriptionAddress;
private final int mCapabilities;
private final int mIconResId;
+ private final String mIconPackageName;
+ private final Bitmap mIconBitmap;
private final int mColor;
private final CharSequence mLabel;
private final CharSequence mShortDescription;
private final List<String> mSupportedUriSchemes;
+ /**
+ * Helper class for creating a {@link PhoneAccount}.
+ */
public static class Builder {
private PhoneAccountHandle mAccountHandle;
private Uri mAddress;
private Uri mSubscriptionAddress;
private int mCapabilities;
private int mIconResId;
+ private String mIconPackageName;
+ private Bitmap mIconBitmap;
private int mColor = NO_COLOR;
private CharSequence mLabel;
private CharSequence mShortDescription;
private List<String> mSupportedUriSchemes = new ArrayList<String>();
+ /**
+ * Creates a builder with the specified {@link PhoneAccountHandle} and label.
+ */
public Builder(PhoneAccountHandle accountHandle, CharSequence label) {
this.mAccountHandle = accountHandle;
this.mLabel = label;
@@ -151,37 +169,97 @@ public class PhoneAccount implements Parcelable {
mSubscriptionAddress = phoneAccount.getSubscriptionAddress();
mCapabilities = phoneAccount.getCapabilities();
mIconResId = phoneAccount.getIconResId();
+ mIconPackageName = phoneAccount.getIconPackageName();
+ mIconBitmap = phoneAccount.getIconBitmap();
mColor = phoneAccount.getColor();
mLabel = phoneAccount.getLabel();
mShortDescription = phoneAccount.getShortDescription();
mSupportedUriSchemes.addAll(phoneAccount.getSupportedUriSchemes());
}
+ /**
+ * Sets the address. See {@link PhoneAccount#getAddress}.
+ *
+ * @param value The address of the phone account.
+ * @return The builder.
+ */
public Builder setAddress(Uri value) {
this.mAddress = value;
return this;
}
+ /**
+ * Sets the subscription address. See {@link PhoneAccount#getSubscriptionAddress}.
+ *
+ * @param value The subscription address.
+ * @return The builder.
+ */
public Builder setSubscriptionAddress(Uri value) {
this.mSubscriptionAddress = value;
return this;
}
+ /**
+ * Sets the capabilities. See {@link PhoneAccount#getCapabilities}.
+ *
+ * @param value The capabilities to set.
+ * @return The builder.
+ */
public Builder setCapabilities(int value) {
this.mCapabilities = value;
return this;
}
+ /**
+ * Sets the icon resource ID. See {@link PhoneAccount#getIconResId}.
+ *
+ * @param value The resource ID of the icon.
+ * @return The builder.
+ */
public Builder setIconResId(int value) {
this.mIconResId = value;
return this;
}
+ /**
+ * Sets the icon package name. See {@link PhoneAccount#getIconPackageName}.
+ *
+ * @param value The name of the package from which to load the icon.
+ * @return The builder.
+ */
+ public Builder setIconPackageName(String value) {
+ this.mIconPackageName = value;
+ return this;
+ }
+
+ /**
+ * Sets the icon bitmap. See {@link PhoneAccount#getIconBitmap}.
+ *
+ * @param value The icon bitmap.
+ * @return The builder.
+ */
+ public Builder setIconBitmap(Bitmap value) {
+ this.mIconBitmap = value;
+ return this;
+ }
+
+ /**
+ * Sets the color. See {@link PhoneAccount#getColor}.
+ *
+ * @param value The resource ID of the icon.
+ * @return The builder.
+ */
public Builder setColor(int value) {
this.mColor = value;
return this;
}
+ /**
+ * Sets the short description. See {@link PhoneAccount#getShortDescription}.
+ *
+ * @param value The short description.
+ * @return The builder.
+ */
public Builder setShortDescription(CharSequence value) {
this.mShortDescription = value;
return this;
@@ -191,7 +269,7 @@ public class PhoneAccount implements Parcelable {
* Specifies an additional URI scheme supported by the {@link PhoneAccount}.
*
* @param uriScheme The URI scheme.
- * @return The Builder.
+ * @return The builder.
* @hide
*/
public Builder addSupportedUriScheme(String uriScheme) {
@@ -205,7 +283,7 @@ public class PhoneAccount implements Parcelable {
* Specifies the URI schemes supported by the {@link PhoneAccount}.
*
* @param uriSchemes The URI schemes.
- * @return The Builder.
+ * @return The builder.
*/
public Builder setSupportedUriSchemes(List<String> uriSchemes) {
mSupportedUriSchemes.clear();
@@ -235,6 +313,8 @@ public class PhoneAccount implements Parcelable {
mSubscriptionAddress,
mCapabilities,
mIconResId,
+ mIconPackageName,
+ mIconBitmap,
mColor,
mLabel,
mShortDescription,
@@ -248,6 +328,8 @@ public class PhoneAccount implements Parcelable {
Uri subscriptionAddress,
int capabilities,
int iconResId,
+ String iconPackageName,
+ Bitmap iconBitmap,
int color,
CharSequence label,
CharSequence shortDescription,
@@ -257,6 +339,8 @@ public class PhoneAccount implements Parcelable {
mSubscriptionAddress = subscriptionAddress;
mCapabilities = capabilities;
mIconResId = iconResId;
+ mIconPackageName = iconPackageName;
+ mIconBitmap = iconBitmap;
mColor = color;
mLabel = label;
mShortDescription = shortDescription;
@@ -302,6 +386,9 @@ public class PhoneAccount implements Parcelable {
* The raw callback number used for this {@code PhoneAccount}, as distinct from
* {@link #getAddress()}. For the majority of {@code PhoneAccount}s this should be registered
* as {@code null}. It is used by the system for SIM-based {@code PhoneAccount} registration
+ * where {@link android.telephony.TelephonyManager#setLine1NumberForDisplay(String, String)}
+ * has been used to alter the callback number.
+ * <p>
*
* @return The subscription number, suitable for display to the user.
*/
@@ -379,6 +466,12 @@ public class PhoneAccount implements Parcelable {
/**
* The icon resource ID for the icon of this {@code PhoneAccount}.
+ * <p>
+ * Creators of a {@code PhoneAccount} who possess the icon in static resources should prefer
+ * this method of indicating the icon rather than using {@link #getIconBitmap()}, since it
+ * leads to less resource usage.
+ * <p>
+ * Clients wishing to display a {@code PhoneAccount} should use {@link #getIcon(Context)}.
*
* @return A resource ID.
*/
@@ -387,6 +480,20 @@ public class PhoneAccount implements Parcelable {
}
/**
+ * The package name from which to load the icon of this {@code PhoneAccount}.
+ * <p>
+ * If this property is {@code null}, the resource {@link #getIconResId()} will be loaded from
+ * the package in the {@link ComponentName} of the {@link #getAccountHandle()}.
+ * <p>
+ * Clients wishing to display a {@code PhoneAccount} should use {@link #getIcon(Context)}.
+ *
+ * @return A package name.
+ */
+ public String getIconPackageName() {
+ return mIconPackageName;
+ }
+
+ /**
* A highlight color to use in displaying information about this {@code PhoneAccount}.
*
* @return A hexadecimal color value.
@@ -396,30 +503,51 @@ public class PhoneAccount implements Parcelable {
}
/**
- * An icon to represent this {@code PhoneAccount} in a user interface.
+ * A literal icon bitmap to represent this {@code PhoneAccount} in a user interface.
+ * <p>
+ * If this property is specified, it is to be considered the preferred icon. Otherwise, the
+ * resource specified by {@link #getIconResId()} should be used.
+ * <p>
+ * Clients wishing to display a {@code PhoneAccount} should use {@link #getIcon(Context)}.
*
- * @return An icon for this {@code PhoneAccount}.
+ * @return A bitmap.
*/
- public Drawable getIcon(Context context) {
- return getIcon(context, mIconResId);
+ public Bitmap getIconBitmap() {
+ return mIconBitmap;
}
- private Drawable getIcon(Context context, int resId) {
- Context packageContext;
- try {
- packageContext = context.createPackageContext(
- mAccountHandle.getComponentName().getPackageName(), 0);
- } catch (PackageManager.NameNotFoundException e) {
- Log.w(this, "Cannot find package %s", mAccountHandle.getComponentName().getPackageName());
- return null;
+ /**
+ * Builds and returns an icon {@code Drawable} to represent this {@code PhoneAccount} in a user
+ * interface. Uses the properties {@link #getIconResId()}, {@link #getIconPackageName()}, and
+ * {@link #getIconBitmap()} as necessary.
+ *
+ * @param context A {@code Context} to use for loading {@code Drawable}s.
+ *
+ * @return An icon for this {@code PhoneAccount}.
+ */
+ public Drawable getIcon(Context context) {
+ if (mIconBitmap != null) {
+ return new BitmapDrawable(context.getResources(), mIconBitmap);
}
- try {
- return packageContext.getDrawable(resId);
- } catch (NotFoundException|MissingResourceException e) {
- Log.e(this, e, "Cannot find icon %d in package %s",
- resId, mAccountHandle.getComponentName().getPackageName());
- return null;
+
+ if (mIconResId != 0) {
+ String packageName = mIconPackageName == null
+ ? mAccountHandle.getComponentName().getPackageName()
+ : mIconPackageName;
+
+ try {
+ Context packageContext = context.createPackageContext(packageName, 0);
+ try {
+ return packageContext.getDrawable(mIconResId);
+ } catch (NotFoundException | MissingResourceException e) {
+ Log.e(this, e, "Cannot find icon %d in package %s", mIconResId, packageName);
+ }
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.w(this, "Cannot find package %s", packageName);
+ }
}
+
+ return new ColorDrawable(Color.TRANSPARENT);
}
//
@@ -438,6 +566,8 @@ public class PhoneAccount implements Parcelable {
out.writeParcelable(mSubscriptionAddress, 0);
out.writeInt(mCapabilities);
out.writeInt(mIconResId);
+ out.writeString(mIconPackageName);
+ out.writeParcelable(mIconBitmap, 0);
out.writeInt(mColor);
out.writeCharSequence(mLabel);
out.writeCharSequence(mShortDescription);
@@ -465,6 +595,8 @@ public class PhoneAccount implements Parcelable {
mSubscriptionAddress = in.readParcelable(getClass().getClassLoader());
mCapabilities = in.readInt();
mIconResId = in.readInt();
+ mIconPackageName = in.readString();
+ mIconBitmap = in.readParcelable(getClass().getClassLoader());
mColor = in.readInt();
mLabel = in.readCharSequence();
mShortDescription = in.readCharSequence();
@@ -473,4 +605,19 @@ public class PhoneAccount implements Parcelable {
in.readList(supportedUriSchemes, classLoader);
mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes);
}
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder().append("[PhoneAccount: ")
+ .append(mAccountHandle)
+ .append(" Capabilities: ")
+ .append(mCapabilities)
+ .append(" Schemes: ");
+ for (String scheme : mSupportedUriSchemes) {
+ sb.append(scheme)
+ .append(" ");
+ }
+ sb.append("]");
+ return sb.toString();
+ }
}
diff --git a/telecomm/java/android/telecom/PhoneAccountHandle.java b/telecomm/java/android/telecom/PhoneAccountHandle.java
index 652befe5..bc4cc8c 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;
@@ -24,10 +23,17 @@ import android.os.Parcelable;
import java.util.Objects;
/**
- * The unique identifier for a {@link PhoneAccount}.
- * @hide
+ * 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>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}.
*/
-@SystemApi
public class PhoneAccountHandle implements Parcelable {
private ComponentName mComponentName;
private String mId;
@@ -74,9 +80,11 @@ public class PhoneAccountHandle implements Parcelable {
@Override
public String toString() {
+ // Note: Log.pii called for mId as it can contain personally identifying phone account
+ // information such as SIP account IDs.
return new StringBuilder().append(mComponentName)
.append(", ")
- .append(mId)
+ .append(Log.pii(mId))
.toString();
}
diff --git a/telecomm/java/android/telecom/PhoneCapabilities.java b/telecomm/java/android/telecom/PhoneCapabilities.java
index de2abcb..3d3c6bd 100644
--- a/telecomm/java/android/telecom/PhoneCapabilities.java
+++ b/telecomm/java/android/telecom/PhoneCapabilities.java
@@ -16,14 +16,10 @@
package android.telecom;
-import android.annotation.SystemApi;
-
/**
- * Defines capabilities a phone call can support, such as conference calling and video telephony.
- * Also defines properties of a phone call, such as whether it is using VoLTE technology.
- * @hide
+ * Defines capabilities for {@link Connection}s and {@link Conference}s such as hold, swap, and
+ * merge.
*/
-@SystemApi
public final class PhoneCapabilities {
/** Call can currently be put on hold or unheld. */
public static final int HOLD = 0x00000001;
@@ -32,15 +28,22 @@ public final class PhoneCapabilities {
public static final int SUPPORT_HOLD = 0x00000002;
/**
- * Calls within a conference can be merged. Some connection services create a conference call
- * only after two calls have been merged. However, a conference call can also be added the
- * moment there are more than one call. CDMA calls are implemented in this way because the call
- * actions are more limited when more than one call exists. This flag allows merge to be exposed
- * as a capability on the conference call instead of individual calls.
+ * Calls within a conference can be merged. A {@link ConnectionService} has the option to
+ * add a {@link Conference} call before the child {@link Connection}s are merged. This is how
+ * CDMA-based {@link Connection}s are implemented. For these unmerged {@link Conference}s, this
+ * capability allows a merge button to be shown while the conference call is in the foreground
+ * of the in-call UI.
+ * <p>
+ * This is only intended for use by a {@link Conference}.
*/
public static final int MERGE_CONFERENCE = 0x00000004;
- /** Calls withing a conference can be swapped between foreground and background. */
+ /**
+ * Calls within a conference can be swapped between foreground and background.
+ * See {@link #MERGE_CONFERENCE} for additional information.
+ * <p>
+ * This is only intended for use by a {@link Conference}.
+ */
public static final int SWAP_CONFERENCE = 0x00000008;
/** Call currently supports adding another call to this one. */
@@ -53,8 +56,8 @@ public final class PhoneCapabilities {
public static final int MUTE = 0x00000040;
/**
- * Call supports conference call management. This capability only applies to conference calls
- * which can have other calls as children.
+ * Call supports conference call management. This capability only applies to {@link Conference}
+ * calls which can have {@link Connection}s as children.
*/
public static final int MANAGE_CONFERENCE = 0x00000080;
@@ -96,43 +99,65 @@ public final class PhoneCapabilities {
| ADD_CALL | RESPOND_VIA_TEXT | MUTE | MANAGE_CONFERENCE | SEPARATE_FROM_CONFERENCE
| DISCONNECT_FROM_CONFERENCE;
+ /**
+ * Whether this set of capabilities supports the specified capability.
+ * @param capabilities The set 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;
+ }
+
+ /**
+ * Removes the specified capability from the set of capabilities and returns the new set.
+ * @param capabilities The set of capabilities.
+ * @param capability The capability to remove from the set.
+ * @return The set of capabilities, with the capability removed.
+ * @hide
+ */
+ public static int remove(int capabilities, int capability) {
+ return capabilities & ~capability;
+ }
+
public static String toString(int capabilities) {
StringBuilder builder = new StringBuilder();
builder.append("[Capabilities:");
- if ((capabilities & HOLD) != 0) {
+ if (can(capabilities, HOLD)) {
builder.append(" HOLD");
}
- if ((capabilities & SUPPORT_HOLD) != 0) {
+ if (can(capabilities, SUPPORT_HOLD)) {
builder.append(" SUPPORT_HOLD");
}
- if ((capabilities & MERGE_CONFERENCE) != 0) {
+ if (can(capabilities, MERGE_CONFERENCE)) {
builder.append(" MERGE_CONFERENCE");
}
- if ((capabilities & SWAP_CONFERENCE) != 0) {
+ if (can(capabilities, SWAP_CONFERENCE)) {
builder.append(" SWAP_CONFERENCE");
}
- if ((capabilities & ADD_CALL) != 0) {
+ if (can(capabilities, ADD_CALL)) {
builder.append(" ADD_CALL");
}
- if ((capabilities & RESPOND_VIA_TEXT) != 0) {
+ if (can(capabilities, RESPOND_VIA_TEXT)) {
builder.append(" RESPOND_VIA_TEXT");
}
- if ((capabilities & MUTE) != 0) {
+ if (can(capabilities, MUTE)) {
builder.append(" MUTE");
}
- if ((capabilities & MANAGE_CONFERENCE) != 0) {
+ if (can(capabilities, MANAGE_CONFERENCE)) {
builder.append(" MANAGE_CONFERENCE");
}
- if ((capabilities & SUPPORTS_VT_LOCAL) != 0) {
+ if (can(capabilities, SUPPORTS_VT_LOCAL)) {
builder.append(" SUPPORTS_VT_LOCAL");
}
- if ((capabilities & SUPPORTS_VT_REMOTE) != 0) {
+ if (can(capabilities, SUPPORTS_VT_REMOTE)) {
builder.append(" SUPPORTS_VT_REMOTE");
}
- if ((capabilities & VoLTE) != 0) {
+ if (can(capabilities, VoLTE)) {
builder.append(" VoLTE");
}
- if ((capabilities & VoWIFI) != 0) {
+ if (can(capabilities, VoWIFI)) {
builder.append(" VoWIFI");
}
builder.append("]");
diff --git a/telecomm/java/android/telecom/RemoteConference.java b/telecomm/java/android/telecom/RemoteConference.java
index b548274..eba7580 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 {
diff --git a/telecomm/java/android/telecom/RemoteConnection.java b/telecomm/java/android/telecom/RemoteConnection.java
index 4a89692..816e2bf 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 {
@@ -410,6 +407,29 @@ public final class RemoteConnection {
}
/**
+ * @hide
+ */
+ RemoteConnection(String callId, IConnectionService connectionService,
+ ParcelableConnection connection) {
+ mConnectionId = callId;
+ mConnectionService = connectionService;
+ mConnected = true;
+ mState = connection.getState();
+ mDisconnectCause = connection.getDisconnectCause();
+ mRingbackRequested = connection.isRingbackRequested();
+ mCallCapabilities = connection.getCapabilities();
+ mVideoState = connection.getVideoState();
+ mVideoProvider = new RemoteConnection.VideoProvider(connection.getVideoProvider());
+ mIsVoipAudioMode = connection.getIsVoipAudioMode();
+ mStatusHints = connection.getStatusHints();
+ mAddress = connection.getHandle();
+ mAddressPresentation = connection.getHandlePresentation();
+ mCallerDisplayName = connection.getCallerDisplayName();
+ mCallerDisplayNamePresentation = connection.getCallerDisplayNamePresentation();
+ mConference = null;
+ }
+
+ /**
* Create a RemoteConnection which is used for failed connections. Note that using it for any
* "real" purpose will almost certainly fail. Callers should note the failure and act
* accordingly (moving on to another RemoteConnection, for example)
@@ -418,7 +438,7 @@ public final class RemoteConnection {
* @hide
*/
RemoteConnection(DisconnectCause disconnectCause) {
- this("NULL", null, null);
+ mConnectionId = "NULL";
mConnected = false;
mState = Connection.STATE_DISCONNECTED;
mDisconnectCause = disconnectCause;
diff --git a/telecomm/java/android/telecom/RemoteConnectionService.java b/telecomm/java/android/telecom/RemoteConnectionService.java
index af4ee22..4bb78c0 100644
--- a/telecomm/java/android/telecom/RemoteConnectionService.java
+++ b/telecomm/java/android/telecom/RemoteConnectionService.java
@@ -41,8 +41,9 @@ import java.util.UUID;
*/
final class RemoteConnectionService {
+ // Note: Casting null to avoid ambiguous constructor reference.
private static final RemoteConnection NULL_CONNECTION =
- new RemoteConnection("NULL", null, null);
+ new RemoteConnection("NULL", null, (ConnectionRequest) null);
private static final RemoteConference NULL_CONFERENCE =
new RemoteConference("NULL", null);
@@ -286,6 +287,15 @@ final class RemoteConnectionService {
.setConferenceableConnections(conferenceable);
}
}
+
+ @Override
+ public void addExistingConnection(String callId, ParcelableConnection connection) {
+ // TODO: add contents of this method
+ RemoteConnection remoteConnction = new RemoteConnection(callId,
+ mOutgoingConnectionServiceRpc, connection);
+
+ mOurConnectionServiceImpl.addRemoteExistingConnection(remoteConnction);
+ }
};
private final ConnectionServiceAdapterServant mServant =
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 e87615e..4eac5ac 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -21,6 +21,7 @@ import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.telephony.TelephonyManager;
+import android.text.TextUtils;
import android.util.Log;
import com.android.internal.telecom.ITelecomService;
@@ -30,8 +31,17 @@ import java.util.Collections;
import java.util.List;
/**
- * Provides access to Telecom-related functionality.
- * TODO: Move this all into PhoneManager.
+ * Provides access to information about active calls and registration/call-management functionality.
+ * Apps can use methods in this class to determine the current call state. Apps can also register new
+ * {@link PhoneAccount}s and get a listing of existing {@link PhoneAccount}s.
+ * <p>
+ * Apps do not instantiate this class directly; instead, they retrieve a reference to an instance
+ * through {@link Context#getSystemService Context.getSystemService(Context.TELECOM_SERVICE)}.
+ * <p>
+ * Note that access to some telecom information is permission-protected. Your app cannot access the
+ * protected information or gain access to protected functionality unless it has the appropriate
+ * permissions declared in its manifest file. Where permissions apply, they are noted in the method
+ * descriptions.
*/
public class TelecomManager {
@@ -60,7 +70,6 @@ public class TelecomManager {
/**
* The {@link android.content.Intent} action used to configure a
* {@link android.telecom.ConnectionService}.
- * @hide
*/
public static final String ACTION_CONNECTION_SERVICE_CONFIGURE =
"android.telecom.action.CONNECTION_SERVICE_CONFIGURE";
@@ -74,7 +83,6 @@ public class TelecomManager {
/**
* The {@link android.content.Intent} action used to show the settings page used to configure
* {@link PhoneAccount} preferences.
- * @hide
*/
public static final String ACTION_CHANGE_PHONE_ACCOUNTS =
"android.telecom.action.CHANGE_PHONE_ACCOUNTS";
@@ -105,7 +113,6 @@ public class TelecomManager {
* {@link PhoneAccountHandle} to use when making the call.
* <p class="note">
* Retrieve with {@link android.content.Intent#getParcelableExtra(String)}.
- * @hide
*/
public static final String EXTRA_PHONE_ACCOUNT_HANDLE =
"android.telecom.extra.PHONE_ACCOUNT_HANDLE";
@@ -154,7 +161,6 @@ public class TelecomManager {
/**
* Optional extra for {@link android.telephony.TelephonyManager#ACTION_PHONE_STATE_CHANGED}
* containing the component name of the associated connection service.
- * @hide
*/
public static final String EXTRA_CONNECTION_SERVICE =
"android.telecom.extra.CONNECTION_SERVICE";
@@ -190,7 +196,6 @@ 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
*/
public static final String EXTRA_CALL_BACK_NUMBER = "android.telecom.extra.CALL_BACK_NUMBER";
@@ -437,7 +442,6 @@ public class TelecomManager {
* {@code PhoneAccount}.
*
* @return The phone account handle of the current connection manager.
- * @hide
*/
public PhoneAccountHandle getConnectionManager() {
return getSimCallManager();
@@ -495,7 +499,6 @@ public class TelecomManager {
*
* @return {@code true} if the device has more than one account registered and {@code false}
* otherwise.
- * @hide
*/
public boolean hasMultipleCallCapableAccounts() {
return getCallCapablePhoneAccounts().size() > 1;
@@ -505,7 +508,6 @@ public class TelecomManager {
* Returns a list of all {@link PhoneAccount}s registered for the calling package.
*
* @return A list of {@code PhoneAccountHandle} objects.
- * @hide
*/
public List<PhoneAccountHandle> getPhoneAccountsForPackage() {
try {
@@ -524,7 +526,6 @@ public class TelecomManager {
*
* @param account The {@link PhoneAccountHandle}.
* @return The {@link PhoneAccount} object.
- * @hide
*/
public PhoneAccount getPhoneAccount(PhoneAccountHandle account) {
try {
@@ -592,12 +593,19 @@ public class TelecomManager {
}
/**
- * Register a {@link PhoneAccount} for use by the system.
+ * Register a {@link PhoneAccount} for use by the system. When registering
+ * {@link PhoneAccount}s, existing registrations will be overwritten if the
+ * {@link PhoneAccountHandle} matches that of a {@link PhoneAccount} which is already
+ * registered. Once registered, the {@link PhoneAccount} is listed to the user as an option
+ * when placing calls. The user may still need to enable the {@link PhoneAccount} within
+ * the phone app settings before the account is usable.
+ * <p>
+ * A {@link SecurityException} will be thrown if an app tries to register a
+ * {@link PhoneAccountHandle} where the package name specified within
+ * {@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()) {
@@ -612,9 +620,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()) {
@@ -627,9 +633,7 @@ public class TelecomManager {
/**
* Remove all Accounts that belong to the calling package from the system.
- * @hide
*/
- @SystemApi
public void clearAccounts() {
try {
if (isServiceConnected()) {
@@ -641,6 +645,20 @@ public class TelecomManager {
}
/**
+ * Remove all Accounts that belong to the specified package from the system.
+ * @hide
+ */
+ public void clearAccountsForPackage(String packageName) {
+ try {
+ if (isServiceConnected() && !TextUtils.isEmpty(packageName)) {
+ getTelecomService().clearAccounts(packageName);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelecomService#clearAccountsForPackage()", e);
+ }
+ }
+
+ /**
* @hide
*/
@SystemApi
@@ -683,7 +701,6 @@ public class TelecomManager {
* Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE}
* </p>
*/
- @SystemApi
public boolean isInCall() {
try {
if (isServiceConnected()) {
@@ -701,6 +718,11 @@ public class TelecomManager {
* {@link TelephonyManager#CALL_STATE_RINGING}
* {@link TelephonyManager#CALL_STATE_OFFHOOK}
* {@link TelephonyManager#CALL_STATE_IDLE}
+ *
+ * Note that this API does not require the
+ * {@link android.Manifest.permission#READ_PHONE_STATE} permission. This is intentional, to
+ * preserve the behavior of {@link TelephonyManager#getCallState()}, which also did not require
+ * the permission.
* @hide
*/
@SystemApi
@@ -834,9 +856,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()) {
@@ -875,6 +895,7 @@ public class TelecomManager {
* Processes the specified dial string as an MMI code.
* MMI codes are any sequence of characters entered into the dialpad that contain a "*" or "#".
* Some of these sequences launch special behavior through handled by Telephony.
+ * This method uses the default subscription.
* <p>
* Requires that the method-caller be set as the system dialer app.
* </p>
@@ -895,6 +916,31 @@ public class TelecomManager {
}
/**
+ * Processes the specified dial string as an MMI code.
+ * MMI codes are any sequence of characters entered into the dialpad that contain a "*" or "#".
+ * Some of these sequences launch special behavior through handled by Telephony.
+ * <p>
+ * Requires that the method-caller be set as the system dialer app.
+ * </p>
+ *
+ * @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.
+ *
+ */
+ public boolean handleMmi(PhoneAccountHandle accountHandle, String dialString) {
+ ITelecomService service = getTelecomService();
+ if (service != null) {
+ try {
+ return service.handlePinMmiForPhoneAccount(accountHandle, dialString);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelecomService#handlePinMmi", e);
+ }
+ }
+ return false;
+ }
+
+ /**
* Removes the missed-call notification if one is present.
* <p>
* Requires that the method-caller be set as the system dialer app.