Android 10 因內存消耗大、使用困難而棄用了 ConfigStore HAL,並將 HAL 替換為系統屬性。在安卓 10 中:
- ConfigStore 使用構建標誌將配置值存儲在供應商分區中,系統分區中的服務使用 HIDL 訪問這些值(在 Android 9 中也是如此)。
- 系統屬性使用
PRODUCT_DEFAULT_PROPERTY_OVERRIDES
將系統屬性存儲在供應商分區的default.prop
中,服務使用sysprop
讀取這些屬性。
ConfigStore HAL 保留在 AOSP 中以支持舊的供應商分區。在運行 Android 10 的設備上, surfaceflinger
首先讀取系統屬性;如果在SurfaceFlingerProperties.sysprop
中沒有為配置項定義系統屬性, surfaceflinger
將回退到 ConfigStore HAL。
構建標誌和系統屬性
ConfigStore 中的每個構建標誌都有一個匹配的系統屬性,如下表所示。
構建標誌 | 系統屬性 |
---|---|
TARGET_ | ro. |
TARGET_ | ro. |
TARGET_ | ro. |
NUM_ | ro. |
MAX_ | ro. |
PRIMARY_ | ro. |
PRESENT_ | ro. |
TARGET_ | ro. |
SF_ | ro. |
TARGET_ | ro. |
USE_ | ro. |
VSYNC_ | ro. |
SF_ | ro. |
新系統屬性
Android 10 包括以下新系統屬性:
-
ro.surface_flinger.default_composition_dataspace
-
ro.surface_flinger.default_composition_pixel_format
-
ro.surface_flinger.use_color_management
-
ro.surface_flinger.wcg_composition_dataspace
-
ro.surface_flinger.wcg_composition_pixel_format
-
ro.surface_flinger.display_primary_red
-
ro.surface_flinger.display_primary_green
-
ro.surface_flinger.display_primary_blue
-
ro.surface_flinger.display_primary_white
-
ro.surface_flinger.protected_contents
-
ro.surface_flinger.set_idle_timer_ms
-
ro.surface_flinger.set_touch_timer_ms
-
ro.surface_flinger.use_smart_90_for_video
-
ro.surface_flinger.protected_contents
-
ro.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);
...
}
...