最近在做android 9.0的项目,发现在setting==》About==》status==>Version 中显示的Android 系统的版本号为9,看着很别扭。于是想要修改为9.0.0。
下面一步一步从setting app 里面找具体版本号最终是在哪设置的。
1.packages\apps\Settings\src\com\android\tv\settings\about\
@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\
/** Various version strings. */
public static class VERSION {
/**
* The internal value used by the underlying source control to
* represent this build. ., a perforce changelist number
* or a git hash.
*/
public static final String INCREMENTAL = getString("");
/**
* The user-visible version string. ., "1.0" or "3.4b5".
*/
public static final String RELEASE = getString(""); //此处调用设置
/**
* The base OS build the product is based on.
*
*/
public static final String BASE_OS = SystemProperties.get(".base_os", "");
/**
* The user-visible security patch level.
*/
public static final String SECURITY_PATCH = SystemProperties.get(
".security_patch", "");
private static String getString(String property) {
return SystemProperties.get(property, UNKNOWN); //而getstring是通过get properties 得到的。
}
-
接下来就要找从哪里set的
属性
build/make/tools/
echo "# begin build properties"
echo "# autogenerated by "
echo "=$BUILD_ID"
echo "=$BUILD_DISPLAY_ID"
echo "=$BUILD_NUMBER"
echo "=$PLATFORM_SDK_VERSION"
echo ".preview_sdk=$PLATFORM_PREVIEW_SDK_VERSION"
echo "=$PLATFORM_VERSION_CODENAME"
echo ".all_codenames=$PLATFORM_VERSION_ALL_CODENAMES"
echo "=$PLATFORM_VERSION" // 这里设置
echo ".security_patch=$PLATFORM_SECURITY_PATCH"
echo ".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 即可