[SPTSDKUX-1938] Resolve issue that can't profile 2.3.1 wearable
authorjaeyong lee <jae-yong.lee@samsung.com>
Mon, 29 Aug 2016 07:20:53 +0000 (16:20 +0900)
committergihun chang <gihun.chang@samsung.com>
Tue, 30 Aug 2016 07:29:05 +0000 (16:29 +0900)
* This issue is mainly cuased from "getting root permission" for
  Platform Dynamic Analyzer even though DA is running as normal mode.
* Change the permission logic to enable only when platform DA is set
  on setting file.
* Remove deprecated function.

Change-Id: I4aa562f31ea45ba4b262fdb97a2e02112111dfea

org.tizen.dynamicanalyzer.workbench/src/org/tizen/dynamicanalyzer/common/path/PathManager.java
org.tizen.dynamicanalyzer.workbench/src/org/tizen/dynamicanalyzer/workbench/ApplicationWorkbenchWindowAdvisor.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/CommunicatorUtils.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DeviceManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/protocol/p30/Communicator30.java

index dde5736..16e332f 100644 (file)
@@ -251,11 +251,23 @@ public class PathManager {
 
                return aboutFilePath;
        }
-       
+
+       /**
+        * isPlatformSDK() functionality is replaced.
+        *
+        * @deprecated use SettingDataManager.INSTANCE.isPlatformDA() instead.
+        */
+       @Deprecated
        public static boolean isPlatformSDK() {
                return checkPlatformPlugin();
        }
 
+       /**
+        * checkPlatformPlugin() functionality is replaced.
+        *
+        * @deprecated use SettingDataManager.INSTANCE.isPlatformDA() instead.
+        */
+       @Deprecated
        public static boolean checkPlatformPlugin() {
                String idePluginPath = TIZEN_SDK_INSTALL_PATH + File.separator
                                + PathConstants.IDE_FOLDER_NAME + File.separator
index 4961b8d..6a9d688 100644 (file)
@@ -101,10 +101,6 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
                configurer.setTitle("Dynamic Analyzer");
                configurer.setShowCoolBar(false);
                configurer.setShowFastViewBars(false);
-               if (PathManager.isPlatformSDK())
-                       configurer.setTitle(WorkbenchLabels.DA_PLATFORM_WORKBENCH_TITLE);
-               else
-                       configurer.setTitle(WorkbenchLabels.DA_PUBLIC_WORKBENCH_TITLE);
        }
 
        public void postWindowOpen() {
index 2adb612..447d804 100644 (file)
@@ -81,6 +81,17 @@ public class CommunicatorUtils {
        }
 
        public static boolean enableRoot(IDevice device) {
+               // the getPlatformCapability() method is working differently between
+               // platform & product and Tizen platform versions.
+
+               //  Tizen Platform  |      2.3       |      2.3.1      |  2.3.2 / 2.4 / 3.0
+               //  ----------------+----------------+-----------------+-------------------
+               //         product  |   available    |    available    |      available
+               //        emulator  | not available  |  not available  |      available
+
+               // If the capability function is available, DA can get the root privilege via getSdbRootPerm().
+               // but if the target image uses "user" binary it dose not permit it. So it returns "sdbd_rootperm:disabled".
+
                boolean availability = false;
 
                try {
@@ -94,7 +105,19 @@ public class CommunicatorUtils {
                } catch (TimeoutException e) {
                        Logger.exception(e);
                } catch (SdbCommandRejectedException e) {
-                       Logger.exception(e);
+                       Logger.debug("getPlatformCapability() failed");
+
+                       // If the platform doesn't have the capability,
+                       // check the root privilege with device.becomeSuperUser API.
+                       if(becomeSuperUser(device,true) == true){
+                               availability = true;
+                       
+                               // Reset if the "root on" was successes to avoid the system runs as root.
+                               becomeSuperUser(device, false);
+                       } else {
+                               availability = false;
+                       }
+                       
                } catch (IOException e) {
                        Logger.exception(e);
                }
index cdca894..0ad8e43 100644 (file)
@@ -38,6 +38,7 @@ import org.tizen.dynamicanalyzer.common.Global;
 import org.tizen.dynamicanalyzer.common.path.PathManager;
 import org.tizen.dynamicanalyzer.handlers.UIActionHolder;
 import org.tizen.dynamicanalyzer.protocol.Protocol;
+import org.tizen.dynamicanalyzer.setting.SettingDataManager;
 import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
 import org.tizen.dynamicanalyzer.util.Logger;
 import org.tizen.sdblib.IDevice;
@@ -122,7 +123,9 @@ public class DeviceManager {
                }
 
                // set availability of root
-               devInfo.setAvailabilityOfRoot(CommunicatorUtils.enableRoot(device));
+               if(SettingDataManager.INSTANCE.isPlatformDA() == true)
+                       devInfo.setAvailabilityOfRoot(CommunicatorUtils.enableRoot(device));
+               
                // connect with swap of device
                DAResult result = devInfo.getCommunicator().connect();
                if (result.isSuccess()) {
index 74d749d..5ca3af7 100644 (file)
@@ -738,17 +738,28 @@ public class Communicator30 extends SubCommunicator {
        protected DAResult pullTheFile(String from, String to) {
                DeviceInfo curDev = parent.getDevice();
 
-               if (!curDev.isRootAvailable()) {
-                       return new DAResult(ErrorCode.ERR_BY_SECURITY);
-               }
+               // First try to pull the binary from device. 
+               SyncResult res = CommunicatorUtils.pull(curDev.getIDevice(), from, to);
 
-               if (!CommunicatorUtils.becomeSuperUser(curDev.getIDevice(), true)) {
-                       return new DAResult(ErrorCode.ERR_BY_SECURITY);
-               }
+               if (null != res && res.isOk() == false){
+                       // if fail to get the binary, Do Second try with the root privilege for Platform DA
+                       if(SettingDataManager.INSTANCE.isPlatformDA() == true){
+                               // to support platform DA features, DA should get the root privilege.
+                               if (!curDev.isRootAvailable()) {
+                                       return new DAResult(ErrorCode.ERR_BY_SECURITY);
+                               }
 
-               SyncResult res = CommunicatorUtils.pull(curDev.getIDevice(), from, to);
+                               // set root on here
+                               if (!CommunicatorUtils.becomeSuperUser(curDev.getIDevice(), true)) {
+                                       return new DAResult(ErrorCode.ERR_BY_SECURITY);
+                               }
 
-               CommunicatorUtils.becomeSuperUser(curDev.getIDevice(), false);
+                               res = CommunicatorUtils.pull(curDev.getIDevice(), from, to);
+
+                               CommunicatorUtils.becomeSuperUser(curDev.getIDevice(), false);
+
+                       }
+               }
 
                if (null != res && res.isOk()) {
                        Logger.debug("binary copy success : " + from);//$NON-NLS-1$ 
@@ -756,6 +767,7 @@ public class Communicator30 extends SubCommunicator {
                } else {
                        Logger.warning("Failed to get " + from); //$NON-NLS-1$
                        DAResult ret = new DAResult(ErrorCode.ERR_DOWNLOAD_FILE_FAILED);
+
                        ret.setDetailMessage(CommonConstants.OPEN_BRACKET + from
                                        + CommonConstants.CLOSE_BRACKET);
                        return ret;