diff --git a/Parser/Device/AbstractDeviceParser.php b/Parser/Device/AbstractDeviceParser.php index cf1d19ae98..3e41bb8d37 100644 --- a/Parser/Device/AbstractDeviceParser.php +++ b/Parser/Device/AbstractDeviceParser.php @@ -2153,7 +2153,7 @@ public function parse(): ?array $deviceModel = $resultClientHint['model'] ?? ''; // is freeze user-agent then restoring the original UA for the device definition - if ('' !== $deviceModel && \preg_match('~Android 10[.\d]*; K(?: Build/|[;)])~i', $this->userAgent)) { + if ('' !== $deviceModel && $this->hasUserAgentClientHintsFragment()) { $osVersion = $this->clientHints ? $this->clientHints->getOperatingSystemVersion() : ''; $this->setUserAgent((string) \preg_replace( '(Android 10[.\d]*; K)', @@ -2162,6 +2162,10 @@ public function parse(): ?array )); } + if ('' === $deviceModel && $this->hasUserAgentClientHintsFragment()) { + return $this->getResult(); + } + if ('' === $deviceModel && $this->hasDesktopFragment()) { return $this->getResult(); } @@ -2301,6 +2305,16 @@ protected function hasDesktopFragment(): bool !$this->matchUserAgent($regexExcludeDesktopFragment); } + /** + * Returns if the parsed UA contains the 'Android 10 K;' or Android 10 K Build/` fragment + * + * @return bool + */ + protected function hasUserAgentClientHintsFragment(): bool + { + return (bool) \preg_match('~Android 10[.\d]*; K(?: Build/|[;)])~i', $this->userAgent); + } + /** * Resets the stored values */