我们手里有一份Android系统的源码,那你如果想知道这份源码是哪个版本的,该怎么办呢?

查找代码:

/build/core/version_defaults.mk

在文件中查找PLATFORM_VERSION,你就会发现如下段代码:

1
2
3
4
5
6
7
ifeq "" "$(PLATFORM_VERSION)"
# 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.
PLATFORM_VERSION := 7.0
endif

这里边的PLATFORM_VERSION := 7.0就是当前代码系统版本。

不同的版本代码稍有差别,但总体**PLATFORM_VERSION **这个关键字是没差别的,搜索就对了。

Android 10 源码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Note that there should be one PLATFORM_VERSION and PLATFORM_VERSION_CODENAME
# entry for each unreleased API level, regardless of
# MIN_PLATFORM_VERSION/MAX_PLATFORM_VERSION. PLATFORM_VERSION is used to
# generate the range of allowed SDK versions, so it must have an entry for every
# unreleased API level targetable by this branch, not just those that are valid
# lunch targets for this branch.
PLATFORM_VERSION.QP1A := 10

# These are the current development codenames, if the build is not a final
# release build. If this is a final release build, it is simply "REL".
PLATFORM_VERSION_CODENAME.QP1A := REL

ifndef PLATFORM_VERSION
PLATFORM_VERSION := $(PLATFORM_VERSION.$(TARGET_PLATFORM_VERSION))
ifndef PLATFORM_VERSION
# PLATFORM_VERSION falls back to TARGET_PLATFORM_VERSION
PLATFORM_VERSION := $(TARGET_PLATFORM_VERSION)
endif
endif
.KATI_READONLY := PLATFORM_VERSION

关键字PLATFORM_VERSION.QP1A := 10表明当前源码版本是Android 10的。