Fix for 1 device and 1 personality not matching. Bug 10843. Should also improve bug 10805, but not in the case of multiple devices. RCL_2_4
authorChad Peckham <chad.peckham@nokia.com>
Thu, 11 Mar 2010 12:12:22 -0600
branchRCL_2_4
changeset 1092 cfabdba53722
parent 1091 9ce8893d737f
child 1093 32ec941623d6
Fix for 1 device and 1 personality not matching. Bug 10843. Should also improve bug 10805, but not in the case of multiple devices.
connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/PCCSConnection.java
--- a/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/PCCSConnection.java	Wed Mar 10 15:28:22 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/PCCSConnection.java	Thu Mar 11 12:12:22 2010 -0600
@@ -675,7 +675,7 @@
 	 * @param personalityList - all USB-connected devices
 	 * @return - null if no personality found
 	 */
-	private DeviceUSBPersonalityInfo findPersonality(int numUSBPersonalities, String serialNumber, String address, Collection<DeviceUSBPersonalityInfo> personalityList) {
+	private DeviceUSBPersonalityInfo findPersonality(int numUSBDevicesExpected, String serialNumber, String address, Collection<DeviceUSBPersonalityInfo> personalityList) {
 	
 		if (DEBUG) System.out.println("findPersonality: start"); //$NON-NLS-1$
 		if (personalityList == null || personalityList.isEmpty()) {
@@ -707,16 +707,27 @@
 				//   0\VID_0421&PID_00AB\0 (no serial number as part of id)
 				//   004401011418023\VID_0421&PID_0500\0 (serial number comes at front)
 				// compare Device IDs
-				String id = address.substring(address.indexOf('\\'), address.lastIndexOf('\\'));
-				if (personality.deviceID.contains(id) && personality.deviceID.contains(serialNumber)) {
-					if (DEBUG) System.out.println("findPersonality: address matches deviceID with serial number"); //$NON-NLS-1$
+				String vidpid = address.substring(address.indexOf('\\'), address.lastIndexOf('\\'));
+				String endid = address.substring(address.lastIndexOf('\\')+1);
+				if (personality.deviceID.contains(vidpid) && personality.deviceID.contains(endid)) {
+					if (DEBUG) System.out.println("findPersonality: address matches deviceID with end number\n"); //$NON-NLS-1$
+					return personality;
+				}
+				else if (personality.deviceID.contains(vidpid) && personality.deviceID.contains(serialNumber)) {
+					if (DEBUG) System.out.println("findPersonality: address matches deviceID with serial number\n"); //$NON-NLS-1$
 					return personality;
 				} else {
+					if (serialNumber.equals(NOT_KNOWN)) {
+						if (personality.deviceID.contains(vidpid) && numUSBDevicesExpected == 1) {
+							if (DEBUG) System.out.println("findPersonality: serial number not known, but VID/PID match\n"); //$NON-NLS-1$
+							return personality;
+						}
+					}
 					String begin = personality.deviceID.substring(0, personality.deviceID.indexOf('\\'));
-					if (begin.equals("0")) {
+					if (begin.equals("0") || numUSBDevicesExpected == 1) {
 						// no serial number at beginning
-						if (personality.deviceID.contains(id)) {
-							if (DEBUG) System.out.println("findPersonality: address matches deviceID without serial number"); //$NON-NLS-1$
+						if (personality.deviceID.contains(vidpid)) {
+							if (DEBUG) System.out.println("findPersonality: address matches deviceID without serial number\n"); //$NON-NLS-1$
 							return personality;
 						}
 					}