Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Improves detection for wearable devices #7608

Merged
merged 5 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion DeviceDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,18 @@ protected function hasAndroidMobileFragment(): bool
return !!$this->matchUserAgent($regex);
}

/**
* Returns if the parsed UA contains the 'Android; Mobile VR;' fragment
*
* @return bool
*/
protected function hasAndroidVRFragment(): bool
{
$regex = 'Android( [\.0-9]+)?; Mobile VR;| VR ';

return !!$this->matchUserAgent($regex);
}

/**
* Returns if the parsed UA contains the 'Desktop;', 'Desktop x32;', 'Desktop x64;' or 'Desktop WOW64;' fragment
*
Expand Down Expand Up @@ -935,7 +947,7 @@ protected function parseDevice(): void
/**
* All devices containing VR fragment are assumed to be a wearable
*/
if (null === $this->device && $this->matchUserAgent(' VR ')) {
if (null === $this->device && $this->hasAndroidVRFragment()) {
$this->device = AbstractDeviceParser::DEVICE_TYPE_WEARABLE;
}

Expand Down
18 changes: 18 additions & 0 deletions Tests/fixtures/wearable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2279,3 +2279,21 @@
model: Neo 3 Link
os_family: Android
browser_family: Chrome
-
user_agent: Mozilla/5.0 (Android 12; Mobile VR; rv:81.0) Gecko/81.0 Firefox/81.0
os:
name: Android
version: "12"
platform: ""
client:
type: browser
name: Firefox Reality
version: ""
engine: Gecko
engine_version: "81.0"
device:
type: wearable
brand: ""
model: ""
os_family: Android
browser_family: Firefox
Loading