Skip to content

Commit

Permalink
feat(device) detect brand Lenovo: Tab M10 FHD Plus (TB-X606X, TB-X606…
Browse files Browse the repository at this point in the history
…F), Tab M10 (TB-X505X, TB-X505L)
  • Loading branch information
sanchezzzhak committed Dec 27, 2024
2 parents ab5d234 + 3669d0c commit 3ca5fa9
Show file tree
Hide file tree
Showing 12 changed files with 490 additions and 76 deletions.
44 changes: 11 additions & 33 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,48 +20,26 @@ permissions:
jobs:
build:
name: PHPUnit
runs-on: ${{ matrix.operating-system }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest]
php-version: ['7.2', '8.3']
os: [ubuntu-latest, windows-latest, macos-latest]
php-version: ['7.2', '8.4']
include:
- php-version: 7.3
operating-system: ubuntu-latest
os: ubuntu-latest
- php-version: 7.4
operating-system: ubuntu-latest
os: ubuntu-latest
- php-version: 8.0
operating-system: ubuntu-latest
os: ubuntu-latest
- php-version: 8.1
operating-system: ubuntu-latest
os: ubuntu-latest
- php-version: 8.2
operating-system: ubuntu-latest
os: ubuntu-latest
- php-version: 8.3
os: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer:v2
extensions: memcached
- name: "Composer install"
run: |
composer install --ignore-platform-reqs
composer require doctrine/cache ~1.2 --ignore-platform-reqs
- name: PHPUnit / PHP ${{ matrix.php-version }}
run: |
php -v
./vendor/bin/phpunit
build2:
name: PHPUnit
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [macOS-latest]
php-version: [ '7.2', '8.3' ]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion DeviceDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ 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$')) {
if ($this->matchUserAgent('Andr0id|(?:Android(?: UHD)?|(?<!Xming )Google) TV|\(lite\) TV|BRAVIA| TV$')) {
$this->device = AbstractDeviceParser::DEVICE_TYPE_TV;
}

Expand Down
8 changes: 7 additions & 1 deletion Parser/Device/AbstractDeviceParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,11 @@ abstract class AbstractDeviceParser extends AbstractParser
'ALS' => 'All Star',
'AA' => 'AllCall',
'3A' => 'AllDocube',
'ALL' => 'allente',
'A2' => 'Allview',
'ALI' => 'ALLINmobile',
'A7' => 'Allwinner',
'ALP' => 'alpsmart',
'A1' => 'Altech UEC',
'66' => 'Altice',
'ALM' => 'Altimo',
Expand Down Expand Up @@ -375,6 +377,7 @@ abstract class AbstractDeviceParser extends AbstractParser
'CY' => 'Coby Kyros',
'XC' => 'Cobalt',
'C6' => 'Comio',
'COM' => 'CommScope',
'CL' => 'Compal',
'CQ' => 'Compaq',
'C7' => 'ComTrade Tesla',
Expand Down Expand Up @@ -644,6 +647,7 @@ abstract class AbstractDeviceParser extends AbstractParser
'44' => 'Four Mobile',
'F0' => 'Fonos',
'F2' => 'FORME',
'FRM' => 'Formovie',
'F5' => 'Formuler',
'FR' => 'Forstar',
'RF' => 'Fortis',
Expand Down Expand Up @@ -737,6 +741,7 @@ abstract class AbstractDeviceParser extends AbstractParser
'GR1' => 'GroBerwert',
'GF' => 'Gretel',
'82' => 'Gresso',
'GRB' => 'Grünberg',
'GU' => 'Grundig',
'GV' => 'Gtel',
'CUO' => 'Guophone',
Expand Down Expand Up @@ -1189,6 +1194,7 @@ abstract class AbstractDeviceParser extends AbstractParser
'72' => 'M-Tech',
'9H' => 'M-Horse',
'MKP' => 'M-KOPA',
'MLB' => 'multibox',
'1R' => 'Multilaser',
'MPS' => 'MultiPOS',
'1M' => 'MYFON',
Expand Down Expand Up @@ -1299,7 +1305,7 @@ abstract class AbstractDeviceParser extends AbstractParser
'OQ' => 'Meta',
'O1' => 'Odys',
'ODP' => 'Odotpad',
'O9' => 'Ok',
'O9' => 'ok.',
'OKA' => 'Okapi',
'OA' => 'Okapia',
'OKI' => 'Oking',
Expand Down
10 changes: 5 additions & 5 deletions README.md

Large diffs are not rendered by default.

33 changes: 12 additions & 21 deletions Tests/DeviceDetectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,8 @@ public function testParse(array $fixtureData): void
$this->assertEquals($fixtureData, $uaInfo, $errorMessage);
}

public function getFixtures(): array
public function getFixtures(): \Generator
{
$fixtures = [];
$fixtureFiles = \glob(\realpath(__DIR__) . '/fixtures/*.yml');

foreach ($fixtureFiles as $fixturesPath) {
Expand All @@ -260,12 +259,10 @@ public function getFixtures(): array
continue;
}

$fixtures = \array_merge(\array_map(static function ($elem) {
return [$elem];
}, $typeFixtures), $fixtures);
foreach ($typeFixtures as $fixture) {
yield [$fixture];
}
}

return $fixtures;
}

/**
Expand Down Expand Up @@ -301,20 +298,17 @@ public function testParseClient(array $fixtureData): void
$this->assertEquals($fixtureData['client'], $uaInfo['client'], $messageError);
}

public function getFixturesClient(): array
public function getFixturesClient(): \Generator
{
$fixtures = [];
$fixtureFiles = \glob(\realpath(__DIR__) . '/Parser/Client/fixtures/*.yml');

foreach ($fixtureFiles as $fixturesPath) {
$typeFixtures = \Spyc::YAMLLoad($fixturesPath);

$fixtures = \array_merge(\array_map(static function ($elem) {
return [$elem];
}, $typeFixtures), $fixtures);
foreach ($typeFixtures as $fixture) {
yield [$fixture];
}
}

return $fixtures;
}

/**
Expand All @@ -341,20 +335,17 @@ public function testParseDevice(array $fixtureData): void
$this->assertEquals($fixtureData['device'], $uaInfo['device']);
}

public function getFixturesDevice(): array
public function getFixturesDevice(): \Generator
{
$fixtures = [];
$fixtureFiles = \glob(\realpath(__DIR__) . '/Parser/Device/fixtures/*.yml');

foreach ($fixtureFiles as $fixturesPath) {
$typeFixtures = \Spyc::YAMLLoad($fixturesPath);

$fixtures = \array_merge(\array_map(static function ($elem) {
return [$elem];
}, $typeFixtures), $fixtures);
foreach ($typeFixtures as $fixture) {
yield [$fixture];
}
}

return $fixtures;
}

public function getFixturesDeviceTypeFromClientHints(): array
Expand Down
36 changes: 36 additions & 0 deletions Tests/fixtures/peripheral.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1630,3 +1630,39 @@
model: MoGo Pro
os_family: Android
browser_family: Chrome
-
user_agent: Mozilla/5.0 (Linux; Android 11; Xming Google TV Build/RTM7.230903.079; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/129.0.6668.102 Mobile Safari/537.36
os:
name: Android TV
version: "11"
platform: ""
client:
type: browser
name: Chrome Webview
version: 129.0.6668.102
engine: Blink
engine_version: 129.0.6668.102
device:
type: peripheral
brand: Formovie
model: Xming
os_family: Android
browser_family: Chrome
-
user_agent: Mozilla/5.0 (Linux; Android 11; SCN550 Build/RTM6.230109.257; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/129.0.6668.102 Mobile Safari/537.36
os:
name: Android
version: "11"
platform: ""
client:
type: browser
name: Chrome Webview
version: 129.0.6668.102
engine: Blink
engine_version: 129.0.6668.102
device:
type: peripheral
brand: Philips
model: Screeneo U5
os_family: Android
browser_family: Chrome
72 changes: 72 additions & 0 deletions Tests/fixtures/tablet-12.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1367,3 +1367,75 @@
model: HI10
os_family: Android
browser_family: Unknown
-
user_agent: Mozilla/5.0 (Linux; Android 10; TB-X606X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Mobile Safari/537.36 EdgA/90.0.818.41
os:
name: Android
version: "10"
platform: ""
client:
type: browser
name: Microsoft Edge
version: 90.0.818.41
engine: Blink
engine_version: 90.0.4430.72
device:
type: tablet
brand: Lenovo
model: Tab M10 FHD Plus
os_family: Android
browser_family: Internet Explorer
-
user_agent: Mozilla/5.0 (Linux; Android 10; TB-X606F Build/QP1A.190711.020) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Mobile Safari/537.36 OPR/77.0.4054.90
os:
name: Android
version: "10"
platform: ""
client:
type: browser
name: Opera Mobile
version: 77.0.4054.90
engine: Blink
engine_version: 91.0.4472.101
device:
type: tablet
brand: Lenovo
model: Tab M10 FHD Plus
os_family: Android
browser_family: Opera
-
user_agent: Mozilla/5.0 (Linux; Android 10; TB-X505X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Mobile Safari/537.36
os:
name: Android
version: "10"
platform: ""
client:
type: browser
name: Chrome Mobile
version: 91.0.4472.101
engine: Blink
engine_version: 91.0.4472.101
device:
type: tablet
brand: Lenovo
model: Tab M10
os_family: Android
browser_family: Chrome
-
user_agent: Mozilla/5.0 (Linux; Android 10; TB-X505L) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Mobile Safari/537.36 OPR/76.0.4017.123
os:
name: Android
version: "10"
platform: ""
client:
type: browser
name: Opera Mobile
version: 76.0.4017.123
engine: Blink
engine_version: 90.0.4430.93
device:
type: tablet
brand: Lenovo
model: Tab M10
os_family: Android
browser_family: Opera
2 changes: 1 addition & 1 deletion Tests/fixtures/tv-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1911,7 +1911,7 @@
engine_version: 75.0.3770.143
device:
type: tv
brand: Ok
brand: ok.
model: 4K (2020)
os_family: Android
browser_family: Chrome
Expand Down
Loading

0 comments on commit 3ca5fa9

Please sign in to comment.