am 170694a5: am a99279fe: am ba740d4f: Allowing enable/disable of phone accounts. (1/3)
* commit '170694a5d8803e26b35bbeba63b0add9e6f2191a': Allowing enable/disable of phone accounts. (1/3)
This commit is contained in:
@@ -28580,9 +28580,12 @@ package android.telecomm {
|
||||
method public java.lang.CharSequence getShortDescription();
|
||||
method public android.net.Uri getSubscriptionAddress();
|
||||
method public java.util.List<java.lang.String> getSupportedUriSchemes();
|
||||
method public boolean hasCapabilities(int);
|
||||
method public boolean isEnabled();
|
||||
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_PLACE_EMERGENCY_CALLS = 16; // 0x10
|
||||
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";
|
||||
@@ -28592,6 +28595,7 @@ package android.telecomm {
|
||||
|
||||
public static class PhoneAccount.Builder {
|
||||
ctor public PhoneAccount.Builder(android.telecomm.PhoneAccountHandle, java.lang.CharSequence);
|
||||
ctor public PhoneAccount.Builder(android.telecomm.PhoneAccount);
|
||||
method public android.telecomm.PhoneAccount build();
|
||||
method public android.telecomm.PhoneAccount.Builder setAddress(android.net.Uri);
|
||||
method public android.telecomm.PhoneAccount.Builder setCapabilities(int);
|
||||
|
||||
@@ -82,6 +82,25 @@ public class PhoneAccount implements Parcelable {
|
||||
*/
|
||||
public static final int CAPABILITY_VIDEO_CALLING = 0x8;
|
||||
|
||||
/**
|
||||
* Flag indicating that this {@code PhoneAccount} is capable of placing emergency calls.
|
||||
* By default all PSTN {@code PhoneAccount}s are capable of placing emergency calls.
|
||||
* <p>
|
||||
* See {@link #getCapabilities}
|
||||
*/
|
||||
public static final int CAPABILITY_PLACE_EMERGENCY_CALLS = 0x10;
|
||||
|
||||
/**
|
||||
* Flag indicating that this {@code PhoneAccount} is always enabled and cannot be disabled by
|
||||
* the user.
|
||||
* This capability is reserved for important {@code PhoneAccount}s such as the emergency calling
|
||||
* only {@code PhoneAccount}.
|
||||
* <p>
|
||||
* See {@link #getCapabilities}
|
||||
* @hide
|
||||
*/
|
||||
public static final int CAPABILITY_ALWAYS_ENABLED = 0x20;
|
||||
|
||||
/**
|
||||
* URI scheme for telephone number URIs.
|
||||
*/
|
||||
@@ -105,6 +124,7 @@ public class PhoneAccount implements Parcelable {
|
||||
private final CharSequence mLabel;
|
||||
private final CharSequence mShortDescription;
|
||||
private final List<String> mSupportedUriSchemes;
|
||||
private final boolean mIsEnabled;
|
||||
|
||||
public static class Builder {
|
||||
private PhoneAccountHandle mAccountHandle;
|
||||
@@ -115,12 +135,31 @@ public class PhoneAccount implements Parcelable {
|
||||
private CharSequence mLabel;
|
||||
private CharSequence mShortDescription;
|
||||
private List<String> mSupportedUriSchemes = new ArrayList<String>();
|
||||
private boolean mIsEnabled = false;
|
||||
|
||||
public Builder(PhoneAccountHandle accountHandle, CharSequence label) {
|
||||
this.mAccountHandle = accountHandle;
|
||||
this.mLabel = label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of the {@link PhoneAccount.Builder} from an existing
|
||||
* {@link PhoneAccount}.
|
||||
*
|
||||
* @param phoneAccount The {@link PhoneAccount} used to initialize the builder.
|
||||
*/
|
||||
public Builder(PhoneAccount phoneAccount) {
|
||||
mAccountHandle = phoneAccount.getAccountHandle();
|
||||
mAddress = phoneAccount.getAddress();
|
||||
mSubscriptionAddress = phoneAccount.getSubscriptionAddress();
|
||||
mCapabilities = phoneAccount.getCapabilities();
|
||||
mIconResId = phoneAccount.getIconResId();
|
||||
mLabel = phoneAccount.getLabel();
|
||||
mShortDescription = phoneAccount.getShortDescription();
|
||||
mSupportedUriSchemes.addAll(phoneAccount.getSupportedUriSchemes());
|
||||
mIsEnabled = phoneAccount.isEnabled();
|
||||
}
|
||||
|
||||
public Builder setAddress(Uri value) {
|
||||
this.mAddress = value;
|
||||
return this;
|
||||
@@ -177,6 +216,24 @@ public class PhoneAccount implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies whether the {@link PhoneAccount} is enabled or not. {@link PhoneAccount}s are
|
||||
* by default not enabled.
|
||||
*
|
||||
* @param value {@code True} if the {@link PhoneAccount} is enabled.
|
||||
* @return The Builder.
|
||||
* @hide
|
||||
*/
|
||||
public Builder setEnabled(boolean value) {
|
||||
this.mIsEnabled = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of a {@link PhoneAccount} based on the current builder settings.
|
||||
*
|
||||
* @return The {@link PhoneAccount}.
|
||||
*/
|
||||
public PhoneAccount build() {
|
||||
// If no supported URI schemes were defined, assume "tel" is supported.
|
||||
if (mSupportedUriSchemes.isEmpty()) {
|
||||
@@ -191,7 +248,8 @@ public class PhoneAccount implements Parcelable {
|
||||
mIconResId,
|
||||
mLabel,
|
||||
mShortDescription,
|
||||
mSupportedUriSchemes);
|
||||
mSupportedUriSchemes,
|
||||
mIsEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,7 +261,8 @@ public class PhoneAccount implements Parcelable {
|
||||
int iconResId,
|
||||
CharSequence label,
|
||||
CharSequence shortDescription,
|
||||
List<String> supportedUriSchemes) {
|
||||
List<String> supportedUriSchemes,
|
||||
boolean enabled) {
|
||||
mAccountHandle = account;
|
||||
mAddress = address;
|
||||
mSubscriptionAddress = subscriptionAddress;
|
||||
@@ -212,6 +271,7 @@ public class PhoneAccount implements Parcelable {
|
||||
mLabel = label;
|
||||
mShortDescription = shortDescription;
|
||||
mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes);
|
||||
mIsEnabled = enabled;
|
||||
}
|
||||
|
||||
public static Builder builder(
|
||||
@@ -220,6 +280,14 @@ public class PhoneAccount implements Parcelable {
|
||||
return new Builder(accountHandle, label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a builder initialized with the current {@link PhoneAccount} instance.
|
||||
*
|
||||
* @return The builder.
|
||||
* @hide
|
||||
*/
|
||||
public Builder toBuilder() { return new Builder(this); }
|
||||
|
||||
/**
|
||||
* The unique identifier of this {@code PhoneAccount}.
|
||||
*
|
||||
@@ -264,6 +332,17 @@ public class PhoneAccount implements Parcelable {
|
||||
return mCapabilities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if this {@code PhoneAccount} has a capabilities specified by the passed in
|
||||
* bit mask.
|
||||
*
|
||||
* @param capability The capabilities to check.
|
||||
* @return {@code True} if the phone account has the capability.
|
||||
*/
|
||||
public boolean hasCapabilities(int capability) {
|
||||
return (mCapabilities & capability) == capability;
|
||||
}
|
||||
|
||||
/**
|
||||
* A short label describing a {@code PhoneAccount}.
|
||||
*
|
||||
@@ -312,6 +391,15 @@ public class PhoneAccount implements Parcelable {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether this {@code PhoneAccount} is enabled.
|
||||
*
|
||||
* @return {@code True} if this {@code PhoneAccount} is enabled..
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
return mIsEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* The icon resource ID for the icon of this {@code PhoneAccount}.
|
||||
*
|
||||
@@ -367,6 +455,7 @@ public class PhoneAccount implements Parcelable {
|
||||
out.writeCharSequence(mLabel);
|
||||
out.writeCharSequence(mShortDescription);
|
||||
out.writeList(mSupportedUriSchemes);
|
||||
out.writeInt(mIsEnabled ? 1 : 0);
|
||||
}
|
||||
|
||||
public static final Creator<PhoneAccount> CREATOR
|
||||
@@ -396,5 +485,6 @@ public class PhoneAccount implements Parcelable {
|
||||
List<String> supportedUriSchemes = new ArrayList<>();
|
||||
in.readList(supportedUriSchemes, classLoader);
|
||||
mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes);
|
||||
mIsEnabled = in.readInt() == 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.util.Log;
|
||||
import com.android.internal.telecomm.ITelecommService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -347,8 +348,8 @@ public class TelecommManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of {@link PhoneAccountHandle}s which can be used to make and receive phone
|
||||
* calls.
|
||||
* Return a list of enabled {@link PhoneAccountHandle}s which can be used to make and receive
|
||||
* phone calls.
|
||||
*
|
||||
* @see #EXTRA_PHONE_ACCOUNT_HANDLE
|
||||
* @return A list of {@code PhoneAccountHandle} objects.
|
||||
@@ -356,10 +357,10 @@ public class TelecommManager {
|
||||
public List<PhoneAccountHandle> getEnabledPhoneAccounts() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecommService().getOutgoingPhoneAccounts();
|
||||
return getTelecommService().getEnabledPhoneAccounts();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecommService#getOutgoingPhoneAccounts", e);
|
||||
Log.e(TAG, "Error calling ITelecommService#getEnabledPhoneAccounts", e);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
@@ -425,8 +426,8 @@ 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.
|
||||
* Returns a list of the enabled {@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
|
||||
@@ -475,6 +476,78 @@ public class TelecommManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a count of enabled and disabled {@link PhoneAccount}s.
|
||||
*
|
||||
* @return The count of enabled and disabled {@link PhoneAccount}s.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public int getAllPhoneAccountsCount() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecommService().getAllPhoneAccountsCount();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecommService#getAllPhoneAccountsCount", e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all {@link PhoneAccount}s.
|
||||
*
|
||||
* @return All {@link PhoneAccount}s.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public List<PhoneAccount> getAllPhoneAccounts() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecommService().getAllPhoneAccounts();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecommService#getAllPhoneAccounts", e);
|
||||
}
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all {@link PhoneAccountHandle}s.
|
||||
*
|
||||
* @return All {@link PhoneAccountHandle}s.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public List<PhoneAccountHandle> getAllPhoneAccountHandles() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecommService().getAllPhoneAccountHandles();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecommService#getAllPhoneAccountHandles", e);
|
||||
}
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables a {@link PhoneAccount}.
|
||||
*
|
||||
* @param account The {@link PhoneAccountHandle} to enable or disable.
|
||||
* @param isEnabled {@code True} if the phone account should be enabled.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public void setPhoneAccountEnabled(PhoneAccountHandle account, boolean isEnabled) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
getTelecommService().setPhoneAccountEnabled(account, isEnabled);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecommService#setPhoneAccountEnabled", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a {@link PhoneAccount} for use by the system.
|
||||
*
|
||||
|
||||
@@ -50,9 +50,9 @@ interface ITelecommService {
|
||||
void setUserSelectedOutgoingPhoneAccount(in PhoneAccountHandle account);
|
||||
|
||||
/**
|
||||
* @see TelecommServiceImpl#getOutgoingPhoneAccounts
|
||||
* @see TelecommServiceImpl#getEnabledPhoneAccounts
|
||||
*/
|
||||
List<PhoneAccountHandle> getOutgoingPhoneAccounts();
|
||||
List<PhoneAccountHandle> getEnabledPhoneAccounts();
|
||||
|
||||
/**
|
||||
* @see TelecommManager#getPhoneAccountsSupportingScheme
|
||||
@@ -64,6 +64,21 @@ interface ITelecommService {
|
||||
*/
|
||||
PhoneAccount getPhoneAccount(in PhoneAccountHandle account);
|
||||
|
||||
/**
|
||||
* @see TelecommManager#getAllPhoneAccountsCount
|
||||
*/
|
||||
int getAllPhoneAccountsCount();
|
||||
|
||||
/**
|
||||
* @see TelecommManager#getAllPhoneAccounts
|
||||
*/
|
||||
List<PhoneAccount> getAllPhoneAccounts();
|
||||
|
||||
/**
|
||||
* @see TelecommManager#getAllPhoneAccountHandles
|
||||
*/
|
||||
List<PhoneAccountHandle> getAllPhoneAccountHandles();
|
||||
|
||||
/**
|
||||
* @see TelecommServiceImpl#getSimCallManager
|
||||
*/
|
||||
@@ -79,6 +94,11 @@ interface ITelecommService {
|
||||
*/
|
||||
List<PhoneAccountHandle> getSimCallManagers();
|
||||
|
||||
/**
|
||||
* @see TelecommServiceImpl#setPhoneAccountEnabled
|
||||
*/
|
||||
void setPhoneAccountEnabled(in PhoneAccountHandle account, in boolean isEnabled);
|
||||
|
||||
/**
|
||||
* @see TelecommServiceImpl#registerPhoneAccount
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user