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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user