在 Android 中,系統屬性會儲存在 ConfigStore 類別中。ConfigStore 會使用建構標記,將設定值儲存在供應商分割區中,而系統分割區中的服務會使用 HIDL 存取這些值。
系統屬性會使用PRODUCT_DEFAULT_PROPERTY_OVERRIDES,將系統屬性儲存在供應商分割區的 default.prop 中,而服務會使用 sysprop 讀取這些屬性。
  ConfigStore HAL 仍保留在 AOSP 中,以支援舊版供應商分區。在搭載 Android 10 的裝置上,surfaceflinger 會先讀取系統屬性;如果 SurfaceFlingerProperties.sysprop 中沒有為設定項目定義任何系統屬性,surfaceflinger 就會改用 ConfigStore HAL。
建構旗標和系統屬性
ConfigStore 中的每個建構標記都有相應的系統屬性,如下表所示。
| 建構旗標 | 系統屬性 | 
|---|---|
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
    | 
  
新的系統屬性
Android 10 包含下列新的系統屬性:
ro.surface_flinger.default_composition_dataspacero.surface_flinger.default_composition_pixel_formatro.surface_flinger.use_color_managementro.surface_flinger.wcg_composition_dataspacero.surface_flinger.wcg_composition_pixel_formatro.surface_flinger.display_primary_redro.surface_flinger.display_primary_greenro.surface_flinger.display_primary_bluero.surface_flinger.display_primary_whitero.surface_flinger.protected_contentsro.surface_flinger.set_idle_timer_msro.surface_flinger.set_touch_timer_msro.surface_flinger.use_smart_90_for_videoro.surface_flinger.protected_contentsro.surface_flinger.support_kernel_idle_timer
  如要進一步瞭解這些屬性,請參閱 frameworks/native/services/surfaceflinger/sysprop/SurfaceFlingerProperties.sysprop。
使用 SurfaceFlingerProperties
  在 SurfaceFlingerProperties 程式庫的下列範例中,函式名稱為 SurfaceFlingerProperties.sysprop 中的 api_name。
cc_binary { name: "cc_client", srcs: ["baz.cpp"], shared_libs: ["SurfaceFlingerProperties"], } java_library { name: "JavaClient", srcs: ["foo/bar.java"], libs: ["SurfaceFlingerProperties"], }
import android.sysprop.SurfaceFlingerProperties; ... static void foo() { ... boolean temp = SurfaceFlingerProperties.vsync_event_phase_offset_ns().orElse(true); ... } ...
#include <SurfaceFlingerProperties.sysprop.h> using namespace android::sysprop; ... void bar() { ... bool temp = SurfaceFlingerProperties::vsync_event_phase_offset_ns(true); ... } ...