Skip to content

Commit

Permalink
Detect OS HarmonyOS (#6861)
Browse files Browse the repository at this point in the history
* feat(os) detect OS HarmonyOS

issue 6832

* feat(os) added version detection for HarmonyOS and Detect device Honor30 for Huawei brand

* fix: test

Co-authored-by: Stefan Giehl <[email protected]>
  • Loading branch information
sanchezzzhak and sgiehl authored Sep 20, 2021
1 parent 043ddcc commit b6ce16a
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Parser/OperatingSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class OperatingSystem extends AbstractParser
'HPX' => 'HP-UX',
'HAI' => 'Haiku OS',
'IPA' => 'iPadOS',
'HAR' => 'HarmonyOS',
'HAS' => 'HasCodingOS',
'IRI' => 'IRIX',
'INF' => 'Inferno',
Expand Down Expand Up @@ -145,7 +146,7 @@ class OperatingSystem extends AbstractParser
* @var array
*/
protected static $osFamilies = [
'Android' => ['AND', 'CYN', 'FIR', 'REM', 'RZD', 'MLD', 'MCD', 'YNS', 'GRI'],
'Android' => ['AND', 'CYN', 'FIR', 'REM', 'RZD', 'MLD', 'MCD', 'YNS', 'GRI', 'HAR'],
'AmigaOS' => ['AMG', 'MOR'],
'BlackBerry' => ['BLB', 'QNX'],
'Brew' => ['BMP'],
Expand Down
2 changes: 1 addition & 1 deletion Tests/Parser/OperatingSystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,6 @@ public function testAllOperatingSystemsTested(): void
{
$allBrowsers = OperatingSystem::getAvailableOperatingSystems();
$osNotTested = \array_diff($allBrowsers, self::$osTested);
$this->assertEmpty($osNotTested, 'Following browsers are not tested: ' . \implode(', ', $osNotTested));
$this->assertEmpty($osNotTested, 'Following oss are not tested: ' . \implode(', ', $osNotTested));
}
}
8 changes: 8 additions & 0 deletions Tests/Parser/fixtures/oss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2391,3 +2391,11 @@
version: "15.0"
platform: ""
family: iOS
-
user_agent: Mozilla/5.0 (Linux; Android 10; HarmonyOS; TAS-AL00; HMSCore 6.0.1.306) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.93 HuaweiBrowser/11.1.2.301 Mobile Safari/537.36
os:
name: HarmonyOS
short_name: HAR
version: ""
platform: ""
family: Android
16 changes: 16 additions & 0 deletions Tests/fixtures/mobile_apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1215,3 +1215,19 @@
model: iPhone
os_family: iOS
browser_family: Unknown
-
user_agent: Mozilla/5.0 (Linux; Android 10; BMH-TN10 Build/HUAWEIBMH-TN10; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 Mobile Safari/537.36 T7/12.23 BDOS/1.0 (HarmonyOS 2.1.0) SP-engine/2.35.0 baiduboxapp/12.23.5.10 (Baidu; P1 10) NABar/1.0
os:
name: HarmonyOS
version: 2.1.0
platform: ""
client:
type: mobile app
name: Baidu Box App
version: 12.23.5.10
device:
type: smartphone
brand: Huawei
model: Honor 30
os_family: Android
browser_family: Unknown
2 changes: 1 addition & 1 deletion regexes/device/mobiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7182,7 +7182,7 @@ Huawei:
model: 'Honor 20 Pro'
- regex: '(MAR-LX1H|YAL-AL50)(?:[);/ ]|$)'
model: 'Honor 20S'
- regex: '(?:BMH-AN[12]0)(?:[);/ ]|$)'
- regex: 'BMH-(?:AN[12]0|TN10)(?:[);/ ]|$)'
model: 'Honor 30'
- regex: 'EBG-[AT]N00(?:[);/ ]|$)'
model: 'Honor 30 Pro'
Expand Down
4 changes: 4 additions & 0 deletions regexes/oss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@
##########
# Custom Android Roms
##########
- regex: 'HarmonyOS(?:[/ ](\d+[\.\d]+))?'
name: 'HarmonyOS'
version: '$1'

- regex: 'RazoDroiD(?: v(\d+[\.\d]*))?'
name: 'RazoDroiD'
version: '$1'
Expand Down

0 comments on commit b6ce16a

Please sign in to comment.