In Android 10, the phone account suggestion service allows suggestions for phone accounts to be shown to users when making a call. For example, for users with a device with multiple SIMs and lower rates for intra-network calls, this service first identifies the callee's carrier and then suggests using the SIM on the same network as the callee.
The phone account suggestion service is optional and can be implemented on devices running Android 10 or higher.
Implementation
To implement phone account suggestions, implement one
PhoneAccountSuggestionService
service in an app that is located in /system/priv-app/
. The service isn't
queried if more than one PhoneAccountSuggestionService
is implemented. The
service must declare the
android.Manifest.permission.BIND_PHONE_ACCOUNT_SUGGESTION_SERVICE
permission.
When a user makes an outgoing call where neither the
default outgoing phone account
nor the
preferred phone account
is set for the callee, the telecom service binds to
PhoneAccountSuggestionService
to gather information about the accounts,
onAccountSuggestionRequest(String number)
is called, and the outgoing call process is suspended.
PhoneAccountSuggestionService
must call
suggestPhoneAccounts(String number, List<PhoneAccountSuggestion> suggestions)
with the number returned by
onAccountSuggestionRequest(String number)
.
When
suggestPhoneAccounts(String number, List<PhoneAccountSuggestion> suggestions)
is called, the telecom service returns a list of suggested phone accounts. The
dialer must then display the list of suggested phone accounts for the user to
choose from to make the call.
PhoneAccountSuggestion
To make suggestions, use the
PhoneAccountSuggestion
class.
For example, if the service determines the callee is on the same carrier as one
of the SIMs in the device, the service should mark the phone account with
REASON_INTRA_CARRIER
.
This information can then be conveyed to the user in the dialer.
For example, in a situation where the user has configured the device to use
a work SIM for all contacts
in a work Google Account, the service should mark the phone account with
REASON_USER_SET
and set
shouldAutoSelect
to true to allow the dialer to bypass the selection dialog and automatically
place the call using the phone account.
For information on other suggestions, see
PhoneAccountSuggestion
.
Dialer
When the call enters the
STATE_SELECT_PHONE_ACCOUNT
state, the dialer must use the information from
PhoneAccountSuggestion
to handle
EXTRA_SUGGESTED_PHONE_ACCOUNTS
.
Disable the service
To customize your implementation for specific carriers, you can enable or
disable the service using
setComponentEnabledSetting
.
The service is not queried if disabled.
System UI implementation
Depending on your implementation, changes to the system UI may be required. For example, to allow users to specify that all calls to a specific contact are made from a specific phone account, you must implement a customized set up flow and settings UI for the device.
Validation
To validate your implementation, run the following CTS tests: