devicemap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wk...@apache.org
Subject svn commit: r1722533 - /devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceMapClient.java
Date Fri, 01 Jan 2016 18:55:26 GMT
Author: wkeil
Date: Fri Jan  1 18:55:26 2016
New Revision: 1722533

URL: http://svn.apache.org/viewvc?rev=1722533&view=rev
Log:
DMAP-186: Some arguments like debug/log won't work in Java Console 

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

Modified:
    devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceMapClient.java

Modified: devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceMapClient.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceMapClient.java?rev=1722533&r1=1722532&r2=1722533&view=diff
==============================================================================
--- devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceMapClient.java
(original)
+++ devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceMapClient.java
Fri Jan  1 18:55:26 2016
@@ -162,6 +162,7 @@ public class DeviceMapClient {
 
     private static final String DEVICE_OS_VERSION = "device_os_version";
     private static final String ANDROID = "Android";
+    private static final String LIKE_MAC = "like Mac OS X";
     
     private DeviceType fixFromUserAgent(final DeviceType device, final UserAgent userAgent)
{
 		String pattern = userAgent.getPatternElementsInside();
@@ -178,13 +179,27 @@ public class DeviceMapClient {
 			String[] parts = pattern.split(";");
 		
 			for (String part : parts) {
-				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 != 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)) {
+						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);
+							}
+						}
 					}
 				}
 			}



Mime
View raw message