Skip to content

Improve HarmonyOS Detection Code#59

Draft
victorbash400 wants to merge 2 commits into
devfrom
conversion/upstream-pr-59
Draft

Improve HarmonyOS Detection Code#59
victorbash400 wants to merge 2 commits into
devfrom
conversion/upstream-pr-59

Conversation

@victorbash400

@victorbash400 victorbash400 commented Jun 17, 2026

Copy link
Copy Markdown

Imported from upstream pull request fastfetch-cli/fastfetch pull request 2162: fastfetch-cli#2162

Original author: cyberMilosz
Original state: OPEN
Original labels: none
Original assignees: none


Summary

Current HarmonyOS detection code assumes that uname will accurately identify the OS. However, this is not the case on more recent emulators (as they seem to just use the Linux kernel):

# uname -a
Linux localhost 5.10.210 upstream issue 1 in fastfetch-cli/fastfetch SMP Tue Nov 11 15:26:56 CST 2025 x86_64

Real hardware still identifies itself correctly:

$ uname -a
HarmonyOS localhost HongMeng Kernel 1.10.5 upstream issue 1 in fastfetch-cli/fastfetch SMP Wed Dec 24 05:34:51 UTC 2025 aarch64

Instead of uname, we should rely on param output - we can get the OS name, version, API version, and security patch like so:

Emulator:

# param get const.product.os.dist.name
HarmonyOS
# param get const.product.os.dist.version
6.0.0
# param get const.product.incremental.version
6.0.1.112
# param get const.ohos.apiversion
21
# param get const.product.software.version.name
HarmonyOS NEXT Developer Beta1
# param get const.product.software.version
emulator 6.0.0.112(SP3DEVC00E112R4P11)
# param get const.ohos.version.security_patch
2025/11/01

Real hardware (note param get const.product.software.version.name appears to be a recent addition, so it's missing here):

$ param get const.product.os.dist.name
HarmonyOS
$ param get const.product.os.dist.version
5.1.0
$ param get const.product.incremental.version
5.1.1.208
$ param get const.ohos.apiversion
19
$ param get const.product.software.version.name
Get parameter "const.product.software.version.name" fail! errNum is:106!
$ param get const.product.software.version
TXZ-W10M 5.1.0.151(C00E151R4P1)
$ param get const.ohos.version.security_patch
2026/01/01

Tested on multiple Huawei emulators [6.0.1(21), 5.1.1(19), 5.1.0(18)] and a Huawei MatePad 11.5 running HarmonyOS 5.1.0.151

Example output from a current emulator:

image

Changes

  • Introduce HarmonyOS detection logic based on param output, falling back to existing uname logic as a last resort.

Checklist

  • I have tested my changes locally.

Existing code relied on `uname` accurately identifying itself as HarmonyOS, but Huawei's official emulators are still running the Linux kernel (unlike physical devices). This change adds support for identifying HarmonyOS 5+ and retrieving system parameters including version, build ID, and security patch date.
@victorbash400 victorbash400 added upstream-import Copied from the upstream repository. upstream-pr Copied from an upstream pull request. labels Jun 16, 2026
@victorbash400 victorbash400 changed the title [Upstream PR] Improve HarmonyOS Detection Code Improve HarmonyOS Detection Code Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

upstream-import Copied from the upstream repository. upstream-pr Copied from an upstream pull request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants