android 系统中修改系统的版本号

最近在做android 9.0的项目,发现在setting==》About==》status==>Version 中显示的Android 系统的版本号为9,看着很别扭。于是想要修改为9.0.0。

下面一步一步从setting app 里面找具体版本号最终是在哪设置的。

1.packages\apps\Settings\src\com\android\tv\settings\about\AboutFragment.java

  @Override
    public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
        setPreferencesFromResource(R.xml.device_info_settings, null);
        final PreferenceScreen screen = getPreferenceScreen();

        refreshDeviceName();
        final Preference deviceNamePref = findPreference(KEY_DEVICE_NAME);
        PreferenceUtils.resolveSystemActivityOrRemove(getActivity(), screen, deviceNamePref, 0);

        final Preference firmwareVersionPref = findPreference(KEY_FIRMWARE_VERSION);
        firmwareVersionPref.setSummary(Build.VERSION.RELEASE);  //从此处设置
        firmwareVersionPref.setEnabled(true);

2.frameworks\base\core\java\android\os\Build.java

   /** Various version strings. */
    public static class VERSION {
        /**
         * The internal value used by the underlying source control to
         * represent this build.  E.g., a perforce changelist number
         * or a git hash.
         */
        public static final String INCREMENTAL = getString("ro.build.version.incremental");

        /**
         * The user-visible version string.  E.g., "1.0" or "3.4b5".
         */
        public static final String RELEASE = getString("ro.build.version.release");  //此处调用设置

        /**
         * The base OS build the product is based on.
         *
         */
        public static final String BASE_OS = SystemProperties.get("ro.build.version.base_os", "");

        /**
         * The user-visible security patch level.
         */
        public static final String SECURITY_PATCH = SystemProperties.get(
                "ro.build.version.security_patch", "");



    private static String getString(String property) {
        return SystemProperties.get(property, UNKNOWN);  //而getstring是通过get properties 得到的。
    }
  1. 接下来就要找从哪里set的 ro.build.version.release属性

    build/make/tools/buildinfo.sh

echo "# begin build properties"
echo "# autogenerated by buildinfo.sh"
echo "ro.build.id=$BUILD_ID"
echo "ro.build.display.id=$BUILD_DISPLAY_ID"
echo "ro.build.version.incremental=$BUILD_NUMBER"
echo "ro.build.version.sdk=$PLATFORM_SDK_VERSION"
echo "ro.build.version.preview_sdk=$PLATFORM_PREVIEW_SDK_VERSION"
echo "ro.build.version.codename=$PLATFORM_VERSION_CODENAME"
echo "ro.build.version.all_codenames=$PLATFORM_VERSION_ALL_CODENAMES"
echo "ro.build.version.release=$PLATFORM_VERSION"   // 这里设置
echo "ro.build.version.security_patch=$PLATFORM_SECURITY_PATCH"
echo "ro.build.version.base_os=$PLATFORM_BASE_OS"

4. build / make/core/version_defaults.mk


DEFAULT_PLATFORM_VERSION := PPR1
MIN_PLATFORM_VERSION := PPR1
MAX_PLATFORM_VERSION := PPR1

ALLOWED_VERSIONS := $(call allowed-platform-versions,\
  $(MIN_PLATFORM_VERSION),\
  $(MAX_PLATFORM_VERSION),\
  $(DEFAULT_PLATFORM_VERSION))

ifndef TARGET_PLATFORM_VERSION
  TARGET_PLATFORM_VERSION := $(DEFAULT_PLATFORM_VERSION)
endif

ifeq (,$(filter $(ALLOWED_VERSIONS), $(TARGET_PLATFORM_VERSION)))
  $(warning Invalid TARGET_PLATFORM_VERSION '$(TARGET_PLATFORM_VERSION)', must be one of)
  $(error $(ALLOWED_VERSIONS))
endif

# Default versions for each TARGET_PLATFORM_VERSION
# TODO: PLATFORM_VERSION, PLATFORM_SDK_VERSION, etc. should be conditional
# on this

# This is the canonical definition of the platform version,
# which is the version that we reveal to the end user.
# Update this value when the platform version changes (rather
# than overriding it somewhere else).  Can be an arbitrary string.

# When you add a new PLATFORM_VERSION which will result in a new
# PLATFORM_SDK_VERSION please ensure you add a corresponding isAtLeast*
# method in the following java file:
# frameworks/support/compat/gingerbread/android/support/v4/os/BuildCompat.java

# When you change PLATFORM_VERSION for a given PLATFORM_SDK_VERSION
# please add that PLATFORM_VERSION as well as clean up obsolete PLATFORM_VERSION's
# in the following text file:
# cts/tests/tests/os/assets/platform_versions.txt
PLATFORM_VERSION.PPR1 := 9   // 找到,将此处修改为 9.0.0 即可
到此就可以修改android 系统的版本号
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

假装多好123

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值