ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
บริการเลือกโดเมน
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
สำหรับอุปกรณ์ที่ใช้ Android 15 ขึ้นไป คุณสามารถติดตั้งใช้งานการเลือกโดเมนระหว่างบริการ IMS กับบริการเดิมผ่านเครือข่ายแบบใช้วงจรได้โดยใช้ API ระบบ DomainSelectionService
DomainSelectionService
เป็นอินเทอร์เฟซที่กําหนดไว้อย่างชัดเจนระหว่างแพลตฟอร์ม Android กับการใช้งานการเลือกโดเมนที่ผู้ให้บริการระบุ อินเทอร์เฟซนี้ช่วยให้การติดตั้งใช้งานของผู้ให้บริการสามารถส่งข้อมูลสัญญาณไปยังแพลตฟอร์มได้ เช่น โดเมนที่มีการโทรออกและ SMS และค่ากําหนดประเภทเครือข่ายในการสแกนเครือข่าย
รูปที่ 1 แผนภาพสถาปัตยกรรมของฟีเจอร์การเลือกโดเมน
ตัวอย่างและแหล่งที่มา
Android มีการใช้งานอ้างอิงสำหรับฟีเจอร์การเลือกโดเมนใน AOSP ที่ TelephonyDomainSelectionService
ดูเอกสารประกอบโดยละเอียดสำหรับ DomainSelectionService
API ได้ที่ DomainSelectionService
และคลาสอื่นๆ ใน API
การใช้งาน
หากต้องการใช้ฟีเจอร์การเลือกโดเมนในอุปกรณ์ Android คุณต้องทำตามขั้นตอนต่อไปนี้
สร้างแอปการเลือกโดเมน โดยต้องกำหนดบริการในไฟล์ AndroidManifest.xml
เพิ่มการกําหนดค่าลงในการวางซ้อนอุปกรณ์เพื่อให้แพลตฟอร์มเชื่อมโยงกับการใช้งานDomainSelectionService
รองรับอินเทอร์เฟซ HAL ของวิทยุที่จำเป็นสำหรับฟีเจอร์การเลือกโดเมน
ส่วนนี้จะให้รายละเอียดเพิ่มเติมเกี่ยวกับขั้นตอนเหล่านี้
เพิ่มรายการบริการใน AndroidManifest.xml
หากต้องการให้แอปการเลือกโดเมนลงทะเบียนบริการ DomainSelectionService
กับเฟรมเวิร์ก ให้เพิ่มรายการบริการในไฟล์ Manifest โดยใช้รูปแบบต่อไปนี้
<service
android:name="com.example.domainselection.DomainSelectionService"
android:directBootAware="true"
android:persistent="true"
…
android:permission="android.permission.BIND_DOMAIN_SELECTION_SERVICE"
…
<intent-filter>
<action android:name="android.telephony.DomainSelectionService"/>
</intent-filter>
…
</service>
คําจํากัดความบริการใน AndroidManifest.xml
ต้องกําหนดแอตทริบิวต์ต่อไปนี้เพื่อให้ฟีเจอร์การเลือกโดเมนทํางานได้
directBootAware="true"
: อนุญาตให้ระบบโทรคมนาคมค้นพบและเรียกใช้บริการก่อนที่จะมีการปลดล็อกอุปกรณ์ บริการจะเข้าถึงพื้นที่เก็บข้อมูลที่เข้ารหัสในอุปกรณ์ไม่ได้ก่อนที่ผู้ใช้จะปลดล็อกอุปกรณ์ ดูข้อมูลเพิ่มเติมได้ที่รองรับโหมดการบูตโดยตรงและการเข้ารหัสตามไฟล์
persistent="true"
: ช่วยให้บริการทำงานอย่างต่อเนื่องและระบบจะไม่หยุดบริการเพื่อเรียกคืนหน่วยความจำ แอตทริบิวต์นี้จะใช้งานได้ก็ต่อเมื่อแอปสร้างขึ้นเป็นแอประบบเท่านั้น
permission="android.permission.BIND_DOMAIN_SELECTION_SERVICE"
: ตรวจสอบว่าเฉพาะกระบวนการที่ได้รับสิทธิ์ BIND_DOMAIN_SELECTION_SERVICE
เท่านั้นที่จะเชื่อมโยงกับแอปได้ ซึ่งจะช่วยป้องกันไม่ให้แอปที่เป็นอันตรายเชื่อมโยงกับบริการได้ เนื่องจากเฟรมเวิร์กจะมอบสิทธิ์นี้ให้กับแอประบบเท่านั้น
บริการต้องระบุองค์ประกอบ intent-filter
ที่มีการดำเนินการ android.telephony.DomainSelectionService
ด้วย ซึ่งจะช่วยให้เฟรมเวิร์กค้นหาบริการ DomainSelectionService
ได้
กำหนดค่าในการวางซ้อนอุปกรณ์
หากต้องการให้แพลตฟอร์มเชื่อมโยงกับบริการ DomainSelectionService
อย่างปลอดภัย ให้เพิ่มการกําหนดค่าต่อไปนี้ลงในการวางซ้อนอุปกรณ์
เนื่องจาก Android ไม่รองรับแอปที่มีการใช้งานDomainSelectionService
ของบุคคลที่สาม แอปการเลือกโดเมนจึงต้องเป็นแอประบบที่อยู่ในโฟลเดอร์ /system_ext/priv-app/
หรือ /product/priv-app/
เฟรมเวิร์กจะตรวจสอบว่าชื่อแพ็กเกจของการติดตั้งใช้งานตรงกับค่าการวางซ้อนของอุปกรณ์หรือไม่ เพื่อให้มั่นใจว่ามีการกำหนดค่าเฉพาะแอปที่เชื่อถือได้ซึ่งติดตั้งไว้ล่วงหน้าเท่านั้น
รองรับอินเทอร์เฟซ HAL ของวิทยุ
หากต้องการเปิดใช้ฟีเจอร์การเลือกโดเมน ให้รองรับอินเทอร์เฟซ HAL ของวิทยุที่จําเป็นต่อไปนี้
IRadioNetwork
void setEmergencyMode(int serial, EmergencyMode emcModeType);
void triggerEmergencyNetworkScan(int serial,
EmergencyNetworkScanTrigger request);
void cancelEmergencyNetworkScan(int serial, boolean resetScan);
void exitEmergencyMode(int serial);
IRadioNetworkIndication
void emergencyNetworkScanResult(RadioIndicationType type,
EmergencyRegResult result);
การตรวจสอบความถูกต้อง
หากต้องการทดสอบว่าเฟรมเวิร์กโทรศัพท์ตอบสนองต่ออินเทอร์เฟซ DomainSelectionService
อย่างถูกต้อง ให้ทำการทดสอบ CTS ใน DomainSelectionServiceTestOnMockModem
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[[["เข้าใจง่าย","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-26 UTC"],[],[],null,["# Domain selection service\n\nFor devices running Android 15 or higher, you can\nimplement domain selection\nbetween the IMS service and legacy services over circuit switched networks using\nthe [`DomainSelectionService`](https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/base/telephony/java/android/telephony/DomainSelectionService.java) system API. `DomainSelectionService`\nis a well-defined interface between the Android platform and a vendor provided\ndomain selection implementation. This interface lets the vendor implementation\nprovide signaling information, such as the domain that outgoing calls and SMS\nare placed and network type preference in network scanning, to the platform.\n\n**Figure 1.** Architecture diagram for the domain selection feature\n\nExamples and source\n-------------------\n\nAndroid provides a reference implementation for the domain selection feature in\nAOSP at [`TelephonyDomainSelectionService`](https://cs.android.com/android/platform/superproject/+/android-latest-release:packages/services/Telephony/src/com/android/services/telephony/domainselection/). For detailed\ndocumentation for the `DomainSelectionService` API, see\n[`DomainSelectionService`](https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/base/telephony/java/android/telephony/DomainSelectionService.java) and the other classes in the API.\n\nImplementation\n--------------\n\nTo implement the domain selection feature on an Android device, the following\nsteps are required:\n\n1. Create a domain selection app. The service must be defined in the\n `AndroidManifest.xml` file.\n\n2. Add a configuration to the device overlay to let the platform bind to the\n `DomainSelectionService` implementation.\n\n3. Support the required radio HAL interfaces for the domain selection feature.\n\nThis section provides further details of these steps.\n\n### Add service entry in AndroidManifest.xml\n\nFor your domain selection app to register the `DomainSelectionService` service\nwith the framework, add a service entry in the manifest file using the following\nformat: \n\n \u003cservice\n android:name=\"com.example.domainselection.DomainSelectionService\"\n android:directBootAware=\"true\"\n android:persistent=\"true\"\n ...\n android:permission=\"android.permission.BIND_DOMAIN_SELECTION_SERVICE\"\n ...\n \u003cintent-filter\u003e\n \u003caction android:name=\"android.telephony.DomainSelectionService\"/\u003e\n \u003c/intent-filter\u003e\n ...\n \u003c/service\u003e\n\nThe service definition in `AndroidManifest.xml` must define the following\nattributes for the domain selection feature to operate.\n\n- `directBootAware=\"true\"`: Lets the service be discovered and run by\n telephony before the user unlocks the device. The service can't access\n *device-encrypted* storage before the user unlocks the device. For more\n information,\n see [Support Direct Boot mode](https://developer.android.com/privacy-and-security/direct-boot) and [File-Based Encryption](/docs/security/features/encryption/file-based).\n\n- `persistent=\"true\"`: Lets the service be run persistently and not be\n killed by the system to reclaim memory. This attribute works *only* if the\n app is built as a system app.\n\n- `permission=\"android.permission.BIND_DOMAIN_SELECTION_SERVICE\"`: Ensures\n that only a process that has the `BIND_DOMAIN_SELECTION_SERVICE` permission\n granted to it can bind to the app. This prevents a rogue app from binding to\n the service, because only system apps can be granted the permission by the\n framework.\n\nThe service must also specify the `intent-filter` element with the\n`android.telephony.DomainSelectionService` action. This lets the framework find\nthe `DomainSelectionService` service.\n\n### Define configuration in device overlay\n\nFor the platform to securely bind to the `DomainSelectionService` service, add\nthe following configuration to the device overlay:\n\n- [`config_domain_selection_service_component_name`](https://cs.android.com/android/platform/superproject/+/android-latest-release:packages/services/Telephony/res/values/config.xml?q=config_domain_selection_service_component_name): The component name (a flattened `ComponentName` string) for the `DomainSelectionService` service\n\nBecause Android doesn't support apps with third-party downloadable\n`DomainSelectionService` implementations, the domain selection app must be a\nsystem app that resides in the `/system_ext/priv-app/` or `/product/priv-app/`\nfolder. The framework verifies whether the package name of the implementation\nmatches the device overlay value to ensure only trusted, preinstalled apps are\nbound.\n\n### Support radio HAL interfaces\n\nTo enable the domain selection feature, support the following required radio HAL\ninterfaces:\n\n- [`IRadioNetwork`](https://cs.android.com/android/platform/superproject/+/android-latest-release:hardware/interfaces/radio/aidl/android/hardware/radio/network/IRadioNetwork.aidl)\n\n void setEmergencyMode(int serial, EmergencyMode emcModeType);\n void triggerEmergencyNetworkScan(int serial,\n EmergencyNetworkScanTrigger request);\n void cancelEmergencyNetworkScan(int serial, boolean resetScan);\n void exitEmergencyMode(int serial);\n\n- [`IRadioNetworkIndication`](https://cs.android.com/android/platform/superproject/+/android-latest-release:hardware/interfaces/radio/aidl/android/hardware/radio/network/IRadioNetworkIndication.aidl)\n\n void emergencyNetworkScanResult(RadioIndicationType type,\n EmergencyRegResult result);\n\nValidation\n----------\n\nTo test that the telephony framework properly responds to the\n`DomainSelectionService` interface, run the CTS tests in\n[`DomainSelectionServiceTestOnMockModem`](https://cs.android.com/android/platform/superproject/+/android-latest-release:cts/tests/tests/telephony/current/src/android/telephony/cts/DomainSelectionServiceTestOnMockModem.java)."]]