自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
個人化設定
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Android 設定應用程式會在 Android 8.0 中為使用者提供建議清單。這些建議通常會宣傳手機的功能,而且可以自訂 (例如「設定零打擾時間表」或「開啟 Wi-Fi 通話」)。這項功能會根據任何情境信號或使用者過去與建議內容的互動情形,為建議內容提供排名。
目前的 Android 開放原始碼計畫 (AOSP) 預設排名模型,是根據使用者先前與建議互動的情況而建立,這是透過邏輯迴歸訓練的簡單線性模型,可妥善權衡互動信號。預設實作方式會將顯示、點選或略過的建議視為指標,並搭配這些事件的近期性,為建議排序,提高預測使用者與這些建議互動的可能性。這個模型是使用有限量的記錄使用者資料建立。裝置製造商 (OEM) 可以根據任何收集到的資料,自行開發排名模型,並納入內容比對信號和校正排名。
實作
在 AOSP 中找出預設的 packages/apps/Settings/src/com/android/settings/dashboard/suggestions/SuggestionRanker.java
實作項目。
這項功能受到標記 isSmartSuggestionEnabled
的保護,預設為設為 false。如果已啟用 (設為 true),這項功能會使用預設的 AOSP 實作項目運作,無須額外修改。原始設備製造商 (OEM) 可以使用預設實作方式,也可以自行實作這項功能。
原始設備製造商 (OEM) 可以實作 platform/packages/apps/Settings/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProvider.java
功能,並覆寫檔案的 rankSuggestions
方法,藉此自訂這項功能。這個方法會取得兩個清單,其中包含建議方塊和對應的 suggestionId。此方法應只根據所需排名分數重新排序清單中的圖塊。視排名導入方式而定 (例如與此特定建議互動的最近時間),建議 ID 可用於明確識別建議,並擷取建議的必要過往資訊。
驗證
實作者可以編寫類似 packages/apps/Settings/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionRankerTest.java
的單元測試來驗證排名,確保功能的版本能正常運作。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。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,["# Personalized settings\n\nThe Android Settings app provides a list of suggestions to the users in Android 8.0.\nThese suggestions typically promote features of the phone, and they are customizable\n(e.g., \"Set Do Not Disturb schedule\" or \"Turn on Wi-Fi Calling\"). This feature provides\nranking for suggestions, based on any contextual signal or the user's past interactions\nwith suggestions.\n\n\nThe current default Android Open Source Project (AOSP) ranking model is based on\nuser's previous interactions with the suggestion, which is a simple linear model\ntrained with logistic regression to properly weight the interaction signals. The\ndefault implementation uses suggestions shown, clicked or dismissed as\nindicators along with the recency of these events to rank the suggestions and\nincrease the chance of predicting a user's interaction with these suggestions.\nThis model was built with a limited amount of logged user data. Device manufacturers\n(OEMs) can develop their own ranking model based on any collected data and potentially\ninclude contextual signals and calibrate the ranking.\n\nImplementation\n--------------\n\n\nFind the default `packages/apps/Settings/src/com/android/settings/dashboard/suggestions/SuggestionRanker.java` implementation in AOSP.\n\n\nThis feature is guarded by a flag, `isSmartSuggestionEnabled`, which\nis set to false by default. If enabled (set to true), the feature operates\nwithout additional modification using the default AOSP implementation. OEMs can\neither use the default implementation or introduce their own implementation to\nenable this feature.\n\n\nOEMs may customize the feature by implementing `platform/packages/apps/Settings/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProvider.java\n` feature and Overriding the file's `rankSuggestions` method.\nThis method gets two lists containing suggestion Tiles and the corresponding\nsuggestionIds. This method should reorder the tiles in the list only according\nto the desired ranking score. The suggestionIds can be used to uniquely identify\nsuggestions and extract the required past information about the suggestion,\ndepending on the ranking implementation (e.g., recency of interaction with this\nparticular suggestion).\n\nValidation\n----------\n\n\nImplementers can ensure their version of the feature works as intended by\nwriting their own unit tests similar to `packages/apps/Settings/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionRankerTest.java` to verify the ranking."]]