Skip to content

Commit 458850b

Browse files
Add support for OS.get_version_alias() on Android
1 parent 6c9765d commit 458850b

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

doc/classes/OS.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,9 @@
598598
<method name="get_version_alias" qualifiers="const">
599599
<return type="String" />
600600
<description>
601-
Returns the branded version used in marketing, followed by the build number (on Windows) or the version number (on macOS). Examples include [code]11 (build 22000)[/code] and [code]Sequoia (15.0.0)[/code]. This value can then be appended to [method get_name] to get a full, human-readable operating system name and version combination for the operating system. Windows feature updates such as 24H2 are not contained in the resulting string, but Windows Server is recognized as such (e.g. [code]2025 (build 26100)[/code] for Windows Server 2025).
602-
[b]Note:[/b] This method is only supported on Windows and macOS. On other operating systems, it returns the same value as [method get_version].
601+
Returns the branded version used in marketing, followed by the build number (on Windows), the version number (on macOS), or the SDK version and incremental build number (on Android). Examples include [code]11 (build 22000)[/code], [code]Sequoia (15.0.0)[/code], and [code]15 (SDK 35 build abc528-11988f)[/code].
602+
This value can then be appended to [method get_name] to get a full, human-readable operating system name and version combination for the operating system. Windows feature updates such as 24H2 are not contained in the resulting string, but Windows Server is recognized as such (e.g. [code]2025 (build 26100)[/code] for Windows Server 2025).
603+
[b]Note:[/b] This method is only supported on Windows, macOS, and Android. On other operating systems, it returns the same value as [method get_version].
603604
</description>
604605
</method>
605606
<method name="get_video_adapter_driver_info" qualifiers="const">

platform/android/os_android.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,14 @@ String OS_Android::get_version() const {
327327
return "";
328328
}
329329

330+
String OS_Android::get_version_alias() const {
331+
String release = get_system_property("ro.build.version.release_or_codename");
332+
String sdk_version = get_system_property("ro.build.version.sdk");
333+
String build = get_system_property("ro.build.version.incremental");
334+
335+
return vformat("%s (SDK %s build %s)", release, sdk_version, build);
336+
}
337+
330338
MainLoop *OS_Android::get_main_loop() const {
331339
return main_loop;
332340
}

platform/android/os_android.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ class OS_Android : public OS_Unix {
123123
virtual String get_name() const override;
124124
virtual String get_distribution_name() const override;
125125
virtual String get_version() const override;
126+
virtual String get_version_alias() const override;
127+
126128
virtual MainLoop *get_main_loop() const override;
127129

128130
void main_loop_begin();

0 commit comments

Comments
 (0)