}
try {
- printWriter = new PrintWriter(
- new BufferedWriter(new FileWriter(logPath)), true);
+ printWriter = new PrintWriter(new BufferedWriter(new FileWriter(logPath)), true);
} catch (IOException e) {
e.printStackTrace();
}
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
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;
// TODO : make new protocol field or message for launched app and
// instrucmented app
- if (!app.getAppId().equals(app.getPackageId())) {
+ if (!app.getAppId().startsWith(app.getPackageId())) {
continue;
}
BinaryInfo binInfo = AnalyzerManager.getProject().getDeviceStatusInfo()
.getBinaryInfo(app.getExecPath());
- if (binInfo.getTempBinaryPath() == null) {
+ String temppath = binInfo.getTempBinaryPath();
+ if (temppath == null) {
// this means the app binary does not exist in device
continue;
}
appInst.setExecutablePath(app.getExecPath());
DA_LOG.debug("Set execute path : " + app.getExecPath());
- List<AddrSymbolPair> symbols = app.getSymbols(binInfo.getTempBinaryPath());
+ List<AddrSymbolPair> symbols = app.getSymbols(temppath);
List<FunctionInst> functionInstList = appInst.getFunctionInstList();
int size = (symbols == null) ? 0 : symbols.size();
}
@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();
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)) {
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);
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);
return GlobalInformation.getCurrentDeviceInfo().getDataSock();
}
- private void processTargetInfo(byte[] payload, int index,
- DeviceStatusInfo tInfo) {
+ private void processTargetInfo(byte[] payload, int index, DeviceStatusInfo tInfo) {
long systemMemorySize = 0;
long storageSize = 0;
int bluetoothSupport = 0;
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;
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) {
String targetPath = binPaths.get(i);
sendBin = ByteUtil.getByte(sendBin, targetPath);
}
-
+
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;
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;
outBinaries.add(binInfo);
if (binaryType < 0) {
+ // binary does not exist in target
return;
}
- String[] splitLocalBinaryPath = localBinaryPath
- .split(CommonConstants.SLASH);
+ String[] splitLocalBinaryPath = localBinaryPath.split(CommonConstants.SLASH);
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()) {
- localBinaryPath = PathManager.DA_TEMP_FOLDER_PATH
- + File.separator + getFileName(targetPath);
+ if (splitLocalBinaryPath.length < 3 || !(new File(localBinaryPath)).exists()) {
+ localBinaryPath = PathManager.DA_TEMP_FOLDER_PATH + File.separator
+ + getFileName(targetPath);
result = pullTheFile(targetPath, localBinaryPath);
if (result.isSuccess()) {
binInfo.setTempBinaryPath(localBinaryPath);
try {
Runtime rt = Runtime.getRuntime();
Process process = rt.exec(new String[] {
- AnalyzerShellCommands.CMD_MD_5_SUM,
- localBinaryPath });
+ AnalyzerShellCommands.CMD_MD_5_SUM, localBinaryPath });
process.waitFor();
- BufferedReader reader = new BufferedReader(
- new InputStreamReader(process.getInputStream()));
- BufferedReader error = new BufferedReader(
- new InputStreamReader(process.getErrorStream()));
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ process.getInputStream()));
+ BufferedReader error = new BufferedReader(new InputStreamReader(
+ process.getErrorStream()));
String line = reader.readLine();
String errorStr = error.readLine();
if (null == line) {
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) {
result = HostResult.ERR_BIN_INFO_GET_FAIL;
}
- if (localHashCode != null) {
- String targetHashCode = binInfo.getMd5sumValue();
- if (0 != targetHashCode.compareTo(localHashCode)) {
- localBinaryPath = PathManager.DA_TEMP_FOLDER_PATH
- + File.separator + getFileName(targetPath);
- result = pullTheFile(targetPath, localBinaryPath);
- if (result.isSuccess()) {
- binInfo.setTempBinaryPath(localBinaryPath);
- }
- } else {
+ if (localHashCode == null
+ || 0 != localHashCode.compareTo(binInfo.getMd5sumValue())) {
+ localBinaryPath = PathManager.DA_TEMP_FOLDER_PATH + File.separator
+ + getFileName(targetPath);
+ result = pullTheFile(targetPath, localBinaryPath);
+ if (result.isSuccess()) {
binInfo.setTempBinaryPath(localBinaryPath);
}
+ } else {
+ binInfo.setTempBinaryPath(localBinaryPath);
}
}
} else { // if not linux
- 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);