自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
调试和测试
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
拨号器配有内置的调试和测试框架,借助该框架,您可以验证拨号器应用的功能,而无需使用支持通话功能的设备。这样就不必使用蓝牙功能,也不必连接支持移动网络服务的手机。该拨号器测试框架 (DTF) 可简化以下流程:
- 设置实际设备以快速验证想法的过程通常会很耗时。
- 如需测试多方通话功能,至少需要三部配有 SIM 卡的手机,其中两部手机仅用于拨打电话。
- 调试拨号器及其依赖项。
由于拨号器的功能取决于多个技术栈(包括电信、电话和蓝牙免触摸操作配置文件 [HFP]),因此这些依赖项中出现的 bug 和问题可能会导致拨号器功能不稳定。借助 DTF,拨号器可独立于这些依赖项运行。
功能
DTF 提供以下功能:
- 接打电话。无需使用支持通话功能的设备,通过具有 Android 调试桥 (adb) 广播功能的终端即可接打电话。
- 模拟通话。系统可模拟通话功能,包括保持通话、将通话静音、合并通话和断开通话。
使用 DTF
注意:DTF 仅适用于 Android 11 或更高版本。
如需使用 DTF,请执行以下操作:
- 按以下方式构建和安装
CarDialerAppForTesting
build 变体:
cd %rRepoRoot%/packages/apps/Car/Dialer
m CarDialerAppForTesting
adb install %rRepoRoot%/out/target/product/%buildTarget%/system/priv-app/CarDialerAppForTesting/CarDialerAppForTesting.apk
因此,CarDialerAppForTesting
会替换测试设备上的原始拨号器应用。
CarDialerAppForTesting
不适用于实际设备。如需使用实际设备进行测试,请重新安装 CarDialerApp.apk
。
命令
以下 adb 命令仅在拨号器首次启动后才能发挥作用,并且要求对广播接收器进行初始化。启动拨号器后,必须连接模拟蓝牙设备。为此,请使用以下“(设置)连接设备”命令。
(设置)连接设备
与拨号器建立模拟蓝牙连接;必须先调用该命令,以便启用对所有通话相关命令的访问权限。
如需连接设备,请执行以下操作:
adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "connect"
注意:只有在连接模拟蓝牙设备后,才能使用以下每项命令。
拨出电话
如需拨出电话,请运行以下命令:
adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "addCall" --es "id" "4085524874"
接听来电
如需接听来电,请执行以下操作:
adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "rcvCall" --es "id" "4085524874"
结束通话
如需结束通话,请执行以下操作:
adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "endCall" --es "id" "4085524874"
保持当前通话
如需将当前通话置于保持状态,请运行以下命令:
adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "holdCall"
恢复当前通话
如需让当前通话退出保持状态,请执行以下操作:
adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "unholdCall"
合并通话
将主要通话和次要通话合并到电话会议中。该命令仅在主要通话和次要通话都存在时才有效。系统会将现有电话会议视为单个实体。
如需合并通话,请执行以下操作:
adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "unholdCall"
清除所有通话
如需移除通话列表中的所有通话,请执行以下操作:
adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "clearAll"
模拟器 build
有时,开发者可能想要测试模拟器界面的更改。在这种情况下,与功能更强大的 DTF 项目,CarDialerAppEmulatorBuild
简化了设置流程,并可提供部分功能。
测试数据
拨号器启动后,系统会绕过蓝牙错误页面,并显示 TelecomActivity
的主要内容。通讯录和通话记录会显示在本地设备上。开发者可使用原生“通讯录”应用来创建测试联系人或导入 .vcf
文件。
通话模拟
如需模拟来电,请使用 Android 模拟器来发送 Telnet 命令。如需了解详情,请参阅在 Android 模拟器上运行应用和发送模拟器控制台命令。
telnet localhost 5554
gsm call xxx-xxx-xxxx
在拨号器应用中拨打电话或广播通话 intent,即可启动外拨电话。
adb shell am start -a android.intent.action.CALL tel:xxx-xxx-xxxx
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Debug and test\n\nDialer is equipped with an integrated debugging and testing framework that enables you to\nvalidate Dialer app features without the need for call-ready devices. This eliminates the need\nfor Bluetooth and connected phones with cellular service. This Dialer Testing Framework (DTF)\nsimplifies these processes:\n\n- Setting up a real device to quickly validate ideas typically consumes time.\n- Testing multi-call features requires at least three SIM card equipped phones, two of which are used only to place calls.\n- Debugging Dialer and its dependencies.\n\nSince Dialer's functionality depends on several technology stacks including Telecom, Telephony,\nand Bluetooth Hands Free Profile (HFP), bugs and issues that arise in those dependencies can\ncause Dialer flakiness. The DTF enables Dialer to run independently of these dependencies.\n\nFeatures\n--------\n\nThe DTF provides these features:\n\n- **Call placement.** Place and receive calls without the need for a call-ready device through the terminal with an [Android Debug Bridge (adb)](https://developer.android.com/studio/command-line/adb) broadcast.\n- **Mock calls.** Call functionality is mocked. This includes holding, muting, merging, and disconnecting.\n\nUse the DTF\n-----------\n\n\n**Note:**The DTF is only available in Android 11 or higher.\n\nTo use the DTF:\n\n1. Build and install the `CarDialerAppForTesting` build variant as follows: \n\n ```\n cd %rRepoRoot%/packages/apps/Car/Dialer\n\n m CarDialerAppForTesting\n\n adb install %rRepoRoot%/out/target/product/%buildTarget%/system/priv-app/CarDialerAppForTesting/CarDialerAppForTesting.apk\n ```\n\n As a result, `CarDialerAppForTesting` replaces the original Dialer app on the\n test device.\n\n `CarDialerAppForTesting` doesn't work with real devices. To test with a real device,\n reinstall the `CarDialerApp.apk`.\n\nCommands\n--------\n\nThe following adb commands work only after Dialer is launched for the first time and require\nthe broadcast receiver to be initialized. After launching Dialer, a fake Bluetooth device must\nbe connected. Use the following (Setup) Connect a device command to do so.\n\n### (Set up) Connect a device\n\nEstablishes a fake Bluetooth connection to Dialer and must be called first to enable access\nto all call-related commands.\n\nTo connect a device: \n\n```\nadb shell am broadcast -a com.android.car.dialer.intent.action.adb --es \"action\" \"connect\"\n```\n\n\n**Note:**Only after a fake Bluetooth device has been connected can each of\nthe following commands be used.\n\n### Place an outgoing call\n\nTo place an outgoing call: \n\n```\nadb shell am broadcast -a com.android.car.dialer.intent.action.adb --es \"action\" \"addCall\" --es \"id\" \"4085524874\"\n```\n\n### Receive an incoming call\n\nTo receive an incoming call: \n\n```\nadb shell am broadcast -a com.android.car.dialer.intent.action.adb --es \"action\" \"rcvCall\" --es \"id\" \"4085524874\"\n```\n\n### End a call\n\nTo end a call: \n\n```\nadb shell am broadcast -a com.android.car.dialer.intent.action.adb --es \"action\" \"endCall\" --es \"id\" \"4085524874\"\n```\n\n### Hold the current call\n\nTo place the current call on hold: \n\n```\nadb shell am broadcast -a com.android.car.dialer.intent.action.adb --es \"action\" \"holdCall\"\n```\n\n### Unhold the current call\n\nTo take the current call off hold: \n\n```\nadb shell am broadcast -a com.android.car.dialer.intent.action.adb --es \"action\" \"unholdCall\"\n```\n\n### Merge calls\n\nMerge the primary and secondary calls into a conference call. This command works only when both\nthe primary and secondary calls exist. An existing conference call is considered to be a single\nentity.\n\nTo merge calls: \n\n```\nadb shell am broadcast -a com.android.car.dialer.intent.action.adb --es \"action\" \"unholdCall\"\n```\n\n### Clear all calls\n\nTo remove all calls in the call list: \n\n```\nadb shell am broadcast -a com.android.car.dialer.intent.action.adb --es \"action\" \"clearAll\"\n```\n\nEmulator build\n--------------\n\nSometimes developers may want to test UI changes on an emulator. In such cases,\n`CarDialerAppEmulatorBuild` provides a simplified setup and limited functionality\ncompared to the more powerful DTF.\n\n### Test data\n\nWhen Dialer is launched, the Bluetooth error page is bypassed and the main content of\n`TelecomActivity` is displayed. Contacts and call logs are displayed on the local\ndevice. Developers can use the stock Contacts app to create test contacts or to import a\n`.vcf` file.\n\n### Call mocking\n\nTo mock inbound calls, use Android Emulator to send Telnet commands. To learn more, see\n[Run apps on the Android Emulator](https://developer.android.com/studio/run/emulator)\nand\n[Send Emulator console commands](https://developer.android.com/studio/run/emulator-console). \n\n```\ntelnet localhost 5554\ngsm call xxx-xxx-xxxx\n```\n\nPlacing a phone call in the Dialer app or broadcasting a call intent starts an outbound call. \n\n```\nadb shell am start -a android.intent.action.CALL tel:xxx-xxx-xxxx\n```"]]