[Title] modifed OnDemandInstall#copyPackage() using sdblib.
authorGun Kim <gune.kim@samsung.com>
Tue, 18 Dec 2012 01:35:40 +0000 (10:35 +0900)
committerGun Kim <gune.kim@samsung.com>
Tue, 18 Dec 2012 02:38:08 +0000 (11:38 +0900)
[Type]
[Module]
[Priority]
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: Ia288bdcd7e9ec7bc9ba4acff701c23061b498562

org.tizen.common.connection/src/org/tizen/common/connection/debugtools/OnDemandInstall.java
org.tizen.common/src/org/tizen/common/rds/RdsDeployer.java

index 78902b1..587c0d6 100644 (file)
@@ -30,6 +30,7 @@ package org.tizen.common.connection.debugtools;
 import static org.tizen.common.util.CollectionUtil.isEmpty;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -43,11 +44,13 @@ import org.eclipse.osgi.util.NLS;
 import org.tizen.common.TizenPlatformConstants;
 import org.tizen.common.core.application.InstallPathConfig;
 import org.tizen.common.util.FileUtil;
-import org.tizen.common.util.SdbCommandUtil;
+import org.tizen.common.util.IOUtil;
 import org.tizen.common.util.log.Logger;
 import org.tizen.sdblib.IDevice;
 import org.tizen.sdblib.IDevice.Arch;
 import org.tizen.sdblib.MultiLineReceiver;
+import org.tizen.sdblib.SyncService;
+import org.tizen.sdblib.SyncService.SyncResult;
 
 /**
  * On-demand Install class to deploy SDK tools to Tizen device or an emulator.
@@ -192,8 +195,21 @@ public class OnDemandInstall {
         device = pDevice;
     }
 
-    private boolean copyPackage(String source, String destination) {
-        return SdbCommandUtil.filePush(device, source, destination);
+    private boolean copyPackage(String source, String destination) throws IOException {
+        SyncService syncService = null;
+        try {
+            syncService = device.getSyncService();
+            SyncResult result = syncService.pushFile(source, destination, SyncService.getNullProgressMonitor());
+            
+            if ( result.getCode() == SyncService.RESULT_OK ) {
+                return true;
+            }
+            else {
+                return false;
+            }
+        } finally {
+            IOUtil.tryClose(syncService);
+        }
     }
 
     private void installPackage(IProgressMonitor monitor) {
@@ -234,8 +250,12 @@ public class OnDemandInstall {
         String result = "";
 
         verbose("Deploying: " + tool);
-        if (copyPackage(local, remote) == false) {
-            Logger.error(NLS.bind(OnDemandInstallMessages.CANNOT_COPY_FILE, tool.getBinaryname()));
+        try {
+            if (copyPackage(local, remote) == false) {
+                throw new IOException();
+            }
+        } catch (IOException e) {
+            Logger.error(NLS.bind(OnDemandInstallMessages.CANNOT_COPY_FILE, tool.getBinaryname()), e);
             return;
         }
 
index 39c86ec..a398f93 100644 (file)
@@ -131,7 +131,7 @@ public abstract class RdsDeployer implements Closeable{
                     }
                     else {
                         SyncResult result = getSyncService().pushFile(node.getFullPath(), strRemotePath, SyncService.getNullProgressMonitor());
-                        if ( result.getCode() == SyncService.RESULT_NO_LOCAL_FILE || result.getCode() == SyncService.RESULT_LOCAL_IS_DIRECTORY) {
+                        if ( result.getCode() != SyncService.RESULT_OK ) {
                             throw new IOException(command);
                         }
                     }