diff --git a/Parser/Device/AbstractDeviceParser.php b/Parser/Device/AbstractDeviceParser.php index 45e0c4898a..c45322ecac 100644 --- a/Parser/Device/AbstractDeviceParser.php +++ b/Parser/Device/AbstractDeviceParser.php @@ -2047,11 +2047,11 @@ abstract class AbstractDeviceParser extends AbstractParser protected static $clientHintFormFactorsMapping = [ 'automotive' => self::DEVICE_TYPE_CAR_BROWSER, 'xr' => self::DEVICE_TYPE_WEARABLE, - 'eink' => self::DEVICE_TYPE_TABLET, 'watch' => self::DEVICE_TYPE_WEARABLE, 'mobile' => self::DEVICE_TYPE_SMARTPHONE, 'tablet' => self::DEVICE_TYPE_TABLET, 'desktop' => self::DEVICE_TYPE_DESKTOP, + 'eink' => self::DEVICE_TYPE_TABLET, ]; /** @@ -2212,6 +2212,8 @@ public function parse(): ?array } if (empty($matches)) { + $this->deviceType = $resultClientHint['deviceType'] ?? null; + return $resultClientHint; } @@ -2294,21 +2296,19 @@ protected function buildModel(string $model, array $matches): string protected function parseClientHints(): ?array { if ($this->clientHints && $this->clientHints->getModel()) { - $deviceType = null; - $formFactors = $this->clientHints->getFormFactors(); + $detectedDeviceType = null; + $formFactors = $this->clientHints->getFormFactors(); - if (\count($formFactors) > 0) { - foreach (self::$clientHintFormFactorsMapping as $formFactor => $deviceTypeId) { - if (\array_key_exists($formFactor, $formFactors)) { - $deviceType = self::getDeviceName($deviceTypeId); + foreach (self::$clientHintFormFactorsMapping as $formFactor => $deviceType) { + if (\in_array($formFactor, $formFactors)) { + $detectedDeviceType = $deviceType; - break; - } + break; } } return [ - 'deviceType' => $deviceType, + 'deviceType' => $detectedDeviceType, 'model' => $this->clientHints->getModel(), 'brand' => '', ]; diff --git a/Tests/fixtures/unknown.yml b/Tests/fixtures/unknown.yml index c5f237c0a4..6cb6635139 100644 --- a/Tests/fixtures/unknown.yml +++ b/Tests/fixtures/unknown.yml @@ -3215,6 +3215,19 @@ browser_family: Chrome headers: http-x-requested-with: every.browser.inc +- + user_agent: Some Unknown UA + device: + type: "wearable" + brand: "" + model: "Some Unknown Model" + os: [ ] + client: null + os_family: Unknown + browser_family: Unknown + headers: + sec-ch-ua-form-factors: '"EInk", "Watch"' + sec-ch-ua-model: '"Some Unknown Model"' - user_agent: Microsoft Office Word/16.78.1008 (Desktop; Desktop app; Unknown/Unknown) os: [ ]