From daf65ac0108375fa01d375cc232026352804888b Mon Sep 17 00:00:00 2001 From: greatim Date: Tue, 15 Jul 2014 15:58:47 +0900 Subject: [PATCH] COMM: fix communicator for "settings" app Now some apps like "settings" have non-exist binary info. For that kinds of app, MSG_BINARY_INFO and MSG_START must be work properly. Change-Id: I03b9347f533115959042db8afbec11c28255ec1c Signed-off-by: greatim --- .../swap/communicator/Communicator30.java | 52 +++++++++++++--------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java index 6bbe871..7ac8807 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java @@ -204,7 +204,8 @@ public class Communicator30 extends BaseCommunicator { } try { - printWriter = new PrintWriter(new BufferedWriter(new FileWriter(logPath)), true); + printWriter = new PrintWriter( + new BufferedWriter(new FileWriter(logPath)), true); } catch (IOException e) { e.printStackTrace(); } @@ -214,7 +215,8 @@ public class Communicator30 extends BaseCommunicator { Thread dataThread = new Thread(null, new DataChannelThread(), AnalyzerConstants.COMMUNICATOR_RECEIVE_THREAD); // start message send - HostResult result = handleControlMessage(GlobalInformation.getCurrentDeviceInfo(), ret); + HostResult result = handleControlMessage( + GlobalInformation.getCurrentDeviceInfo(), ret); DA_LOG.performance("TEST", "Start Trace", "Make and Send start message"); // FIX @@ -226,7 +228,8 @@ public class Communicator30 extends BaseCommunicator { if (result.isSuccess()) { if (!isCorrectAck(MSG_START_ACK, result)) { HostResult failResult = HostResult.ERR_MSG_START_FAIL; - failResult.setMessage(ErrorCode.getError(getReturnId(result.getRet())).toString()); + failResult.setMessage(ErrorCode.getError(getReturnId(result.getRet())) + .toString()); DACommunicator.setRunning(false); dataThread = null; return failResult; @@ -432,12 +435,13 @@ public class Communicator30 extends BaseCommunicator { } @Override - public HostResult sendConfigurationMessage(DeviceInfo devInfo, int type, String message) { + public HostResult sendConfigurationMessage(DeviceInfo devInfo, int type, + String message) { // send config message byte[] config = ByteUtil.toBytes(AnalyzerConstants.MSG_CONFIG); RunTimeConfiguration rt = new RunTimeConfiguration(); - rt.setFeatures(ConfigureManager.getInstance().getConfiguration(devInfo), ConfigureManager - .getInstance().getPreConfiguration(devInfo)); + rt.setFeatures(ConfigureManager.getInstance().getConfiguration(devInfo), + ConfigureManager.getInstance().getPreConfiguration(devInfo)); rt.setSystemTracePeriod(ConfigureManager.getInstance().getSystemPeriod()); rt.setSamplingPeriod(ConfigureManager.getInstance().getSamplingPeriod()); byte[] rtByte = rt.toByteStream(); @@ -480,8 +484,8 @@ public class Communicator30 extends BaseCommunicator { byte[] stop = ByteUtil.toBytes(AnalyzerConstants.MSG_STOP_SWAP); int length = 0; byte[] stopMsg = ByteUtil.getByte(stop, length); - HostResult result = handleControlMessage(GlobalInformation.getCurrentDeviceInfo(), - stopMsg); + HostResult result = handleControlMessage( + GlobalInformation.getCurrentDeviceInfo(), stopMsg); if (result.isSuccess()) { if (isCorrectAck(MSG_STOP_ACK, result)) { @@ -599,7 +603,8 @@ public class Communicator30 extends BaseCommunicator { HostResult result = HostResult.SUCCESS; Socket controlSock = null; try { - controlSock = new Socket(CommonConstants.LOCAL_HOST, CommunicatorUtils.LOCAL_PORT); + controlSock = new Socket(CommonConstants.LOCAL_HOST, + CommunicatorUtils.LOCAL_PORT); controlSock.setSoTimeout(AnalyzerConstants.CONTROL_SOCKET_TIMEOUT); controlSock.setReuseAddress(true); controlSock.setTcpNoDelay(true); @@ -627,7 +632,8 @@ public class Communicator30 extends BaseCommunicator { HostResult result = HostResult.SUCCESS; Socket dataSock = null; try { - dataSock = new Socket(CommonConstants.LOCAL_HOST, CommunicatorUtils.LOCAL_PORT); + dataSock = new Socket(CommonConstants.LOCAL_HOST, + CommunicatorUtils.LOCAL_PORT); dataSock.setSoTimeout(AnalyzerConstants.DATA_SOCKET_TIMEOUT); dataSock.setReuseAddress(true); dataSock.setTcpNoDelay(true); @@ -695,13 +701,13 @@ public class Communicator30 extends BaseCommunicator { int index = 0; int msgId = ByteUtil.toInt(data, index); index += INT_SIZE; - // int length = ByteUtils.toInt(data, index); + int paylen = ByteUtil.toInt(data, index); index += INT_SIZE; int retId = ByteUtil.toInt(data, index); index += INT_SIZE; if (ackType == msgId) { - if (retId == ErrorCode.SUCCESS.getErrorNumber()) { + if (paylen != INT_SIZE || retId == ErrorCode.SUCCESS.getErrorNumber()) { return true; } } @@ -933,7 +939,8 @@ public class Communicator30 extends BaseCommunicator { size = size - exSize; libInst = ByteUtil.getByte(libInst, binaryPath, size); for (int i = 0; i < size; i++) { - libInst = ByteUtil.getByte(libInst, functionInstList.get(i).toByteStream()); + libInst = ByteUtil.getByte(libInst, functionInstList.get(i) + .toByteStream()); } } count = count - failedCount; @@ -942,7 +949,8 @@ public class Communicator30 extends BaseCommunicator { msg = ByteUtil.getByte(msg, length, libInst); // ByteUtils.printByteArrayForStart(msg); - HostResult result = handleControlMessage(GlobalInformation.getCurrentDeviceInfo(), msg); + HostResult result = handleControlMessage( + GlobalInformation.getCurrentDeviceInfo(), msg); int ackMsg = AnalyzerConstants.MSG_SWAP_INST_ADD_ACK; if (messageId == AnalyzerConstants.MSG_SWAP_INST_REMOVE) { @@ -973,7 +981,8 @@ public class Communicator30 extends BaseCommunicator { int length = sendBin.length; byte[] msg = ByteUtil.getByte(AnalyzerConstants.MSG_BINARY_INFO, length, sendBin); - HostResult result = handleControlMessage(GlobalInformation.getCurrentDeviceInfo(), msg); + HostResult result = handleControlMessage( + GlobalInformation.getCurrentDeviceInfo(), msg); if (!result.isSuccess() || !isCorrectAck(MSG_BINARY_INFO_ACK, result)) { return HostResult.ERR_BIN_INFO_GET_FAIL; @@ -1001,7 +1010,8 @@ public class Communicator30 extends BaseCommunicator { for (int i = 0; i < count; i++) { String targetPath = targetPaths.get(i); - BinaryInfo binInfo = curDevice.getDeviceStatusInfo().getBinaryInfo(targetPath); + BinaryInfo binInfo = curDevice.getDeviceStatusInfo() + .getBinaryInfo(targetPath); int binaryType = ByteUtil.toInt(payload, index); index += INT_SIZE; @@ -1024,7 +1034,8 @@ public class Communicator30 extends BaseCommunicator { if (CommonUtil.isLinux()) { // check local binary path validation // host has no binary file - pull binary file from target - if (splitLocalBinaryPath.length < 3 || !(new File(localBinaryPath)).exists()) { + if (splitLocalBinaryPath.length < 3 + || !(new File(localBinaryPath)).exists()) { localBinaryPath = PathManager.DA_TEMP_FOLDER_PATH + File.separator + getFileName(targetPath); result = pullTheFile(targetPath, localBinaryPath); @@ -1049,7 +1060,8 @@ public class Communicator30 extends BaseCommunicator { DA_LOG.debug("host md5sum get failed : " + errorStr); result = HostResult.ERR_BIN_INFO_GET_FAIL; } else { - String[] splitResult = line.trim().split(CommonConstants.SPACE); + String[] splitResult = line.trim().split( + CommonConstants.SPACE); localHashCode = new String(splitResult[0]); } } catch (IOException e) { @@ -1062,8 +1074,8 @@ public class Communicator30 extends BaseCommunicator { if (localHashCode == null || 0 != localHashCode.compareTo(binInfo.getMd5sumValue())) { - localBinaryPath = PathManager.DA_TEMP_FOLDER_PATH + File.separator - + getFileName(targetPath); + localBinaryPath = PathManager.DA_TEMP_FOLDER_PATH + + File.separator + getFileName(targetPath); result = pullTheFile(targetPath, localBinaryPath); if (result.isSuccess()) { binInfo.setTempBinaryPath(localBinaryPath); -- 2.7.4