diff options
author | sgiehl <stefan@piwik.org> | 2014-02-13 14:05:44 +0400 |
---|---|---|
committer | sgiehl <stefan@piwik.org> | 2014-02-13 14:05:44 +0400 |
commit | 2e3b70c4900fd115de7a6173ce466074001410d4 (patch) | |
tree | 646d150b785a372ab15eae936f8cffde46560287 /plugins/DevicesDetection | |
parent | c463dadc2c2645c03d991490aaf95829d13edbd6 (diff) |
Improve device type detection for devices running android that couldn't be detected.
Devices running Android 3.X are always tablets, as that Android version was designed for tablets only
Devices running Android < 2 are smartphones, as the first tablets were running Android 2.X
Diffstat (limited to 'plugins/DevicesDetection')
-rw-r--r-- | plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php b/plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php index 72d6de19b8..0e51996f3d 100644 --- a/plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php +++ b/plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php @@ -507,6 +507,23 @@ class UserAgentParserEnhanced } else if (empty($this->device) && $this->isDesktop()) { $this->device = array_search('desktop', self::$deviceTypes); } + + /** + * Android up to 3.0 was designed for smartphones only. But as 3.0, which was tablet only, was published + * too late, there were a bunch of tablets running with 2.x + * With 4.0 the two trees were merged and it is for smartphones and tablets + * + * So were are expecting that all devices running Android < 2 are smartphones + * Devices running Android 3.X are tablets. Device type of Android 2.X and 4.X+ are unknown + */ + if (empty($this->device) && $this->getOs('short_name') == 'AND' && $this->getOs('version') != '') { + if (version_compare($this->getOs('version'), '2.0') == -1) { + $this->device = array_search('smartphone', self::$deviceTypes); + } else if (version_compare($this->getOs('version'), '3.0') >= 0 AND version_compare($this->getOs('version'), '4.0') == -1) { + $this->device = array_search('tablet', self::$deviceTypes); + } + } + if ($this->debug) { var_export($this->brand, $this->model, $this->device); } |