summaryrefslogtreecommitdiffstats
path: root/telecomm/java/android/telecom
diff options
context:
space:
mode:
Diffstat (limited to 'telecomm/java/android/telecom')
-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.java15
-rw-r--r--telecomm/java/android/telecom/PhoneAccount.java132
-rw-r--r--telecomm/java/android/telecom/TelecomManager.java20
5 files changed, 323 insertions, 24 deletions
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 2932721..9bdbba8 100644
--- a/telecomm/java/android/telecom/Connection.java
+++ b/telecomm/java/android/telecom/Connection.java
@@ -82,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 */
@@ -1117,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/PhoneAccount.java b/telecomm/java/android/telecom/PhoneAccount.java
index b9bae8e..3fc1d3d 100644
--- a/telecomm/java/android/telecom/PhoneAccount.java
+++ b/telecomm/java/android/telecom/PhoneAccount.java
@@ -16,9 +16,14 @@
package android.telecom;
+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;
@@ -121,6 +126,8 @@ 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;
@@ -135,6 +142,8 @@ public class PhoneAccount implements Parcelable {
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;
@@ -160,6 +169,8 @@ 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();
@@ -210,6 +221,34 @@ public class PhoneAccount implements Parcelable {
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;
@@ -274,6 +313,8 @@ public class PhoneAccount implements Parcelable {
mSubscriptionAddress,
mCapabilities,
mIconResId,
+ mIconPackageName,
+ mIconBitmap,
mColor,
mLabel,
mShortDescription,
@@ -287,6 +328,8 @@ public class PhoneAccount implements Parcelable {
Uri subscriptionAddress,
int capabilities,
int iconResId,
+ String iconPackageName,
+ Bitmap iconBitmap,
int color,
CharSequence label,
CharSequence shortDescription,
@@ -296,6 +339,8 @@ public class PhoneAccount implements Parcelable {
mSubscriptionAddress = subscriptionAddress;
mCapabilities = capabilities;
mIconResId = iconResId;
+ mIconPackageName = iconPackageName;
+ mIconBitmap = iconBitmap;
mColor = color;
mLabel = label;
mShortDescription = shortDescription;
@@ -420,8 +465,13 @@ public class PhoneAccount implements Parcelable {
}
/**
- * The icon resource ID for the icon of this {@code PhoneAccount}. Telecom will search for the
- * icon using the package name specified in the {@link PhoneAccountHandle}.
+ * 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.
*/
@@ -430,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.
@@ -439,35 +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) {
- if (resId == 0) {
- 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);
}
- 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;
- }
- 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);
}
//
@@ -486,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);
@@ -513,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();
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index 2652b45..bc51a70 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;
@@ -625,6 +626,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
@@ -684,6 +699,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