feat: detect HarmonyOS NEXT - #429
Merged
Merged
Conversation
Huawei's Android-free HarmonyOS (OpenHarmony 5+, ArkWeb) sends "(Phone; OpenHarmony 5.0) ... Mobile", "(Tablet; OpenHarmony 5.0)" or "(PC; OpenHarmony 5.0; HarmonyOS 5.0)". Phones were mobile with os unknown; tablets and PCs were desktop with no OS. All three now report os 'harmonyos' with the right type, and the harmonyos class branch follows device.type (new `harmonyos desktop` classes for PCs). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VR63CHdvbRNYKvpNqMWVdm
Closed
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes B1 from the project audit (搂3.3, the remaining Medium detection bug): Huawei's Android-free HarmonyOS NEXT (OpenHarmony 5 and later, ArkWeb engine) was not recognised. Its user agents have no
Androidand noHarmonyOStoken, onlyOpenHarmonyand a device-type token:(Phone; OpenHarmony 5.0) ... ArkWeb/4.1.6.1 Mobileunknown/mobile, classmobileharmonyos/mobile, classesharmonyos mobile(Tablet; OpenHarmony 5.0) ... ArkWeb/4.1.6.1unknown/desktop, classdesktopharmonyos/tablet, classesharmonyos tablet(PC; OpenHarmony 5.0; HarmonyOS 5.0) ...harmonyos/desktop, classesharmonyos mobileharmonyos/desktop, classesharmonyos desktopChanges
device.harmonyos()also matchesopenharmony.(Phone/Mobileand(Tablettokens and feeddevice.mobile()/device.tablet(). The Android-based HarmonyOS 2 to 4 keep going throughandroidPhone()/androidTablet();device.android()stays false for HarmonyOS NEXT.harmonyosclass branch now followsdevice.type(tablet, mobile, else the newharmonyos desktop), which also fixes the PC case above, where the classes disagreed with the type.Fixtures
Three new fixtures. The PC one is verbatim from the Matomo fixtures. The phone and tablet strings are Huawei's documented default user agent format (linked as
source); the Huawei developer site could not be reached from this environment to re-verify the page, so the fixture comment says they are the documented format rather than a capture. Theopenharmonytoken and the(Phone/(Tablet/(PCdevice-type tokens are the stable part of that format; the Chrome and ArkWeb versions vary.Test plan
pnpm run typecheck,pnpm run test(641 passed, 1 expected failure),pnpm run build,pnpm run test:dist(99 passed, 1 expected failure)pnpm run corpus: no change outside the OpenHarmony entries (89.1% type accuracy, Android groups unchanged)navigator.userAgentfrom it would confirm the phone/tablet strings馃 Generated with Claude Code
https://claude.ai/code/session_01VR63CHdvbRNYKvpNqMWVdm
Generated by Claude Code