am 857a001f: am 012f470a: am 42c4a935: Merge "Wire up multi-SIM experience (1/4)" into lmp-dev

* commit '857a001f32387211b3b06b82cb5ce275d02c63a2':
  Wire up multi-SIM experience (1/4)
This commit is contained in:
Ihab Awad
2014-07-18 17:33:12 +00:00
committed by Android Git Automerger
6 changed files with 136 additions and 92 deletions

View File

@@ -28436,28 +28436,29 @@ package android.telecomm {
}
public class PhoneAccount implements android.os.Parcelable {
ctor public PhoneAccount(android.content.ComponentName, java.lang.String, android.net.Uri, int);
ctor public PhoneAccount(android.content.ComponentName, java.lang.String);
method public int describeContents();
method public int getCapabilities();
method public android.content.ComponentName getComponentName();
method public android.net.Uri getHandle();
method public java.lang.String getId();
method public void writeToParcel(android.os.Parcel, int);
field public static final int CAPABILITY_CALL_PROVIDER = 2; // 0x2
field public static final int CAPABILITY_SIM_CALL_MANAGER = 1; // 0x1
field public static final int CAPABILITY_SIM_SUBSCRIPTION = 4; // 0x4
field public static final android.os.Parcelable.Creator CREATOR;
}
public class PhoneAccountMetadata implements android.os.Parcelable {
ctor public PhoneAccountMetadata(android.telecomm.PhoneAccount, int, java.lang.String, java.lang.String, boolean);
ctor public PhoneAccountMetadata(android.telecomm.PhoneAccount, android.net.Uri, int, int, java.lang.String, java.lang.String, boolean);
method public int describeContents();
method public android.telecomm.PhoneAccount getAccount();
method public int getCapabilities();
method public android.net.Uri getHandle();
method public android.graphics.drawable.Drawable getIcon(android.content.Context);
method public int getIconResId();
method public java.lang.String getLabel();
method public java.lang.String getShortDescription();
method public boolean isVideoCallingSupported();
method public void writeToParcel(android.os.Parcel, int);
field public static final int CAPABILITY_CALL_PROVIDER = 2; // 0x2
field public static final int CAPABILITY_SIM_CALL_MANAGER = 1; // 0x1
field public static final android.os.Parcelable.Creator CREATOR;
}
@@ -28567,9 +28568,10 @@ package android.telecomm {
public class TelecommManager {
method public void clearAccounts(java.lang.String);
method public android.telecomm.PhoneAccount getDefaultOutgoingPhoneAccount();
method public java.util.List<android.telecomm.PhoneAccount> getEnabledPhoneAccounts();
method public android.telecomm.PhoneAccountMetadata getPhoneAccountMetadata(android.telecomm.PhoneAccount);
method public void registerPhoneAccount(android.telecomm.PhoneAccount, android.telecomm.PhoneAccountMetadata);
method public void registerPhoneAccount(android.telecomm.PhoneAccountMetadata);
method public void unregisterPhoneAccount(android.telecomm.PhoneAccount);
}

View File

@@ -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.
* Flag indicating that this {@code PhoneAccount} represents built-in PSTN SIM subscription.
* <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.
* <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();
}
}

View File

@@ -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;
@@ -56,6 +91,27 @@ public class PhoneAccountMetadata implements Parcelable {
return mAccount;
}
/**
* 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}.
*
@@ -74,6 +130,15 @@ public class PhoneAccountMetadata implements Parcelable {
return mShortDescription;
}
/**
* 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.
*
@@ -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();

View File

@@ -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;
}

View File

@@ -55,6 +55,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.
*
@@ -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);

View File

@@ -33,6 +33,11 @@ interface ITelecommService {
*/
void showCallScreen(boolean showDialpad);
/**
* @see TelecommManager#getDefaultOutgoingPhoneAccount
*/
PhoneAccount getDefaultOutgoingPhoneAccount();
/**
* @see TelecommManager#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