devicemap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wk...@apache.org
Subject svn commit: r1749117 - in /devicemap/trunk: clients/1.0/java/client/src/main/java/org/apache/devicemap/ clients/1.0/java/client/src/main/java/org/apache/devicemap/data/ data/1.0/device-data/src/main/resources/devicedata/
Date Sun, 19 Jun 2016 01:10:34 GMT
Author: wkeil
Date: Sun Jun 19 01:10:33 2016
New Revision: 1749117

URL: http://svn.apache.org/viewvc?rev=1749117&view=rev
Log:
DMAP-166: New device: Sony Xperia E1 

Task-Url: https://issues.apache.org/jira/browse/DMAP-166

Modified:
    devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceFixer.java
    devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/UserAgent.java
    devicemap/trunk/data/1.0/device-data/src/main/resources/devicedata/BuilderDataSource.xml
    devicemap/trunk/data/1.0/device-data/src/main/resources/devicedata/DeviceDataSource.xml
    devicemap/trunk/data/1.0/device-data/src/main/resources/devicedata/oddrVocabulary.xml

Modified: devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceFixer.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceFixer.java?rev=1749117&r1=1749116&r2=1749117&view=diff
==============================================================================
--- devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceFixer.java
(original)
+++ devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceFixer.java
Sun Jun 19 01:10:33 2016
@@ -24,114 +24,153 @@ import static org.apache.devicemap.data.
 import java.util.HashMap;
 import java.util.Map;
 import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.devicemap.data.DeviceType;
 import org.apache.devicemap.data.UserAgent;
 
 /**
  * @author Werner Keil
- * @version 0.1
+ * @version 0.2
  */
 abstract class DeviceFixer {
-	private static final Logger LOG = Logger.getLogger(DeviceFixer.class
-			.getName());
+    private static final Logger LOG = Logger.getLogger(DeviceFixer.class
+	    .getName());
 
-	private static final String DEVICE_OS = "device_os";
-	private static final String DEVICE_OS_VERSION = "device_os_version";
-//	private static final String VENDOR = "vendor";
-	private static final String LIKE_MAC = "like Mac OS X";
-
-	static final DeviceType fixFromUserAgent(final DeviceType device,
-			final UserAgent userAgent) {
-		String pattern = userAgent.getPatternElementsInside();
-		if (pattern != null && pattern.contains(";")) {
-			Map<String, String> attributes;
-			if (device.isLocked()) {
-				// clone map
-				attributes = new HashMap<String, String>();
-
-				attributes.putAll(device.getAttributes());
-			} else {
-				attributes = device.getAttributes();
+    private static final String DEVICE_OS = "device_os";
+    private static final String DEVICE_OS_VERSION = "device_os_version";
+    // private static final String VENDOR = "vendor";
+    private static final String LIKE_MAC = "like Mac OS X";
+
+    private static final String CHROME = "Chrome";
+    private static final String SAFARI = "Safari";
+
+    private static final String CHROME_VERSION_REGEXP = "Chrome.([0-9a-z\\.b]+).*";
+    private static final String SAFARI_REGEXP = ".*Safari/([0-9\\.]+).*?";
+    
+    private static final String BROWSER = "mobile_browser";
+    private static final String BROWSER_VERSION = "mobile_browser_version";
+
+    static final DeviceType fixFromUserAgent(final DeviceType device,
+	    final UserAgent userAgent) {
+	Map<String, String> attributes;
+	if (device.isLocked()) {
+	    // clone map
+	    attributes = new HashMap<String, String>();
+
+	    attributes.putAll(device.getAttributes());
+	} else {
+	    attributes = device.getAttributes();
+	}
+	
+	// OS
+	String pattern = userAgent.getPatternElementsInside();
+	if (pattern != null && pattern.contains(";")) {
+	    String[] parts = pattern.split(";");
+
+	    for (String part : parts) {
+		if (part != null) {
+		    if (part.trim().startsWith(ANDROID)) {
+			final String versionPart = part.trim()
+				.substring(ANDROID.length()).trim();
+			final String versionExisting = attributes
+				.get(DEVICE_OS_VERSION);
+			if (!versionPart.equals(versionExisting)) {
+			    LOG.fine("Fixing '" + versionExisting + "' to '"
+				    + versionPart + "'");
+			    attributes.put(DEVICE_OS_VERSION, versionPart);
+			    device.setAttributes(attributes);
 			}
-			String[] parts = pattern.split(";");
-
-			for (String part : parts) {
-				if (part != null) {
-					if (part.trim().startsWith(ANDROID)) {
-						final String versionPart = part.trim()
-								.substring(ANDROID.length()).trim();
-						final String versionExisting = attributes
-								.get(DEVICE_OS_VERSION);
-						if (!versionPart.equals(versionExisting)) {
-							LOG.fine("Fixing '" + versionExisting + "' to '"
-									+ versionPart + "'");
-							attributes.put(DEVICE_OS_VERSION, versionPart);
-							device.setAttributes(attributes);
-						}
-					}
-					if (part.trim().endsWith(LIKE_MAC)) {
-						final String versionCandidate = part
-								.trim().substring(0, 
-								part.trim().length() - LIKE_MAC.length()).trim();
-						if (versionCandidate.contains("OS")) {
-							final String versionPart = versionCandidate
-									.substring(
-											versionCandidate.indexOf("OS") + 2)
-									.trim().replaceAll("_", ".");
-							final String versionExisting = attributes
-									.get(DEVICE_OS_VERSION);
-							if (!versionPart.equals(versionExisting)) {
-								LOG.fine("Fixing '" + versionExisting
-										+ "' to '" + versionPart + "'");
-								attributes.put(DEVICE_OS_VERSION, versionPart);
-								device.setAttributes(attributes);
-							}
-						}
-					}
-					if (part.trim().startsWith(WINDOWS)) {
-						final String versionCandidate = part.trim();
-						DeviceHints.WindowsVersion version = DeviceHints.WindowsVersion
-								.ofToken(versionCandidate);
-						if (version != null) {
-							final String osExisting = attributes.get(DEVICE_OS);
-							LOG.fine("Fixing '" + osExisting + "' to '"
-									+ version.getDescription() + "'");
-							attributes.put(DEVICE_OS, version.getDescription());
-							final String versionExisting = attributes
-									.get(DEVICE_OS_VERSION);
-							if (!version.getVersion().equals(versionExisting)) {
-								LOG.fine("Fixing '" + versionExisting
-										+ "' to '" + version.getVersion() + "'");
-								attributes.put(DEVICE_OS_VERSION,
-										version.getVersion());
-							}
-							// final String vendorExisting =
-							// attributes.get(VENDOR);
-							// if (vendorExisting == null ||
-							// vendorExisting.length()==0 ||
-							// "-".equals(vendorExisting) ) {
-							// LOG.finer("Desktop" +
-							// attributes.get("is_desktop"));
-							// if
-							// (Boolean.parseBoolean(attributes.get("is_desktop")))
-							// {
-							// attributes.put(VENDOR, "Microsoft");
-							// }
-							// }
-							device.setAttributes(attributes);
-						}
-					} /*
-					 * else { String versionCandidate = part.trim();
-					 * System.out.println(versionCandidate); }
-					 */
-				}
+		    }
+		    if (part.trim().endsWith(LIKE_MAC)) {
+			final String versionCandidate = part
+				.trim()
+				.substring(
+					0,
+					part.trim().length()
+						- LIKE_MAC.length()).trim();
+			if (versionCandidate.contains("OS")) {
+			    final String versionPart = versionCandidate
+				    .substring(
+					    versionCandidate.indexOf("OS") + 2)
+				    .trim().replaceAll("_", ".");
+			    final String versionExisting = attributes
+				    .get(DEVICE_OS_VERSION);
+			    if (!versionPart.equals(versionExisting)) {
+				LOG.fine("Fixing '" + versionExisting
+					+ "' to '" + versionPart + "'");
+				attributes.put(DEVICE_OS_VERSION, versionPart);
+				device.setAttributes(attributes);
+			    }
 			}
+		    }
+		    if (part.trim().startsWith(WINDOWS)) {
+			final String versionCandidate = part.trim();
+			DeviceHints.WindowsVersion version = DeviceHints.WindowsVersion
+				.ofToken(versionCandidate);
+			if (version != null) {
+			    final String osExisting = attributes.get(DEVICE_OS);
+			    LOG.fine("Fixing '" + osExisting + "' to '"
+				    + version.getDescription() + "'");
+			    attributes.put(DEVICE_OS, version.getDescription());
+			    final String versionExisting = attributes
+				    .get(DEVICE_OS_VERSION);
+			    if (!version.getVersion().equals(versionExisting)) {
+				LOG.fine("Fixing '" + versionExisting
+					+ "' to '" + version.getVersion() + "'");
+				attributes.put(DEVICE_OS_VERSION,
+					version.getVersion());
+			    }
+			    // final String vendorExisting =
+			    // attributes.get(VENDOR);
+			    // if (vendorExisting == null ||
+			    // vendorExisting.length()==0 ||
+			    // "-".equals(vendorExisting) ) {
+			    // LOG.finer("Desktop" +
+			    // attributes.get("is_desktop"));
+			    // if
+			    // (Boolean.parseBoolean(attributes.get("is_desktop")))
+			    // {
+			    // attributes.put(VENDOR, "Microsoft");
+			    // }
+			    // }
+			}
+		    } /*
+		       * else { String versionCandidate = part.trim();
+		       * System.out.println(versionCandidate); }
+		       */
+		}
+	    }
+	}
+
+	// Browser
+	pattern = userAgent.getPatternElementsPost();
+	if (pattern != null) {
+	    if (pattern.contains(CHROME)) {
+		String parts = pattern.substring(pattern.indexOf(CHROME));
+		String version = parts.substring(CHROME.length() + 1,
+			parts.indexOf(" "));
+//		System.out.println(version);
+		// Matcher chromeVersionMatcher =
+		// chromeVersionPattern.matcher(pattern);
+		// System.out.println(chromeVersionMatcher);
+		final String versionExisting = attributes
+			.get(BROWSER_VERSION);
+		if (!version.equals(versionExisting)) {
+		    LOG.fine("Fixing '" + versionExisting + "' to '"
+			    + version + "'");
+		    attributes.put(BROWSER_VERSION, version);
 		}
-		
-		
-		// logger.info("Device: " + device.getId() + " - " +
-		// device.getPropertiesMap());
-		return device;
+	    }
+	    // Pattern safariPattern = Pattern.compile(SAFARI_REGEXP);
+
 	}
+	
+	device.setAttributes(attributes);
+
+	// logger.info("Device: " + device.getId() + " - " +
+	// device.getPropertiesMap());
+	return device;
+    }
 }

Modified: devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/UserAgent.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/UserAgent.java?rev=1749117&r1=1749116&r2=1749117&view=diff
==============================================================================
--- devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/UserAgent.java
(original)
+++ devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/UserAgent.java
Sun Jun 19 01:10:33 2016
@@ -23,7 +23,7 @@ import java.util.regex.Pattern;
 
 /**
  * @author Werner Keil
- * @version 0.3
+ * @version 0.4
  */
 public class UserAgent {
 	public static final String ANDROID = "Android";
@@ -79,12 +79,10 @@ public class UserAgent {
                         operaVersion = result2.group(1);
                     }
                 }
-
             } else {
                 mozillaPattern = true;
                 mozillaVersion = version;
             }
-
         } else {
             mozillaPattern = false;
             operaPattern = false;
@@ -98,34 +96,27 @@ public class UserAgent {
 
         if (userAgent.contains(ANDROID)) {
             containsAndroid = true;
-
         } else {
             containsAndroid = false;
             if (userAgent.matches(".*(?!like).iPad.*") || userAgent.matches(".*(?!like).iPod.*")
|| userAgent.matches(".*(?!like).iPhone.*")) {
                 containsIOSDevices = true;
-
             } else {
                 containsIOSDevices = false;
                 if (userAgent.matches(".*[Bb]lack.?[Bb]erry.*|.*RIM.?Tablet.?OS.*")) {
                     containsBlackBerryOrRim = true;
-
                 } else {
                     containsBlackBerryOrRim = false;
                     if (userAgent.matches(".*Symbian.*|.*SymbOS.*|.*Series.?60.*")) {
                         containsSymbian = true;
-
                     } else {
                         containsSymbian = false;
                         if (userAgent.matches(".*Windows.?(?:(?:CE)|(?:Phone)|(?:NT)|(?:Mobile)).*"))
{
                             containsWindowsPhone = true;
-
                         } else {
                             containsWindowsPhone = false;
                         }
-
                         if (userAgent.matches(".*MSIE.([0-9\\.b]+).*")) {
                             containsMSIE = true;
-
                         } else {
                             containsMSIE = false;
                         }

Modified: devicemap/trunk/data/1.0/device-data/src/main/resources/devicedata/BuilderDataSource.xml
URL: http://svn.apache.org/viewvc/devicemap/trunk/data/1.0/device-data/src/main/resources/devicedata/BuilderDataSource.xml?rev=1749117&r1=1749116&r2=1749117&view=diff
==============================================================================
--- devicemap/trunk/data/1.0/device-data/src/main/resources/devicedata/BuilderDataSource.xml
(original)
+++ devicemap/trunk/data/1.0/device-data/src/main/resources/devicedata/BuilderDataSource.xml
Sun Jun 19 01:10:33 2016
@@ -18,7 +18,7 @@
 <ODDR>
     <version>
         <ver>1.0.4-SNAPSHOT</ver>
-        <last_updated>2015-06-19 17:00:00</last_updated>
+        <last_updated>2016-06-19 03:00:00</last_updated>
         <official_url>http://devicemap.apache.org</official_url>
         <statement>Licensed under http://www.apache.org/licenses/LICENSE-2.0</statement>
     </version>

Modified: devicemap/trunk/data/1.0/device-data/src/main/resources/devicedata/DeviceDataSource.xml
URL: http://svn.apache.org/viewvc/devicemap/trunk/data/1.0/device-data/src/main/resources/devicedata/DeviceDataSource.xml?rev=1749117&r1=1749116&r2=1749117&view=diff
==============================================================================
--- devicemap/trunk/data/1.0/device-data/src/main/resources/devicedata/DeviceDataSource.xml
(original)
+++ devicemap/trunk/data/1.0/device-data/src/main/resources/devicedata/DeviceDataSource.xml
Sun Jun 19 01:10:33 2016
@@ -12,7 +12,7 @@
 <ODDR>
 	<version>
 		<ver>1.0.4-SNAPSHOT</ver>
-		<last_updated>2016-02-20 19:00:00</last_updated>
+		<last_updated>2016-06-19 03:00:00</last_updated>
 		<official_url>http://devicemap.apache.org</official_url>
 		<statement>Licensed under http://www.apache.org/licenses/LICENSE-2.0
 		</statement>
@@ -42983,6 +42983,7 @@
 			<property name="ajax_support_event_listener" value="true" />
 			<property name="image_inlining" value="true" />
 			<property name="inputDevices" value="touchscreen" />
+			<property name="multiTouch" value="true" />
 			<property name="from" value="oddr" />
 		</device>
 		<device id="D2005" parentId="genericSony">
@@ -42990,7 +42991,7 @@
 			<property name="marketing_name" value="Xperia E1" />
 			<property name="displayWidth" value="480" />
 			<property name="displayHeight" value="800" />
-			<property name="mobile_browser" value="Android Webkit" />
+			<property name="mobile_browser" value="Chrome" />
 			<property name="device_os" value="Android" />
 			<property name="device_os_version" value="4.3" />
 			<property name="dual_orientation" value="true" />
@@ -43003,6 +43004,9 @@
 			<property name="ajax_support_event_listener" value="true" />
 			<property name="image_inlining" value="true" />
 			<property name="inputDevices" value="touchscreen" />
+			<property name="multiTouch" value="true" />
+			<property name="weight" value="120 g"/>
+			<property name="sim" value="Mini-SIM"/>
 			<property name="from" value="devicemap" />
 		</device>
 		<device id="SM-P605V" parentId="genericSamsung">

Modified: devicemap/trunk/data/1.0/device-data/src/main/resources/devicedata/oddrVocabulary.xml
URL: http://svn.apache.org/viewvc/devicemap/trunk/data/1.0/device-data/src/main/resources/devicedata/oddrVocabulary.xml?rev=1749117&r1=1749116&r2=1749117&view=diff
==============================================================================
--- devicemap/trunk/data/1.0/device-data/src/main/resources/devicedata/oddrVocabulary.xml
(original)
+++ devicemap/trunk/data/1.0/device-data/src/main/resources/devicedata/oddrVocabulary.xml
Sun Jun 19 01:10:33 2016
@@ -12,7 +12,7 @@
 <ODDR>
 	<version>
 		<ver>1.0.4-SNAPSHOT</ver>
-		<last_updated>2016-02-20 19:10:00</last_updated>
+		<last_updated>2016-06-19 03:00:00</last_updated>
 		<official_url>http://devicemap.apache.org</official_url>
 		<statement>Licensed under http://www.apache.org/licenses/LICENSE-2.0
 		</statement>
@@ -137,8 +137,14 @@
 				defaultAspect="device" name="video" />
 			<Property aspects="device" datatype="dmap:deviceOrientation"
 				defaultAspect="device" name="default_orientation" />
+			<Property aspects="device" datatype="xs:boolean"
+				defaultAspect="device" name="multiTouch" />
 			<Property aspects="device" datatype="xs:string"
 				defaultAspect="device" name="released" />
+			<Property aspects="device" datatype="xs:string"
+				defaultAspect="device" name="sim" />
+			<Property aspects="device" datatype="xs:string"
+				defaultAspect="device" name="weight" />
 		</Properties>
 	</VocabularyDescription>
 </ODDR>



Mime
View raw message