[SRADA-136] Add supported device checker
authorjoon.c.baek <joon.c.baek@samsung.com>
Thu, 10 Mar 2016 10:42:44 +0000 (19:42 +0900)
committerjoon.c.baek <joon.c.baek@samsung.com>
Wed, 16 Mar 2016 07:14:35 +0000 (16:14 +0900)
Add supported device checker at Connect(), BaseCommunicator.
Pop-up shown when not supported device connected.

This patch is going to check
'/usr/bin/profile_command' file on target.
If this file doesn't exist, InputStream will be empty.
at that time, Stopping connect(), Make a popup.

Change-Id: Iabf55d9a3d31c203c0d80a1186474081692ebad1
Signed-off-by: joon.c.baek <joon.c.baek@samsung.com>
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerConstants.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerShellCommands.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/DAResult.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/BaseCommunicator.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DeviceManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/control/StartTraceManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/CommonAction.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/UserErrorWarningLabels.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/UserErrorWarningLabels.properties

index fa8f5f3..ad562bf 100644 (file)
@@ -60,6 +60,9 @@ public class AnalyzerConstants {
        public static final String TIZEN_APP_PATH = "/opt/apps"; //$NON-NLS-1$
        public static final String TIZEN_USR_APP_PATH = "/opt/usr/apps"; //$NON-NLS-1$
 
+       /* Executable file name */
+       public static final String DA_EXECUTABLE = "/usr/bin/profile_command";
+
        /* Save Data table */
        public static final String LEAK_DATA_TABLE_NAME = "LeakData"; //$NON-NLS-1$
        public static final String FAILED_DATA_TABLE_NAME = "FailedData"; //$NON-NLS-1$
index c3ae2a4..6c4bb05 100755 (executable)
@@ -48,6 +48,7 @@ public class AnalyzerShellCommands {
        public static final String DACOMMAND_CHECK_VERSION = "/usr/bin/profile_command getversion";
        public static final String DACOMMAND_READLINK = "/usr/bin/profile_command readlink ";
        public static final String DACOMMAND_GETAPI = "/usr/bin/profile_command getprobemap";
+       public static final String DACOMMAND_CHECK_EXIST = "which /usr/bin/profile_command";
 
        // direct shell command
        public static final String CMD_FIND_IME = "/usr/bin/pkginfo --arg-flt 10 http://tizen.org/category/ime";
index a4121a1..eaa72a1 100755 (executable)
@@ -58,6 +58,7 @@ public class DAResult {
                ERR_OUT_OF_MEMORY(-1001, UserErrorWarningLabels.ERROR_OUT_OF_MEMORY),
                ERR_NO_DEVICE(-1010, UserErrorWarningLabels.ERROR_DEVICE_NOT_FOUND),
                ERR_DISCONNECTED(-1011, UserErrorWarningLabels.ERROR_DEVICE_CONNECTION),
+               ERR_NOT_SUPPORTED(-1012, UserErrorWarningLabels.ERROR_DEVICE_NOT_SUPPORTED),
                ERR_NO_APP(-1020, UserErrorWarningLabels.ERROR_NONEXIST_APPLICATION),
                ERR_INVALID_APP(-1021, UserErrorWarningLabels.ERROR_UNSUPPORTED_APPLICATION),
                ERR_BY_SECURITY(-1030, UserErrorWarningLabels.ERROR_BY_SECURITY_REASON),
index 6bd62b5..e9b57a8 100755 (executable)
@@ -110,6 +110,34 @@ public class BaseCommunicator {
                                }
                                device.emulatorScreenshot = new EmulatorScreenshot();
                        }
+                       
+                       final List<String> lines = new ArrayList<String>();
+
+                       CommunicatorUtils.execShellCommand(device.getIDevice(),
+                                       AnalyzerShellCommands.DACOMMAND_CHECK_EXIST, new MultiLineReceiver() {
+                                               @Override
+                                               public void processNewLines(String[] newlines) {
+                                                       for (int i = 0; i < newlines.length; i++) {
+                                                               lines.add(newlines[i]);
+                                                       }
+                                               }
+                                       });
+                       
+                       if (lines.size() > 0) {
+                               if (lines.get(0).contains(AnalyzerConstants.DA_EXECUTABLE)) {
+                                       Logger.debug("The device is supported : " + device.getIDevice().getDeviceName());
+                               }
+                               else {
+                                       Logger.debug("Could not found /usr/bin/profile_command, " + lines.get(0));
+                                       result = new DAResult(ErrorCode.ERR_NOT_SUPPORTED);
+                                       return result;
+                               }
+                       } else {
+                               Logger.debug("Could not found /usr/bin/profile_command");
+                               result = new DAResult(ErrorCode.ERR_NOT_SUPPORTED);
+                               return result;
+                       }
+                       
 
                        // start swap manager
                        CommunicatorUtils.execShellCommand(device.getIDevice(),
index 015b785..bf10b95 100755 (executable)
@@ -33,8 +33,10 @@ import java.util.List;
 
 import org.eclipse.swt.widgets.Display;
 import org.tizen.dynamicanalyzer.common.DAResult;
+import org.tizen.dynamicanalyzer.common.DAResult.ErrorCode;
 import org.tizen.dynamicanalyzer.common.Global;
 import org.tizen.dynamicanalyzer.common.path.PathManager;
+import org.tizen.dynamicanalyzer.handlers.UIAction;
 import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
 import org.tizen.dynamicanalyzer.util.Logger;
 import org.tizen.sdblib.IDevice;
@@ -121,8 +123,14 @@ public class DeviceManager {
                if (result.isSuccess()) {
                        devices.add(devInfo);
                        bAdded = true;
-               } else {
+               }
+               else if (result.equals(new DAResult(ErrorCode.ERR_NOT_SUPPORTED))){
+                       Logger.warning("Cannot found /usr/bin/profile_command : " + result.getMessage());
+                       UIAction.showWarning(result);
+               }
+               else {
                        Logger.warning("Cannot connect with swap manager : " + result.getMessage());
+                       UIAction.showWarning(result);
                }
 
                return bAdded;
index ec507a1..dfeda12 100644 (file)
@@ -154,6 +154,7 @@ public class StartTraceManager implements Runnable {
                                result = new DAResult(ErrorCode.ERR_DISCONNECTED);
                                return;
                        }
+                       
                        setStageComplete(STAGE.CHECK_DEV);
 
                        if (!CommonAction.checkApplicationValidness()) {
index c24ea1f..a2aa558 100644 (file)
@@ -87,13 +87,7 @@ public class CommonAction {
                        Logger.debug("Current device is null");
                        return false;
                }
-
-               DeviceInfo foundDev = DeviceManager.getDeviceByName(curDev.getIDevice().getSerialNumber());
-               if (foundDev == null) {
-                       Logger.warning("It is not valid device");
-                       return false;
-               }
-
+       
                return true;
        }
 
index b3bcf15..64ead9d 100755 (executable)
@@ -36,6 +36,7 @@ public class UserErrorWarningLabels extends NLS {
        public static String ERROR_LIB_NOT_FOUND_INRPM;
        public static String ERROR_NO_APPID_FOR_LAUNCHPAD;
        public static String ERROR_DEVICE_CONNECTION;
+       public static String ERROR_DEVICE_NOT_SUPPORTED;
        public static String ERROR_DEVICE_NOT_FOUND;
        public static String ERROR_UNSUPPORTED_PROTOCOL;
 
index d0ac93e..b0736f6 100755 (executable)
@@ -3,6 +3,7 @@ ERROR_RPM_NOT_FOUND=Library rpm package file cannot be found.
 ERROR_LIB_NOT_FOUND_INRPM=Library file cannot be found in rpm package. 
 ERROR_NO_APPID_FOR_LAUNCHPAD=There is no appid for launch_app.
 ERROR_DEVICE_CONNECTION= Failed to connect with the device. \nPlease re-run Dynamic Analyzer and reboot the device.
+ERROR_DEVICE_NOT_SUPPORTED=Current device is not supported. \nPlease ask to administrator.
 ERROR_DEVICE_NOT_FOUND=There is no connected device. \nPlease check the connection with device.
 ERROR_UNSUPPORTED_PROTOCOL=This version of platform of the device is not supported.\nPlease update the platform of device and retry.