user版本修改Build number

在文件 `packages/apps/Settings/src/com/android/settings/DeviceInfoSettings.java` 中

setStringSummary("build_number", Build.DISPLAY);

指定了设置--关于设备--版本号。

Build.DISPLAY即Build类中的 DISPLAY 变量,在文件frameworks/base/core/java/android/os/Build.java 中:

public static final String DISPLAY = getString("ro.build.display.id");

ro.build.display.id在文件build/tools/buildinfo.sh中:

echo "ro.build.display.id=$BUILD_DISPLAY_ID"

而BUILD_DISPLAY_ID在文件build/core/Makefile中:

BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER)

其中 BUILD_ID在build/core/build_id.mk中赋值

BUILD_ID:=OPENMASTER

BUILD_NUMBER在 build/core/version_defaults.mk中赋值:

BUILD_NUMBER := eng.$(USER).$(shell date +%Y%m%d.%H%M%S)

所以在版本号中会出现编译时间的字段。

ro.build.display.id编译后保持在system下的build.prop文件


最终修改build/core/Makefile

# BUILD_DISPLAY_ID is shown under Settings -> About Phone
ifeq ($(TARGET_BUILD_VARIANT),user)
  # User builds should show:
  # release build number or branch.buld_number non-release builds

  # Dev. branches should have DISPLAY_BUILD_NUMBER set
  ifeq (true,$(DISPLAY_BUILD_NUMBER))
    BUILD_DISPLAY_ID := $(BUILD_DESC)
  else
    BUILD_DISPLAY_ID := $(BUILD_DESC)
  endif
else
  # Non-user builds should show detailed build information
  BUILD_DISPLAY_ID := $(BUILD_DESC)
endif

 

posted @ 2024-05-24 16:53  xiaowang_lj  阅读(18)  评论(0编辑  收藏  举报