天天看点

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 系统的版本号