Add getSelfManagedPhoneAccounts() TelecomManager API.

This is consistent with the existing getCallCapablePhoneAccounts API
which is used to get the phone accounts capable of placing phone calls.

Test: CTS
Bug: 34159263
Merged-In: I1396c63a6882947cd66721528e53b6964a9091e0
Change-Id: I1396c63a6882947cd66721528e53b6964a9091e0
(cherry picked from commit 8931707058)
This commit is contained in:
Tyler Gunn
2017-04-07 14:57:37 -07:00
parent 4a30689414
commit 4774fb36d0
5 changed files with 34 additions and 0 deletions

View File

@@ -754,6 +754,32 @@ public class TelecomManager {
return getCallCapablePhoneAccounts(false);
}
/**
* Returns a list of {@link PhoneAccountHandle}s for self-managed {@link ConnectionService}s.
* <p>
* Self-Managed {@link ConnectionService}s have a {@link PhoneAccount} with
* {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.
* <p>
* Requires permission {@link android.Manifest.permission#READ_PHONE_STATE}, or that the caller
* is the default dialer app.
* <p>
* A {@link SecurityException} will be thrown if a called is not the default dialer, or lacks
* the {@link android.Manifest.permission#READ_PHONE_STATE} permission.
*
* @return A list of {@code PhoneAccountHandle} objects.
*/
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
public List<PhoneAccountHandle> getSelfManagedPhoneAccounts() {
try {
if (isServiceConnected()) {
return getTelecomService().getSelfManagedPhoneAccounts(mContext.getOpPackageName());
}
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelecomService#getSelfManagedPhoneAccounts()", e);
}
return new ArrayList<>();
}
/**
* Returns a list of {@link PhoneAccountHandle}s including those which have not been enabled
* by the user.