connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/PCCSConnection.java
branchRCL_2_4
changeset 1092 cfabdba53722
parent 1080 43348591c4a0
child 1124 f68b7751b408
equal deleted inserted replaced
1091:9ce8893d737f 1092:cfabdba53722
   673 	 * @param serialNumber - serial number from connectivity API
   673 	 * @param serialNumber - serial number from connectivity API
   674 	 * @param address - this contains the device ID from the connectivity API
   674 	 * @param address - this contains the device ID from the connectivity API
   675 	 * @param personalityList - all USB-connected devices
   675 	 * @param personalityList - all USB-connected devices
   676 	 * @return - null if no personality found
   676 	 * @return - null if no personality found
   677 	 */
   677 	 */
   678 	private DeviceUSBPersonalityInfo findPersonality(int numUSBPersonalities, String serialNumber, String address, Collection<DeviceUSBPersonalityInfo> personalityList) {
   678 	private DeviceUSBPersonalityInfo findPersonality(int numUSBDevicesExpected, String serialNumber, String address, Collection<DeviceUSBPersonalityInfo> personalityList) {
   679 	
   679 	
   680 		if (DEBUG) System.out.println("findPersonality: start"); //$NON-NLS-1$
   680 		if (DEBUG) System.out.println("findPersonality: start"); //$NON-NLS-1$
   681 		if (personalityList == null || personalityList.isEmpty()) {
   681 		if (personalityList == null || personalityList.isEmpty()) {
   682 			if (DEBUG) System.out.println("findPersonality: list is empty");
   682 			if (DEBUG) System.out.println("findPersonality: list is empty");
   683 			return null;
   683 			return null;
   705 			if (!address.equals(NOT_KNOWN) && !personality.deviceID.equals(NOT_KNOWN)) {
   705 			if (!address.equals(NOT_KNOWN) && !personality.deviceID.equals(NOT_KNOWN)) {
   706 				// example device ids:
   706 				// example device ids:
   707 				//   0\VID_0421&PID_00AB\0 (no serial number as part of id)
   707 				//   0\VID_0421&PID_00AB\0 (no serial number as part of id)
   708 				//   004401011418023\VID_0421&PID_0500\0 (serial number comes at front)
   708 				//   004401011418023\VID_0421&PID_0500\0 (serial number comes at front)
   709 				// compare Device IDs
   709 				// compare Device IDs
   710 				String id = address.substring(address.indexOf('\\'), address.lastIndexOf('\\'));
   710 				String vidpid = address.substring(address.indexOf('\\'), address.lastIndexOf('\\'));
   711 				if (personality.deviceID.contains(id) && personality.deviceID.contains(serialNumber)) {
   711 				String endid = address.substring(address.lastIndexOf('\\')+1);
   712 					if (DEBUG) System.out.println("findPersonality: address matches deviceID with serial number"); //$NON-NLS-1$
   712 				if (personality.deviceID.contains(vidpid) && personality.deviceID.contains(endid)) {
       
   713 					if (DEBUG) System.out.println("findPersonality: address matches deviceID with end number\n"); //$NON-NLS-1$
       
   714 					return personality;
       
   715 				}
       
   716 				else if (personality.deviceID.contains(vidpid) && personality.deviceID.contains(serialNumber)) {
       
   717 					if (DEBUG) System.out.println("findPersonality: address matches deviceID with serial number\n"); //$NON-NLS-1$
   713 					return personality;
   718 					return personality;
   714 				} else {
   719 				} else {
       
   720 					if (serialNumber.equals(NOT_KNOWN)) {
       
   721 						if (personality.deviceID.contains(vidpid) && numUSBDevicesExpected == 1) {
       
   722 							if (DEBUG) System.out.println("findPersonality: serial number not known, but VID/PID match\n"); //$NON-NLS-1$
       
   723 							return personality;
       
   724 						}
       
   725 					}
   715 					String begin = personality.deviceID.substring(0, personality.deviceID.indexOf('\\'));
   726 					String begin = personality.deviceID.substring(0, personality.deviceID.indexOf('\\'));
   716 					if (begin.equals("0")) {
   727 					if (begin.equals("0") || numUSBDevicesExpected == 1) {
   717 						// no serial number at beginning
   728 						// no serial number at beginning
   718 						if (personality.deviceID.contains(id)) {
   729 						if (personality.deviceID.contains(vidpid)) {
   719 							if (DEBUG) System.out.println("findPersonality: address matches deviceID without serial number"); //$NON-NLS-1$
   730 							if (DEBUG) System.out.println("findPersonality: address matches deviceID without serial number\n"); //$NON-NLS-1$
   720 							return personality;
   731 							return personality;
   721 						}
   732 						}
   722 					}
   733 					}
   723 				}
   734 				}
   724 			}
   735 			}