Skip to content

Commit

Permalink
detect windows 8 (RT) devices having a 'Touch' token within the usera…
Browse files Browse the repository at this point in the history
…gent as tablets, as most touch enabled devices running windows 8 should be tablets (instead of desktops)
  • Loading branch information
sgiehl committed Feb 28, 2014
1 parent 3055a65 commit 729253e
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,19 @@ public function parse()
}
}

/**
* According to http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx
* Internet Explorer 10 introduces the "Touch" UA string token. If this token is present at the end of the
* UA string, the computer has touch capability, and is running Windows 8 (or later).
* This UA string will be transmitted on a touch-enabled system running Windows 8 (RT)
*
* As most touch enabled devices are tablets and only a smaller part are desktops/notebooks we assume that
* all Windows 8 touch devices are tablets.
*/
if (empty($this->device) && in_array($this->getOs('short_name'), array('WI8', 'WRT')) && $this->isTouchEnabled()) {
$this->device = array_search('tablet', self::$deviceTypes);
}

if ($this->debug) {
var_export($this->brand, $this->model, $this->device);
}
Expand Down Expand Up @@ -795,6 +808,12 @@ public function isHbbTv()
return $this->matchUserAgent($regex);
}

public function isTouchEnabled()
{
$regex = 'Touch';
return $this->matchUserAgent($regex);
}

public function isMobile()
{
return !$this->isDesktop();
Expand Down
72 changes: 68 additions & 4 deletions tests/PHPUnit/Fixtures/userAgentParserEnhancedFixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6009,7 +6009,7 @@
short_name: IE
version: 10.0
device:
type: desktop
type: tablet
brand:
model:
os_family: Windows
Expand Down Expand Up @@ -6185,7 +6185,7 @@
short_name: IE
version: 10.0
device:
type: desktop
type: tablet
brand:
model:
os_family: Windows
Expand Down Expand Up @@ -21455,7 +21455,7 @@
os_family: Android
browser_family: Android Browser
-
user_agent: Mozilla/5.0 (Linux; U; Android 4.1.1; zh-cn; HW-HUAWEI_C8813/C8813V100R001C92B169; 480*854; CTC/2.0) AppleWebKit/534.30 (KHTML, like Gecko) Mobile Safari/534.30
user_agent: 'Mozilla/5.0 (Linux; U; Android 4.1.1; zh-cn; HW-HUAWEI_C8813/C8813V100R001C92B169; 480*854; CTC/2.0) AppleWebKit/534.30 (KHTML, like Gecko) Mobile Safari/534.30'
os:
name: Android
short_name: AND
Expand Down Expand Up @@ -22125,4 +22125,68 @@
brand: HT
model: Evo 3D GSM
os_family: Android
browser_family: Android Browser
browser_family: Android Browser
-
user_agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0; Touch; ARMBJS)
os:
name: Windows RT
short_name: WRT
version:
browser:
name: Internet Explorer
short_name: IE
version: 10.0
device:
type: tablet
brand:
model:
os_family: Windows
browser_family: Internet Explorer
-
user_agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; Touch; MALCJS; WebView/1.0)
os:
name: Windows 8
short_name: WI8
version: 8
browser:
name: Internet Explorer
short_name: IE
version: 10.0
device:
type: tablet
brand:
model:
os_family: Windows
browser_family: Internet Explorer
-
user_agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0; Touch; MAARJS)
os:
name: Windows 8
short_name: WI8
version: 8
browser:
name: Internet Explorer
short_name: IE
version: 10.0
device:
type: tablet
brand:
model:
os_family: Windows
browser_family: Internet Explorer
-
user_agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.3; Trident/7.0; Touch; MALCJS)
os:
name: Windows 8
short_name: WI8
version: 8
browser:
name: Internet Explorer
short_name: IE
version: 11.0
device:
type: tablet
brand:
model:
os_family: Windows
browser_family: Internet Explorer

0 comments on commit 729253e

Please sign in to comment.