自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
實作已簽署的設定
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
簽署設定功能可讓您在 APK 中嵌入非 SDK 介面限制的設定。這樣一來,您就能從黑名單中移除特定非 SDK 介面,讓 AndroidX 安全地使用這些介面。這可讓 AndroidX 團隊在已發布的 Android 版本中新增支援新功能。此功能支援 Android 10 以上版本。
正確支援已簽署的設定檔,可確保 AndroidX 程式庫日後能在裝置上正常運作。
無法自訂這項功能。AOSP 完全支援這項功能,且無須原始設備製造商 (OEM) 提供支援。
範例和來源
功能實作項目位於 frameworks/base/services/core/java/com/android/server/signedconfig
的系統伺服器中。CTS 測試 CtsSignedConfigHostTestCases
包含範例用法,以及 cts/hostsidetests/signedconfig/app/version1_AndroidManifest.xml
中的範例設定。
實作
您無須特別支援這項功能,也沒有特定的硬體需求。
這項功能會使用兩個應用程式中繼資料鍵,在 APK 中嵌入設定和簽名。這些金鑰分別是 android.settings.global
和 android.settings.global.signature
。如果或當 AndroidX 程式庫日後需要將非 SDK 介面從黑名單中移除時,這些鍵的值將由 Android 團隊和/或 AndroidX 發布。
APK 中繼資料鍵 android.settings.global
和 android.settings.global.signature
都包含以 Base-64 編碼的資料。鍵 android.settings.global
的值是 JSON 編碼設定值,會套用至 SettingsProvider
中的全域設定。android.settings.global.signature
的值是 JSON 資料的 ECDSA-p256 簽署。簽名可用於驗證設定資料的來源。
使用者無法看到這項功能。
自訂
這項功能不提供自訂選項。我們不鼓勵原始設備製造商修改這項功能,包括替換按鍵。任何變更都可能導致 AndroidX 在受影響的裝置上無法正常運作。
驗證
CTS 測試 CtsSignedConfigHostTestCases
會驗證功能實作方式。
您也可以安裝適當的 APK 並檢查 adb logcat
輸出內容,手動測試這項功能:
$ adb install CtsSignedConfigTestAppV1.apk
...
$ adb logcat
...
I SignedConfig: Verified config using production key
...
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間: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"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Implement Signed Config\n\nThe Signed Config feature allows embedding configuration of non-SDK interface restrictions\nin APKs. This allows removing specific non-SDK interfaces from the blacklist, to\nallow AndroidX to safely use them. This allows the AndroidX team to add support\nfor new features on Android versions that have already been released. It is\nsupported in Android 10 and later.\n\nProperly supporting Signed Config ensures that the AndroidX libraries will\nfunction correctly on devices in the future.\n\nNo customization of this feature is possible. It is fully supported in AOSP and\nrequires no OEM effort to support it.\n\nExamples and source\n-------------------\n\nThe feature implementation is in the system server at\n`frameworks/base/services/core/java/com/android/server/signedconfig`. The CTS\ntest `CtsSignedConfigHostTestCases` includes example usage, and an example\nconfiguration in\n`cts/hostsidetests/signedconfig/app/version1_AndroidManifest.xml`.\n\nImplementation\n--------------\n\nNo effort is required to support the feature, and there are no specific hardware\nrequirements.\n\nThe feature uses two application metadata keys to embed configuration and a\nsignature inside APKs. Those keys are `android.settings.global` and\n`android.settings.global.signature`. If or when the AndroidX libraries require\nnon-SDK interfaces to be removed from the blacklist in the future, values for\nthese keys will be published by the Android team and/or as part of AndroidX.\n\nThe APK metadata keys `android.settings.global` and\n`android.settings.global.signature` both contain base-64 encoded data. The value\nfor key `android.settings.global` is JSON-encoded config values to be applied to\nthe global settings in `SettingsProvider`. The value for\n`android.settings.global.signature` is an ECDSA-p256 signature of the JSON data.\nThe signature is used to verify the origin of the configuration data.\n\nThe feature isn't user visible.\n\nCustomization\n-------------\n\nThe feature isn't intended for customization. OEMs are discouraged from\nmodifying the feature, including replacing the keys. Any changes to it are\nlikely to cause AndroidX to not function properly on affected devices in the\nfuture.\n\nValidation\n----------\n\nThe CTS test `CtsSignedConfigHostTestCases` verifies the feature implementation.\n\nYou can also test the feature manually by installing an appropriate APK and\ninspecting the `adb logcat` output: \n\n $ adb install CtsSignedConfigTestAppV1.apk\n ...\n $ adb logcat\n ...\n I SignedConfig: Verified config using production key\n ..."]]