diff options
-rw-r--r-- | plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php | 17 | ||||
-rw-r--r-- | tests/PHPUnit/Fixtures/userAgentParserEnhancedFixtures.yml | 30 |
2 files changed, 40 insertions, 7 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); } diff --git a/tests/PHPUnit/Fixtures/userAgentParserEnhancedFixtures.yml b/tests/PHPUnit/Fixtures/userAgentParserEnhancedFixtures.yml index cc4ca67d33..c274c1d1c4 100644 --- a/tests/PHPUnit/Fixtures/userAgentParserEnhancedFixtures.yml +++ b/tests/PHPUnit/Fixtures/userAgentParserEnhancedFixtures.yml @@ -8937,7 +8937,7 @@ short_name: AN version: device: - type: + type: tablet brand: model: os_family: Android @@ -8985,7 +8985,7 @@ short_name: AN version: device: - type: + type: tablet brand: model: os_family: Android @@ -9209,7 +9209,7 @@ short_name: AN version: device: - type: + type: tablet brand: model: os_family: Android @@ -9241,7 +9241,7 @@ short_name: AN version: device: - type: + type: tablet brand: model: os_family: Android @@ -9257,7 +9257,7 @@ short_name: AN version: device: - type: + type: tablet brand: model: os_family: Android @@ -9273,7 +9273,7 @@ short_name: AN version: device: - type: + type: tablet brand: model: os_family: Android @@ -9321,7 +9321,7 @@ short_name: AN version: device: - type: + type: tablet brand: model: os_family: Android @@ -16846,4 +16846,20 @@ brand: HT model: One os_family: Android + browser_family: Android Browser +- + user_agent: Mozilla/5.0 (Linux; U; Android 0.5; en-us) AppleWebKit/522+ (KHTML, like Gecko) Safari/419.3 + os: + name: Android + short_name: AND + version: 0.5 + browser: + name: Android Browser + short_name: AN + version: + device: + type: smartphone + brand: + model: + os_family: Android browser_family: Android Browser
\ No newline at end of file |