Debug and test

Dialer is equipped with an integrated debugging and testing framework that enables you to validate Dialer app features without the need for call-ready devices. This eliminates the need for Bluetooth and connected phones with cellular service. This Dialer Testing Framework (DTF) simplifies these processes:

  • Setting up a real device to quickly validate ideas typically consumes time.
  • Testing multi-call features requires at least three SIM card equipped phones, two of which are used only to place calls.
  • Debugging Dialer and its dependencies.

Since Dialer's functionality depends on several technology stacks including Telecom, Telephony, and Bluetooth Hands Free Profile (HFP), bugs and issues that arise in those dependencies can cause Dialer flakiness. The DTF enables Dialer to run independently of these dependencies.

Features

The DTF provides these features:

  • Call placement. Place and receive calls without the need for a call-ready device through the terminal with an Android Debug Bridge (adb) broadcast.
  • Mock calls. Call functionality is mocked. This includes holding, muting, merging, and disconnecting.

Use the DTF

Note: The DTF is only available in Android 11 or higher.

To use the DTF:

  1. Build and install the CarDialerAppForTesting build variant as follows:
    cd %rRepoRoot%/packages/apps/Car/Dialer
    
    m CarDialerAppForTesting
    
    adb install %rRepoRoot%/out/target/product/%buildTarget%/system/priv-app/CarDialerAppForTesting/CarDialerAppForTesting.apk
    

    As a result, CarDialerAppForTesting replaces the original Dialer app on the test device.

    CarDialerAppForTesting doesn't work with real devices. To test with a real device, reinstall the CarDialerApp.apk.

Commands

The following adb commands work only after Dialer is launched for the first time and require the broadcast receiver to be initialized. After launching Dialer, a fake Bluetooth device must be connected. Use the following (Setup) Connect a device command to do so.

(Set up) Connect a device

Establishes a fake Bluetooth connection to Dialer and must be called first to enable access to all call-related commands.

To connect a device:

adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "connect"

Note: Only after a fake Bluetooth device has been connected can each of the following commands be used.

Place an outgoing call

To place an outgoing call:

adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "addCall" --es "id" "4085524874"

Receive an incoming call

To receive an incoming call:

adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "rcvCall" --es "id" "4085524874"

End a call

To end a call:

adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "endCall" --es "id" "4085524874"

Hold the current call

To place the current call on hold:

adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "holdCall"

Unhold the current call

To take the current call off hold:

adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "unholdCall"

Merge calls

Merge the primary and secondary calls into a conference call. This command works only when both the primary and secondary calls exist. An existing conference call is considered to be a single entity.

To merge calls:

adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "unholdCall"

Clear all calls

To remove all calls in the call list:

adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "clearAll"

Emulator build

Sometimes developers may want to test UI changes on an emulator. In such cases, CarDialerAppEmulatorBuild provides a simplified setup and limited functionality compared to the more powerful DTF.

Test data

When Dialer is launched, the Bluetooth error page is bypassed and the main content of TelecomActivity is displayed. Contacts and call logs are displayed on the local device. Developers can use the stock Contacts app to create test contacts or to import a .vcf file.

Call mocking

To mock inbound calls, use Android Emulator to send Telnet commands. To learn more, see Run apps on the Android Emulator and Send Emulator console commands.

telnet localhost 5554
gsm call xxx-xxx-xxxx

Placing a phone call in the Dialer app or broadcasting a call intent starts an outbound call.

adb shell am start -a android.intent.action.CALL tel:xxx-xxx-xxxx