範例 Java 廣播電台應用程式 (packages/apps/Car/Radio) 可做為參考實作。應用程式服務啟動時,會要求 Radio Manager 開啟 Radio Tuner。接著,應用程式可以向 Radio Tuner 傳送要求,例如調到特定電台、頻率,或搜尋下一個可用的電台。應用程式會從 Radio 中的 Radio Manager 和 Radio Tuner 接收更新,例如目前的節目資訊、電台節目清單、設定和供應商定義的參數。參考的收音機應用程式僅支援 AM 和 FM 收音機。原始設備製造商 (OEM) 可視需要修改或取代 Radio 應用程式。
廣播管理員
當應用程式要求 Radio Manager 開啟調諧器時,Radio Manager (frameworks/base/core/java/android/hardware/radio/RadioManager.java) 會要求 Broadcast Radio Service (BRS) 開啟調諧器工作階段,然後在 Radio Tuner (frameworks/base/core/java/android/hardware/radio/RadioTuner.java) 中包裝工作階段,並將其傳回至應用程式。Radio Tuner 中定義的回呼方法 (RadioTuner.Callback) 會將廣播電台 HAL 的更新內容 (例如目前的節目資訊、節目清單和廠商定義的參數) 從 BRS 傳送至應用程式。
廣播電台服務
廣播電台服務 (frameworks/base/services/core/java/com/android/server/broadcastradio) 是廣播電台 HAL 的用戶端服務。BRS 會協調多個 Radio Manager 與廣播電台 HAL。BRS 支援 HAL 介面定義語言 (HIDL) 和 Android 介面定義語言 (AIDL) 廣播無線電 HAL。當任何 AIDL HAL 服務存在時,BRS 會連結至 AIDL HAL;否則,服務會連結至 HIDL HAL。BRS 會為每個可用的 HAL 例項 (例如 AM、FM 和 DAB) 建立 Radio 模組。
每個 Radio Manager 都可以要求 BRS 根據無線電類型,在對應的 Radio Module 上建立調諧器工作階段。每個調諧器工作階段都可以呼叫方法,例如 tune、step 和 cancel (在 HAL 介面中定義),以便在相應的廣播電台 HAL 例項上執行作業。當一個調諧器工作階段收到 HAL 更新 (例如目前的節目資訊、節目清單、設定標記和供應商參數) 的 HAL 例項回呼時,系統會將有關更新的回呼傳送至與同一個無線電模組連結的所有無線電調諧器。
廣播電台 HAL
如要進一步瞭解廣播電台的 HIDL 和 AIDL 介面,以及兩者之間的差異,請參閱「廣播電台 HAL 介面」。
[[["容易理解","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"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Overview\n\nThe broadcast radio stack consists of the components illustrated in Figure 1.\n**Figure 1.** Broadcast Radio architecture.\n\nRadio reference app\n-------------------\n\nFor details about how to implement radio control, see\n[Radio control implementation](/docs/automotive/radio/radio-control-implementation).\n\nA sample Java radio app (`packages/apps/Car/Radio`) serves as a reference\nimplementation. When the app service starts, it requests Radio Manager to open a Radio Tuner. Then,\nthe app can send requests to the Radio Tuner, such as tuning to a specific radio station, frequency,\nor to seek the next available radio station. The app receives updates from the Radio Manager and\nRadio Tuner in Radio, such as current program information, radio program lists, configurations, and\nvendor-defined parameters. The reference Radio app only supports AM and FM radio. OEMs can modify or\nreplace the Radio app as desired.\n\nRadio Manager\n-------------\n\nWhen the app requests Radio Manager to open a tuner, the Radio Manager\n(`frameworks/base/core/java/android/hardware/radio/RadioManager.java`) requests the\nBroadcast Radio Service (BRS) to open a Tuner session and then wraps the session in a Radio Tuner\n(`frameworks/base/core/java/android/hardware/radio/RadioTuner.java`), which is returned\nto the app.\n\nThe Radio Tuner defines APIs (such as tune, step, and cancel) that can be called from radio apps\nand send requests to BRS. Callback methods (`RadioTuner.Callback`) defined in Radio\nTuner send updates about the broadcast radio HAL, such as current program information, program\nlists, and vendor-defined parameters, from the BRS to apps.\n\nBroadcast Radio Service\n-----------------------\n\nThe Broadcast Radio Service\n(`frameworks/base/services/core/java/com/android/server/broadcastradio`) is the client\nservice for Broadcast Radio HAL. The BRS coordinates multiple Radio Managers with Broadcast Radio\nHALs. The BRS supports\n[HAL interface definition language (HIDL)](/docs/core/architecture/hidl) and\n[Android interface definition language (AIDL)](/docs/core/architecture/aidl) broadcast\nradio HALs. The BRS links to the AIDL HAL when any AIDL HAL service exists;\notherwise, the service links to the HIDL HAL. The BRS creates a Radio Module\nfor each available HAL instance (such as AM, FM, and DAB).\n\nEach Radio Manager can request the BRS to create a tuner session on the\ncorresponding Radio Module, based on the type of radio. Each tuner session can call methods, such\nas tune, step, and cancel (defined in HAL interfaces) to perform operations on the\ncorresponding broadcast radio HAL instance. When one tuner session receives a callback from the HAL\ninstance on a HAL update, such as current program info, program list, configuration flags and,\nvendor parameters, callbacks about the update are sent to all Radio Tuners linked to the same\nRadio Module.\n\nBroadcast Radio HAL\n-------------------\n\n| In Android 13 and lower, versions of the BRS are provided in HIDL and AIDL. New features are added **only** to releases of Android 14 and higher.\n\nTo learn more about the HIDL and AIDL interfaces of broadcast radio and the differences between\nthe two, see\n[Broadcast Radio HAL interface](/docs/automotive/radio/broadcast-radio-hal)."]]