summaryrefslogtreecommitdiffstats
path: root/telecomm
diff options
context:
space:
mode:
authorIhab Awad <ihab@google.com>2014-07-17 11:21:19 -0700
committerIhab Awad <ihab@google.com>2014-07-18 10:02:25 -0700
commit94cf4bff1345f9f7ec981d0bf7f8988f3d93c7a8 (patch)
tree27956c95c1f0c65e971853bac85d88db42d2d09e /telecomm
parent010150a1361d0a161cc40c8c1ca52a3ea30ac12e (diff)
downloadframeworks_base-94cf4bff1345f9f7ec981d0bf7f8988f3d93c7a8.zip
frameworks_base-94cf4bff1345f9f7ec981d0bf7f8988f3d93c7a8.tar.gz
frameworks_base-94cf4bff1345f9f7ec981d0bf7f8988f3d93c7a8.tar.bz2
Wire up multi-SIM experience (1/4)
Change-Id: Ib63843267f06b329a675e7ea86167b2cbb554f1b
Diffstat (limited to 'telecomm')
-rw-r--r--telecomm/java/android/telecomm/PhoneAccount.java87
-rw-r--r--telecomm/java/android/telecomm/PhoneAccountMetadata.java79
-rw-r--r--telecomm/java/android/telecomm/RemoteConnectionService.java4
-rw-r--r--telecomm/java/android/telecomm/TelecommManager.java35
-rw-r--r--telecomm/java/com/android/internal/telecomm/ITelecommService.aidl7
5 files changed, 127 insertions, 85 deletions
diff --git a/telecomm/java/android/telecomm/PhoneAccount.java b/telecomm/java/android/telecomm/PhoneAccount.java
index b246d92..bb335c3 100644
--- a/telecomm/java/android/telecomm/PhoneAccount.java
+++ b/telecomm/java/android/telecomm/PhoneAccount.java
@@ -16,8 +16,10 @@
package android.telecomm;
+import org.json.JSONException;
+import org.json.JSONObject;
+
import android.content.ComponentName;
-import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
@@ -26,55 +28,27 @@ import java.util.Objects;
/**
* Represents a distinct account, line of service or call placement method that
* the system can use to place phone calls.
+ *
+ * TODO: Per feedback from API Council, rename to "PhoneAccountHandle". See also comment on class
+ * PhoneAccountMetadata.
*/
public class PhoneAccount implements Parcelable {
-
- /**
- * Flag indicating that this {@code PhoneAccount} can act as a call manager for traditional
- * SIM-based telephony calls. The {@link ConnectionService} associated with this phone-account
- * will be allowed to manage SIM-based phone calls including using its own proprietary
- * phone-call implementation (like VoIP calling) to make calls instead of the telephony stack.
- * When a user opts to place a call using the SIM-based telephony stack, the connection-service
- * associated with this phone-account will be attempted first if the user has explicitly
- * selected it to be used as the default call-manager.
- * <p>
- * See {@link #getCapabilities}
- */
- public static final int CAPABILITY_SIM_CALL_MANAGER = 0x1;
-
- /**
- * Flag indicating that this {@code PhoneAccount} can make phone calls in place of 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_SIM_CALL_MANAGER} in that it is not allowed to manage calls from or use
- * the built-in telephony stack to place its calls.
- * <p>
- * See {@link #getCapabilities}
- */
- public static final int CAPABILITY_CALL_PROVIDER = 0x2;
-
/**
- * Flag indicating that this {@code PhoneAccount} represents a built-in PSTN SIM subscription.
+ * Flag indicating that this {@code PhoneAccount} represents built-in PSTN SIM subscription.
* <p>
- * Only the android framework can set this capability on a phone-account.
+ * Only the android framework can set this capability on a phone account.
*/
public static final int CAPABILITY_SIM_SUBSCRIPTION = 0x4;
private ComponentName mComponentName;
private String mId;
- private Uri mHandle;
- private int mCapabilities;
public PhoneAccount(
ComponentName componentName,
- String id,
- Uri handle,
- int capabilities) {
+ String id) {
mComponentName = componentName;
mId = id;
- mHandle = handle;
- mCapabilities = capabilities;
}
/**
@@ -97,31 +71,9 @@ public class PhoneAccount implements Parcelable {
return mId;
}
- /**
- * The handle (e.g., a phone number) associated with this {@code PhoneAccount}. This represents
- * the destination from which outgoing calls using this {@code PhoneAccount} will appear to
- * come, if applicable, and the destination to which incoming calls using this
- * {@code PhoneAccount} may be addressed.
- *
- * @return A handle expressed as a {@code Uri}, for example, a phone number.
- */
- public Uri getHandle() {
- return mHandle;
- }
-
- /**
- * The capabilities of this {@code PhoneAccount}.
- *
- * @return A bit field of flags describing this {@code PhoneAccount}'s capabilities.
- */
- public int getCapabilities() {
- return mCapabilities;
- }
-
@Override
public int hashCode() {
- return Objects.hashCode(mComponentName) + Objects.hashCode(mId) +
- Objects.hashCode(mHandle) + mCapabilities;
+ return Objects.hashCode(mComponentName) + Objects.hashCode(mId);
}
@Override
@@ -130,20 +82,16 @@ public class PhoneAccount implements Parcelable {
.append(", ")
.append(mId)
.append(", ")
- .append(Log.pii(mHandle))
.append(", ")
- .append(String.valueOf(mCapabilities))
.toString();
}
- /**
- * TODO: Change this to just be equals() and use Set<> in Telecomm code instead of Lists.
- * @hide
- */
- public boolean equalsComponentAndId(PhoneAccount other) {
+ @Override
+ public boolean equals(Object other) {
return other != null &&
- Objects.equals(other.getComponentName(), getComponentName()) &&
- Objects.equals(other.getId(), getId());
+ other instanceof PhoneAccount &&
+ Objects.equals(((PhoneAccount) other).getComponentName(), getComponentName()) &&
+ Objects.equals(((PhoneAccount) other).getId(), getId());
}
//
@@ -159,8 +107,6 @@ public class PhoneAccount implements Parcelable {
public void writeToParcel(Parcel out, int flags) {
out.writeParcelable(mComponentName, flags);
out.writeString(mId);
- out.writeString(mHandle != null ? mHandle.toString() : "");
- out.writeInt(mCapabilities);
}
public static final Creator<PhoneAccount> CREATOR = new Creator<PhoneAccount>() {
@@ -178,8 +124,5 @@ public class PhoneAccount implements Parcelable {
private PhoneAccount(Parcel in) {
mComponentName = in.readParcelable(getClass().getClassLoader());
mId = in.readString();
- String uriString = in.readString();
- mHandle = uriString.length() > 0 ? Uri.parse(uriString) : null;
- mCapabilities = in.readInt();
}
}
diff --git a/telecomm/java/android/telecomm/PhoneAccountMetadata.java b/telecomm/java/android/telecomm/PhoneAccountMetadata.java
index 7232218..e5e41ff 100644
--- a/telecomm/java/android/telecomm/PhoneAccountMetadata.java
+++ b/telecomm/java/android/telecomm/PhoneAccountMetadata.java
@@ -19,6 +19,7 @@ package android.telecomm;
import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
+import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
@@ -26,21 +27,55 @@ import java.util.MissingResourceException;
/**
* Provides user interface description information for a {@code PhoneAccount}.
+ *
+ * TODO: Per feedback from API Council, rename to "PhoneAccount". See also comment on class
+ * PhoneAccount.
*/
public class PhoneAccountMetadata implements Parcelable {
- private PhoneAccount mAccount;
- private int mIconResId;
- private String mLabel;
- private String mShortDescription;
+
+ /**
+ * Flag indicating that this {@code PhoneAccount} can act as a call manager for traditional
+ * SIM-based telephony calls. The {@link ConnectionService} associated with this phone-account
+ * will be allowed to manage SIM-based phone calls including using its own proprietary
+ * phone-call implementation (like VoIP calling) to make calls instead of the telephony stack.
+ * When a user opts to place a call using the SIM-based telephony stack, the connection-service
+ * associated with this phone-account will be attempted first if the user has explicitly
+ * selected it to be used as the default call-manager.
+ * <p>
+ * See {@link #getCapabilities}
+ */
+ public static final int CAPABILITY_SIM_CALL_MANAGER = 0x1;
+
+ /**
+ * Flag indicating that this {@code PhoneAccount} can make phone calls in place of 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_SIM_CALL_MANAGER} in that it is not allowed to manage calls from or use
+ * the built-in telephony stack to place its calls.
+ * <p>
+ * See {@link #getCapabilities}
+ */
+ public static final int CAPABILITY_CALL_PROVIDER = 0x2;
+
+ private final PhoneAccount mAccount;
+ private final Uri mHandle;
+ private final int mCapabilities;
+ private final int mIconResId;
+ private final String mLabel;
+ private final String mShortDescription;
private boolean mVideoCallingSupported;
public PhoneAccountMetadata(
PhoneAccount account,
+ Uri handle,
+ int capabilities,
int iconResId,
String label,
String shortDescription,
boolean supportsVideoCalling) {
mAccount = account;
+ mHandle = handle;
+ mCapabilities = capabilities;
mIconResId = iconResId;
mLabel = label;
mShortDescription = shortDescription;
@@ -57,6 +92,27 @@ public class PhoneAccountMetadata implements Parcelable {
}
/**
+ * The handle (e.g., a phone number) associated with this {@code PhoneAccount}. This represents
+ * the destination from which outgoing calls using this {@code PhoneAccount} will appear to
+ * come, if applicable, and the destination to which incoming calls using this
+ * {@code PhoneAccount} may be addressed.
+ *
+ * @return A handle expressed as a {@code Uri}, for example, a phone number.
+ */
+ public Uri getHandle() {
+ return mHandle;
+ }
+
+ /**
+ * The capabilities of this {@code PhoneAccount}.
+ *
+ * @return A bit field of flags describing this {@code PhoneAccount}'s capabilities.
+ */
+ public int getCapabilities() {
+ return mCapabilities;
+ }
+
+ /**
* A short string label describing a {@code PhoneAccount}.
*
* @return A label for this {@code PhoneAccount}.
@@ -75,6 +131,15 @@ public class PhoneAccountMetadata implements Parcelable {
}
/**
+ * The icon resource ID for the icon of this {@code PhoneAccount}.
+ *
+ * @return A resource ID.
+ */
+ public int getIconResId() {
+ return mIconResId;
+ }
+
+ /**
* An icon to represent this {@code PhoneAccount} in a user interface.
*
* @return An icon for this {@code PhoneAccount}.
@@ -122,10 +187,12 @@ public class PhoneAccountMetadata implements Parcelable {
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeParcelable(mAccount, 0);
+ out.writeParcelable(mHandle, 0);
+ out.writeInt(mCapabilities);
out.writeInt(mIconResId);
out.writeString(mLabel);
out.writeString(mShortDescription);
- out.writeInt(mVideoCallingSupported ? 1: 0);
+ out.writeInt(mVideoCallingSupported ? 1 : 0);
}
public static final Creator<PhoneAccountMetadata> CREATOR
@@ -143,6 +210,8 @@ public class PhoneAccountMetadata implements Parcelable {
private PhoneAccountMetadata(Parcel in) {
mAccount = in.readParcelable(getClass().getClassLoader());
+ mHandle = in.readParcelable(getClass().getClassLoader());
+ mCapabilities = in.readInt();
mIconResId = in.readInt();
mLabel = in.readString();
mShortDescription = in.readString();
diff --git a/telecomm/java/android/telecomm/RemoteConnectionService.java b/telecomm/java/android/telecomm/RemoteConnectionService.java
index 25ff5bc..c2b574c 100644
--- a/telecomm/java/android/telecomm/RemoteConnectionService.java
+++ b/telecomm/java/android/telecomm/RemoteConnectionService.java
@@ -260,9 +260,7 @@ final class RemoteConnectionService implements DeathRecipient {
List<PhoneAccount> accounts = new LinkedList<>();
accounts.add(new PhoneAccount(
mComponentName,
- null /* id */,
- null /* handle */,
- 0 /* capabilities */));
+ null /* id */));
return accounts;
}
diff --git a/telecomm/java/android/telecomm/TelecommManager.java b/telecomm/java/android/telecomm/TelecommManager.java
index 8bf80bb..89fcdb5 100644
--- a/telecomm/java/android/telecomm/TelecommManager.java
+++ b/telecomm/java/android/telecomm/TelecommManager.java
@@ -56,6 +56,34 @@ 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()}.
+ * <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 phone call must either create their {@link android.content.Intent#ACTION_CALL} or
+ * {@link android.content.Intent#ACTION_DIAL} {@code Intent} with no
+ * {@link TelecommConstants#EXTRA_PHONE_ACCOUNT}, or present the user with an affordance
+ * to select one of the elements of {@link #getEnabledPhoneAccounts()}.
+ * <p>
+ * An {@link android.content.Intent#ACTION_CALL} or {@link android.content.Intent#ACTION_DIAL}
+ * {@code Intent} with no {@link TelecommConstants#EXTRA_PHONE_ACCOUNT} 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}.
+ */
+ public PhoneAccount getDefaultOutgoingPhoneAccount() {
+ try {
+ if (isServiceConnected()) {
+ return getTelecommService().getDefaultOutgoingPhoneAccount();
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelecommService#getDefaultOutgoingPhoneAccount", e);
+ }
+ return null;
+ }
+
+ /**
* Return a list of {@link PhoneAccount}s which can be used to make and receive phone calls.
*
* @see #EXTRA_PHONE_ACCOUNT
@@ -94,13 +122,12 @@ public class TelecommManager {
/**
* Register a {@link PhoneAccount} for use by the system.
*
- * @param account The {@link PhoneAccount}.
- * @param metadata The metadata for the account.
+ * @param metadata The complete {@link PhoneAccountMetadata}.
*/
- public void registerPhoneAccount(PhoneAccount account, PhoneAccountMetadata metadata) {
+ public void registerPhoneAccount(PhoneAccountMetadata metadata) {
try {
if (isServiceConnected()) {
- getTelecommService().registerPhoneAccount(account, metadata);
+ getTelecommService().registerPhoneAccount(metadata);
}
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelecommService#registerPhoneAccount", e);
diff --git a/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl b/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl
index 43caa1e..59393ed 100644
--- a/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl
+++ b/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl
@@ -34,6 +34,11 @@ interface ITelecommService {
void showCallScreen(boolean showDialpad);
/**
+ * @see TelecommManager#getDefaultOutgoingPhoneAccount
+ */
+ PhoneAccount getDefaultOutgoingPhoneAccount();
+
+ /**
* @see TelecommManager#getEnabledPhoneAccounts
*/
List<PhoneAccount> getEnabledPhoneAccounts();
@@ -46,7 +51,7 @@ interface ITelecommService {
/**
* @see TelecommManager#registerPhoneAccount
*/
- void registerPhoneAccount(in PhoneAccount account, in PhoneAccountMetadata metadata);
+ void registerPhoneAccount(in PhoneAccountMetadata metadata);
/**
* @see TelecommManager#unregisterPhoneAccount