Detect tablet devices.
@param {string} mockUserAgent - Allow passing a mock user agent for testing.
350329
function isTablet (mockUserAgent) {
  var userAgent = mockUserAgent || window.navigator.userAgent;
  return /ipad|Nexus (7|9)|xoom|sch-i800|playbook|tablet|kindle/i.test(userAgent);
}
314273
protected function detectEngine($userAgent)
	{
		if (stripos($userAgent, 'MSIE') !== false || stripos($userAgent, 'Trident') !== false)
		{
			// Attempt to detect the client engine -- starting with the most popular ... for now.
			$this->engine = self::TRIDENT;
		}
		elseif (stripos($userAgent, 'Edge') !== false || stripos($userAgent, 'EdgeHTML') !== false)
		{
			$this->engine = self::EDGE;
		}
		elseif (stripos($userAgent, 'Edg') !== false)
		{
			$this->engine = self::BLINK;
		}
		elseif (stripos($userAgent, 'Chrome') !== false)
		{
			$result  = explode('/', stristr($userAgent, 'Chrome'));
			$version = explode(' ', $result[1]);

			if ($version[0] >= 28)
			{
				$this->engine = self::BLINK;
			}
			else
			{
				$this->engine = self::WEBKIT;
			}
		}
		elseif (stripos($userAgent, 'AppleWebKit') !== false || stripos($userAgent, 'blackberry') !== false)
		{
			if (stripos($userAgent, 'AppleWebKit') !== false)
			{
				$result  = explode('/', stristr($userAgent, 'AppleWebKit'));
				$version = explode(' ', $result[1]);

				if ($version[0] === 537.36)
				{
					// AppleWebKit/537.36 is Blink engine specific, exception is Blink emulated IEMobile, Trident or Edge
					$this->engine = self::BLINK;
				}
			}

			// Evidently blackberry uses WebKit and doesn't necessarily report it.  Bad RIM.
			$this->engine = self::WEBKIT;
		}
		elseif (stripos($userAgent, 'Gecko') !== false && stripos($userAgent, 'like Gecko') === false)
		{
			// We have to check for like Gecko because some other browsers spoof Gecko.
			$this->engine = self::GECKO;
		}
		elseif (stripos($userAgent, 'Opera') !== false || stripos($userAgent, 'Presto') !== false)
		{
			$version = false;

			if (preg_match('/Opera[\/| ]?([0-9.]+)/u', $userAgent, $match))
			{
				$version = \floatval($match[1]);
			}

			if (preg_match('/Version\/([0-9.]+)/u', $userAgent, $match))
			{
				if (\floatval($match[1]) >= 10)
				{
					$version = \floatval($match[1]);
				}
			}

			if ($version !== false && $version >= 15)
			{
				$this->engine = self::BLINK;
			}
			else
			{
				$this->engine = self::PRESTO;
			}
		}
		elseif (stripos($userAgent, 'KHTML') !== false)
		{
			// *sigh*
			$this->engine = self::KHTML;
		}
		elseif (stripos($userAgent, 'Amaya') !== false)
		{
			// Lesser known engine but it finishes off the major list from Wikipedia :-)
			$this->engine = self::AMAYA;
		}

		// Mark this detection routine as run.
		$this->detection['engine'] = true;
	}
157345
public static DeviceType getDevice(final HttpServletRequest request) {
		// User agent
		String userAgent = ((HttpServletRequest) request).getHeader("User-Agent");
		if (Util.empty(userAgent)) {
			LOG.warn("No User-Agent details in the request headers. Will assume normal device.");
			return DeviceType.NORMAL;
		}

		// Check for device type
		UAgentInfo agentInfo = new UAgentInfo(userAgent, null);
		if (agentInfo.detectMobileQuick()) {
			return DeviceType.MOBILE;
		} else if (agentInfo.detectTierTablet()) {
			return DeviceType.TABLET;
		}
		return DeviceType.NORMAL;
	}
1054523
function getDevice() {
  const language = navigator.language ? 'language' : 'userLanguage';
  return {
    h: screen.height,
    w: screen.width,
    dnt: getDNT() ? 1 : 0,
    language: navigator[language].split('-')[0],
    make: navigator.vendor ? navigator.vendor : '',
    ua: navigator.userAgent
  };
}
229790
def detectTizen(self):
        
        return UAgentInfo.deviceTizen in self.__userAgent \
            and UAgentInfo.mobile in self.__userAgent
497154
private static function checkWindowsPhone(Device $device, UserAgent $userAgent)
    {
        if (stripos($userAgent->getUserAgentString(), 'Windows Phone') !== false) {
            if (preg_match('/Microsoft; (Lumia [^)]*)\)/', $userAgent->getUserAgentString(), $matches)) {
                $device->setName($matches[1]);
                return true;
            }

            $device->setName($device::WINDOWS_PHONE);
            return true;
        }
        return false;
    }
962255
function UserAgent(userAgent, // @arg String = navigator.userAgent
                   options) { // @arg Object = {} - { WEB_VIEW, DISPLAY_DPR, DISPLAY_LONG, DISPLAY_SHORT }
    if (UserAgent["DISABLE_CACHE"]) {
        return UserAgent_parse(userAgent, options || {});
    }
    if (!UserAgent["cache"]) {
        UserAgent["cache"] = UserAgent_parse(userAgent, options || {});
    }
    return UserAgent["cache"];
}
147354
public static function isDesktopBrowserHeavyDutyAnalysis($userAgent){
		// Check Smart TV keywords
		if (WURFL_Handlers_Utils::isSmartTV($userAgent)) return false;
		// Chrome
		if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Chrome') && !WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, array('Android', 'Ventana'))) return true;
		// Check mobile keywords
		if (WURFL_Handlers_Utils::isMobileBrowser($userAgent)) return false;

		if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'PPC')) return false; // PowerPC; not always mobile, but we'll kick it out
		// Firefox;  fennec is already handled in the WURFL_Constants::$MOBILE_BROWSERS keywords
		if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Firefox') && !WURFL_Handlers_Utils::checkIfContains($userAgent, 'Tablet')) return true;
		// Safari
		if (preg_match('#^Mozilla/5\.0 \((?:Macintosh|Windows)[^\)]+\) AppleWebKit/[\d\.]+ \(KHTML, like Gecko\) Version/[\d\.]+ Safari/[\d\.]+$#', $userAgent)) return true;
		// Opera Desktop
		if (WURFL_Handlers_Utils::checkIfStartsWith($userAgent, 'Opera/9.80 (Windows NT', 'Opera/9.80 (Macintosh')) return true;
		// Check desktop keywords
		if (WURFL_Handlers_Utils::isDesktopBrowser($userAgent)) return true;
		// Internet Explorer 9
		if (preg_match('/^Mozilla\/5\.0 \(compatible; MSIE 9\.0; Windows NT \d\.\d/', $userAgent)) return true;
		// Internet Explorer <9
		if (preg_match('/^Mozilla\/4\.0 \(compatible; MSIE \d\.\d; Windows NT \d\.\d/', $userAgent)) return true;
		return false;
	}
143203
function deviceFound(device)
	{
		// For debugging, print advertisement data.
		//console.log(JSON.stringify(device.advertisementData))

		/*
		// Alternative way to identify the device by advertised service UUID.
		if (device.advertisementData.kCBAdvDataServiceUUIDs.indexOf(
			'0000aa10-0000-1000-8000-00805f9b34fb') > -1)
		{
			showMessage('Found the TI SensorTag!')
		}
		*/

		if (device.getName() == 'CC2650 SensorTag')
		{
			showMessage('Found the TI SensorTag!')

			// Stop scanning.
			evothings.easyble.stopScan()

			// Connect.
			connectToDevice(device)
		}
	}
1305781
public boolean isValidUserAgent(final String agent) {
        if (!validateUserAgent) {
            return true;
        }
        final Matcher matcher = AGENT_PATTERN.matcher(agent);
        return matcher.matches();
    }
114662
def detectWebOSTablet(self):
        
        return UAgentInfo.deviceWebOShp in self.__userAgent \
            and UAgentInfo.deviceTablet in self.__userAgent
1242747
public function filter($userAgent, $deviceID)
    {
        if ($this->canHandle($userAgent)) {
            $this->updateUserAgentsWithDeviceIDMap($userAgent, $deviceID);

            return true;
        }

        return false;
    }
536537
public static function isUserAgentMobile() {
		
		$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? strtolower($_SERVER['HTTP_USER_AGENT']) : '';
		
		$devices = array('phone', 'iphone', 'itouch', 'ipod', 'symbian', 'android', 'htc_', 'htc-',
				'palmos', 'blackberry', 'opera mini', 'iemobile', 'windows ce', 'nokia', 'fennec',
				'hiptop', 'kindle', 'mot ', 'mot-', 'webos\/', 'samsung', 'sonyericsson', '^sie-',
				'nintendo');
		
		if (preg_match('/' . implode('|', $devices) . '/', $user_agent)) {
			return TRUE;
		} else {
			return FALSE;
		}
		
	}
947141
public static function detect(Device $device, UserAgent $userAgent)
    {
        $device->setName($device::UNKNOWN);

        /*iphone，ipad，windowphone*/
        $flag = self::checkIpad($device, $userAgent) ||self::checkIphone($device, $userAgent) || self::checkWindowsPhone($device, $userAgent);
        if( $flag ){
        	return true;
		}
        /*android*/
		if (stripos($userAgent->getUserAgentString(), 'android') !== false) {
			$device->setName(Device::Android);
			foreach (self::$androidList as $androidName ) {
				$funcName = 'check'. $androidName;
				if ( self::$funcName( $device, $userAgent ) ) {
					return true;
				}
			}
		}

		return false;

    }
612222
function handler(req, res, next) {
  var userAgent = req.headers["user-agent"];

  //-- set device
  req.device = new Device(userAgent);

  return next();
}
1167292
private static function checkIphone(Device $device, UserAgent $userAgent)
    {
        if (stripos($userAgent->getUserAgentString(), 'iphone;') !== false) {
            $device->setName(Device::IPHONE);
            return true;
        }

        return false;
    }
625242
function _getDeviceType() {
  let ua = navigator.userAgent;

  // Tablets must be checked before phones.
  if ((/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i).test(ua)) {
    return 5; // "tablet"
  }
  if ((/Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/).test(ua)) {
    return 4; // "phone"
  }
  // Consider that all other devices are personal computers
  return 2;
}