Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 65bd3eaa authored by Tyler Gunn's avatar Tyler Gunn Committed by Android (Google) Code Review
Browse files

Merge "Add supported URI scheme to PhoneAccounts. (1/4)" into lmp-dev

parents 897b59e3 f5b29dc8
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -28327,10 +28327,15 @@ package android.telecomm {
    method public java.lang.CharSequence getLabel();
    method public java.lang.CharSequence getShortDescription();
    method public java.lang.String getSubscriptionNumber();
    method public java.util.List<java.lang.String> getSupportedUriSchemes();
    method public boolean supportsUriScheme(java.lang.String);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final int CAPABILITY_CONNECTION_MANAGER = 1; // 0x1
    field public static final int CAPABILITY_SIM_SUBSCRIPTION = 4; // 0x4
    field public static final android.os.Parcelable.Creator CREATOR;
    field public static final java.lang.String SCHEME_SIP = "sip";
    field public static final java.lang.String SCHEME_TEL = "tel";
    field public static final java.lang.String SCHEME_VOICEMAIL = "voicemail";
  }
  public static class PhoneAccount.Builder {
@@ -28343,6 +28348,8 @@ package android.telecomm {
    method public android.telecomm.PhoneAccount.Builder withLabel(java.lang.CharSequence);
    method public android.telecomm.PhoneAccount.Builder withShortDescription(java.lang.CharSequence);
    method public android.telecomm.PhoneAccount.Builder withSubscriptionNumber(java.lang.String);
    method public android.telecomm.PhoneAccount.Builder withSupportedUriScheme(java.lang.String);
    method public android.telecomm.PhoneAccount.Builder withSupportedUriSchemes(java.util.List<java.lang.String>);
  }
  public class PhoneAccountHandle implements android.os.Parcelable {
@@ -28471,9 +28478,10 @@ package android.telecomm {
    method public void addNewIncomingCall(android.telecomm.PhoneAccountHandle, android.os.Bundle);
    method public void cancelMissedCallsNotification();
    method public void clearAccounts(java.lang.String);
    method public android.telecomm.PhoneAccountHandle getDefaultOutgoingPhoneAccount();
    method public android.telecomm.PhoneAccountHandle getDefaultOutgoingPhoneAccount(java.lang.String);
    method public java.util.List<android.telecomm.PhoneAccountHandle> getEnabledPhoneAccounts();
    method public android.telecomm.PhoneAccount getPhoneAccount(android.telecomm.PhoneAccountHandle);
    method public java.util.List<android.telecomm.PhoneAccountHandle> getPhoneAccountsSupportingScheme(java.lang.String);
    method public boolean handleMmi(java.lang.String);
    method public boolean hasMultipleEnabledAccounts();
    method public boolean isInCall();
+97 −2
Original line number Diff line number Diff line
@@ -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(); }
@@ -227,6 +285,36 @@ public class PhoneAccount implements Parcelable {
        return mShortDescription;
    }

    /**
     * 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}.
     *
@@ -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);
    }
}
+29 −4
Original line number Diff line number Diff line
@@ -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);
@@ -365,6 +367,29 @@ public class TelecommManager {
        return new ArrayList<>();
    }

    /**
     * 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.
     *
+7 −2
Original line number Diff line number Diff line
@@ -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);