From: greatim Date: Sun, 31 Aug 2014 07:12:18 +0000 (+0900) Subject: INTERNAL: change managing app list X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F85%2F26885%2F1;p=sdk%2Ftools%2Fdynamic-analyzer.git INTERNAL: change managing app list change launch target to package from application Change-Id: I70288e55c5d7c4d538629f67e47d514ae89b5bc6 Signed-off-by: greatim --- diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AutoStartManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AutoStartManager.java index 7a09027..56a095c 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AutoStartManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AutoStartManager.java @@ -26,13 +26,13 @@ package org.tizen.dynamicanalyzer.common; -import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.tizen.dynamicanalyzer.communicator.DACommunicator; import org.tizen.dynamicanalyzer.model.DeviceInfo; import org.tizen.dynamicanalyzer.project.AppInfo; +import org.tizen.dynamicanalyzer.project.PackageInfo; import org.tizen.dynamicanalyzer.resources.ImageResources; import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea; import org.tizen.dynamicanalyzer.util.Logger; @@ -112,17 +112,8 @@ public class AutoStartManager implements Runnable { DeviceInfo device = DACommunicator.getDeviceByName(deviceName); GlobalInformation.setCurrentDeviceInfo(device); - List appList = device.getAppInfoList(); - - AppInfo appInfo = null; - for (int i = 0; i < appList.size(); i++) { - if (appid.equals(appList.get(i).getInfo(AppInfo.PROPERTY.PACKAGE.index))) { - appInfo = appList.get(i); - break; - } - } - - if (null == appInfo) { + PackageInfo pkgInfo = DACommunicator.getPkgInfoByPkgId(appid); + if (null == pkgInfo) { Display.getDefault().syncExec(new Runnable() { public void run() { Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell(); @@ -141,7 +132,7 @@ public class AutoStartManager implements Runnable { Logger.debug("invalid application name :" + appid); return; } - final String appLabel = appInfo.getInfo(AppInfo.PROPERTY.LABEL.index); + final String appLabel = pkgInfo.getMainApp().getInfo(AppInfo.PROPERTY.LABEL.index); Logger.debug("IDE recv - deviceName: " + deviceName + " appName : " + appLabel); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/GlobalInformation.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/GlobalInformation.java index 1924181..d8217c0 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/GlobalInformation.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/GlobalInformation.java @@ -1,7 +1,7 @@ package org.tizen.dynamicanalyzer.common; import org.tizen.dynamicanalyzer.model.DeviceInfo; -import org.tizen.dynamicanalyzer.project.AppInfo; +import org.tizen.dynamicanalyzer.project.PackageInfo; import org.tizen.dynamicanalyzer.project.Project; import org.tizen.dynamicanalyzer.swap.channel.control.RunTimeConfiguration; @@ -9,7 +9,7 @@ import org.tizen.dynamicanalyzer.swap.channel.control.RunTimeConfiguration; // So this class contains only static methods and variables. public class GlobalInformation { private static DeviceInfo currentDevice = null; - private static AppInfo currentApplication = null; + private static PackageInfo currentApplication = null; private static Project currentProject = null; private static RunTimeConfiguration currentConfiguration = null; @@ -29,12 +29,12 @@ public class GlobalInformation { currentProject = project; } - public static AppInfo getCurrentApplication() { + public static PackageInfo getCurrentApplication() { return currentApplication; } - public static void setCurrentApplication(AppInfo appInfo) { - currentApplication = appInfo; + public static void setCurrentApplication(PackageInfo pkgInfo) { + currentApplication = pkgInfo; } public static RunTimeConfiguration getCurrentConfiguration() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/BaseCommunicator.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/BaseCommunicator.java index 1a9cf36..53bffd1 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/BaseCommunicator.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/BaseCommunicator.java @@ -30,7 +30,7 @@ import java.net.Socket; import org.tizen.dynamicanalyzer.common.HostResult; import org.tizen.dynamicanalyzer.model.DeviceInfo; -import org.tizen.dynamicanalyzer.project.AppInfo; +import org.tizen.dynamicanalyzer.project.PackageInfo; public abstract class BaseCommunicator { @@ -69,6 +69,6 @@ public abstract class BaseCommunicator { public abstract void closeSock(); - public void onAppSelected(AppInfo app) { + public void onAppSelected(PackageInfo pkg) { } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/Communicator22.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/Communicator22.java index 702d565..46da58c 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/Communicator22.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/Communicator22.java @@ -44,6 +44,7 @@ import org.tizen.dynamicanalyzer.common.HostResult; import org.tizen.dynamicanalyzer.constant.CommonConstants; import org.tizen.dynamicanalyzer.model.DeviceInfo; import org.tizen.dynamicanalyzer.project.AppInfo; +import org.tizen.dynamicanalyzer.project.PackageInfo; import org.tizen.dynamicanalyzer.swap.channel.control.EventObject; import org.tizen.dynamicanalyzer.swap.channel.control.ReplayEvent; import org.tizen.dynamicanalyzer.swap.logparser.DataManagerRegistry; @@ -169,15 +170,15 @@ public class Communicator22 extends BaseCommunicator { isEmul = 1; } - AppInfo app = GlobalInformation.getCurrentApplication(); - if (null == app) { + PackageInfo pkg = GlobalInformation.getCurrentApplication(); + if (null == pkg) { return HostResult.ERR_SELECTED_APP_IS_NULL; } String rearMessage = CommonConstants.EMPTY + res + isEmul + isArm + CommonConstants.CMD_SPLIT + ConfigureManager.getInstance().getConfiguration(device) + CommonConstants.CMD_SPLIT - + app.getInfo(AppInfo.PROPERTY.EXEC.index); + + pkg.getMainApp().getInfo(AppInfo.PROPERTY.EXEC.index); String message = AnalyzerConstants.MSG_START + CommonConstants.CMD_SPLIT + rearMessage.length() diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DACommunicator.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DACommunicator.java index b87784a..229c782 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DACommunicator.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DACommunicator.java @@ -35,7 +35,6 @@ import java.io.BufferedReader; import java.io.File; import java.net.Socket; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -75,8 +74,6 @@ public class DACommunicator { private static List devices = null; private static List filterMultiLines = new ArrayList(); - private static List unittestList = new ArrayList(); - private static List imeList = new ArrayList(); private static List uploadDataResult = new ArrayList(); private static List checkVersionResult = new ArrayList(); @@ -114,7 +111,6 @@ public class DACommunicator { cmdResultMultiLines.clear(); filterMultiLines.clear(); uploadDataResult.clear(); - unittestList.clear(); } public static List getDevices() { @@ -237,19 +233,39 @@ public class DACommunicator { return devNameList; } - public static List getAppListFromTarget() { - if (null == GlobalInformation.getCurrentDeviceInfo()) { + public static Map getAppListFromTarget() { + DeviceInfo curDev = GlobalInformation.getCurrentDeviceInfo(); + if (curDev == null) { return null; } - List appInfoList = GlobalInformation.getCurrentDeviceInfo() - .getAppInfoList(); - HashMap appInfoHash = GlobalInformation.getCurrentDeviceInfo() - .getAppInfoHash(); - List backList = new ArrayList(); - backList.addAll(appInfoHash.values()); cmdResultMultiLines.clear(); + CommunicatorUtils.execHostCommand(AnalyzerShellCommands.DACOMMAND_FIND_UNITTEST, + new MultiLineReceiver() { + @Override + public void processNewLines(String[] appLines) { + for (int i = 0; i < appLines.length; i++) { + filterMultiLines.add(appLines[i]); + } + } + }); + + curDev.parseUnittestList(cmdResultMultiLines); + cmdResultMultiLines.clear(); + CommunicatorUtils.execShellCommand(AnalyzerShellCommands.DACOMMAND_FIND_IME, + new MultiLineReceiver() { + @Override + public void processNewLines(String[] appLines) { + for (int i = 0; i < appLines.length; i++) { + filterMultiLines.add(appLines[i]); + } + } + }); + + curDev.parseImeList(cmdResultMultiLines); + + cmdResultMultiLines.clear(); CommunicatorUtils.execShellCommand(AnalyzerShellCommands.CMD_APPLICATION_LIST, new MultiLineReceiver() { @Override @@ -261,9 +277,6 @@ public class DACommunicator { }); cmdResultMultiLines.add(""); - checkUnittest(); - checkIME(); - // add lines for running process cmdResultMultiLines.add(AppInfo.PROPERTY.APPID.name + ":" + AnalyzerConstants.RUNNING_PROCESS); @@ -271,8 +284,7 @@ public class DACommunicator { + AnalyzerConstants.RUNNING_PROCESS); cmdResultMultiLines.add(AppInfo.PROPERTY.LABEL.name + ":" + AnalyzerConstants.RUNNING_PROCESS); - cmdResultMultiLines.add(AppInfo.PROPERTY.APPTYPE.name + ":" - + AppInfo.APPTYPE_RUNNING); + cmdResultMultiLines.add(AppInfo.PROPERTY.APPTYPE.name + ":" + AppInfo.APPTYPE_RUNNING); cmdResultMultiLines.add(""); // add lines for without-executable @@ -282,8 +294,7 @@ public class DACommunicator { + AnalyzerConstants.COMMON_EXECUTABLE); cmdResultMultiLines.add(AppInfo.PROPERTY.LABEL.name + ":" + AnalyzerConstants.COMMON_EXECUTABLE); - cmdResultMultiLines.add(AppInfo.PROPERTY.APPTYPE.name + ":" - + AppInfo.APPTYPE_EXEC); + cmdResultMultiLines.add(AppInfo.PROPERTY.APPTYPE.name + ":" + AppInfo.APPTYPE_EXEC); cmdResultMultiLines.add(""); // add lines for without-executable @@ -293,58 +304,12 @@ public class DACommunicator { + AnalyzerConstants.WITHOUT_EXECUTABLE); cmdResultMultiLines.add(AppInfo.PROPERTY.LABEL.name + ":" + AnalyzerConstants.WITHOUT_EXECUTABLE); - cmdResultMultiLines.add(AppInfo.PROPERTY.APPTYPE.name + ":" - + AppInfo.APPTYPE_NONE); + cmdResultMultiLines.add(AppInfo.PROPERTY.APPTYPE.name + ":" + AppInfo.APPTYPE_NONE); cmdResultMultiLines.add(""); - int size = cmdResultMultiLines.size(); + curDev.parseAppList(cmdResultMultiLines); - for (int i = 0; i < size; i++) { - String line = cmdResultMultiLines.get(i); - if (line.startsWith("Appid")) { - List lines = new ArrayList(); - int ii; - for (ii = 0; ii + i < size; ii++) { - String inputLine = cmdResultMultiLines.get(ii + i); - if (inputLine.isEmpty()) { - continue; - } else if (ii != 0 && inputLine.startsWith("Appid")) { - break; - } - lines.add(cmdResultMultiLines.get(ii + i)); - } - i += ii - 1; - - AppInfo appInfo = makePackageInfo( - GlobalInformation.getCurrentDeviceInfo(), lines); - if (null != appInfo) { - // && appInfo.getInfo(AppInfo.MULTIPLE_INDEX).equals( - // AppInfo.FLAG_ZERO) - // && appInfo.getInfo(AppInfo.NODISPLAY_INDEX).equals( - // AppInfo.FLAG_ZERO)) { - String pkgId = appInfo.getInfo(AppInfo.PROPERTY.PACKAGE.index); - String appId = appInfo.getInfo(AppInfo.PROPERTY.APPID.index); - - if (null == appInfoHash.get(appId)) { - if (!isUnittest(pkgId) && !isIME(appId)) { - appInfoList.add(appInfo); - appInfoHash.put(appId, appInfo); - } - } else { - backList.remove(appInfoHash.get(appId)); - } - } - } - } - if (!backList.isEmpty()) { - for (AppInfo app : backList) { - String appId = app.getInfo(AppInfo.PROPERTY.APPID.index); - appInfoList.remove(app); - appInfoHash.remove(appId); - } - } - - return appInfoList; + return curDev.getPackageInfoHash(); } public static Map getProcessListFromTarget() { @@ -385,154 +350,34 @@ public class DACommunicator { return processMap; } - private static boolean isUnittest(String pkgId) { - if (null != unittestList && !unittestList.isEmpty()) { - for (String id : unittestList) { - if (id.equals(pkgId)) { - return true; - } - } - } - return false; - } - - private static boolean isIME(String appId) { - if (null != imeList && !imeList.isEmpty()) { - for (String id : imeList) { - if (id.equals(appId)) { - return true; - } - } - } - return false; - } - - private static void checkUnittest() { - unittestList.clear(); - if (null == GlobalInformation.getCurrentDeviceInfo()) { - return; - } - String appInstallPath = GlobalInformation.getCurrentDeviceInfo().getIDevice() - .getAppInstallPath(); - - filterMultiLines.clear(); - CommunicatorUtils.execHostCommand(AnalyzerShellCommands.DACOMMAND_FIND_UNITTEST, - new MultiLineReceiver() { - @Override - public void processNewLines(String[] appLines) { - for (int i = 0; i < appLines.length; i++) { - filterMultiLines.add(appLines[i]); - } - } - }); - - if (filterMultiLines.isEmpty()) { - return; - } - - for (String line : filterMultiLines) { - if (line.contains(appInstallPath)) { - line = line.replaceFirst(appInstallPath + CommonConstants.SLASH, - CommonConstants.EMPTY); - int index = line.indexOf(CommonConstants.SLASH); - line = line.substring(0, index); - unittestList.add(line); - } - } - } - - private static void checkIME() { - imeList.clear(); - if (null == GlobalInformation.getCurrentDeviceInfo()) { - return; - } + public static PackageInfo getPkgInfoByLabel(String appLabel) { + DeviceInfo curDev = GlobalInformation.getCurrentDeviceInfo(); + if (null != curDev) { + Map pkgHash = curDev.getPackageInfoHash(); - filterMultiLines.clear(); - CommunicatorUtils.execShellCommand(AnalyzerShellCommands.DACOMMAND_FIND_IME, - new MultiLineReceiver() { - @Override - public void processNewLines(String[] appLines) { - for (int i = 0; i < appLines.length; i++) { - filterMultiLines.add(appLines[i]); - } - } - }); - - if (filterMultiLines.isEmpty()) { - return; - } - - for (String line : filterMultiLines) { - String appId = "appid";//$NON-NLS-1$ - if (line.contains("apptype") && line.contains("c++app")) { - line = line.trim(); - int index = line.indexOf(appId); - // 2 means length of String " [" - line = line.substring(index + appId.length() + 2, line.length() - 1); - imeList.add(line); - } - } - } - - private static AppInfo makePackageInfo(DeviceInfo device, List lines) { - AppInfo appInfo = new AppInfo(); - for (int i = 0; i < lines.size(); i++) { - String line = lines.get(i); - int index = line.indexOf(":"); - if (index > 0) { - String key = line.substring(0, index).trim(); - String data = line.substring(index + 1, line.length()).trim(); - - AppInfo.PROPERTY p = AppInfo.PROPERTY.get(key); - if (p != null) { - appInfo.setInfo(p.index, data); + for (Map.Entry entry : pkgHash.entrySet()) { + AppInfo app = entry.getValue().getMainApp(); + String label = app.getInfo(AppInfo.PROPERTY.LABEL.index); + if (appLabel.equals(label)) { + return entry.getValue(); } } } - String pkgId = appInfo.getInfo(AppInfo.PROPERTY.PACKAGE.index); - PackageInfo pkgInfo = device.getPackageInfoHash().get(pkgId); - if (null == pkgInfo) { - pkgInfo = new PackageInfo(pkgId); - pkgInfo.addAppInfo(appInfo); - device.getPackageInfoHash().put(pkgId, pkgInfo); - } else { - pkgInfo.addAppInfo(appInfo); - } - return appInfo; - } - - public static AppInfo getPkgInfoByName(String appLabel) { - if (null != GlobalInformation.getCurrentDeviceInfo()) { - int size = GlobalInformation.getCurrentDeviceInfo().getAppInfoList().size(); - for (int i = 0; i < size; i++) { - AppInfo pkgInfo = GlobalInformation.getCurrentDeviceInfo() - .getAppInfoList().get(i); - if (pkgInfo.getInfo(AppInfo.PROPERTY.LABEL.index).equals(appLabel)) { - return pkgInfo; - } - } - } return null; } - public static AppInfo getPkgInfoByAppPkgId(String pkgid) { + public static PackageInfo getPkgInfoByPkgId(String pkgid) { if (null != GlobalInformation.getCurrentDeviceInfo()) { - int size = GlobalInformation.getCurrentDeviceInfo().getAppInfoList().size(); - for (int i = 0; i < size; i++) { - AppInfo ai = GlobalInformation.getCurrentDeviceInfo().getAppInfoList() - .get(i); - if (ai.getInfo(AppInfo.PROPERTY.PACKAGE.index).equals(pkgid)) { - return ai; - } - } + return GlobalInformation.getCurrentDeviceInfo().getPackageInfoHash().get(pkgid); + } else { + return null; } - return null; } public static void removeCommand(String path) { - CommunicatorUtils.execShellCommand(AnalyzerShellCommands.CMD_REMOVE - + CommonConstants.SPACE + path); + CommunicatorUtils.execShellCommand(AnalyzerShellCommands.CMD_REMOVE + CommonConstants.SPACE + + path); } public static boolean isTargetEmulator() { @@ -646,8 +491,7 @@ public class DACommunicator { } }); - Logger.debug("device changed : " + device.getSerialNumber() + " " - + changeMask); + Logger.debug("device changed : " + device.getSerialNumber() + " " + changeMask); if (1 == changeMask) { if (!AnalyzerManager.isRunning()) { DeviceInfo devInfo = new DeviceInfo(device); @@ -707,8 +551,7 @@ public class DACommunicator { Display.getDefault().syncExec(new Runnable() { @Override public void run() { - ToolbarArea.getInstance().setDeviceComboItems(selectedDevice, - deviceSerials); + ToolbarArea.getInstance().setDeviceComboItems(selectedDevice, deviceSerials); } }); } @@ -751,8 +594,7 @@ public class DACommunicator { Logger.debug("Failed to get " + from); //$NON-NLS-1$ } - AnalyzerUtil - .checkLogs(PathManager.DA_LOG_PATH, DAEMONLOG_PREFIX, DAEMONLOG_COUNT); + AnalyzerUtil.checkLogs(PathManager.DA_LOG_PATH, DAEMONLOG_PREFIX, DAEMONLOG_COUNT); } // public static String getLocalhost() { @@ -788,8 +630,7 @@ public class DACommunicator { } public static BufferedReader getSockBufferedReader() { - return GlobalInformation.getCurrentDeviceInfo().getCommunicator() - .getDataBufferedReader(); + return GlobalInformation.getCurrentDeviceInfo().getCommunicator().getDataBufferedReader(); } public static void closeAll() { @@ -801,16 +642,14 @@ public class DACommunicator { } public static HostResult handleControlMessage(String msg) { - return GlobalInformation.getCurrentDeviceInfo().getCommunicator() - .handleControlMessage(msg); + return GlobalInformation.getCurrentDeviceInfo().getCommunicator().handleControlMessage(msg); } public static Map sendProcessAddInfoMessage(List pids) { DeviceInfo dev = GlobalInformation.getCurrentDeviceInfo(); if (dev != null) { if (isSWAPVersion()) { - return ((Communicator30) dev.getCommunicator()) - .sendProcessAddInfoMessage(pids); + return ((Communicator30) dev.getCommunicator()).sendProcessAddInfoMessage(pids); } } return null; @@ -818,24 +657,24 @@ public class DACommunicator { public static HostResult sendBinaryInfoMessageForLib(List input) { if (isSWAPVersion()) { - return ((Communicator30) GlobalInformation.getCurrentDeviceInfo() - .getCommunicator()).sendBinaryInfoMessageForLib(input); + return ((Communicator30) GlobalInformation.getCurrentDeviceInfo().getCommunicator()) + .sendBinaryInfoMessageForLib(input); } return null; } public static HostResult sendSWAPMessage(int messageId, List input) { if (isSWAPVersion()) { - return ((Communicator30) GlobalInformation.getCurrentDeviceInfo() - .getCommunicator()).sendSWAPMessage(messageId, input); + return ((Communicator30) GlobalInformation.getCurrentDeviceInfo().getCommunicator()) + .sendSWAPMessage(messageId, input); } return null; } public static HostResult sendScreenShotMessage() { if (isSWAPVersion()) { - return ((Communicator30) GlobalInformation.getCurrentDeviceInfo() - .getCommunicator()).sendScreenShotRequest(); + return ((Communicator30) GlobalInformation.getCurrentDeviceInfo().getCommunicator()) + .sendScreenShotRequest(); } return null; } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/IDECommunicator.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/IDECommunicator.java index 428994e..e98e094 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/IDECommunicator.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/IDECommunicator.java @@ -54,6 +54,7 @@ import org.tizen.dynamicanalyzer.constant.CommonConstants; import org.tizen.dynamicanalyzer.model.DeviceInfo; import org.tizen.dynamicanalyzer.nl.AnalyzerLabels; import org.tizen.dynamicanalyzer.project.AppInfo; +import org.tizen.dynamicanalyzer.project.PackageInfo; import org.tizen.dynamicanalyzer.resources.ImageResources; import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea; import org.tizen.dynamicanalyzer.util.CommonUtil; @@ -265,8 +266,7 @@ public class IDECommunicator implements Runnable { final String deviceName = new String(strMsg[MSG_INDEX_DEVICE].trim()); final String projectType = new String(strMsg[MSG_INDEX_PROJECT_TYPE].trim()); - final String binaryOfTarget = new String( - strMsg[MSG_INDEX_BINARY_OF_TARGET].trim()); + final String binaryOfTarget = new String(strMsg[MSG_INDEX_BINARY_OF_TARGET].trim()); final String executablePath = new String(strMsg[MSG_INDEX_EXECUTABLE_PATH].trim()); List localPackagePathList = new ArrayList(); for (int i = MSG_INDEX_LOCAL_PACKAGE_PATH; i < strMsg.length; i++) { @@ -290,22 +290,21 @@ public class IDECommunicator implements Runnable { GlobalInformation.setCurrentDeviceInfo(device); DACommunicator.getAppListFromTarget(); - AppInfo appInfo = null; + PackageInfo pkgInfo = null; if (projectType.equals(PROJECT_TYPE_OSP) || projectType.equals(PROJECT_TYPE_EFL) || projectType.equals(PROJECT_TYPE_WEBAPP)) { - appInfo = DACommunicator.getPkgInfoByAppPkgId(binaryOfTarget); - if (appInfo == null) { + pkgInfo = DACommunicator.getPkgInfoByPkgId(binaryOfTarget); + if (pkgInfo == null) { popupMessageUnsupportedApp(binaryOfTarget); return; } if (localPackagePathList.size() > 0) { - appInfo.setLocalPackagePath(localPackagePathList); + pkgInfo.getMainApp().setLocalPackagePath(localPackagePathList); } - final String appLabel = appInfo.getInfo(AppInfo.PROPERTY.LABEL.index); - Logger.debug("IDE recv - deviceName: " + deviceName + " appName : " - + appLabel); + final String appLabel = pkgInfo.getMainApp().getInfo(AppInfo.PROPERTY.LABEL.index); + Logger.debug("IDE recv - deviceName: " + deviceName + " appName : " + appLabel); Display.getDefault().syncExec(new Runnable() { public void run() { @@ -324,11 +323,9 @@ public class IDECommunicator implements Runnable { for (int i = 0; i < localPackagePathList.size(); i++) { String path = localPackagePathList.get(i); - if (path.endsWith(RpmUtil.RPM_EXT) - && path.contains(RpmUtil.DEBUGINFO)) { + if (path.endsWith(RpmUtil.RPM_EXT) && path.contains(RpmUtil.DEBUGINFO)) { debugrpm = path; - } else if (path.endsWith(RpmUtil.RPM_EXT) - && path.contains(RpmUtil.DEBUGSOURCE)) { + } else if (path.endsWith(RpmUtil.RPM_EXT) && path.contains(RpmUtil.DEBUGSOURCE)) { srcrpm = path; } else if (path.endsWith(RpmUtil.RPM_EXT)) { mainrpm = path; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/model/DeviceInfo.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/model/DeviceInfo.java index 611f2b5..58c07dd 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/model/DeviceInfo.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/model/DeviceInfo.java @@ -30,6 +30,7 @@ import java.net.Socket; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Map; import org.tizen.dynamicanalyzer.common.AnalyzerConstants; import org.tizen.dynamicanalyzer.common.HostResult; @@ -47,14 +48,16 @@ import org.tizen.sdblib.IDevice; public class DeviceInfo { private IDevice device = null; - private String selectedApplication = null; + private String selectedPackage = null; private String targetVersion = null; private BaseCommunicator communicator = null; private boolean configSuccess = false; - private List appInfoList = null; - private HashMap appInfoHash = null; - private HashMap pkgInfoHash = null; + private Map pkgInfoHash = new HashMap(); + private List pkgInfoString = new ArrayList(); + + private List unittestList = new ArrayList(); + private List imeList = new ArrayList(); private DeviceStatusInfo statusInfo = null; @@ -67,32 +70,21 @@ public class DeviceInfo { public DeviceInfo(IDevice device) { this.device = device; - appInfoList = new ArrayList(); - appInfoHash = new HashMap(); - pkgInfoHash = new HashMap(); statusInfo = new DeviceStatusInfo(CommunicatorUtils.getApiMap(device)); } - public void setSelectedAppName(String name) { - selectedApplication = name; + public void setSelectedPackageID(String id) { + selectedPackage = id; } - public String getSelectedAppName() { - return selectedApplication; + public String getSelectedPackageID() { + return selectedPackage; } public IDevice getIDevice() { return device; } - public List getAppInfoList() { - return appInfoList; - } - - public HashMap getAppInfoHash() { - return appInfoHash; - } - public void setTargetVersion(String version) { targetVersion = version; if (version.contains(AnalyzerConstants.DA_VERSION_SWAP)) { @@ -132,8 +124,7 @@ public class DeviceInfo { } public boolean equals(DeviceInfo target) { - if (device.getSerialNumber().equals( - target.getIDevice().getSerialNumber())) { + if (device.getSerialNumber().equals(target.getIDevice().getSerialNumber())) { return true; } return false; @@ -164,7 +155,7 @@ public class DeviceInfo { return communicator.sendConfigurationMessage(this, type, message); } - public HashMap getPackageInfoHash() { + public Map getPackageInfoHash() { return pkgInfoHash; } @@ -188,4 +179,152 @@ public class DeviceInfo { public void setConfigSuccess(boolean success) { configSuccess = success; } + + public void parseUnittestList(List lines) { + unittestList.clear(); + if (lines.isEmpty()) { + return; + } + + String appInstallPath = getIDevice().getAppInstallPath(); + + for (String line : lines) { + if (line.contains(appInstallPath)) { + line = line.replaceFirst(appInstallPath + CommonConstants.SLASH, + CommonConstants.EMPTY); + int index = line.indexOf(CommonConstants.SLASH); + line = line.substring(0, index); + unittestList.add(line); + } + } + } + + public void parseImeList(List lines) { + imeList.clear(); + if (lines.isEmpty()) { + return; + } + + for (String line : lines) { + String appId = "appid";//$NON-NLS-1$ + if (line.contains("apptype") && line.contains("c++app")) { + line = line.trim(); + int index = line.indexOf(appId); + // 2 means length of String " [" + line = line.substring(index + appId.length() + 2, line.length() - 1); + imeList.add(line); + } + } + } + + public void parseAppList(List lines) { + if (changedAppList(lines)) { + pkgInfoString.clear(); + pkgInfoString.addAll(lines); + + // parsing app list lines + pkgInfoHash.clear(); + + int size = lines.size(); + + for (int i = 0; i < size; i++) { + if (lines.get(i).startsWith("Appid")) { + List applines = new ArrayList(); + + int k; + for (k = 0; k + i < size; k++) { + String inputLine = lines.get(k + i); + if (inputLine.isEmpty()) { + continue; + } else if (k != 0 && inputLine.startsWith("Appid")) { + break; + } + applines.add(inputLine); + } + i += k - 1; + + AppInfo appInfo = makeAppInfo(applines); + + String appID = appInfo.getAppId(); + String pkgID = appInfo.getPackageId(); + + if (!isUnittest(pkgID) && !isIME(appID)) { + PackageInfo pkgInfo = pkgInfoHash.get(pkgID); + if (null == pkgInfo) { + pkgInfo = new PackageInfo(pkgID); + pkgInfoHash.put(pkgID, pkgInfo); + } + pkgInfo.addAppInfo(appInfo); + } + } + } + } + } + + private AppInfo makeAppInfo(List lines) { + AppInfo appInfo = new AppInfo(); + for (int i = 0; i < lines.size(); i++) { + String line = lines.get(i); + int index = line.indexOf(':'); + if (index > 0) { + String key = line.substring(0, index).trim(); + String data = line.substring(index + 1, line.length()).trim(); + + AppInfo.PROPERTY p = AppInfo.PROPERTY.get(key); + if (p != null) { + appInfo.setInfo(p.index, data); + } + } + } + + return appInfo; + } + + private boolean changedAppList(List strings) { + if (pkgInfoString != null) { + if (pkgInfoString.size() == strings.size()) { + int i; + int ssize = pkgInfoString.size(); + for (i = 0; i < ssize; i++) { + if (pkgInfoString.get(i) == null) { + if (strings.get(i) != null) { + break; + } + } else if (strings.get(i) == null) { + break; + } else if (!pkgInfoString.get(i).equals(strings.get(i))) { + break; + } + } + + if (i == ssize) + return false; + } + } + + return true; + } + + private boolean isUnittest(String pkgId) { + if (null != unittestList && !unittestList.isEmpty()) { + for (String id : unittestList) { + if (id.equals(pkgId)) { + return true; + } + } + } + return false; + } + + private boolean isIME(String appId) { + if (null != imeList && !imeList.isEmpty()) { + for (String id : imeList) { + if (id.equals(appId)) { + return true; + } + } + } + return false; + } + } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/PackageInfo.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/PackageInfo.java index cbb379f..af73f90 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/PackageInfo.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/PackageInfo.java @@ -63,4 +63,9 @@ public class PackageInfo { public List getAppInfos() { return appInfos; } + + // TODO: ensure main app is the first app in package + public AppInfo getMainApp() { + return appInfos.get(0); + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/Project.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/Project.java index 57a58a5..b406b61 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/Project.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/Project.java @@ -75,10 +75,8 @@ public class Project { private static final String SECTION_E = "]"; private static final String PRIMITIVE_SECTION = SECTION_F + "Primitive" + SECTION_E; - private static final String DEVICE_SECTION = SECTION_F + "Device Information" - + SECTION_E; - private static final String APP_SECTION = SECTION_F + "Application information" - + SECTION_E; + private static final String DEVICE_SECTION = SECTION_F + "Device Information" + SECTION_E; + private static final String APP_SECTION = SECTION_F + "Application information" + SECTION_E; private static final String VERSION = "version"; private static final String PROTOCOL_VERSION = "protocolVersion"; @@ -289,31 +287,27 @@ public class Project { public void initForTrace() { if (null == GlobalInformation.getCurrentApplication()) { String comboText = ToolbarArea.getInstance().getAppCombo().getText(); - AppInfo appInfo = DACommunicator.getPkgInfoByName(comboText); - GlobalInformation.setCurrentApplication(appInfo); - GlobalInformation.getCurrentDeviceInfo().getCommunicator() - .onAppSelected(appInfo); + PackageInfo pkgInfo = DACommunicator.getPkgInfoByLabel(comboText); + GlobalInformation.setCurrentApplication(pkgInfo); + GlobalInformation.getCurrentDeviceInfo().getCommunicator().onAppSelected(pkgInfo); } setProtocolVersion(GlobalInformation.getCurrentDeviceInfo().getTargetVersion()); - setDeviceStatusInfo(GlobalInformation.getCurrentDeviceInfo() - .getDeviceStatusInfo()); - setApplicationInfo(GlobalInformation.getCurrentApplication()); + setDeviceStatusInfo(GlobalInformation.getCurrentDeviceInfo().getDeviceStatusInfo()); + setApplicationInfo(GlobalInformation.getCurrentApplication().getMainApp()); RunTimeConfiguration currentConfig = GlobalInformation.getCurrentConfiguration(); if (currentConfig != null) { addConfigHistory(currentConfig); } - setAppName(GlobalInformation.getCurrentApplication().getInfo( - AppInfo.PROPERTY.LABEL.index)); - setPackageID(GlobalInformation.getCurrentApplication().getInfo( - AppInfo.PROPERTY.PACKAGE.index)); + setAppName(GlobalInformation.getCurrentApplication().getMainApp() + .getInfo(AppInfo.PROPERTY.LABEL.index)); + setPackageID(GlobalInformation.getCurrentApplication().getPackageId()); DeviceInfo deviceName = GlobalInformation.getCurrentDeviceInfo(); if (null != deviceName && null != deviceName.getIDevice().getSerialNumber() && !deviceName.getIDevice().getSerialNumber().isEmpty()) { - setDevice(GlobalInformation.getCurrentDeviceInfo().getIDevice() - .getSerialNumber()); + setDevice(GlobalInformation.getCurrentDeviceInfo().getIDevice().getSerialNumber()); } else { setDevice(CommonConstants.SPACE); } @@ -468,10 +462,10 @@ public class Project { List functionNames = targetDeviceStatusInfo.getFunctionList(); int size = functionNames.size(); List> insertData = new ArrayList>(); - - for(int i = 0; i < size; i++) { + + for (int i = 0; i < size; i++) { List insertRowData = new ArrayList(); - + try { insertRowData.add(new Integer(i)); insertRowData.add(new String(functionNames.get(i))); @@ -542,8 +536,7 @@ public class Project { private BufferedReader getOpenReader(String savePath) { BufferedReader reader = null; StringBuffer projectInfoSavedFile = new StringBuffer(savePath); - projectInfoSavedFile.append(File.separator).append( - PathConstants.PROJECT_INFO_FILE_NAME); + projectInfoSavedFile.append(File.separator).append(PathConstants.PROJECT_INFO_FILE_NAME); File saveFile = new File(projectInfoSavedFile.toString()); if (saveFile.isFile()) { @@ -640,12 +633,13 @@ public class Project { List> functionNames = functionNameTable.getFunctionNameFromDB(); if (null == functionNames) { Logger.error("failed - load function names"); - } else { + } else { int size = functionNames.size(); for (int i = 0; i < size; i++) { List functionName = functionNames.get(i); int id = (Integer) functionName.get(FunctionNameDBTable.COLUMN.FUNCTIONID.index); - String name = (String) functionName.get(FunctionNameDBTable.COLUMN.FUNCTIONNAME.index); + String name = (String) functionName + .get(FunctionNameDBTable.COLUMN.FUNCTIONNAME.index); functionList.add(id, name); } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/callstack/BaseCallstackManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/callstack/BaseCallstackManager.java index d10ee81..fd08e9f 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/callstack/BaseCallstackManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/callstack/BaseCallstackManager.java @@ -161,10 +161,11 @@ public abstract class BaseCallstackManager { public String getUserFunctionPosition() { if (userFunctionBin == null || userFunctionBin.isEmpty()) { if (AnalyzerManager.isOsp()) { - userFunctionBin = new String(GlobalInformation.getCurrentApplication() - .getInfo(AppInfo.PROPERTY.EXEC.index) + ".exe"); //$NON-NLS-1$ + userFunctionBin = new String(GlobalInformation.getCurrentApplication().getMainApp() + .getInfo(AppInfo.PROPERTY.EXEC.index) + + ".exe"); //$NON-NLS-1$ } else { - userFunctionBin = new String(GlobalInformation.getCurrentApplication() + userFunctionBin = new String(GlobalInformation.getCurrentApplication().getMainApp() .getInfo(AppInfo.PROPERTY.EXEC.index)); } } @@ -178,8 +179,7 @@ public abstract class BaseCallstackManager { if (pmap != null) { int binaryID = pmap.getMainbinary().getBinaryID(); - return project.getDeviceStatusInfo().getBinaryInfo(binaryID) - .getTargetBinaryPath(); + return project.getDeviceStatusInfo().getBinaryInfo(binaryID).getTargetBinaryPath(); } else { return CommonConstants.EMPTY; } @@ -233,12 +233,10 @@ public abstract class BaseCallstackManager { if (binInfo.getType() != 1) { isPieBuild = false; } - functionName = SymbolManager.addr2func(localPath, pcStr, isPieBuild, - baseAddr); + functionName = SymbolManager.addr2func(localPath, pcStr, isPieBuild, baseAddr); } - if (null == functionName || functionName.isEmpty() - || functionName.equals("_end")) { //$NON-NLS-1$ + if (null == functionName || functionName.isEmpty() || functionName.equals("_end")) { //$NON-NLS-1$ functionName = InformationViewLabels.CALLSTACK_TABLE_UNKNOWN_FUNCTION; } else { String prevFunctionName = functionName; @@ -249,8 +247,8 @@ public abstract class BaseCallstackManager { symbol = getUserFunctionPosition(pid, time) + AnalyzerConstants.CALLSTACK_API_TOKEN_STRING + functionName; } else { - HashMap binInfoMap = BinarySettingManager - .getInstance().getTargetBinInfoMap(); + HashMap binInfoMap = BinarySettingManager.getInstance() + .getTargetBinInfoMap(); LibraryObject libraryObject = pmap.getLibraryByAddress(addr); if (null != libraryObject) { @@ -271,23 +269,21 @@ public abstract class BaseCallstackManager { if (binInfo.getType() != 1) { isPieBuild = false; } - functionName = SymbolManager.addr2func(localPath, pcStr, - isPieBuild, baseAddr); + functionName = SymbolManager.addr2func(localPath, pcStr, isPieBuild, + baseAddr); if (null == functionName || functionName.isEmpty() || functionName.equals("_end")) { //$NON-NLS-1$ functionName = InformationViewLabels.CALLSTACK_TABLE_UNKNOWN_FUNCTION; } else { String prevFunctionName = functionName; - functionName = SymbolManager - .demanglingFunctionName(prevFunctionName); + functionName = SymbolManager.demanglingFunctionName(prevFunctionName); } // need to be checked again - in case pid is not main // application } else { functionName = InformationViewLabels.CALLSTACK_TABLE_UNKNOWN_FUNCTION; } - symbol = path + AnalyzerConstants.CALLSTACK_API_TOKEN_STRING - + functionName; + symbol = path + AnalyzerConstants.CALLSTACK_API_TOKEN_STRING + functionName; } } } 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 265eb03..d7595a6 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 @@ -105,9 +105,9 @@ import org.tizen.sdblib.service.SyncResult; public class Communicator30 extends BaseCommunicator { static final boolean PRINT_CONTROL_LOG_TOFILE = true; - + private static final int CONTROL_HEADER_SIZE = 8; - + private PrintWriter printWriter = null; @Override @@ -193,26 +193,22 @@ public class Communicator30 extends BaseCommunicator { replayData = ByteUtil.getByte(ReplayTraceHandler.REPLAY_OFF); } - byte[] rear = ByteUtil - .getByte(userSpaceInst.toByteStream(), replayData); + byte[] rear = ByteUtil.getByte(userSpaceInst.toByteStream(), replayData); int length = rear.length; - byte[] ret = ByteUtil.getByte(AnalyzerConstants.MSG_START_SWAP, length, - rear); + byte[] ret = ByteUtil.getByte(AnalyzerConstants.MSG_START_SWAP, length, rear); Logger.debug("print start message"); // ByteUtils.printByteArrayForStart(ret); if (PRINT_CONTROL_LOG_TOFILE) { - File logPath = new File( - PathManager.DA_DEBUG_CONTROL_CHANNEL_LOG_FILE); + File logPath = new File(PathManager.DA_DEBUG_CONTROL_CHANNEL_LOG_FILE); if (logPath.exists()) { logPath.delete(); } try { - printWriter = new PrintWriter(new BufferedWriter( - new FileWriter(logPath)), true); + printWriter = new PrintWriter(new BufferedWriter(new FileWriter(logPath)), true); } catch (IOException e) { e.printStackTrace(); } @@ -222,8 +218,7 @@ 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); Logger.performance("TEST", "Start Trace", "Make and Send start message"); // FIX @@ -235,8 +230,7 @@ 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; @@ -250,8 +244,7 @@ public class Communicator30 extends BaseCommunicator { index += INT_SIZE; int nano = ByteUtil.toInt(data, index); - AnalyzerManager.getProject().setProfilingStartTime( - new DATime(sec, nano)); + AnalyzerManager.getProject().setProfilingStartTime(new DATime(sec, nano)); } } else { DACommunicator.setRunning(false); @@ -276,8 +269,7 @@ public class Communicator30 extends BaseCommunicator { ToolbarArea.getInstance().startTimer(); Logger.performance("TEST", "Start Trace", "Start Timer"); SWAPLogParser.startLogParser(); - Logger.performance("TEST", "Start Trace", - "Start SWAP log parser thread"); + Logger.performance("TEST", "Start Trace", "Start SWAP log parser thread"); // start registered data manager thread DataManagerRegistry.startThreads(); Logger.performance("TEST", "Start Trace", "Start DataManager threads"); @@ -297,13 +289,10 @@ public class Communicator30 extends BaseCommunicator { if (pkgInfo.getPackageId().equals(AnalyzerConstants.RUNNING_PROCESS)) { // if running process is selected for tracing - Map selectedProcess = apps.get(0) - .getRunningProcesses(); + Map selectedProcess = apps.get(0).getRunningProcesses(); if (selectedProcess != null && selectedProcess.size() > 0) { - for (Map.Entry entry : selectedProcess - .entrySet()) { - BinaryInfo binInfo = AnalyzerManager.getProject() - .getDeviceStatusInfo() + for (Map.Entry entry : selectedProcess.entrySet()) { + BinaryInfo binInfo = AnalyzerManager.getProject().getDeviceStatusInfo() .getBinaryInfo(entry.getValue()); String temppath = binInfo.getTempBinaryPath(); if (temppath == null) { @@ -316,15 +305,13 @@ public class Communicator30 extends BaseCommunicator { appInst.setApplicationId(entry.getKey().toString()); appInst.setExecutablePath(entry.getValue()); - List functionInstList = getFunctionInstList( - apps.get(0), temppath); + List functionInstList = getFunctionInstList(apps.get(0), temppath); appInst.getFunctionInstList().addAll(functionInstList); appInst.setFunctionCount(functionInstList.size()); output.getAppInstList().add(appInst); } } - } else if (pkgInfo.getPackageId().equals( - AnalyzerConstants.WITHOUT_EXECUTABLE)) { + } else if (pkgInfo.getPackageId().equals(AnalyzerConstants.WITHOUT_EXECUTABLE)) { // TODO : if no executable is selected for tracing (system wide // tracing) return null; @@ -342,8 +329,8 @@ public class Communicator30 extends BaseCommunicator { continue; } - BinaryInfo binInfo = AnalyzerManager.getProject() - .getDeviceStatusInfo().getBinaryInfo(app.getExecPath()); + BinaryInfo binInfo = AnalyzerManager.getProject().getDeviceStatusInfo() + .getBinaryInfo(app.getExecPath()); String temppath = binInfo.getTempBinaryPath(); if (temppath == null) { // this means the app binary does not exist in device @@ -371,8 +358,7 @@ public class Communicator30 extends BaseCommunicator { appInst.setExecutablePath(app.getExecPath()); Logger.debug("Set execute path : " + app.getExecPath()); - List functionInstList = getFunctionInstList(app, - temppath); + List functionInstList = getFunctionInstList(app, temppath); appInst.getFunctionInstList().addAll(functionInstList); appInst.setFunctionCount(functionInstList.size()); output.getAppInstList().add(appInst); @@ -404,7 +390,7 @@ public class Communicator30 extends BaseCommunicator { return functionInstList; } - public HostResult sendBinaryInfoMessage(AppInfo selectedApp) { + public HostResult sendBinaryInfoMessage(PackageInfo selectedPkg) { // send config message List paths = new ArrayList(); byte[] msgBinInfo = ByteUtil.toBytes(AnalyzerConstants.MSG_BINARY_INFO); @@ -412,8 +398,8 @@ public class Communicator30 extends BaseCommunicator { DeviceInfo curDevice = GlobalInformation.getCurrentDeviceInfo(); - if (AnalyzerConstants.RUNNING_PROCESS.equals(selectedApp.getAppId())) { - Map selProcess = selectedApp.getRunningProcesses(); + if (AnalyzerConstants.RUNNING_PROCESS.equals(selectedPkg.getPackageId())) { + Map selProcess = selectedPkg.getMainApp().getRunningProcesses(); int binCount = selProcess.size(); preMsg = ByteUtil.getByte(binCount); @@ -421,14 +407,11 @@ public class Communicator30 extends BaseCommunicator { paths.add(entry.getValue()); preMsg = ByteUtil.getByte(preMsg, entry.getValue()); } - } else if (AnalyzerConstants.WITHOUT_EXECUTABLE.equals(selectedApp - .getAppId())) { + } else if (AnalyzerConstants.WITHOUT_EXECUTABLE.equals(selectedPkg.getPackageId())) { // do not send message for system wide trace return HostResult.SUCCESS; } else { - PackageInfo pkgInfo = curDevice.getPackageInfoHash().get( - selectedApp.getPackageId()); - List apps = pkgInfo.getAppInfos(); + List apps = selectedPkg.getAppInfos(); if (null == apps) { return HostResult.ERR_BIN_INFO_GET_FAIL; } @@ -472,8 +455,7 @@ public class Communicator30 extends BaseCommunicator { private HostResult pullTheFile(String from, String to) { try { - GlobalInformation.getCurrentDeviceInfo().getIDevice() - .becomeSuperUser(true); + GlobalInformation.getCurrentDeviceInfo().getIDevice().becomeSuperUser(true); } catch (TimeoutException e) { e.printStackTrace(); } catch (SdbCommandRejectedException e) { @@ -494,16 +476,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.setSystemTracePeriod(ConfigureManager.getInstance() - .getSystemPeriod()); + rt.setFeatures(ConfigureManager.getInstance().getConfiguration(devInfo), ConfigureManager + .getInstance().getPreConfiguration(devInfo)); + rt.setSystemTracePeriod(ConfigureManager.getInstance().getSystemPeriod()); rt.setSamplingPeriod(ConfigureManager.getInstance().getSamplingPeriod()); byte[] rtByte = rt.toByteStream(); int length = rtByte.length; @@ -529,8 +508,7 @@ public class Communicator30 extends BaseCommunicator { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { - final Shell shell = WorkbenchUtil.getWorkbenchWindow() - .getShell(); + final Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell(); DADialog dialog = new DADialog(shell, SWT.NONE, 550, 153); dialog.setIcon(ImageResources.DIALOG_WARNING_ICON); dialog.setMessage("Configuration failed.."); @@ -546,8 +524,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)) { @@ -597,25 +575,24 @@ public class Communicator30 extends BaseCommunicator { printWriter.printf("\n"); } controlSock.getOutputStream().write(message); - Logger.debug("wait for ack... [send message : " - + ByteUtil.toInt(message) + " ]"); + Logger.debug("wait for ack... [send message : " + ByteUtil.toInt(message) + " ]"); int readsize = -1; byte[] cbuf = new byte[DACommunicator.READ_BUFFER_SIZE]; - + Logger.debug("blocked"); blocked = true; - + ByteArrayOutputStream baos = new ByteArrayOutputStream(); readsize = controlSock.getInputStream().read(cbuf, 0, CONTROL_HEADER_SIZE); if (readsize == CONTROL_HEADER_SIZE) { baos.write(cbuf, 0, readsize); int payloadsize = ByteUtil.toInt(cbuf, INT_SIZE); - + do { readsize = controlSock.getInputStream().read(cbuf); baos.write(cbuf, 0, readsize); - + payloadsize -= readsize; } while (payloadsize > 0); blocked = false; @@ -674,8 +651,7 @@ 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); @@ -703,8 +679,7 @@ 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); @@ -778,8 +753,7 @@ public class Communicator30 extends BaseCommunicator { index += INT_SIZE; if (ackType == msgId) { - if (paylen != INT_SIZE - || retId == ErrorCode.SUCCESS.getErrorNumber()) { + if (paylen != INT_SIZE || retId == ErrorCode.SUCCESS.getErrorNumber()) { return true; } } @@ -791,8 +765,7 @@ public class Communicator30 extends BaseCommunicator { 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; @@ -920,9 +893,9 @@ public class Communicator30 extends BaseCommunicator { } @Override - public void onAppSelected(AppInfo app) { - if (app != null) { - HostResult hr = sendBinaryInfoMessage(app); + public void onAppSelected(PackageInfo pkg) { + if (pkg != null) { + HostResult hr = sendBinaryInfoMessage(pkg); if (!hr.isSuccess()) { Logger.debug("binary info get failed :" + hr.getMessage()); } @@ -932,8 +905,7 @@ public class Communicator30 extends BaseCommunicator { public HostResult sendScreenShotRequest() { byte[] msg = ByteUtil.getByte(AnalyzerConstants.MSG_GET_SCREENSHOT, 0); HostResult result = HostResult.SUCCESS; - Socket controlSock = GlobalInformation.getCurrentDeviceInfo() - .getControlSock(); + Socket controlSock = GlobalInformation.getCurrentDeviceInfo().getControlSock(); try { if (null != controlSock && !controlSock.isClosed()) { @@ -963,10 +935,9 @@ public class Communicator30 extends BaseCommunicator { return result; } - public HostResult sendSWAPMessage(int messageId, - List settings) { - HashMap targetBinInfoMap = BinarySettingManager - .getInstance().getTargetBinInfoMap(); + public HostResult sendSWAPMessage(int messageId, List settings) { + HashMap targetBinInfoMap = BinarySettingManager.getInstance() + .getTargetBinInfoMap(); byte[] msg = new byte[0]; int count = settings.size(); int failedCount = 0; @@ -1014,8 +985,7 @@ 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; @@ -1024,8 +994,7 @@ 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) { @@ -1052,16 +1021,12 @@ public class Communicator30 extends BaseCommunicator { } int length = sendbin.length; - byte[] msg = ByteUtil - .getByte(AnalyzerConstants.MSG_GET_PROCESS_ADD_INFO, - length, sendbin); - HostResult result = handleControlMessage( - GlobalInformation.getCurrentDeviceInfo(), msg); + byte[] msg = ByteUtil.getByte(AnalyzerConstants.MSG_GET_PROCESS_ADD_INFO, length, + sendbin); + HostResult result = handleControlMessage(GlobalInformation.getCurrentDeviceInfo(), msg); if (result.isSuccess() - && isCorrectAck( - AnalyzerConstants.MSG_GET_PROCESS_ADD_INFO_ACK, - result)) { + && isCorrectAck(AnalyzerConstants.MSG_GET_PROCESS_ADD_INFO_ACK, result)) { // parse binary info byte[] payload = getMessagePayload(result.getRet()); int index = 0; @@ -1087,8 +1052,7 @@ public class Communicator30 extends BaseCommunicator { return infoMap; } - public HostResult sendBinaryInfoMessageForLib( - List binaryData) { + public HostResult sendBinaryInfoMessageForLib(List binaryData) { List binPaths = new ArrayList(); for (BinarySettingData data : binaryData) { @@ -1105,10 +1069,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); + byte[] msg = ByteUtil.getByte(AnalyzerConstants.MSG_BINARY_INFO, length, sendBin); + HostResult result = handleControlMessage(GlobalInformation.getCurrentDeviceInfo(), msg); if (!result.isSuccess() || !isCorrectAck(MSG_BINARY_INFO_ACK, result)) { return HostResult.ERR_BIN_INFO_GET_FAIL; @@ -1136,8 +1098,7 @@ 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; @@ -1160,8 +1121,7 @@ public class Communicator30 extends BaseCommunicator { // 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); @@ -1173,8 +1133,7 @@ public class Communicator30 extends BaseCommunicator { String localHashCode = null; try { Runtime rt = Runtime.getRuntime(); - Process process = rt.exec(new String[] { - getMd5Command(), localBinaryPath }); + Process process = rt.exec(new String[] { getMd5Command(), localBinaryPath }); process.waitFor(); BufferedReader reader = new BufferedReader(new InputStreamReader( process.getInputStream())); @@ -1186,7 +1145,8 @@ public class Communicator30 extends BaseCommunicator { Logger.debug("host md5sum get failed : " + errorStr); result = HostResult.ERR_BIN_INFO_GET_FAIL; } else { - // md5sum.exe prepend "\" when target binary is not in current directory + // md5sum.exe prepend "\" when target binary is not in + // current directory if (CommonUtil.isWin()) { line = line.replace("\\", ""); } @@ -1200,10 +1160,9 @@ public class Communicator30 extends BaseCommunicator { result = HostResult.ERR_BIN_INFO_GET_FAIL; } - if (localHashCode == null - || 0 != localHashCode.compareTo(binInfo.getMd5sumValue())) { - localBinaryPath = PathManager.DA_TEMP_FOLDER_PATH - + File.separator + getFileName(targetPath); + 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); @@ -1214,39 +1173,38 @@ public class Communicator30 extends BaseCommunicator { } } } - + private String getMd5Command() { String cmd = null; if (CommonUtil.isLinux()) { - cmd = AnalyzerShellCommands.CMD_LINUX_MD_5_SUM; + cmd = AnalyzerShellCommands.CMD_LINUX_MD_5_SUM; } else if (CommonUtil.isMac()) { - cmd = AnalyzerShellCommands.CMD_MAC_MD_5_SUM; + cmd = AnalyzerShellCommands.CMD_MAC_MD_5_SUM; } else if (CommonUtil.isWin()) { - cmd = PathManager.DA_TOOL_FOLDER_PATH + File.separator - + "md5sum.exe"; + cmd = PathManager.DA_TOOL_FOLDER_PATH + File.separator + "md5sum.exe"; } else { // should never be here Logger.error("Unknown host OS!\n"); } - + return cmd; } - + private String parseMd5Result(String line) { String md5value = null; - String[] splitResult = line.trim().split( - CommonConstants.SPACE); - + String[] splitResult = line.trim().split(CommonConstants.SPACE); + if (CommonUtil.isLinux()) { md5value = new String(splitResult[0]); - } else if (CommonUtil.isMac()) { // In md5's output, hash value comes last + } else if (CommonUtil.isMac()) { // In md5's output, hash value comes + // last md5value = new String(splitResult[splitResult.length - 1]); } else if (CommonUtil.isWin()) { - md5value = new String(splitResult[0]); + md5value = new String(splitResult[0]); } else { // should never be here - Logger.error("Unknown host OS!\n"); + Logger.error("Unknown host OS!\n"); } - + return md5value; } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ToolbarArea.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ToolbarArea.java index d4cc79c..1fb8813 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ToolbarArea.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ToolbarArea.java @@ -53,6 +53,7 @@ import org.tizen.dynamicanalyzer.handlers.ReplayTraceHandler; import org.tizen.dynamicanalyzer.model.DeviceInfo; import org.tizen.dynamicanalyzer.nl.AnalyzerLabels; import org.tizen.dynamicanalyzer.project.AppInfo; +import org.tizen.dynamicanalyzer.project.PackageInfo; import org.tizen.dynamicanalyzer.project.ProcessInformation; import org.tizen.dynamicanalyzer.project.Project; import org.tizen.dynamicanalyzer.resources.ColorResources; @@ -90,8 +91,8 @@ public class ToolbarArea { public static final int REPLAY_EDIT_BUTTON = 9; public static final String ALL_PROCESS = "All Processes"; - public static final String PROCESS_SPLITER = CommonConstants.SPACE - + CommonConstants.COLON + CommonConstants.SPACE; + public static final String PROCESS_SPLITER = CommonConstants.SPACE + CommonConstants.COLON + + CommonConstants.SPACE; private static ToolbarArea coolbarArea; @@ -178,8 +179,7 @@ public class ToolbarArea { String text = appCombo.getText(); if ((null != pDeviceName && !pDeviceName.isEmpty() && pDeviceName .equals(sDeviceName)) - && (null != appName && !appName.isEmpty() && appName - .equals(text))) { + && (null != appName && !appName.isEmpty() && appName.equals(text))) { replayButton.setButtonEnabled(true); replayEditButton.setButtonEnabled(false); // disable button until complete TV SDK @@ -197,8 +197,7 @@ public class ToolbarArea { @Override public void selectionEvent(DACustomCombo combo) { String oldDeviceName = null; - DeviceInfo oldDevInfo = GlobalInformation - .getCurrentDeviceInfo(); + DeviceInfo oldDevInfo = GlobalInformation.getCurrentDeviceInfo(); if (oldDevInfo != null) oldDeviceName = oldDevInfo.getIDevice().getSerialNumber(); String serial = combo.getText(); @@ -227,8 +226,7 @@ public class ToolbarArea { if (null != idevices) { for (int i = 0; i < idevices.length; i++) { - int index = serials.indexOf(idevices[i] - .getSerialNumber()); + int index = serials.indexOf(idevices[i].getSerialNumber()); if (index < 0) { diffList.add(idevices[i]); } @@ -248,42 +246,34 @@ public class ToolbarArea { if (null != appName && !appName.isEmpty()) { boolean enablestart = true; - AppInfo selectedApp = DACommunicator - .getPkgInfoByName(appName); - if (null != selectedApp) { + PackageInfo selectedPkg = DACommunicator.getPkgInfoByLabel(appName); + if (null != selectedPkg) { if (appName.equals(AnalyzerConstants.RUNNING_PROCESS)) { - Shell shell = WorkbenchUtil.getWorkbenchWindow() - .getShell(); - ProcessExplorerDialog pdialog = new ProcessExplorerDialog( - shell); - pdialog.setProcessList(selectedApp - .getRunningProcesses()); + Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell(); + ProcessExplorerDialog pdialog = new ProcessExplorerDialog(shell); + pdialog.setProcessList(selectedPkg.getMainApp().getRunningProcesses()); Object result = pdialog.open(); if (result != null) { @SuppressWarnings("unchecked") Map processes = (Map) result; - selectedApp.setRunningProcesses(processes); + selectedPkg.getMainApp().setRunningProcesses(processes); } - if (selectedApp.getRunningProcesses() == null) { + if (selectedPkg.getMainApp().getRunningProcesses() == null) { enablestart = false; } } - GlobalInformation.setCurrentApplication(selectedApp); - GlobalInformation.getCurrentDeviceInfo() - .getCommunicator().onAppSelected(selectedApp); - GlobalInformation - .getCurrentDeviceInfo() - .setSelectedAppName( - selectedApp - .getInfo(AppInfo.PROPERTY.LABEL.index)); + GlobalInformation.setCurrentApplication(selectedPkg); + GlobalInformation.getCurrentDeviceInfo().getCommunicator() + .onAppSelected(selectedPkg); + GlobalInformation.getCurrentDeviceInfo().setSelectedPackageID( + selectedPkg.getPackageId()); } else { enablestart = false; } - if (enablestart - && null != GlobalInformation.getCurrentDeviceInfo()) { + if (enablestart && null != GlobalInformation.getCurrentDeviceInfo()) { // AnalyzerUtil // .setRecordState(RecordStateSourceProvider.RECORD_READY); AnalyzerManager.setRunningState(false); @@ -311,8 +301,7 @@ public class ToolbarArea { @Override public void selectionEvent(DACustomCombo combo) { - BaseView baseView = (BaseView) WorkbenchUtil - .getViewPart(BaseView.ID); + BaseView baseView = (BaseView) WorkbenchUtil.getViewPart(BaseView.ID); baseView.getTopComposite().updateView(); } }); @@ -333,19 +322,15 @@ public class ToolbarArea { int pcount = pids.length; for (int i = 0; i < pcount; i++) { - ProcessInformation process = project - .getProcessInformation(pids[i]); + ProcessInformation process = project.getProcessInformation(pids[i]); String binName = process.getProcessName(); if (binName == null || binName.isEmpty()) { - int bid = process.getLastProcessMemoryMap() - .getMainbinary().getBinaryID(); - String binPath = project.getDeviceStatusInfo() - .getBinaryInfo(bid).getTargetBinaryPath(); + int bid = process.getLastProcessMemoryMap().getMainbinary().getBinaryID(); + String binPath = project.getDeviceStatusInfo().getBinaryInfo(bid) + .getTargetBinaryPath(); if (null != binPath && !binPath.isEmpty()) { - int index = binPath - .lastIndexOf(CommonConstants.SLASH); - binName = binPath.substring(index + 1, - binPath.length()); + int index = binPath.lastIndexOf(CommonConstants.SLASH); + binName = binPath.substring(index + 1, binPath.length()); } } @@ -369,39 +354,35 @@ public class ToolbarArea { } }); - saveTraceButton - .addClickListener(new DACustomButtonClickEventListener() { - - @Override - public void handleClickEvent(DACustomButton button) { - Shell shell = WorkbenchUtil.getWorkbenchWindow() - .getShell(); - SaveAsDialog dialog = new SaveAsDialog(shell); - Object result = dialog.open(); - if (null != result) { - if (!CommandActionHandler.save(dialog.getSaveFileName())) { - DADialog warninglog = new DADialog(shell, SWT.NONE); - warninglog.setIcon(ImageResources.DIALOG_WARNING_ICON); - warninglog.setMessage(AnalyzerLabels.SAVE_FAILED); - warninglog.open(); - } + saveTraceButton.addClickListener(new DACustomButtonClickEventListener() { - button.setButtonEnabled(false); - } + @Override + public void handleClickEvent(DACustomButton button) { + Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell(); + SaveAsDialog dialog = new SaveAsDialog(shell); + Object result = dialog.open(); + if (null != result) { + if (!CommandActionHandler.save(dialog.getSaveFileName())) { + DADialog warninglog = new DADialog(shell, SWT.NONE); + warninglog.setIcon(ImageResources.DIALOG_WARNING_ICON); + warninglog.setMessage(AnalyzerLabels.SAVE_FAILED); + warninglog.open(); } - }); - openTraceButton - .addClickListener(new DACustomButtonClickEventListener() { + button.setButtonEnabled(false); + } + } + }); - @Override - public void handleClickEvent(DACustomButton button) { - Shell shell = WorkbenchUtil.getWorkbenchWindow() - .getShell(); - OpenTraceDialog dialog = new OpenTraceDialog(shell); - dialog.open(); - } - }); + openTraceButton.addClickListener(new DACustomButtonClickEventListener() { + + @Override + public void handleClickEvent(DACustomButton button) { + Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell(); + OpenTraceDialog dialog = new OpenTraceDialog(shell); + dialog.open(); + } + }); replayButton.addClickListener(new DACustomButtonClickEventListener() { @@ -415,17 +396,15 @@ public class ToolbarArea { } }); - replayEditButton - .addClickListener(new DACustomButtonClickEventListener() { + replayEditButton.addClickListener(new DACustomButtonClickEventListener() { - @Override - public void handleClickEvent(DACustomButton button) { - Shell shell = WorkbenchUtil.getWorkbenchWindow() - .getShell(); - ReplayEditDialog dialog = new ReplayEditDialog(shell); - dialog.open(); - } - }); + @Override + public void handleClickEvent(DACustomButton button) { + Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell(); + ReplayEditDialog dialog = new ReplayEditDialog(shell); + dialog.open(); + } + }); configButton.addClickListener(new DACustomButtonClickEventListener() { @@ -437,14 +416,13 @@ public class ToolbarArea { } }); - screenshotButton - .addClickListener(new DACustomButtonClickEventListener() { + screenshotButton.addClickListener(new DACustomButtonClickEventListener() { - @Override - public void handleClickEvent(DACustomButton button) { - DACommunicator.sendScreenShotMessage(); - } - }); + @Override + public void handleClickEvent(DACustomButton button) { + DACommunicator.sendScreenShotMessage(); + } + }); aboutButton.addClickListener(new DACustomButtonClickEventListener() { @@ -456,15 +434,14 @@ public class ToolbarArea { } }); - viewSourceButton - .addClickListener(new DACustomButtonClickEventListener() { - @Override - public void handleClickEvent(DACustomButton button) { + viewSourceButton.addClickListener(new DACustomButtonClickEventListener() { + @Override + public void handleClickEvent(DACustomButton button) { - // TODO : use for test code... + // TODO : use for test code... - } - }); + } + }); } public void setStartButtonToolTipText(final String text) { @@ -489,18 +466,15 @@ public class ToolbarArea { setToolbarStartStopState(true); - if (null == DACommunicator.getDevices() - || DACommunicator.getDevices().isEmpty()) { + if (null == DACommunicator.getDevices() || DACommunicator.getDevices().isEmpty()) { deviceCombo.setEnabled(false); } - if (!deviceCombo.isEnabled() - || null == GlobalInformation.getCurrentDeviceInfo()) { + if (!deviceCombo.isEnabled() || null == GlobalInformation.getCurrentDeviceInfo()) { appCombo.setEnabled(false); } - if (!appCombo.isEnabled() - || null == GlobalInformation.getCurrentApplication()) { + if (!appCombo.isEnabled() || null == GlobalInformation.getCurrentApplication()) { setStartButtonEnablement(false); } @@ -515,8 +489,7 @@ public class ToolbarArea { @Override public void run() { - StartProcessManager.getInstance().startProcessStart( - "prepare for tracing"); + StartProcessManager.getInstance().startProcessStart("prepare for tracing"); } }); @@ -543,9 +516,8 @@ public class ToolbarArea { /** which contains start, TimerClock, save, open and replay buttons. */ // Creates start button. - startButton = new DACustomButton(parent, ImageResources.START, - ImageResources.START_PUSH, ImageResources.START_HOVER, - ImageResources.START_DISABLE); + startButton = new DACustomButton(parent, ImageResources.START, ImageResources.START_PUSH, + ImageResources.START_HOVER, ImageResources.START_DISABLE); // startButton.setButtonEnabled(false); setStartButtonState(false); startButton.setToolTipText(ShortCutManager.START_TRACE); @@ -557,18 +529,16 @@ public class ToolbarArea { timerClock.setClockFont(FontResources.TIMER); // // Creates save trace button. - saveTraceButton = new DACustomButton(parent, ImageResources.SAVE, - ImageResources.SAVE_PUSH, ImageResources.SAVE_HOVER, - ImageResources.SAVE_DISABLE); + saveTraceButton = new DACustomButton(parent, ImageResources.SAVE, ImageResources.SAVE_PUSH, + ImageResources.SAVE_HOVER, ImageResources.SAVE_DISABLE); saveTraceButton.setButtonEnabled(false); saveTraceButton.setBackground(ColorResources.COOLBAR_BG_COLOR); saveTraceButton.setToolTipText(ShortCutManager.SAVE_TRACE); buttons.put(SAVE_BUTTON, saveTraceButton); // // Creates open trace button. - openTraceButton = new DACustomButton(parent, ImageResources.OPEN, - ImageResources.OPEN_PUSH, ImageResources.OPEN_HOVER, - ImageResources.OPEN_DISABLE); + openTraceButton = new DACustomButton(parent, ImageResources.OPEN, ImageResources.OPEN_PUSH, + ImageResources.OPEN_HOVER, ImageResources.OPEN_DISABLE); openTraceButton.setToolTipText(ShortCutManager.OPEN_TRACE); openTraceButton.setBackground(ColorResources.COOLBAR_BG_COLOR); buttons.put(OPEN_BUTTON, openTraceButton); @@ -582,51 +552,42 @@ public class ToolbarArea { buttons.put(REPLAY_BUTTON, replayButton); // Creates replayEdit button. - replayEditButton = new DACustomButton(parent, - ImageResources.REPLAY_EDIT, ImageResources.REPLAY_EDIT_PUSH, - ImageResources.REPLAY_EDIT_HOVER, + replayEditButton = new DACustomButton(parent, ImageResources.REPLAY_EDIT, + ImageResources.REPLAY_EDIT_PUSH, ImageResources.REPLAY_EDIT_HOVER, ImageResources.REPLAY_EDIT_DISABLE); replayEditButton.setToolTipText(ShortCutManager.REPLAY_EDIT); replayEditButton.setBackground(ColorResources.COOLBAR_BG_COLOR); buttons.put(REPLAY_EDIT_BUTTON, replayEditButton); // Creates config button - configButton = new DACustomButton(parent, - ImageResources.SETTINGS_NORMAL, ImageResources.SETTINGS_PUSH, - ImageResources.SETTINGS_HOVER, ImageResources.SETTINGS_DISABLE); + configButton = new DACustomButton(parent, ImageResources.SETTINGS_NORMAL, + ImageResources.SETTINGS_PUSH, ImageResources.SETTINGS_HOVER, + ImageResources.SETTINGS_DISABLE); configButton.setToolTipText(ShortCutManager.COOLBAR_AREA_SETTING); configButton.setBackground(ColorResources.COOLBAR_BG_COLOR); buttons.put(CONFIG_BUTTON, configButton); // Creates screenshot button - screenshotButton = new DACustomButton(parent, - ImageResources.SCREEN_SHOT_NORMAL, - ImageResources.SCREEN_SHOT_PUSH, - ImageResources.SCREEN_SHOT_HOVER, + screenshotButton = new DACustomButton(parent, ImageResources.SCREEN_SHOT_NORMAL, + ImageResources.SCREEN_SHOT_PUSH, ImageResources.SCREEN_SHOT_HOVER, ImageResources.SCREEN_SHOT_DISABLE); screenshotButton.setToolTipText("Capture screen"); screenshotButton.setBackground(ColorResources.COOLBAR_BG_COLOR); buttons.put(SCREENSHOT_BUTTON, screenshotButton); // Creates about button. - aboutButton = new DACustomButton(parent, ImageResources.ABOUT, - ImageResources.ABOUT_PUSH, ImageResources.ABOUT_HOVER, - ImageResources.ABOUT_DISABLE); + aboutButton = new DACustomButton(parent, ImageResources.ABOUT, ImageResources.ABOUT_PUSH, + ImageResources.ABOUT_HOVER, ImageResources.ABOUT_DISABLE); aboutButton.setToolTipText(ShortCutManager.COOLBAR_AREA_ABOUT); aboutButton.setBackground(ColorResources.COOLBAR_BG_COLOR); buttons.put(ABOUT_BUTTON, aboutButton); // Creates view source button. - viewSourceButton = new DACustomToggleButton(parent, - ImageResources.VIEW_SOURCE_NORMAL, - ImageResources.VIEW_SOURCE_PUSH, - ImageResources.VIEW_SOURCE_HOVER, - ImageResources.VIEW_SOURCE_DISABLE, - ImageResources.VIEW_SOURCE_TOGGLE, - ImageResources.VIEW_SOURCE_TOGGLE_HOVER, - ImageResources.VIEW_SOURCE_TOGGLE_PUSH); - viewSourceButton - .setToolTipText(ShortCutManager.COOLBAR_AREA_VIEW_SOURCE); + viewSourceButton = new DACustomToggleButton(parent, ImageResources.VIEW_SOURCE_NORMAL, + ImageResources.VIEW_SOURCE_PUSH, ImageResources.VIEW_SOURCE_HOVER, + ImageResources.VIEW_SOURCE_DISABLE, ImageResources.VIEW_SOURCE_TOGGLE, + ImageResources.VIEW_SOURCE_TOGGLE_HOVER, ImageResources.VIEW_SOURCE_TOGGLE_PUSH); + viewSourceButton.setToolTipText(ShortCutManager.COOLBAR_AREA_VIEW_SOURCE); viewSourceButton.setBackground(ColorResources.COOLBAR_BG_COLOR); buttons.put(SOURCE_BUTTON, viewSourceButton); @@ -761,17 +722,12 @@ public class ToolbarArea { private DACustomCombo makeDACustomCombo(Composite parent) { DACustomCombo returnCombo = new DACustomCombo(parent, SWT.NONE); - returnCombo.setComboGradation( - ColorResources.TOOLBAR_COMBO_NORMAL_START, - ColorResources.TOOLBAR_COMBO_NORMAL_END, - ColorResources.TOOLBAR_COMBO_PUSH_START, - ColorResources.TOOLBAR_COMBO_PUSH_END, - ColorResources.TOOLBAR_COMBO_HOVER_START, - ColorResources.TOOLBAR_COMBO_HOVER_END, - ColorResources.TOOLBAR_COMBO_DISABLE_START, + returnCombo.setComboGradation(ColorResources.TOOLBAR_COMBO_NORMAL_START, + ColorResources.TOOLBAR_COMBO_NORMAL_END, ColorResources.TOOLBAR_COMBO_PUSH_START, + ColorResources.TOOLBAR_COMBO_PUSH_END, ColorResources.TOOLBAR_COMBO_HOVER_START, + ColorResources.TOOLBAR_COMBO_HOVER_END, ColorResources.TOOLBAR_COMBO_DISABLE_START, ColorResources.TOOLBAR_COMBO_DISABLE_END); - returnCombo.setOutlineColors( - ColorResources.TOOLBAR_COMBO_OUTLINE_NORMAL_IN_COLOR, + returnCombo.setOutlineColors(ColorResources.TOOLBAR_COMBO_OUTLINE_NORMAL_IN_COLOR, ColorResources.TOOLBAR_COMBO_OUTLINE_PUSH_IN_COLOR, ColorResources.TOOLBAR_COMBO_OUTLINE_HOVER_IN_COLOR, ColorResources.TOOLBAR_COMBO_OUTLINE_DISABLE_IN_COLOR); @@ -780,13 +736,11 @@ public class ToolbarArea { ImageResources.TOOLBAR_COMBO_BUTTON_NORMAL, ImageResources.TOOLBAR_COMBO_BUTTON_DISABLE); returnCombo.setComboImagePoint(new Point(130, 9)); - returnCombo.setComboButtonColor( - ColorResources.TOOLBAR_COMBO_BUTTON_NORMAL_COLOR, + returnCombo.setComboButtonColor(ColorResources.TOOLBAR_COMBO_BUTTON_NORMAL_COLOR, ColorResources.TOOLBAR_COMBO_BUTTON_PUSH_COLOR, ColorResources.TOOLBAR_COMBO_BUTTON_HOVER_COLOR, ColorResources.TOOLBAR_COMBO_BUTTON_DISABLE_COLOR); - returnCombo.setArrowOutlineColors( - ColorResources.TOOLBAR_COMBO_ARROW_OUTLINE_COLOR, + returnCombo.setArrowOutlineColors(ColorResources.TOOLBAR_COMBO_ARROW_OUTLINE_COLOR, ColorResources.TOOLBAR_COMBO_ARROW_OUTLINE_COLOR, ColorResources.TOOLBAR_COMBO_ARROW_OUTLINE_COLOR, ColorResources.TOOLBAR_COMBO_ARROW_OUTLINE_COLOR); @@ -796,8 +750,7 @@ public class ToolbarArea { returnCombo.setEnabled(true); returnCombo.setComboFont(FontResources.COMBO); returnCombo.setItemFont(FontResources.DROPDOWN); - returnCombo.setFontColors( - ColorResources.TOOLBAR_COMBO_FONT_NORMAL_COLOR, + returnCombo.setFontColors(ColorResources.TOOLBAR_COMBO_FONT_NORMAL_COLOR, ColorResources.TOOLBAR_COMBO_FONT_NORMAL_COLOR, ColorResources.TOOLBAR_COMBO_FONT_NORMAL_COLOR, ColorResources.TOOLBAR_COMBO_FONT_DISABLE_COLOR); @@ -831,36 +784,26 @@ public class ToolbarArea { appCombo.setEnabled(true); appCombo.initCombo(); - List apps = addToAppComboFromTarget(); - - if (apps != null && apps.size() > 0) { - String appName = GlobalInformation.getCurrentDeviceInfo() - .getSelectedAppName(); - if (null == appName) { + List pkgs = addToAppComboFromTarget(); + + if (pkgs != null && pkgs.size() > 0) { + String packageID = GlobalInformation.getCurrentDeviceInfo().getSelectedPackageID(); + if (null != packageID && DACommunicator.getPkgInfoByPkgId(packageID) != null) { + PackageInfo pkgInfo = DACommunicator.getPkgInfoByPkgId(packageID); + appCombo.setText(pkgInfo.getMainApp().getInfo(AppInfo.PROPERTY.LABEL.index)); + GlobalInformation.setCurrentApplication(pkgInfo); + GlobalInformation.getCurrentDeviceInfo().getCommunicator().onAppSelected(pkgInfo); + GlobalInformation.getCurrentDeviceInfo().setSelectedPackageID( + pkgInfo.getPackageId()); + // startButton.setButtonEnabled(true); + setStartButtonState(true); + } else { appCombo.select(0); - GlobalInformation.setCurrentApplication(apps.get(0)); + GlobalInformation.setCurrentApplication(pkgs.get(0)); GlobalInformation.getCurrentDeviceInfo().getCommunicator() - .onAppSelected(apps.get(0)); - GlobalInformation.getCurrentDeviceInfo().setSelectedAppName( - apps.get(0).getInfo(AppInfo.PROPERTY.LABEL.index)); - } else { - AppInfo appInfo = DACommunicator.getPkgInfoByName(appName); - if (null != appInfo) { - appCombo.setText(appName); - GlobalInformation.setCurrentApplication(appInfo); - GlobalInformation.getCurrentDeviceInfo().getCommunicator() - .onAppSelected(appInfo); - GlobalInformation - .getCurrentDeviceInfo() - .setSelectedAppName( - appInfo.getInfo(AppInfo.PROPERTY.LABEL.index)); - // startButton.setButtonEnabled(true); - setStartButtonState(true); - } else { - appCombo.setText(appName); - appCombo.select(0); - GlobalInformation.setCurrentApplication(null); - } + .onAppSelected(pkgs.get(0)); + GlobalInformation.getCurrentDeviceInfo().setSelectedPackageID( + pkgs.get(0).getPackageId()); } } else { appCombo.select(0); @@ -891,8 +834,8 @@ public class ToolbarArea { } else { int size = items.size(); int selIndex = 0; - String selDevice = GlobalInformation.getCurrentDeviceInfo() - .getIDevice().getSerialNumber(); + String selDevice = GlobalInformation.getCurrentDeviceInfo().getIDevice() + .getSerialNumber(); for (int i = 0; i < size; i++) { deviceCombo.add(items.get(i)); if (items.get(i).equals(selDevice)) { @@ -901,8 +844,8 @@ public class ToolbarArea { } deviceCombo.select(selIndex); - GlobalInformation.setCurrentDeviceInfo(DACommunicator - .getDeviceByName(items.get(selIndex))); + GlobalInformation.setCurrentDeviceInfo(DACommunicator.getDeviceByName(items + .get(selIndex))); deviceCombo.setToolTipText(items.get(selIndex)); if (null == oldDevice || !oldDevice.equals(selDevice)) { @@ -916,49 +859,51 @@ public class ToolbarArea { } } - private void addToAppCombo(List apps) { + private void addToAppCombo(List appPkgs) { appCombo.initCombo(); - if (apps != null && apps.size() > 0) { - int itemsSize = apps.size(); + if (appPkgs != null && appPkgs.size() > 0) { + int itemsSize = appPkgs.size(); for (int i = 0; i < itemsSize; i++) { - appCombo.add(apps.get(i).getInfo(AppInfo.PROPERTY.LABEL.index)); + AppInfo mainapp = appPkgs.get(i).getMainApp(); + String label = mainapp.getInfo(AppInfo.PROPERTY.LABEL.index); + if (label.isEmpty()) { + label = mainapp.getExecFileName(); + mainapp.setInfo(AppInfo.PROPERTY.LABEL.index, label); + } + appCombo.add(label); } } else { appCombo.add(CommonConstants.EMPTY); } } - private List addToAppComboFromTarget() { - List apps = DACommunicator.getAppListFromTarget(); + private List addToAppComboFromTarget() { + Map pkgInfos = DACommunicator.getAppListFromTarget(); - List appcomboList = new ArrayList(); - if (apps != null) { + List appcomboList = new ArrayList(); + if (pkgInfos != null) { // TODO : reconstruct real app list for app combo // relation between package and app? - for (AppInfo app : apps) { - String appid = app.getInfo(AppInfo.PROPERTY.APPID.index); - String pkgid = app.getInfo(AppInfo.PROPERTY.PACKAGE.index); - if (appid.startsWith(pkgid) - && !appid.contains(AnalyzerConstants.APPCONTROL)) { - appcomboList.add(app); + for (Map.Entry entry : pkgInfos.entrySet()) { + AppInfo mainapp = entry.getValue().getMainApp(); + if (!mainapp.getAppId().contains(AnalyzerConstants.APPCONTROL)) { + appcomboList.add(entry.getValue()); } } } addToAppCombo(appcomboList); - return apps; + return appcomboList; } public void setAppComboText(final String text) { - AppInfo appInfo = DACommunicator.getPkgInfoByName(text); - if (null != appInfo) { - GlobalInformation.setCurrentApplication(appInfo); - GlobalInformation.getCurrentDeviceInfo().getCommunicator() - .onAppSelected(appInfo); - GlobalInformation.getCurrentDeviceInfo().setSelectedAppName( - appInfo.getInfo(AppInfo.PROPERTY.LABEL.index)); + PackageInfo pkgInfo = DACommunicator.getPkgInfoByLabel(text); + if (null != pkgInfo) { + GlobalInformation.setCurrentApplication(pkgInfo); + GlobalInformation.getCurrentDeviceInfo().getCommunicator().onAppSelected(pkgInfo); + GlobalInformation.getCurrentDeviceInfo().setSelectedPackageID(pkgInfo.getPackageId()); Display.getDefault().syncExec(new Runnable() { @Override public void run() { @@ -969,14 +914,12 @@ public class ToolbarArea { } public void setAppComboTextByAppId(String id) { - AppInfo appInfo = DACommunicator.getPkgInfoByAppPkgId(id); - if (null != appInfo) { - GlobalInformation.setCurrentApplication(appInfo); - GlobalInformation.getCurrentDeviceInfo().getCommunicator() - .onAppSelected(appInfo); - GlobalInformation.getCurrentDeviceInfo().setSelectedAppName( - appInfo.getInfo(AppInfo.PROPERTY.LABEL.index)); - appCombo.setText(appInfo.getInfo(AppInfo.PROPERTY.LABEL.index)); + PackageInfo pkgInfo = DACommunicator.getPkgInfoByPkgId(id); + if (null != pkgInfo) { + GlobalInformation.setCurrentApplication(pkgInfo); + GlobalInformation.getCurrentDeviceInfo().getCommunicator().onAppSelected(pkgInfo); + GlobalInformation.getCurrentDeviceInfo().setSelectedPackageID(pkgInfo.getPackageId()); + appCombo.setText(pkgInfo.getMainApp().getInfo(AppInfo.PROPERTY.LABEL.index)); } } @@ -1008,8 +951,8 @@ public class ToolbarArea { } String text = deviceCombo.getText(); - String device = GlobalInformation.getCurrentDeviceInfo() - .getIDevice().getSerialNumber(); + String device = GlobalInformation.getCurrentDeviceInfo().getIDevice() + .getSerialNumber(); if (!device.equals(text)) { // startButton.setButtonEnabled(false); setStartButtonState(false); @@ -1051,14 +994,12 @@ public class ToolbarArea { private void setStartButtonImagesToStop(boolean isStarted) { if (isStarted) { - startButton.setImages(ImageResources.STOP, - ImageResources.STOP_PUSH, ImageResources.STOP_HOVER, - ImageResources.START_DISABLE); + startButton.setImages(ImageResources.STOP, ImageResources.STOP_PUSH, + ImageResources.STOP_HOVER, ImageResources.START_DISABLE); startButton.setToolTipText(ShortCutManager.STOP_TRACE); } else { - startButton.setImages(ImageResources.START, - ImageResources.START_PUSH, ImageResources.START_HOVER, - ImageResources.START_DISABLE); + startButton.setImages(ImageResources.START, ImageResources.START_PUSH, + ImageResources.START_HOVER, ImageResources.START_DISABLE); startButton.setToolTipText(ShortCutManager.START_TRACE); } }