自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
SurfaceFlinger 中的系統屬性
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
ConfigStore HAL 仍會保留在 AOSP 中,以支援舊版供應商分區。在執行 Android 10 以上版本的裝置上,surfaceflinger
會先讀取系統屬性;如果 SurfaceFlingerProperties.sysprop
中沒有為設定項目定義系統屬性,surfaceflinger
會改用 ConfigStore HAL。
建構旗標和系統屬性
ConfigStore 中的每個建構標記都有對應的系統屬性,如下表所示。如要進一步瞭解這些屬性,請參閱 frameworks/native/services/surfaceflinger/sysprop/SurfaceFlingerProperties.sysprop
。
建構旗標 |
系統屬性 |
TARGET_FORCE_HWC_FOR_VIRTUAL_DISPLAYS
|
ro.surface_flinger.force_hwc_copy_for_virtual_displays
|
TARGET_HAS_HDR_DISPLAY
|
ro.surface_flinger.has_HDR_display
|
TARGET_HAS_WIDE_COLOR_DISPLAY
|
ro.surface_flinger.has_wide_color_display
|
NUM_FRAMEBUFFER_SURFACE_BUFFERS
|
ro.surface_flinger.max_frame_buffer_acquired_buffers
|
MAX_VIRTUAL_DISPLAY_DIMENSION
|
ro.surface_flinger.max_virtual_display_dimension
|
PRIMARY_DISPLAY_ORIENTATION
|
ro.surface_flinger.primary_display_orientation
|
PRESENT_TIME_OFFSET_FROM_VSYNC_NS
|
ro.surface_flinger.present_time_offset_from_vsync_ns
|
TARGET_RUNNING_WITHOUT_SYNC_FRAMEWORK
|
ro.surface_flinger.running_without_sync_framework
|
SF_START_GRAPHICS_ALLOCATOR_SERVICE
|
ro.surface_flinger.start_graphics_allocator_service
|
TARGET_USE_CONTEXT_PRIORITY
|
ro.surface_flinger.use_context_priority
|
USE_VR_FLINGER
|
ro.surface_flinger.use_vr_flinger
|
VSYNC_EVENT_PHASE_OFFSET_NS
|
ro.surface_flinger.vsync_event_phase_offset_ns
|
SF_VSYNC_EVENT_PHASE_OFFSET_NS
|
ro.surface_flinger.vsync_sf_event_phase_offset_ns
|
使用 SurfaceFlingerProperties
以下範例說明如何使用 SurfaceFlingerProperties 程式庫和 Surface Flinger 屬性 ro.surface_flinger.vsync_event_phase_offset_ns
。
如要查詢參照中的屬性值,請使用屬性的 api_name
做為函式名稱。
在建構檔案中加入 SurfaceFlingerProperties
,如下所示:
cc_binary {
name: "cc_client",
srcs: ["baz.cpp"],
shared_libs: ["SurfaceFlingerProperties"],
}
java_library {
name: "JavaClient",
srcs: ["foo/bar.java"],
libs: ["SurfaceFlingerProperties"],
}
下列 Java 程式碼片段使用 ro.surface_flinger.vsync_event_phase_offset_ns
系統屬性:
import android.sysprop.SurfaceFlingerProperties;
...
static void foo() {
...
boolean temp = SurfaceFlingerProperties.vsync_event_phase_offset_ns().orElse(true);
...
}
...
以下 C++ 程式碼片段使用 ro.surface_flinger.vsync_event_phase_offset_ns
系統屬性:
#include <SurfaceFlingerProperties.sysprop.h>
using namespace android::sysprop;
...
void bar() {
...
bool temp = SurfaceFlingerProperties::vsync_event_phase_offset_ns(true);
...
}
...
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。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,["# System properties in SurfaceFlinger\n\nThe ConfigStore HAL remains in AOSP to support legacy vendor partitions. On\ndevices running Android 10+, `surfaceflinger` reads\nsystem properties first; if no system property is defined for a config item in\n`SurfaceFlingerProperties.sysprop`, `surfaceflinger` falls back to the\nConfigStore HAL.\n\nBuild flags and system properties\n---------------------------------\n\nEach build flag in ConfigStore has a matching system property, as shown in the\nfollowing table. For details on these properties, refer to `frameworks/native/services/surfaceflinger/sysprop/SurfaceFlingerProperties.sysprop`.\n\n| Build flags | System properties |\n|-----------------------------------------|----------------------------------------------------------|\n| `TARGET_FORCE_HWC_FOR_VIRTUAL_DISPLAYS` | `ro.surface_flinger.force_hwc_copy_for_virtual_displays` |\n| `TARGET_HAS_HDR_DISPLAY` | `ro.surface_flinger.has_HDR_display` |\n| `TARGET_HAS_WIDE_COLOR_DISPLAY` | `ro.surface_flinger.has_wide_color_display` |\n| `NUM_FRAMEBUFFER_SURFACE_BUFFERS` | `ro.surface_flinger.max_frame_buffer_acquired_buffers` |\n| `MAX_VIRTUAL_DISPLAY_DIMENSION` | `ro.surface_flinger.max_virtual_display_dimension` |\n| `PRIMARY_DISPLAY_ORIENTATION` | `ro.surface_flinger.primary_display_orientation` |\n| `PRESENT_TIME_OFFSET_FROM_VSYNC_NS` | `ro.surface_flinger.present_time_offset_from_vsync_ns` |\n| `TARGET_RUNNING_WITHOUT_SYNC_FRAMEWORK` | `ro.surface_flinger.running_without_sync_framework` |\n| `SF_START_GRAPHICS_ALLOCATOR_SERVICE` | `ro.surface_flinger.start_graphics_allocator_service` |\n| `TARGET_USE_CONTEXT_PRIORITY` | `ro.surface_flinger.use_context_priority` |\n| `USE_VR_FLINGER` | `ro.surface_flinger.use_vr_flinger` |\n| `VSYNC_EVENT_PHASE_OFFSET_NS` | `ro.surface_flinger.vsync_event_phase_offset_ns` |\n| `SF_VSYNC_EVENT_PHASE_OFFSET_NS` | `ro.surface_flinger.vsync_sf_event_phase_offset_ns` |\n\nUsing SurfaceFlingerProperties\n------------------------------\n\nThe following examples show how to use the SurfaceFlingerProperties library and\nthe Surface Flinger property `ro.surface_flinger.vsync_event_phase_offset_ns`.\n\nTo query for the value of the property in reference, use the property's\n`api_name` as the function name.\n\nInclude `SurfaceFlingerProperties` in your build file, as follows: \n\n```carbon\ncc_binary {\n name: \"cc_client\",\n srcs: [\"baz.cpp\"],\n shared_libs: [\"SurfaceFlingerProperties\"],\n}\njava_library {\n name: \"JavaClient\",\n srcs: [\"foo/bar.java\"],\n libs: [\"SurfaceFlingerProperties\"],\n}\n```\n\nThe following Java code snippet uses the `ro.surface_flinger.vsync_event_phase_offset_ns`\nsystem property: \n\n```python\nimport android.sysprop.SurfaceFlingerProperties;\n...\n\nstatic void foo() {\n ...\n boolean temp = SurfaceFlingerProperties.vsync_event_phase_offset_ns().orElse(true);\n ...\n}\n...\n```\n\nThe following C++ code snippet uses the `ro.surface_flinger.vsync_event_phase_offset_ns`\nsystem property: \n\n```arduino\n#include \u003cSurfaceFlingerProperties.sysprop.h\u003e\nusing namespace android::sysprop;\n\n...\n\nvoid bar() {\n ...\n bool temp = SurfaceFlingerProperties::vsync_event_phase_offset_ns(true);\n ...\n}\n...\n```"]]