COMMANDER: Set timeout 10000ms in case of refreshing and listing 59/12959/1
authordonghyuk.yang <donghyuk.yang@samsung.com>
Wed, 27 Nov 2013 01:07:56 +0000 (10:07 +0900)
committerdonghyuk.yang <donghyuk.yang@samsung.com>
Wed, 27 Nov 2013 01:07:56 +0000 (10:07 +0900)
packages

On device, set timeout 10000ms when refreshing repositories and listing
packages. If use default timeout (300000ms), it feel like hang.

Signed-off-by: donghyuk.yang <donghyuk.yang@samsung.com>
Change-Id: I3b82c98018f2b50f2d7957ce231fcfc1c7b85f8a

org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderCommon.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderDevice.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderHost.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderRootstrap.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandLauncherOnDevice.java

index 6b9ba34..d25d345 100644 (file)
@@ -91,6 +91,8 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
 
     abstract protected ICommandStatus execute(String command, IProgressMonitor monitor);
 
+    abstract protected ICommandStatus execute(String command, int timeout, IProgressMonitor monitor);
+
     abstract protected ICommandStatus execute(String command, IProgressMonitor monitor,
             boolean printlog);
 
@@ -98,6 +100,9 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
             IProgressMonitor monitor);
 
     abstract protected ICommandStatus execute(String command, PackageManagerOuputReceiver rec,
+            int timeout, IProgressMonitor monitor);
+
+    abstract protected ICommandStatus execute(String command, PackageManagerOuputReceiver rec,
             IProgressMonitor monitor, boolean printLog);
 
     abstract protected void changeUpdateMode();
@@ -643,7 +648,7 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
         String command = makeCommand(getProxyCommand(), getResetRpmDb(),
                 ZypperTool.remotePkgListCommandWithXmlOut());
         PackageManagerOuputReceiver hrec = getNewOuputReceiver();
-        ICommandStatus status = execute(command, hrec, null);
+        ICommandStatus status = execute(command, hrec, 10000, null);
         if (!status.isOk()) {
             printResultLog("Failed to get remote package list");
             return null;
@@ -761,7 +766,7 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
         String command = makeCommand(getProxyCommand(), getResetRpmDb(),
                 ZypperTool.refreshRepoCommandXmlOut());
         PackageManagerOuputReceiver hrec = getNewOuputReceiver();
-        ICommandStatus status = execute(command, hrec, null);
+        ICommandStatus status = execute(command, hrec, 10000, null);
         if (!status.isOk()) {
             printResultLog("Failed to refresh repository");
         } else {
@@ -781,7 +786,7 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
         // refreshRepoListXmlOut();
         String command = makeCommand(getProxyCommand(), getResetRpmDb(),
                 ZypperTool.refreshRepoCommand());
-        ICommandStatus status = execute(command, null);
+        ICommandStatus status = execute(command, 10000, null);
         if (!status.isOk()) {
             printResultLog("Failed to refresh repository");
         }
index c76ea07..29d584e 100644 (file)
@@ -191,7 +191,8 @@ public class RpmCommanderDevice extends RpmCommanderCommon {
         if (!a_label.isEmpty()) {
             sbCommand.append(String.format(" -a %s", a_label));
         } else {
-            String log = String.format("[RDS] Do not need to change smack (access permission is empty): %s", path);
+            String log = String.format(
+                    "[RDS] Do not need to change smack (access permission is empty): %s", path);
             printResultLog(log);
             return new CommandStatus(ICommandStatus.OK, "", log, null);
         }
@@ -270,6 +271,10 @@ public class RpmCommanderDevice extends RpmCommanderCommon {
         return execute(command, monitor, true);
     }
 
+    protected ICommandStatus execute(String command, int timeout, IProgressMonitor monitor) {
+        return execute(command, timeout, monitor, true);
+    }
+
     protected ICommandStatus execute(String command, IProgressMonitor monitor, boolean printCommand) {
         if (printCommand) {
             printCommandLog(command);
@@ -281,6 +286,18 @@ public class RpmCommanderDevice extends RpmCommanderCommon {
         return status;
     }
 
+    protected ICommandStatus execute(String command, int timeout, IProgressMonitor monitor,
+            boolean printCommand) {
+        if (printCommand) {
+            printCommandLog(command);
+        }
+        ICommandStatus status = CommandLauncherOnDevice.execute(device, command, rec, timeout);
+        if (!status.isOk()) {
+            logger.error(status.getMessage(), status.getException());
+        }
+        return status;
+    }
+
     protected ICommandStatus execute(String command, IProgressMonitor monitor,
             boolean printCommand, boolean printLog) {
         if (printCommand) {
@@ -300,6 +317,11 @@ public class RpmCommanderDevice extends RpmCommanderCommon {
     }
 
     protected ICommandStatus execute(String command, PackageManagerOuputReceiver rec,
+            int timeout, IProgressMonitor monitor) {
+        return execute(command, rec, timeout, monitor, true);
+    }
+
+    protected ICommandStatus execute(String command, PackageManagerOuputReceiver rec,
             IProgressMonitor monitor, boolean printlog) {
         if (printlog) {
             printCommandLog(command);
@@ -311,6 +333,18 @@ public class RpmCommanderDevice extends RpmCommanderCommon {
         return status;
     }
 
+    protected ICommandStatus execute(String command, PackageManagerOuputReceiver rec,
+            int timeout, IProgressMonitor monitor, boolean printlog) {
+        if (printlog) {
+            printCommandLog(command);
+        }
+        ICommandStatus status = CommandLauncherOnDevice.execute(device, command, rec, timeout);
+        if (!status.isOk()) {
+            logger.error(status.getMessage(), status.getException());
+        }
+        return status;
+    }
+
     protected PackageManagerOuputReceiver getNewOuputReceiver() {
         PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver();
         rec.setPrintConsole(false);
index d3d6fca..5dda299 100644 (file)
@@ -77,6 +77,11 @@ public class RpmCommanderHost extends RpmCommanderCommon {
     }
 
     @Override
+    protected ICommandStatus execute(String command, int timeout, IProgressMonitor monitor) {
+        return null;
+    }
+
+    @Override
     protected ICommandStatus execute(String command, IProgressMonitor monitor, boolean printlog) {
         return null;
     }
@@ -89,6 +94,12 @@ public class RpmCommanderHost extends RpmCommanderCommon {
 
     @Override
     protected ICommandStatus execute(String command, PackageManagerOuputReceiver rec,
+            int timeout, IProgressMonitor monitor) {
+        return null;
+    }
+
+    @Override
+    protected ICommandStatus execute(String command, PackageManagerOuputReceiver rec,
             IProgressMonitor monitor, boolean printLog) {
         return null;
     }
index d49c370..12e51a7 100644 (file)
@@ -109,6 +109,10 @@ public class RpmCommanderRootstrap extends RpmCommanderCommon {
         return execute(command, monitor, true);
     }
 
+    protected ICommandStatus execute(String command, int timeout, IProgressMonitor monitor) {
+        return execute(command, monitor, true);
+    }
+
     protected ICommandStatus execute(String command, IProgressMonitor monitor, boolean printCommand) {
         String chrootedCommand = getChrootedCommand(command);
         if (printCommand) {
@@ -128,6 +132,11 @@ public class RpmCommanderRootstrap extends RpmCommanderCommon {
     }
 
     protected ICommandStatus execute(String command, PackageManagerOuputReceiver rec,
+            int timeout, IProgressMonitor monitor) {
+        return execute(command, rec, monitor, true);
+    }
+
+    protected ICommandStatus execute(String command, PackageManagerOuputReceiver rec,
             IProgressMonitor monitor, boolean printlog) {
         String chrootedCommand = getChrootedCommand(command);
         if (printlog) {
index 4790f41..0e06025 100644 (file)
@@ -46,13 +46,19 @@ public class CommandLauncherOnDevice {
 
     public static synchronized ICommandStatus execute(IDevice device, String command,
             PackageManagerOuputReceiver rec) {
+        int defaultTimeout = CommonPlugin.getDefault().getPreferenceStore()
+                .getInt(SdbPreferencePage.KEY_SDB_RESPONSE_TIMEOUT);
+        return execute(device, command, rec, defaultTimeout);
+    }
+
+    public static synchronized ICommandStatus execute(IDevice device, String command,
+            PackageManagerOuputReceiver rec, int timeout) {
         String[] prevLog = {};
         if (rec.getLog() != null) {
             prevLog = rec.getLog();
         }
-        int defaultTimeout = CommonPlugin.getDefault().getPreferenceStore().getInt(SdbPreferencePage.KEY_SDB_RESPONSE_TIMEOUT);
         try {
-            device.executeShellCommand(command, rec, defaultTimeout);
+            device.executeShellCommand(command, rec, timeout);
         } catch (TimeoutException e) {
             return new CommandStatus(IStatus.ERROR, command, e.getMessage(), e);
         } catch (SdbCommandRejectedException e) {