App 可以访问 Build.java 里面的变量获取系统相关信息,例如 Build.PRODUCT, Build.DEVICE等信息,
这个文件位置在 frameworks/base/core/java/android/os/Build.java :
/**
* Information about the current build, extracted from system properties.
*/
public class Build {
private static final String TAG = "Build";
/** Value used for when a build property is unknown. */
public static final String UNKNOWN = "unknown";
/** Either a changelist number, or a label like "M4-rc20". */
public static final String ID = getString("ro.build.id");
/** A build ID string meant for displaying to the user */
public static final String DISPLAY = getString("ro.build.display.id");
/** The name of the overall product. */
public static final String PRODUCT = getString("ro.product.name");
/** The name of the industrial design. */
public static final String DEVICE = getString("ro.product.device");
/** The name of the underlying board, like "goldfish". */
public static final String BOARD = getString("ro.product.board");
Build类调用 SystemProperties 类,然后调用 frameworks/base/core/jni/android_os_SystemProperties.cpp 文件,
jni中调用 property_get 函数, 在property_service.c中调用 __system_property_get函数,这个函数在bionic/libc/bionic/system_properties.c文件中
要扩展系统属性,需要编辑 device/xxxx/system.prop 文件。
读写属性的代码:system/core/init/property_service.c
属性权限定义:external/sepolicy/property_contexts