001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.kernel.mobile.device;
016    
017    import java.util.Map;
018    import java.util.Set;
019    
020    import javax.servlet.http.HttpServletRequest;
021    
022    /**
023     * @author Milen Dyankov
024     */
025    public class DeviceDetectionUtil {
026    
027            public static Device detectDevice(HttpServletRequest request) {
028                    return _deviceRecognitionProvider.detectDevice(request);
029            }
030    
031            public static Set<VersionableName> getKnownBrands() {
032                    KnownDevices knownDevices =
033                            _deviceRecognitionProvider.getKnownDevices();
034    
035                    return knownDevices.getBrands();
036            }
037    
038            public static Set<VersionableName> getKnownBrowsers() {
039                    KnownDevices knownDevices =
040                            _deviceRecognitionProvider.getKnownDevices();
041    
042                    return knownDevices.getBrowsers();
043            }
044    
045            public static Set<String> getKnownDeviceIdsByCapability(
046                    Capability capability) {
047    
048                    KnownDevices knownDevices =
049                            _deviceRecognitionProvider.getKnownDevices();
050    
051                    Map<Capability, Set<String>> deviceIds = knownDevices.getDeviceIds();
052    
053                    return deviceIds.get(capability);
054            }
055    
056            public static Set<VersionableName> getKnownOperatingSystems() {
057                    KnownDevices knownDevices =
058                            _deviceRecognitionProvider.getKnownDevices();
059    
060                    return knownDevices.getOperatingSystems();
061            }
062    
063            public static Set<String> getKnownPointingMethods() {
064                    KnownDevices knownDevices =
065                            _deviceRecognitionProvider.getKnownDevices();
066    
067                    return knownDevices.getPointingMethods();
068            }
069    
070            public void setDeviceRecognitionProvider(
071                    DeviceRecognitionProvider deviceRecognitionProvider) {
072    
073                    _deviceRecognitionProvider = deviceRecognitionProvider;
074            }
075    
076            private static volatile DeviceRecognitionProvider
077                    _deviceRecognitionProvider;
078    
079    }