summaryrefslogtreecommitdiffstats
path: root/telecomm
diff options
context:
space:
mode:
authorTyler Gunn <tgunn@google.com>2014-09-03 09:09:12 -0700
committerTyler Gunn <tgunn@google.com>2014-09-03 09:09:12 -0700
commitf5b29dc8cb7ec19232c6499ac41e5cd267ebd6f1 (patch)
tree46a03c492cf7126ccc70b3e6a4e852679641b126 /telecomm
parente2c88d39b2c5b33d55c42230db7899202625a96a (diff)
downloadframeworks_base-f5b29dc8cb7ec19232c6499ac41e5cd267ebd6f1.zip
frameworks_base-f5b29dc8cb7ec19232c6499ac41e5cd267ebd6f1.tar.gz
frameworks_base-f5b29dc8cb7ec19232c6499ac41e5cd267ebd6f1.tar.bz2
Add supported URI scheme to PhoneAccounts. (1/4)
Modified PhoneAccount and builder to support specifying supported URI schemes. Bug: 17140110 Change-Id: Ieef33bb1a6719de6f3897ed10ec38843808a7f85
Diffstat (limited to 'telecomm')
-rw-r--r--telecomm/java/android/telecomm/PhoneAccount.java99
-rw-r--r--telecomm/java/android/telecomm/TelecommManager.java33
-rw-r--r--telecomm/java/com/android/internal/telecomm/ITelecommService.aidl9
3 files changed, 133 insertions, 8 deletions
diff --git a/telecomm/java/android/telecomm/PhoneAccount.java b/telecomm/java/android/telecomm/PhoneAccount.java
index 5b46409..1d61a6e 100644
--- a/telecomm/java/android/telecomm/PhoneAccount.java
+++ b/telecomm/java/android/telecomm/PhoneAccount.java
@@ -23,7 +23,12 @@ import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
+import android.text.TextUtils;
+import java.lang.String;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import java.util.MissingResourceException;
/**
@@ -77,6 +82,21 @@ public class PhoneAccount implements Parcelable {
*/
public static final int CAPABILITY_VIDEO_CALLING = 0x8;
+ /**
+ * URI scheme for telephone number URIs.
+ */
+ public static final String SCHEME_TEL = "tel";
+
+ /**
+ * URI scheme for voicemail URIs.
+ */
+ public static final String SCHEME_VOICEMAIL = "voicemail";
+
+ /**
+ * URI scheme for SIP URIs.
+ */
+ public static final String SCHEME_SIP = "sip";
+
private final PhoneAccountHandle mAccountHandle;
private final Uri mHandle;
private final String mSubscriptionNumber;
@@ -84,6 +104,7 @@ public class PhoneAccount implements Parcelable {
private final int mIconResId;
private final CharSequence mLabel;
private final CharSequence mShortDescription;
+ private final List<String> mSupportedUriSchemes;
public static class Builder {
private PhoneAccountHandle mAccountHandle;
@@ -93,6 +114,7 @@ public class PhoneAccount implements Parcelable {
private int mIconResId;
private CharSequence mLabel;
private CharSequence mShortDescription;
+ private List<String> mSupportedUriSchemes = new ArrayList<String>();
public Builder() {}
@@ -131,7 +153,40 @@ public class PhoneAccount implements Parcelable {
return this;
}
+ /**
+ * Specifies an additional URI scheme supported by the {@link PhoneAccount}.
+ *
+ * @param uriScheme The URI scheme.
+ * @return The Builder.
+ */
+ public Builder withSupportedUriScheme(String uriScheme) {
+ if (!TextUtils.isEmpty(uriScheme) && !mSupportedUriSchemes.contains(uriScheme)) {
+ this.mSupportedUriSchemes.add(uriScheme);
+ }
+ return this;
+ }
+
+ /**
+ * Specifies additional URI schemes supported by the {@link PhoneAccount}.
+ *
+ * @param uriSchemes The URI schemes.
+ * @return The Builder.
+ */
+ public Builder withSupportedUriSchemes(List<String> uriSchemes) {
+ if (uriSchemes != null && !uriSchemes.isEmpty()) {
+ for (String uriScheme : uriSchemes) {
+ withSupportedUriScheme(uriScheme);
+ }
+ }
+ return this;
+ }
+
public PhoneAccount build() {
+ // If no supported URI schemes were defined, assume "tel" is supported.
+ if (mSupportedUriSchemes.isEmpty()) {
+ withSupportedUriScheme(SCHEME_TEL);
+ }
+
return new PhoneAccount(
mAccountHandle,
mHandle,
@@ -139,7 +194,8 @@ public class PhoneAccount implements Parcelable {
mCapabilities,
mIconResId,
mLabel,
- mShortDescription);
+ mShortDescription,
+ mSupportedUriSchemes);
}
}
@@ -150,7 +206,8 @@ public class PhoneAccount implements Parcelable {
int capabilities,
int iconResId,
CharSequence label,
- CharSequence shortDescription) {
+ CharSequence shortDescription,
+ List<String> supportedUriSchemes) {
mAccountHandle = account;
mHandle = handle;
mSubscriptionNumber = subscriptionNumber;
@@ -158,6 +215,7 @@ public class PhoneAccount implements Parcelable {
mIconResId = iconResId;
mLabel = label;
mShortDescription = shortDescription;
+ mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes);
}
public static Builder builder() { return new Builder(); }
@@ -228,6 +286,36 @@ public class PhoneAccount implements Parcelable {
}
/**
+ * The URI schemes supported by this {@code PhoneAccount}.
+ *
+ * @return The URI schemes.
+ */
+ public List<String> getSupportedUriSchemes() {
+ return mSupportedUriSchemes;
+ }
+
+ /**
+ * Determines if the {@link PhoneAccount} supports calls to/from handles with a specified URI
+ * scheme.
+ *
+ * @param uriScheme The URI scheme to check.
+ * @return {@code True} if the {@code PhoneAccount} supports calls to/from handles with the
+ * specified URI scheme.
+ */
+ public boolean supportsUriScheme(String uriScheme) {
+ if (mSupportedUriSchemes == null || uriScheme == null) {
+ return false;
+ }
+
+ for (String scheme : mSupportedUriSchemes) {
+ if (scheme != null && scheme.equals(uriScheme)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
* The icon resource ID for the icon of this {@code PhoneAccount}.
*
* @return A resource ID.
@@ -281,6 +369,7 @@ public class PhoneAccount implements Parcelable {
out.writeInt(mIconResId);
out.writeCharSequence(mLabel);
out.writeCharSequence(mShortDescription);
+ out.writeList(mSupportedUriSchemes);
}
public static final Creator<PhoneAccount> CREATOR
@@ -297,6 +386,8 @@ public class PhoneAccount implements Parcelable {
};
private PhoneAccount(Parcel in) {
+ ClassLoader classLoader = PhoneAccount.class.getClassLoader();
+
mAccountHandle = in.readParcelable(getClass().getClassLoader());
mHandle = in.readParcelable(getClass().getClassLoader());
mSubscriptionNumber = in.readString();
@@ -304,5 +395,9 @@ public class PhoneAccount implements Parcelable {
mIconResId = in.readInt();
mLabel = in.readCharSequence();
mShortDescription = in.readCharSequence();
+
+ List<String> supportedUriSchemes = new ArrayList<>();
+ in.readList(supportedUriSchemes, classLoader);
+ mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes);
}
}
diff --git a/telecomm/java/android/telecomm/TelecommManager.java b/telecomm/java/android/telecomm/TelecommManager.java
index 2243288..071b719 100644
--- a/telecomm/java/android/telecomm/TelecommManager.java
+++ b/telecomm/java/android/telecomm/TelecommManager.java
@@ -258,8 +258,8 @@ public class TelecommManager {
/**
* Return the {@link PhoneAccount} which is the user-chosen default for making outgoing phone
- * calls. This {@code PhoneAccount} will always be a member of the list which is returned from
- * calling {@link #getEnabledPhoneAccounts()}.
+ * calls with a specified URI scheme. This {@code PhoneAccount} will always be a member of the
+ * list which is returned from calling {@link #getEnabledPhoneAccounts()}.
* <p>
* Apps must be prepared for this method to return {@code null}, indicating that there currently
* exists no user-chosen default {@code PhoneAccount}. In this case, apps wishing to initiate a
@@ -272,11 +272,13 @@ public class TelecommManager {
* {@code Intent} with no {@link TelecommManager#EXTRA_PHONE_ACCOUNT_HANDLE} is valid, and
* subsequent steps in the phone call flow are responsible for presenting the user with an
* affordance, if necessary, to choose a {@code PhoneAccount}.
+ *
+ * @param uriScheme The URI scheme.
*/
- public PhoneAccountHandle getDefaultOutgoingPhoneAccount() {
+ public PhoneAccountHandle getDefaultOutgoingPhoneAccount(String uriScheme) {
try {
if (isServiceConnected()) {
- return getTelecommService().getDefaultOutgoingPhoneAccount();
+ return getTelecommService().getDefaultOutgoingPhoneAccount(uriScheme);
}
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelecommService#getDefaultOutgoingPhoneAccount", e);
@@ -366,6 +368,29 @@ public class TelecommManager {
}
/**
+ * Returns a list of {@link PhoneAccountHandle}s which can be used to make and receive phone
+ * calls which support the specified URI scheme.
+ * <P>
+ * For example, invoking with {@code "tel"} will find all {@link PhoneAccountHandle}s which
+ * support telephone calls (e.g. URIs such as {@code tel:555-555-1212}). Invoking with
+ * {@code "sip"} will find all {@link PhoneAccountHandle}s which support SIP calls (e.g. URIs
+ * such as {@code sip:example@sipexample.com}).
+ *
+ * @param uriScheme The URI scheme.
+ * @return A list of {@code PhoneAccountHandle} objects supporting the URI scheme.
+ */
+ public List<PhoneAccountHandle> getPhoneAccountsSupportingScheme(String uriScheme) {
+ try {
+ if (isServiceConnected()) {
+ return getTelecommService().getPhoneAccountsSupportingScheme(uriScheme);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelecommService#getPhoneAccountsSupportingScheme", e);
+ }
+ return new ArrayList<>();
+ }
+
+ /**
* Determine whether the device has more than one account registered and enabled.
*
* @return {@code true} if the device has more than one account registered and enabled and
diff --git a/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl b/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl
index 131307a..a6ab3ac 100644
--- a/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl
+++ b/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl
@@ -37,7 +37,7 @@ interface ITelecommService {
/**
* @see TelecommServiceImpl#getDefaultOutgoingPhoneAccount
*/
- PhoneAccountHandle getDefaultOutgoingPhoneAccount();
+ PhoneAccountHandle getDefaultOutgoingPhoneAccount(in String uriScheme);
/**
* @see TelecommServiceImpl#setDefaultOutgoingPhoneAccount
@@ -50,7 +50,12 @@ interface ITelecommService {
List<PhoneAccountHandle> getOutgoingPhoneAccounts();
/**
- * @see TelecommServiceImpl#getPhoneAccount
+ * @see TelecommManager#getPhoneAccountsSupportingScheme
+ */
+ List<PhoneAccountHandle> getPhoneAccountsSupportingScheme(in String uriScheme);
+
+ /**
+ * @see TelecommManager#getPhoneAccount
*/
PhoneAccount getPhoneAccount(in PhoneAccountHandle account);