* commit 'b6b0bc36362fe3a137759e089e0d3baba98175c7': Add enable/disable properties to phone accounts.
This commit is contained in:
@@ -30323,6 +30323,7 @@ package android.telecom {
|
|||||||
method public android.net.Uri getSubscriptionAddress();
|
method public android.net.Uri getSubscriptionAddress();
|
||||||
method public java.util.List<java.lang.String> getSupportedUriSchemes();
|
method public java.util.List<java.lang.String> getSupportedUriSchemes();
|
||||||
method public boolean hasCapabilities(int);
|
method public boolean hasCapabilities(int);
|
||||||
|
method public boolean isEnabled();
|
||||||
method public boolean supportsUriScheme(java.lang.String);
|
method public boolean supportsUriScheme(java.lang.String);
|
||||||
method public android.telecom.PhoneAccount.Builder toBuilder();
|
method public android.telecom.PhoneAccount.Builder toBuilder();
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
method public void writeToParcel(android.os.Parcel, int);
|
||||||
|
|||||||
@@ -32509,6 +32509,7 @@ package android.telecom {
|
|||||||
method public android.net.Uri getSubscriptionAddress();
|
method public android.net.Uri getSubscriptionAddress();
|
||||||
method public java.util.List<java.lang.String> getSupportedUriSchemes();
|
method public java.util.List<java.lang.String> getSupportedUriSchemes();
|
||||||
method public boolean hasCapabilities(int);
|
method public boolean hasCapabilities(int);
|
||||||
|
method public boolean isEnabled();
|
||||||
method public boolean supportsUriScheme(java.lang.String);
|
method public boolean supportsUriScheme(java.lang.String);
|
||||||
method public android.telecom.PhoneAccount.Builder toBuilder();
|
method public android.telecom.PhoneAccount.Builder toBuilder();
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
method public void writeToParcel(android.os.Parcel, int);
|
||||||
@@ -32650,6 +32651,7 @@ package android.telecom {
|
|||||||
method public void cancelMissedCallsNotification();
|
method public void cancelMissedCallsNotification();
|
||||||
method public deprecated void clearAccounts();
|
method public deprecated void clearAccounts();
|
||||||
method public void clearPhoneAccounts();
|
method public void clearPhoneAccounts();
|
||||||
|
method public void enablePhoneAccount(android.telecom.PhoneAccountHandle, boolean);
|
||||||
method public boolean endCall();
|
method public boolean endCall();
|
||||||
method public android.net.Uri getAdnUriForPhoneAccount(android.telecom.PhoneAccountHandle);
|
method public android.net.Uri getAdnUriForPhoneAccount(android.telecom.PhoneAccountHandle);
|
||||||
method public java.util.List<android.telecom.PhoneAccountHandle> getAllPhoneAccountHandles();
|
method public java.util.List<android.telecom.PhoneAccountHandle> getAllPhoneAccountHandles();
|
||||||
@@ -32665,7 +32667,6 @@ package android.telecom {
|
|||||||
method public android.telecom.PhoneAccount getPhoneAccount(android.telecom.PhoneAccountHandle);
|
method public android.telecom.PhoneAccount getPhoneAccount(android.telecom.PhoneAccountHandle);
|
||||||
method public java.util.List<android.telecom.PhoneAccountHandle> getPhoneAccountsForPackage();
|
method public java.util.List<android.telecom.PhoneAccountHandle> getPhoneAccountsForPackage();
|
||||||
method public java.util.List<android.telecom.PhoneAccountHandle> getPhoneAccountsSupportingScheme(java.lang.String);
|
method public java.util.List<android.telecom.PhoneAccountHandle> getPhoneAccountsSupportingScheme(java.lang.String);
|
||||||
method public java.util.List<android.telecom.PhoneAccountHandle> getRegisteredConnectionManagers();
|
|
||||||
method public android.telecom.PhoneAccountHandle getSimCallManager();
|
method public android.telecom.PhoneAccountHandle getSimCallManager();
|
||||||
method public java.lang.String getVoiceMailNumber(android.telecom.PhoneAccountHandle);
|
method public java.lang.String getVoiceMailNumber(android.telecom.PhoneAccountHandle);
|
||||||
method public boolean handleMmi(java.lang.String);
|
method public boolean handleMmi(java.lang.String);
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ public final class PhoneAccount implements Parcelable {
|
|||||||
private final CharSequence mShortDescription;
|
private final CharSequence mShortDescription;
|
||||||
private final List<String> mSupportedUriSchemes;
|
private final List<String> mSupportedUriSchemes;
|
||||||
private final Icon mIcon;
|
private final Icon mIcon;
|
||||||
|
private boolean mIsEnabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class for creating a {@link PhoneAccount}.
|
* Helper class for creating a {@link PhoneAccount}.
|
||||||
@@ -165,6 +166,7 @@ public final class PhoneAccount implements Parcelable {
|
|||||||
private CharSequence mShortDescription;
|
private CharSequence mShortDescription;
|
||||||
private List<String> mSupportedUriSchemes = new ArrayList<String>();
|
private List<String> mSupportedUriSchemes = new ArrayList<String>();
|
||||||
private Icon mIcon;
|
private Icon mIcon;
|
||||||
|
private boolean mIsEnabled = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a builder with the specified {@link PhoneAccountHandle} and label.
|
* Creates a builder with the specified {@link PhoneAccountHandle} and label.
|
||||||
@@ -190,6 +192,7 @@ public final class PhoneAccount implements Parcelable {
|
|||||||
mShortDescription = phoneAccount.getShortDescription();
|
mShortDescription = phoneAccount.getShortDescription();
|
||||||
mSupportedUriSchemes.addAll(phoneAccount.getSupportedUriSchemes());
|
mSupportedUriSchemes.addAll(phoneAccount.getSupportedUriSchemes());
|
||||||
mIcon = phoneAccount.getIcon();
|
mIcon = phoneAccount.getIcon();
|
||||||
|
mIsEnabled = phoneAccount.isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -287,6 +290,18 @@ public final class PhoneAccount implements Parcelable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the enabled state of the phone account.
|
||||||
|
*
|
||||||
|
* @param isEnabled The enabled state.
|
||||||
|
* @return The builder.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public Builder setIsEnabled(boolean isEnabled) {
|
||||||
|
mIsEnabled = isEnabled;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an instance of a {@link PhoneAccount} based on the current builder settings.
|
* Creates an instance of a {@link PhoneAccount} based on the current builder settings.
|
||||||
*
|
*
|
||||||
@@ -307,7 +322,8 @@ public final class PhoneAccount implements Parcelable {
|
|||||||
mHighlightColor,
|
mHighlightColor,
|
||||||
mLabel,
|
mLabel,
|
||||||
mShortDescription,
|
mShortDescription,
|
||||||
mSupportedUriSchemes);
|
mSupportedUriSchemes,
|
||||||
|
mIsEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,7 +336,8 @@ public final class PhoneAccount implements Parcelable {
|
|||||||
int highlightColor,
|
int highlightColor,
|
||||||
CharSequence label,
|
CharSequence label,
|
||||||
CharSequence shortDescription,
|
CharSequence shortDescription,
|
||||||
List<String> supportedUriSchemes) {
|
List<String> supportedUriSchemes,
|
||||||
|
boolean isEnabled) {
|
||||||
mAccountHandle = account;
|
mAccountHandle = account;
|
||||||
mAddress = address;
|
mAddress = address;
|
||||||
mSubscriptionAddress = subscriptionAddress;
|
mSubscriptionAddress = subscriptionAddress;
|
||||||
@@ -330,6 +347,7 @@ public final class PhoneAccount implements Parcelable {
|
|||||||
mLabel = label;
|
mLabel = label;
|
||||||
mShortDescription = shortDescription;
|
mShortDescription = shortDescription;
|
||||||
mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes);
|
mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes);
|
||||||
|
mIsEnabled = isEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder builder(
|
public static Builder builder(
|
||||||
@@ -436,6 +454,15 @@ public final class PhoneAccount implements Parcelable {
|
|||||||
return mIcon;
|
return mIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether the user has enabled this phone account or not {@code PhoneAccounts}.
|
||||||
|
*
|
||||||
|
* @return The {@code true} if the account is enabled by the user, {@code false} otherwise.
|
||||||
|
*/
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return mIsEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if the {@link PhoneAccount} supports calls to/from addresses with a specified URI
|
* Determines if the {@link PhoneAccount} supports calls to/from addresses with a specified URI
|
||||||
* scheme.
|
* scheme.
|
||||||
@@ -466,6 +493,14 @@ public final class PhoneAccount implements Parcelable {
|
|||||||
return mHighlightColor;
|
return mHighlightColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the enabled state of the phone account.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public void setIsEnabled(boolean isEnabled) {
|
||||||
|
mIsEnabled = isEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Parcelable implementation
|
// Parcelable implementation
|
||||||
//
|
//
|
||||||
@@ -500,12 +535,14 @@ public final class PhoneAccount implements Parcelable {
|
|||||||
out.writeCharSequence(mLabel);
|
out.writeCharSequence(mLabel);
|
||||||
out.writeCharSequence(mShortDescription);
|
out.writeCharSequence(mShortDescription);
|
||||||
out.writeStringList(mSupportedUriSchemes);
|
out.writeStringList(mSupportedUriSchemes);
|
||||||
|
|
||||||
if (mIcon == null) {
|
if (mIcon == null) {
|
||||||
out.writeInt(0);
|
out.writeInt(0);
|
||||||
} else {
|
} else {
|
||||||
out.writeInt(1);
|
out.writeInt(1);
|
||||||
mIcon.writeToParcel(out, flags);
|
mIcon.writeToParcel(out, flags);
|
||||||
}
|
}
|
||||||
|
out.writeByte((byte) (mIsEnabled ? 1 : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<PhoneAccount> CREATOR
|
public static final Creator<PhoneAccount> CREATOR
|
||||||
@@ -547,11 +584,14 @@ public final class PhoneAccount implements Parcelable {
|
|||||||
} else {
|
} else {
|
||||||
mIcon = null;
|
mIcon = null;
|
||||||
}
|
}
|
||||||
|
mIsEnabled = in.readByte() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder().append("[PhoneAccount: ")
|
StringBuilder sb = new StringBuilder().append("[[")
|
||||||
|
.append(mIsEnabled ? 'X' : ' ')
|
||||||
|
.append("] PhoneAccount: ")
|
||||||
.append(mAccountHandle)
|
.append(mAccountHandle)
|
||||||
.append(" Capabilities: ")
|
.append(" Capabilities: ")
|
||||||
.append(mCapabilities)
|
.append(mCapabilities)
|
||||||
|
|||||||
@@ -377,15 +377,23 @@ public class TelecomManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the {@link PhoneAccount} which is the user-chosen default for making outgoing phone
|
* Return the {@link PhoneAccount} which will be used to place outgoing calls to addresses with
|
||||||
* calls with a specified URI scheme.
|
* the specified {@code uriScheme}. This {@link PhoneAccount} will always be a member of the
|
||||||
* <p>
|
* list which is returned from invoking {@link #getCallCapablePhoneAccounts()}. The specific
|
||||||
* Apps must be prepared for this method to return {@code null}, indicating that there currently
|
* account returned depends on the following priorities:
|
||||||
* exists no user-chosen default {@code PhoneAccount}.
|
* <ul>
|
||||||
|
* <li> If the user-selected default {@link PhoneAccount} supports the specified scheme, it will
|
||||||
|
* be returned.
|
||||||
|
* </li>
|
||||||
|
* <li> If there exists only one {@link PhoneAccount} that supports the specified scheme, it
|
||||||
|
* will be returned.
|
||||||
|
* </li>
|
||||||
|
* </ul>
|
||||||
* <p>
|
* <p>
|
||||||
|
* If no {@link PhoneAccount} fits the criteria above, this method will return {@code null}.
|
||||||
|
*
|
||||||
* @param uriScheme The URI scheme.
|
* @param uriScheme The URI scheme.
|
||||||
* @return The {@link PhoneAccountHandle} corresponding to the user-chosen default for outgoing
|
* @return The {@link PhoneAccountHandle} corresponding to the account to be used.
|
||||||
* phone calls for a specified URI scheme.
|
|
||||||
*/
|
*/
|
||||||
public PhoneAccountHandle getDefaultOutgoingPhoneAccount(String uriScheme) {
|
public PhoneAccountHandle getDefaultOutgoingPhoneAccount(String uriScheme) {
|
||||||
try {
|
try {
|
||||||
@@ -403,7 +411,7 @@ public class TelecomManager {
|
|||||||
* Return the {@link PhoneAccount} which is the user-chosen default for making outgoing phone
|
* 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
|
* calls. This {@code PhoneAccount} will always be a member of the list which is returned from
|
||||||
* calling {@link #getCallCapablePhoneAccounts()}
|
* calling {@link #getCallCapablePhoneAccounts()}
|
||||||
*
|
* <p>
|
||||||
* Apps must be prepared for this method to return {@code null}, indicating that there currently
|
* Apps must be prepared for this method to return {@code null}, indicating that there currently
|
||||||
* exists no user-chosen default {@code PhoneAccount}.
|
* exists no user-chosen default {@code PhoneAccount}.
|
||||||
*
|
*
|
||||||
@@ -422,7 +430,7 @@ public class TelecomManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the default account for making outgoing phone calls.
|
* Sets the user-chosen default for making outgoing phone calls.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void setUserSelectedOutgoingPhoneAccount(PhoneAccountHandle accountHandle) {
|
public void setUserSelectedOutgoingPhoneAccount(PhoneAccountHandle accountHandle) {
|
||||||
@@ -439,6 +447,7 @@ public class TelecomManager {
|
|||||||
* Returns the current SIM call manager. Apps must be prepared for this method to return
|
* Returns the current SIM call manager. Apps must be prepared for this method to return
|
||||||
* {@code null}, indicating that there currently exists no user-chosen default
|
* {@code null}, indicating that there currently exists no user-chosen default
|
||||||
* {@code PhoneAccount}.
|
* {@code PhoneAccount}.
|
||||||
|
*
|
||||||
* @return The phone account handle of the current sim call manager.
|
* @return The phone account handle of the current sim call manager.
|
||||||
*/
|
*/
|
||||||
public PhoneAccountHandle getSimCallManager() {
|
public PhoneAccountHandle getSimCallManager() {
|
||||||
@@ -454,6 +463,7 @@ public class TelecomManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the SIM call manager to the specified phone account.
|
* Sets the SIM call manager to the specified phone account.
|
||||||
|
*
|
||||||
* @param accountHandle The phone account handle of the account to set as the sim call manager.
|
* @param accountHandle The phone account handle of the account to set as the sim call manager.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@@ -469,6 +479,7 @@ public class TelecomManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of registered SIM call managers.
|
* Returns the list of registered SIM call managers.
|
||||||
|
*
|
||||||
* @return List of registered SIM call managers.
|
* @return List of registered SIM call managers.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@@ -496,16 +507,6 @@ public class TelecomManager {
|
|||||||
return getSimCallManager();
|
return getSimCallManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the list of registered SIM call managers.
|
|
||||||
* @return List of registered SIM call managers.
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
@SystemApi
|
|
||||||
public List<PhoneAccountHandle> getRegisteredConnectionManagers() {
|
|
||||||
return getSimCallManagers();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of the {@link PhoneAccountHandle}s which can be used to make and receive phone
|
* Returns a list of the {@link PhoneAccountHandle}s which can be used to make and receive phone
|
||||||
* calls which support the specified URI scheme.
|
* calls which support the specified URI scheme.
|
||||||
@@ -534,20 +535,33 @@ public class TelecomManager {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of {@link PhoneAccountHandle}s which can be used to make and receive phone
|
* Returns a list of {@link PhoneAccountHandle}s which can be used to make and receive phone
|
||||||
* calls.
|
* calls. The returned list includes only those accounts which have been explicitly enabled
|
||||||
|
* by the user.
|
||||||
*
|
*
|
||||||
* @see #EXTRA_PHONE_ACCOUNT_HANDLE
|
* @see #EXTRA_PHONE_ACCOUNT_HANDLE
|
||||||
* @return A list of {@code PhoneAccountHandle} objects.
|
* @return A list of {@code PhoneAccountHandle} objects.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public List<PhoneAccountHandle> getCallCapablePhoneAccounts() {
|
public List<PhoneAccountHandle> getCallCapablePhoneAccounts() {
|
||||||
|
return getCallCapablePhoneAccounts(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of {@link PhoneAccountHandle}s including those which have not been enabled
|
||||||
|
* by the user.
|
||||||
|
*
|
||||||
|
* @return A list of {@code PhoneAccountHandle} objects.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public List<PhoneAccountHandle> getCallCapablePhoneAccounts(boolean includeDisabledAccounts) {
|
||||||
try {
|
try {
|
||||||
if (isServiceConnected()) {
|
if (isServiceConnected()) {
|
||||||
return getTelecomService().getCallCapablePhoneAccounts(mContext.getOpPackageName());
|
return getTelecomService().getCallCapablePhoneAccounts(
|
||||||
|
includeDisabledAccounts, mContext.getOpPackageName());
|
||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "Error calling ITelecomService#getCallCapablePhoneAccounts", e);
|
Log.e(TAG, "Error calling ITelecomService#getCallCapablePhoneAccounts(" +
|
||||||
|
includeDisabledAccounts + ")", e);
|
||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
@@ -1163,6 +1177,25 @@ public class TelecomManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables and disables specified phone account.
|
||||||
|
*
|
||||||
|
* @param handle Handle to the phone account.
|
||||||
|
* @param isEnabled Enable state of the phone account.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@SystemApi
|
||||||
|
public void enablePhoneAccount(PhoneAccountHandle handle, boolean isEnabled) {
|
||||||
|
ITelecomService service = getTelecomService();
|
||||||
|
if (service != null) {
|
||||||
|
try {
|
||||||
|
service.enablePhoneAccount(handle, isEnabled);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.e(TAG, "Error enablePhoneAbbount", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private ITelecomService getTelecomService() {
|
private ITelecomService getTelecomService() {
|
||||||
return ITelecomService.Stub.asInterface(ServiceManager.getService(Context.TELECOM_SERVICE));
|
return ITelecomService.Stub.asInterface(ServiceManager.getService(Context.TELECOM_SERVICE));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,8 @@ interface ITelecomService {
|
|||||||
/**
|
/**
|
||||||
* @see TelecomServiceImpl#getCallCapablePhoneAccounts
|
* @see TelecomServiceImpl#getCallCapablePhoneAccounts
|
||||||
*/
|
*/
|
||||||
List<PhoneAccountHandle> getCallCapablePhoneAccounts(String callingPackage);
|
List<PhoneAccountHandle> getCallCapablePhoneAccounts(
|
||||||
|
boolean includeDisabledAccounts, String callingPackage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see TelecomManager#getPhoneAccountsSupportingScheme
|
* @see TelecomManager#getPhoneAccountsSupportingScheme
|
||||||
@@ -226,4 +227,9 @@ interface ITelecomService {
|
|||||||
* @see TelecomServiceImpl#placeCall
|
* @see TelecomServiceImpl#placeCall
|
||||||
*/
|
*/
|
||||||
void placeCall(in Uri handle, in Bundle extras, String callingPackage);
|
void placeCall(in Uri handle, in Bundle extras, String callingPackage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TelecomServiceImpl#enablePhoneAccount
|
||||||
|
*/
|
||||||
|
void enablePhoneAccount(in PhoneAccountHandle accountHandle, boolean isEnabled);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user