瀏覽代碼

Merge pull request #106859 from syntaxerror247/alias

Add support for `OS.get_version_alias()` on Android
Thaddeus Crews 3 月之前
父節點
當前提交
9ee7d78274
共有 3 個文件被更改,包括 13 次插入2 次删除
  1. 3 2
      doc/classes/OS.xml
  2. 8 0
      platform/android/os_android.cpp
  3. 2 0
      platform/android/os_android.h

+ 3 - 2
doc/classes/OS.xml

@@ -598,8 +598,9 @@
 		<method name="get_version_alias" qualifiers="const">
 		<method name="get_version_alias" qualifiers="const">
 			<return type="String" />
 			<return type="String" />
 			<description>
 			<description>
-				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).
-				[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].
+				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].
+				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).
+				[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].
 			</description>
 			</description>
 		</method>
 		</method>
 		<method name="get_video_adapter_driver_info" qualifiers="const">
 		<method name="get_video_adapter_driver_info" qualifiers="const">

+ 8 - 0
platform/android/os_android.cpp

@@ -327,6 +327,14 @@ String OS_Android::get_version() const {
 	return "";
 	return "";
 }
 }
 
 
+String OS_Android::get_version_alias() const {
+	String release = get_system_property("ro.build.version.release_or_codename");
+	String sdk_version = get_system_property("ro.build.version.sdk");
+	String build = get_system_property("ro.build.version.incremental");
+
+	return vformat("%s (SDK %s build %s)", release, sdk_version, build);
+}
+
 MainLoop *OS_Android::get_main_loop() const {
 MainLoop *OS_Android::get_main_loop() const {
 	return main_loop;
 	return main_loop;
 }
 }

+ 2 - 0
platform/android/os_android.h

@@ -123,6 +123,8 @@ public:
 	virtual String get_name() const override;
 	virtual String get_name() const override;
 	virtual String get_distribution_name() const override;
 	virtual String get_distribution_name() const override;
 	virtual String get_version() const override;
 	virtual String get_version() const override;
+	virtual String get_version_alias() const override;
+
 	virtual MainLoop *get_main_loop() const override;
 	virtual MainLoop *get_main_loop() const override;
 
 
 	void main_loop_begin();
 	void main_loop_begin();