[Title] added method in sdblib that get app's install path.
authorGun Kim <gune.kim@samsung.com>
Thu, 21 Mar 2013 02:24:02 +0000 (11:24 +0900)
committerGun Kim <gune.kim@samsung.com>
Thu, 21 Mar 2013 04:50:11 +0000 (13:50 +0900)
[Type]
[Module]
[Priority]
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: I31bfd690222e72e37982a36e78c8f1646c0d9a7f

org.tizen.common.sdblib/src/org/tizen/sdblib/Device.java
org.tizen.common.sdblib/src/org/tizen/sdblib/IDevice.java
org.tizen.common/src/org/tizen/common/TizenPlatformConstants.java

index 74591e6..95b2e97 100644 (file)
@@ -31,6 +31,10 @@ final class Device implements IDevice {
     final static String COMMAND_ARCHITECTURE_INFO = "uname -m";
     final static String EMULATOR = "emulator";
     final static String COMMAND_DEVICE_TYPE = "[ -f /dev/samsung_sdb ] || echo " + EMULATOR;
+    public final static String DEFAULT_APP_INSTALL_PATH = "/opt/usr/apps";
+    public final static String TEMPORARY_PKG_DIRECTORY = "tmp";
+    public final static String PKG_TOOL_INSTALL_PATH_COMMAND = "pkgcmd -a";
+    public final static String PKG_TOOL_INSTALL_PATH_COMMAND_RESULT = "Tizen Application Installation Path:";
 
     /** Serial number of the device */
     private String mSerialNumber = null;
@@ -48,6 +52,8 @@ final class Device implements IDevice {
     private static final String LOG_TAG = "Device";
 
     private SdbShellProcess sdbShellProcess = null;
+    
+    private String appInstallPath = "";
 
     public String getSerialNumber() {
         return mSerialNumber;
@@ -184,7 +190,7 @@ final class Device implements IDevice {
     public String syncPackageToDevice(String localFilePath) throws IOException, SdbCommandRejectedException, TimeoutException {
         try {
             String packageFileName = getFileName(localFilePath);
-            String remoteFilePath = String.format("/opt/apps/tmp/%1$s", packageFileName); //$NON-NLS-1$
+            String remoteFilePath = String.format("%s/%1$s", getDeveloperDirectoryPath(), packageFileName); //$NON-NLS-1$
 
             Log.d(packageFileName, String.format("Uploading %1$s onto device '%2$s'", packageFileName, getSerialNumber()));
 
@@ -254,6 +260,37 @@ final class Device implements IDevice {
             Log.e("sdb", "execute " + COMMAND_DEVICE_TYPE + " failed:" + e);
         }
     }
+    
+    @Override
+    public String getAppInstallPath() {
+        if ( appInstallPath.isEmpty() ) {
+            try {
+                executeShellCommand(PKG_TOOL_INSTALL_PATH_COMMAND, new AppInstallPathReceiver());
+            } catch (Exception e) {
+                appInstallPath = "";
+                Log.e("sdb", "execute " + PKG_TOOL_INSTALL_PATH_COMMAND + " failed:" + e);
+            }
+        }
+        return appInstallPath;
+    }
+    
+    @Override
+    public String getDeveloperDirectoryPath() {
+        return getAppInstallPath() + "/" + Device.TEMPORARY_PKG_DIRECTORY;
+    }
+
+    class AppInstallPathReceiver extends MultiLineReceiver {
+        @Override
+        public void processNewLines(String[] lines) {
+            for ( String line : lines ) {
+                if ( line.startsWith(Device.PKG_TOOL_INSTALL_PATH_COMMAND_RESULT) ) {
+                    appInstallPath = line.replaceFirst(Device.PKG_TOOL_INSTALL_PATH_COMMAND_RESULT, "");
+                    appInstallPath = appInstallPath.trim();
+                    break;
+                }
+            }
+        }
+    }
 
     class ArchInfoReceiver extends MultiLineReceiver {
         @Override
index 11a93d2..c1b2097 100755 (executable)
@@ -277,4 +277,14 @@ public interface IDevice {
     void removeRemotePackage(String remoteFilePath)
             throws TimeoutException, SdbCommandRejectedException, ShellCommandUnresponsiveException,
             IOException;
+    
+    /**
+     * Returns application's installation path.
+     */
+    String getAppInstallPath();
+    
+    /**
+     * Returns temporary directory that has a developer permission.
+     */
+    String getDeveloperDirectoryPath();
 }
index 75718ce..ab4b77c 100644 (file)
@@ -27,6 +27,7 @@
 package org.tizen.common;
 
 import org.tizen.common.util.OSChecker;
+import org.tizen.sdblib.IDevice;
 
 /**
  * All constant definitions related Tizen Platform such as Emulator or Device.
@@ -65,8 +66,15 @@ public class TizenPlatformConstants {
     public static final String HOST_GDBSERVER_PATH = "/usr/bin/gdbserver";
 
     // Definitions for installing
+    /**
+     * @deprecated APP_INSTALL_PATH is deprecated. Use {@link IDevice#getAppInstallPath()}.
+     */
     public static final String APP_INSTALL_PATH;
     public static final String APP_ICON_INSTALL_PATH;
+    
+    /**
+     * @deprecated APP_INSTALL_PATH is deprecated. Use {@link IDevice#getDeveloperDirectoryPath()}.
+     */
     public static final String TEMPORARY_PKG_PATH;
     public static final String PKG_TOOL = "pkgcmd";
     public static final String PKG_TOOL_LIST_COMMAND = PKG_TOOL + " -l  | grep %s";
@@ -74,7 +82,6 @@ public class TizenPlatformConstants {
     public static final String PKG_TOOL_INSTALL_COMMAND = PKG_TOOL + " -q -i -t %s -p %s";
     public static final String PKG_TOOL_RUNNING_CHECK_COMMAND = PKG_TOOL + " -C -t %s -n %s";
     public static final String PKG_TOOL_TERMINATE_COMMAND = PKG_TOOL + " -k -t %s -n %s";
-    public static final String PKG_TOOL_INSTALL_PATH_COMMAND = PKG_TOOL + " -a";
     
     // Definitions for RDS
     public static final String RDS_PUSH_DIRECTORY_COMMAND = "mkdir -p -m 755 \"%s\""+ TizenPlatformConstants.CMD_SUFFIX;
@@ -96,16 +103,15 @@ public class TizenPlatformConstants {
     public static final String PROCESS_GET_PROCESS_ID_COMMAND = "ps -ef | grep '%s' | grep -v grep | awk '{print $2}'";
     public static final String PROCESS_SIGKILL_COMMAND = "kill -9 %s";
     public static final String PKG_TOOL_RUNNUNG_CHECK_COMMAND_RUNNING= "is Running";
-    public static final String PKG_TOOL_INSTALL_PATH_COMMAND_RESULT = "Tizen Application Installation Path:";
 
     // Constants have a potential for change
     static {
         TOOLS_TARGET_PATH = "/home/developer/sdk_tools";
         GDBSERVER_CMD = TizenPlatformConstants.TOOLS_TARGET_PATH + "/gdbserver/gdbserver";
         GDBSERVER_PLATFORM_CMD = TizenPlatformConstants.TOOLS_TARGET_PATH + "/gdbserver-platform/gdbserver";
-        APP_INSTALL_PATH = "/opt/apps";
+        APP_INSTALL_PATH = "/opt/usr/apps";
         APP_ICON_INSTALL_PATH = "shared/res";
-        TEMPORARY_PKG_PATH = "/opt/apps/PKGS/";
+        TEMPORARY_PKG_PATH = "/opt/usr/apps/tmp/";
         DEBUG_COREFILE_PATH = "/opt/usr/share/crash/dump";
         DEBUG_COREFILE_EXTENSION = "coredump";
         DEBUG_COREFILE_EXTRACT_COMMAND = "tar -xvf %s -C %s --wildcards --no-anchored '%s'";