Skip to content

Commit

Permalink
Merge pull request #5479 from piwik/develop
Browse files Browse the repository at this point in the history
Detect Web TV as model instead of brand
  • Loading branch information
sgiehl committed Mar 31, 2016
2 parents e58f96b + ad265db commit 4f4c2b0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DeviceDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class DeviceDetector
/**
* Current version number of DeviceDetector
*/
const VERSION = '3.6.0';
const VERSION = '3.6.1';

/**
* Holds all registered client types
Expand Down
18 changes: 11 additions & 7 deletions Parser/Device/DeviceParserAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@ abstract class DeviceParserAbstract extends ParserAbstract
'VZ' => 'Vizio',
'VW' => 'Videoweb',
'WA' => 'Walton',
'WB' => 'Web TV',
'WE' => 'WellcoM',
'WY' => 'Wexler',
'WI' => 'Wiko',
Expand All @@ -353,7 +352,6 @@ abstract class DeviceParserAbstract extends ParserAbstract
'WX' => 'Woxter',
'XI' => 'Xiaomi',
'XO' => 'Xolo',
'XX' => 'Unknown',
'YA' => 'Yarvik',
'YU' => 'Yuandao',
'YS' => 'Yusun',
Expand All @@ -362,6 +360,10 @@ abstract class DeviceParserAbstract extends ParserAbstract
'ZO' => 'Zonda',
'ZP' => 'Zopo',
'ZT' => 'ZTE',

// legacy brands, might be removed in future versions
'WB' => 'Web TV',
'XX' => 'Unknown'
);

public function getDeviceType()
Expand Down Expand Up @@ -462,12 +464,14 @@ public function parse()
return false;
}

$brandId = array_search($brand, self::$deviceBrands);
if ($brandId === false) {
// This Exception should never be thrown. If so a defined brand name is missing in $deviceBrands
throw new \Exception("The brand with name '$brand' should be listed in the deviceBrands array."); // @codeCoverageIgnore
if ($brand != 'Unknown') {
$brandId = array_search($brand, self::$deviceBrands);
if ($brandId === false) {
// This Exception should never be thrown. If so a defined brand name is missing in $deviceBrands
throw new \Exception("The brand with name '$brand' should be listed in the deviceBrands array."); // @codeCoverageIgnore
}
$this->brand = $brandId;
}
$this->brand = $brandId;

if (isset($regex['device']) && in_array($regex['device'], self::$deviceTypes)) {
$this->deviceType = self::$deviceTypes[$regex['device']];
Expand Down
2 changes: 1 addition & 1 deletion Tests/Parser/Devices/DeviceParserAbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testGetAvailableDeviceTypeNames()
public function testGetFullName()
{
$this->assertEquals('', DeviceParserAbstract::getFullName('Invalid'));
$this->assertEquals('Unknown', DeviceParserAbstract::getFullName('XX'));
$this->assertEquals('Asus', DeviceParserAbstract::getFullName('AU'));
$this->assertEquals('Google', DeviceParserAbstract::getFullName('GO'));
}
}
4 changes: 2 additions & 2 deletions Tests/fixtures/tv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2557,7 +2557,7 @@
engine: Trident
device:
type: tv
brand: WB
model:
brand:
model: Web TV
os_family: WebTV
browser_family: Internet Explorer
6 changes: 3 additions & 3 deletions regexes/device/mobiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4673,11 +4673,11 @@ Fly:
- regex: 'MERIDIAN-([a-z0-9]+)'
model: '$1'

# Web TV
Web TV:
# Devices with undectable brand, but detectable model
Unknown:
regex: 'WebTV/(\d+\.\d+)'
device: 'tv'
model: ''
model: 'Web TV'

# Zeemi
Zeemi:
Expand Down

0 comments on commit 4f4c2b0

Please sign in to comment.