生成 build_fingerprint.txt
134# The string used to uniquely identify the combined build and product; used by the OTA server. 135ifeq (,$(strip $(BUILD_FINGERPRINT))) 136 ifneq ($(filter eng.%,$(BUILD_NUMBER)),) 137 # Trim down BUILD_FINGERPRINT: the default BUILD_NUMBER makes it easily exceed 138 # the Android system property length limit (PROPERTY_VALUE_MAX=92). 139 BF_BUILD_NUMBER := $(shell echo $${USER:0:6})$(shell $(DATE) +%m%d%H%M) 140 else 141 BF_BUILD_NUMBER := $(BUILD_NUMBER) 142 endif 143 BUILD_FINGERPRINT := $(PRODUCT_BRAND)/$(TARGET_PRODUCT)/$(TARGET_DEVICE):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BF_BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS) 144endif 145ifneq ($(words $(BUILD_FINGERPRINT)),1) 146 $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)") 147endif 148 149$(shell mkdir -p $(PRODUCT_OUT) && echo $(BUILD_FINGERPRINT) > $(PRODUCT_OUT)/build_fingerprint.txt) 150BUILD_FINGERPRINT_FROM_FILE := $$(cat $(PRODUCT_OUT)/build_fingerprint.txt)
build/tools/buildinfo.sh
59echo "ro.build.fingerprint=$BUILD_FINGERPRINT"
frameworks/base/core/java/android/os/Build.java
863 private static String deriveFingerprint() { 864 String finger = SystemProperties.get("ro.build.fingerprint"); 865 if (TextUtils.isEmpty(finger)) { 866 finger = getString("ro.product.brand") + '/' + 867 getString("ro.product.name") + '/' + 868 getString("ro.product.device") + ':' + 869 getString("ro.build.version.release") + '/' + 870 getString("ro.build.id") + '/' + 871 getString("ro.build.version.incremental") + ':' + 872 getString("ro.build.type") + '/' + 873 getString("ro.build.tags"); 874 } 875 return finger; 876 }
885 public static void ensureFingerprintProperty() { 886 if (TextUtils.isEmpty(SystemProperties.get("ro.build.fingerprint"))) { 887 try { 888 SystemProperties.set("ro.build.fingerprint", FINGERPRINT); 889 } catch (IllegalArgumentException e) { 890 Slog.e(TAG, "Failed to set fingerprint property", e); 891 } 892 } 893 }
最后在 cts/tests/tests/os/src/android/os/cts/BuildVersionTest.java 中,由于字串匹配失败,所以报错。
134# The string used to uniquely identify the combined build and product; used by the OTA server. 135ifeq (,$(strip $(BUILD_FINGERPRINT))) 136 ifneq ($(filter eng.%,$(BUILD_NUMBER)),) 137 # Trim down BUILD_FINGERPRINT: the default BUILD_NUMBER makes it easily exceed 138 # the Android system property length limit (PROPERTY_VALUE_MAX=92). 139 BF_BUILD_NUMBER := $(shell echo $${USER:0:6})$(shell $(DATE) +%m%d%H%M) 140 else 141 BF_BUILD_NUMBER := $(BUILD_NUMBER) 142 endif 143 BUILD_FINGERPRINT := $(PRODUCT_BRAND)/$(TARGET_PRODUCT)/$(TARGET_DEVICE):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BF_BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS) 144endif 145ifneq ($(words $(BUILD_FINGERPRINT)),1) 146 $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)") 147endif 148 149$(shell mkdir -p $(PRODUCT_OUT) && echo $(BUILD_FINGERPRINT) > $(PRODUCT_OUT)/build_fingerprint.txt) 150BUILD_FINGERPRINT_FROM_FILE := $$(cat $(PRODUCT_OUT)/build_fingerprint.txt) 151