Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsgiehl <stefan@piwik.org>2014-02-13 14:05:44 +0400
committersgiehl <stefan@piwik.org>2014-02-13 14:05:44 +0400
commit2e3b70c4900fd115de7a6173ce466074001410d4 (patch)
tree646d150b785a372ab15eae936f8cffde46560287 /plugins
parentc463dadc2c2645c03d991490aaf95829d13edbd6 (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')
-rw-r--r--plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php17
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);
}