Skip to content

Commit

Permalink
Improve peripheral detection
Browse files Browse the repository at this point in the history
  • Loading branch information
liviuconcioiu committed Dec 27, 2024
1 parent 11c2ea4 commit 4d5a40f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 26 deletions.
14 changes: 6 additions & 8 deletions DeviceDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -1070,15 +1070,13 @@ protected function parseDevice(): void
/**
* All devices that contain Andr0id in string are assumed to be a tv
*/
if ($this->matchUserAgent('Andr0id|(?:Android(?: UHD)?|Google) TV|\(lite\) TV|BRAVIA| TV$')) {
$this->device = AbstractDeviceParser::DEVICE_TYPE_TV;
}
$hasDeviceTvType = false === \in_array($this->device, [
AbstractDeviceParser::DEVICE_TYPE_TV,
AbstractDeviceParser::DEVICE_TYPE_PERIPHERAL,
]) && $this->matchUserAgent('Andr0id|(?:Android(?: UHD)?|Google) TV|\(lite\) TV|BRAVIA| TV$');

/**
* All devices that contain these fragments are assumed to be a peripheral
*/
if ($this->matchUserAgent('STI6110|Xming')) {
$this->device = AbstractDeviceParser::DEVICE_TYPE_PERIPHERAL;
if ($hasDeviceTvType) {
$this->device = AbstractDeviceParser::DEVICE_TYPE_TV;
}

/**
Expand Down
18 changes: 18 additions & 0 deletions Tests/fixtures/peripheral.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1684,3 +1684,21 @@
model: EF-100
os_family: Android
browser_family: Unknown
-
user_agent: Mozilla/5.0 (Linux; Android 10; XK03H Build/QX; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/126.0.6478.133 YaBrowser/24.1.2.221 (lite) TV Safari/537.36
os:
name: Android
version: "10"
platform: ""
client:
type: browser
name: Yandex Browser Lite
version: 24.1.2.221
engine: Blink
engine_version: 126.0.6478.133
device:
type: peripheral
brand: XGIMI
model: Horizon Pro
os_family: Android
browser_family: Unknown
18 changes: 0 additions & 18 deletions Tests/fixtures/tv-3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9165,24 +9165,6 @@
model: 43LE7052D
os_family: Android
browser_family: Chrome
-
user_agent: Mozilla/5.0 (Linux; Android 10; XK03H Build/QX; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/126.0.6478.133 YaBrowser/24.1.2.221 (lite) TV Safari/537.36
os:
name: Android
version: "10"
platform: ""
client:
type: browser
name: Yandex Browser Lite
version: 24.1.2.221
engine: Blink
engine_version: 126.0.6478.133
device:
type: tv
brand: XGIMI
model: Horizon Pro
os_family: Android
browser_family: Unknown
-
user_agent: Mozilla/5.0 (Linux; Android 10; SEI600GO) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Mobile Safari/537.36
os:
Expand Down

0 comments on commit 4d5a40f

Please sign in to comment.