Kể từ ngày 27 tháng 3 năm 2025, bạn nên sử dụng android-latest-release
thay vì aosp-main
để xây dựng và đóng góp cho AOSP. Để biết thêm thông tin, hãy xem phần Thay đổi đối với AOSP.
Thông tin nhận dạng nhà mạng
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Các thiết bị chạy Android 9 có thể nhận dạng thông tin về nhà cung cấp dịch vụ thuê bao để cung cấp mã nhận dạng và tên nhà cung cấp. Android duy trì một cơ sở dữ liệu mã nhận dạng nhà mạng, với các quy tắc so khớp cho từng nhà mạng và mã nhận dạng nhà mạng duy nhất của nhà mạng đó. AOSP bao gồm nội dung của cơ sở dữ liệu mã nhận dạng nhà mạng, trong tệp carrier_list.textpb
.
Cơ sở dữ liệu hợp nhất giúp giảm thiểu logic trùng lặp trong các ứng dụng cần xác định nhà mạng và giới hạn việc hiển thị các thuộc tính nhận dạng nhà mạng.
Để cải thiện phạm vi và độ chính xác của thông tin nhận dạng nhà mạng, Android hỗ trợ cập nhật bảng mã nhận dạng nhà mạng và ngoài phạm vi. Mỗi bản cập nhật đều có số phiên bản và được phát hành cho AOSP.
Triển khai
Những người dùng muốn triển khai bản cập nhật ngoài phạm vi kênh có thể tải tệp nhị phân carrier_list.pb
xuống từ AOSP. Để xem định dạng dễ đọc của bảng, hãy xem carrier_list.textpb
.
Đặt bảng mã nhận dạng nhà mạng vào phân vùng dữ liệu /data/misc/carrierid/
của thiết bị. Nếu bảng mã nhận dạng nhà mạng mới hơn phiên bản hiện có, thì thiết bị sẽ lưu trữ bảng đó vào lớp cơ sở dữ liệu mã nhận dạng nhà mạng.
Thông tin mới nhất từ cơ sở dữ liệu mã nhận dạng của hãng vận chuyển được các phương thức công khai getSimCarrierId()
và getSimCarrierIdName()
thu thập.
Để thêm hoặc cập nhật mã nhận dạng nhà mạng vào cơ sở dữ liệu, hãy gửi yêu cầu bằng cách sử dụng Biểu mẫu thông tin nhận dạng nhà mạng.
Yêu cầu của bạn sẽ được xem xét và nếu được phê duyệt, thay đổi sẽ được đẩy vào cơ sở mã AOSP tại carrier_list.pb
.
Sau đó, bạn có thể sao chép danh sách đã cập nhật và đưa danh sách đó vào bản dựng tuỳ chỉnh.
Tích hợp mã nhận dạng nhà mạng với CarrierConfig
Kể từ Android 10, cấu hình của nhà mạng hỗ trợ việc sử dụng mã nhận dạng nhà mạng làm khoá để tìm nạp cấu hình dành riêng cho nhà mạng từ CarrierService
.
Việc tích hợp mã nhận dạng nhà mạng với CarrierConfig
có những ưu điểm sau:
- Hợp nhất tất cả cặp MCC/MNC cho mỗi nhà mạng vào một vị trí duy nhất, loại bỏ dữ liệu trùng lặp hoặc không nhất quán.
- Tạo giá trị nhận dạng chuẩn cho từng nhà mạng và loại bỏ sự mơ hồ.
- Cho phép xác định nhà cung cấp dịch vụ mạng ảo di động (MVNO) bằng mã nhận dạng riêng lẻ thay vì có cấu hình trong nhà mạng di động (MNO).
Di chuyển dữ liệu cấu hình sang mã nhận dạng nhà mạng
Để di chuyển dữ liệu cấu hình từ cặp MCC/MNC sang mã nhận dạng nhà mạng, hãy làm theo các bước sau:
Nhóm các tệp carrier_config_mccmnc.xml
của một nhà mạng lại với nhau.
Sử dụng carrier_list.textpb
làm tham chiếu để liên kết thông tin MCC, MNC và MVNO với một nhà mạng cụ thể.
Hợp nhất các cấu hình thành một tệp.
(Không bắt buộc) Kế thừa dữ liệu từ các nhà mạng di động. MVNO kế thừa cấu hình từ MNO trong tệp carrier_config_mccmnc.xml
cũ. Vì mã nhận dạng nhà mạng cho phép tất cả nhà mạng, bao gồm cả MVNO, có một tệp cấu hình chuyên dụng, nên bạn nên đưa dữ liệu MNO vào trong quá trình di chuyển.
Nếu không có cấu hình cho mã nhà mạng MVNO, hãy tìm nạp cấu hình từ mã nhà mạng MNO bằng getCarrierIdFromSimMccMnc
.
Đổi tên tệp mới thành carrier_config_carrierid_carrierid_carriername.xml
, trong đó carrierid phải tương ứng với canonical_id
và carriername phải tương ứng với carrier_name
trong carrier_list.textpb
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[],[],null,["# Carrier identification\n\nDevices running Android 9 can recognize subscription\ncarrier information to\nprovide an ID and a carrier name. Android maintains a carrier ID database, with\nmatching rules for each carrier and its unique carrier ID. AOSP includes the\ncontent of the carrier ID database, in the file\n[`carrier_list.textpb`](https://android.googlesource.com/platform/packages/providers/TelephonyProvider/+/android16-release/assets/latest_carrier_id/carrier_list.textpb).\nThe unified database minimizes duplicate logic in apps that need to identify\ncarriers and limits the exposure of carrier-identifying attributes.\n\nTo improve the coverage and accuracy of carrier identification, Android supports\nout-of-band and carrier ID table updates. Each update comes with a version\nnumber and is published to AOSP.\n\nImplementation\n--------------\n\nUsers who want to implement out-of-band updates can download the\n[`carrier_list.pb`](https://android.googlesource.com/platform/packages/providers/TelephonyProvider/+/android16-release/assets/latest_carrier_id/carrier_list.pb)\nbinary from AOSP. To view the readable format of the table, see\n[`carrier_list.textpb`](https://android.googlesource.com/platform/packages/providers/TelephonyProvider/+/android16-release/assets/latest_carrier_id/carrier_list.textpb).\n\nPlace the carrier ID table in the `/data/misc/carrierid/` data partition of the\ndevice. If the carrier ID table is newer than the existing version, the device\npersists the table to the\n[carrier ID database class](https://developer.android.com/reference/android/provider/Telephony.CarrierId).\nThe most recent information from the carrier ID database is picked up by the\npublic methods\n[`getSimCarrierId()`](https://developer.android.com/reference/android/telephony/TelephonyManager#getSimCarrierId())\nand\n[`getSimCarrierIdName()`](https://developer.android.com/reference/android/telephony/TelephonyManager#getSimCarrierIdName()).\n\nAdd carrier ID information to the database\n------------------------------------------\n\nTo add or update a carrier ID to the database, submit a request using the\n[Carrier identification information form](https://docs.google.com/forms/d/1KjwTaExKRjkE9tbR9yavBrGzwvuz1dNku2Ae_7GrdUQ/viewform?edit_requested=true).\n\nYour request is reviewed and if approved, the change is pushed to the AOSP code\nbase at\n[`carrier_list.pb`](https://android.googlesource.com/platform/packages/providers/TelephonyProvider/+/android16-release/assets/latest_carrier_id/carrier_list.pb).\nYou can then copy the updated list and incorporate it into your customized\nbuild.\n\nIntegrate carrier IDs with CarrierConfig\n----------------------------------------\n\nStarting from Android 10,\n[carrier configuration](/docs/core/connect/carrier) supports\nusing carrier IDs as keys to fetch carrier-specific configurations from\n[`CarrierService`](https://developer.android.com/reference/android/service/carrier/CarrierService).\n\nIntegrating carrier IDs with `CarrierConfig` has the following advantages:\n\n- Consolidates all MCC/MNC pairs for each carrier into a single location removing duplicate or inconsistent data.\n- Creates a canonical identifier for each carrier and removes ambiguity.\n- Allows mobile virtual network operators (MVNOs) to be identified with individual IDs instead of having configurations as part of a mobile network operator (MNO).\n\n### Migrate configuration data to carrier IDs\n\nTo migrate configuration data from MCC/MNC pairs to carrier IDs, follow\nthese steps:\n\n1. Group the `carrier_config_mccmnc.xml` files from a single carrier together.\n Use\n [`carrier_list.textpb`](https://android.googlesource.com/platform/packages/providers/TelephonyProvider/+/android16-release/assets/latest_carrier_id/carrier_list.textpb)\n as a reference to map the MCC, MNC, and MVNO information to a particular\n carrier.\n\n2. Merge the configurations into a single file.\n\n3. (Optional) Inherit data from MNOs. MVNOs inherit configurations from\n MNOs in the legacy `carrier_config_mccmnc.xml` file. Because carrier IDs\n allow all carriers including MVNOs to have a dedicated config file, it's\n recommended to include MNO data during migration.\n\n4. If the configuration for an MVNO carrier ID doesn't exist, fetch the\n configuration from its MNO carrier ID using\n [`getCarrierIdFromSimMccMnc`](https://developer.android.com/reference/android/telephony/TelephonyManager#getCarrierIdFromSimMccMnc()).\n\n5. Rename the new file as\n `carrier_config_carrierid_`\u003cvar translate=\"no\"\u003ecarrierid\u003c/var\u003e`_`\u003cvar translate=\"no\"\u003ecarriername\u003c/var\u003e`.xml`\n where \u003cvar translate=\"no\"\u003ecarrierid\u003c/var\u003e must correspond to a `canonical_id` and\n \u003cvar translate=\"no\"\u003ecarriername\u003c/var\u003e should correspond to a `carrier_name` in\n [`carrier_list.textpb`](https://android.googlesource.com/platform/packages/providers/TelephonyProvider/+/android16-release/assets/latest_carrier_id/carrier_list.textpb)\n\n| **Note:** If a `carrier_config_mccmnc` file doesn't have a matching carrier ID, submit a request to add a carrier ID by following the steps in [Adding carrier ID information to the database](#adding_carrier_id_information_to_the_database)."]]