UX: check privilege first before popup process explorer when running process trace
authorgreatim <jaewon81.lim@samsung.com>
Mon, 20 Jul 2015 12:08:50 +0000 (21:08 +0900)
committergreatim <jaewon81.lim@samsung.com>
Tue, 21 Jul 2015 06:48:51 +0000 (15:48 +0900)
check privilege first before popup process explorer when running process trace

Change-Id: I160ea0dca1d7db4a85a7c561d0c842ffb79a5856
Signed-off-by: greatim <jaewon81.lim@samsung.com>
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DACommunicator.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/UserErrorWarningLabels.properties
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/Toolbar.java

index 59b72e9..b4ff13c 100644 (file)
@@ -128,6 +128,19 @@ public class DACommunicator {
                }
        }
 
+       public static DAResult checkPrivilege() {
+               DeviceInfo device = Global.getCurrentDeviceInfo();
+               if (device == null) {
+                       return new DAResult(ErrorCode.ERR_NO_DEVICE);
+               }
+
+               if (!CommunicatorUtils.becomeSuperUser(device.getIDevice())) {
+                       return new DAResult(ErrorCode.ERR_BY_SECURITY);
+               }
+
+               return new DAResult(ErrorCode.SUCCESS);
+       }
+
        public static String getRealpath(String path) {
                DeviceInfo device = Global.getCurrentDeviceInfo();
                if (device == null) {
index 3d83ca1..1986069 100644 (file)
@@ -6,7 +6,7 @@ ERROR_DEVICE_CONNECTION=Failed to connect with the device.\nPlease re-run Dynami
 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.
 
-ERROR_BY_SECURITY_REASON=You cannot analyze this application for the security reason.
+ERROR_BY_SECURITY_REASON=This operation is not allowed due to security reason.
 
 ERROR_NONEXIST_APPLICATION=does not exist in device.\nPlease check that the application has been installed successfully.
 ERROR_UNSUPPORTED_APPLICATION=is unsupported application.
index bd18fdb..3302d4b 100755 (executable)
@@ -233,14 +233,20 @@ public enum Toolbar {
                                        PackageInfo selectedPkg = curDev.getPkgInfoByLabel(appName);
                                        if (null != selectedPkg) {
                                                if (appName.equals(AnalyzerConstants.RUNNING_PROCESS_LABEL)) {
-                                                       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<Integer, String> processes = (Map<Integer, String>) result;
-                                                               selectedPkg.getMainApp().setRunningProcesses(processes);
+                                                       DAResult presult = DACommunicator.checkPrivilege();
+                                                       if (presult.isSuccess()) {
+                                                               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<Integer, String> processes = (Map<Integer, String>) result;
+                                                                       selectedPkg.getMainApp().setRunningProcesses(processes);
+                                                               }
+                                                       } else {
+                                                               UIAction.showWarning(presult);
                                                        }
                                                } else if (appName.equals(AnalyzerConstants.COMMON_EXECUTABLE_LABEL)) {
                                                        Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell();