From fa8dee4583bb1f8faedc21d01ef8ad11139c1e66 Mon Sep 17 00:00:00 2001 From: "kh5325.kim" Date: Tue, 12 Nov 2013 13:22:05 +0900 Subject: [PATCH] LAUNCH: Aligned messages with web and native Aligns messages between web and native launch. Removes user-unfriendly messages. Change-Id: Ifbb5c21e17871e4beb72a21fcd61ad8e01084088 Signed-off-by: kh5325.kim --- .../org/tizen/common/launch/LaunchMessages.java | 8 +- .../tizen/common/launch/LaunchMessages.properties | 3 + .../org/tizen/common/sdb/command/SdbCommand.java | 95 ++++++++++++---------- 3 files changed, 60 insertions(+), 46 deletions(-) diff --git a/org.tizen.common/src/org/tizen/common/launch/LaunchMessages.java b/org.tizen.common/src/org/tizen/common/launch/LaunchMessages.java index a89a5ea..d380555 100644 --- a/org.tizen.common/src/org/tizen/common/launch/LaunchMessages.java +++ b/org.tizen.common/src/org/tizen/common/launch/LaunchMessages.java @@ -47,9 +47,11 @@ public class LaunchMessages extends NLS { public static String UPDATE_MODE_LABEL; public static String UPDATE_MODE_TOOLTIP; + public static String CREATED_PACKAGE; public static String INSTALL_PACKAGE; public static String UNINSTALL_PACKAGE; public static String TRANSFER_PACKAGE; + public static String TRANSFERRED_PACKAGE; public static String RUN_PACKAGE; public static String LAUNCH_START; @@ -72,7 +74,11 @@ public class LaunchMessages extends NLS { return "(" + getTimeInterval(start, end) + " sec)"; } - public static String getStepMessage(String step) { + public static String getStepTitle(String step) { return "[" + step + "]"; } + + public static String getStepMessage(String message) { + return " " + message; + } } diff --git a/org.tizen.common/src/org/tizen/common/launch/LaunchMessages.properties b/org.tizen.common/src/org/tizen/common/launch/LaunchMessages.properties index d21aaca..2304d12 100644 --- a/org.tizen.common/src/org/tizen/common/launch/LaunchMessages.properties +++ b/org.tizen.common/src/org/tizen/common/launch/LaunchMessages.properties @@ -15,12 +15,15 @@ PROJECT_NOT_USABLE = Project is closed or does not exist. UPDATE_MODE_LABEL = Enable update mode UPDATE_MODE_TOOLTIP = If you want to set update mode you should turn off RDS option first of all. +CREATED_PACKAGE = Created the package: {0} + # Install/Uninstall INSTALL_PACKAGE = Installing the package... UNINSTALL_PACKAGE = Uninstalling the package... # Transfer TRANSFER_PACKAGE = Transferring the package... +TRANSFERRED_PACKAGE = Transferred the package: {0} -> {1} # Run RUN_PACKAGE = Running the application... diff --git a/org.tizen.common/src/org/tizen/common/sdb/command/SdbCommand.java b/org.tizen.common/src/org/tizen/common/sdb/command/SdbCommand.java index 3a7fd79..caa046d 100644 --- a/org.tizen.common/src/org/tizen/common/sdb/command/SdbCommand.java +++ b/org.tizen.common/src/org/tizen/common/sdb/command/SdbCommand.java @@ -28,6 +28,8 @@ package org.tizen.common.sdb.command; import java.io.IOException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.tizen.common.TizenPlatformConstants; import org.tizen.common.core.application.InstallPathConfig; import org.tizen.common.sdb.command.message.CommandErrorException; @@ -42,137 +44,125 @@ import org.tizen.sdblib.exception.SdbCommandRejectedException; import org.tizen.sdblib.exception.ShellCommandUnresponsiveException; import org.tizen.sdblib.exception.TimeoutException; - public class SdbCommand { + protected final Logger logger = LoggerFactory.getLogger(getClass()); + public static final int DEFAULT_TIMEOUT = 60000; + private final String SEPARATOR = System.getProperty("line.separator"); + private IDevice device = null; private ITizenConsoleManager console = null; private String endLine = ""; private String commandOutput = ""; private CommandOutputReceiver receiver = null; private String sdbPath; - + private boolean showCommand = false; + public SdbCommand(IDevice device) { this(device, null); } - + public SdbCommand(IDevice device, ITizenConsoleManager console) { this(device, console, new CommandOutputReceiver(console)); } - + public SdbCommand(IDevice device, ITizenConsoleManager console, CommandOutputReceiver receiver) { this.device = device; this.console = console; this.receiver = receiver; - + sdbPath = InstallPathConfig.getSDBPath(); } - - public void runCommand(String command ) throws Exception { - if (console != null) { - console.println("$ " + command); - } + + public void runCommand(String command) throws Exception { + print("$ " + command); device.executeShellCommand(command, receiver); this.endLine = receiver.getEndLine(); this.commandOutput = receiver.getCommandOutput(); } - + public void runLaunchCommand(String command) throws IOException { runLaunchCommand(command, true); } - + private Process runHostCommandImpl(String command, String sdbCommand, boolean isBlock, IShellOutputReceiver userReceiver, boolean isLaunch) throws IOException { + print("$ " + sdbCommand); + Process process = null; - - if (console != null) { - console.println(String.format("$ %s", sdbCommand)); - } - IShellOutputReceiver r = (userReceiver != null) ? userReceiver : this.receiver; if ( isBlock ) { - if (isLaunch) { + if ( isLaunch ) { device.executeLaunchCommand( command, r ); } else { device.executeHostCommand( command, r ); } - if (userReceiver == null) { + if ( userReceiver == null ) { this.endLine = this.receiver.getEndLine(); this.commandOutput = this.receiver.getCommandOutput(); } - } - else { + } else { process = Runtime.getRuntime().exec(sdbCommand); } - + return process; } - + public Process runLaunchCommand(String command, boolean isBlock) throws IOException { final String sdbCommand = String.format("%s -s %s launch %s", sdbPath, device.getSerialNumber(), command); - return runHostCommandImpl(command, sdbCommand, isBlock, null, true); } - + public Process runHostCommand(String command, boolean isBlock) throws IOException { return runHostCommand(command, isBlock, null); } - + public Process runHostCommand(String command, boolean isBlock, IShellOutputReceiver receiver) throws IOException { final String sdbCommand = String.format("%s -s %s %s", sdbPath, device.getSerialNumber(), command); - return runHostCommandImpl(command, sdbCommand, isBlock, receiver, false); } - + public String returnExecuteCommand(String command) { - final String sdbCommand = String.format("%s -s %s shell %s", sdbPath, device.getSerialNumber(), command); - return HostUtil.returnExecute(sdbCommand); } - public CommandErrorType runCommand(String command, CommandErrorType messages ) throws CommandErrorException, TimeoutException, SdbCommandRejectedException, ShellCommandUnresponsiveException, IOException { + public CommandErrorType runCommand(String command, CommandErrorType messages) throws CommandErrorException, TimeoutException, SdbCommandRejectedException, ShellCommandUnresponsiveException, IOException { return runCommand(command, messages, DEFAULT_TIMEOUT); } - public CommandErrorType runCommand(String command, CommandErrorType errorMessages, int timeout ) throws CommandErrorException, TimeoutException, SdbCommandRejectedException, ShellCommandUnresponsiveException, IOException{ - if (console != null) { - console.println("$ " + command); - } + public CommandErrorType runCommand(String command, CommandErrorType errorMessages, int timeout) throws CommandErrorException, TimeoutException, SdbCommandRejectedException, ShellCommandUnresponsiveException, IOException{ + print("$ " + command); device.executeShellCommand( makeCommandWithExitcode(command), receiver, timeout); this.endLine = receiver.getEndLine(); this.commandOutput = receiver.getCommandOutput(); - String endLine = receiver.getEndLine(); int exitcode = parseExitcode(endLine); - errorMessages.findErrorType(exitcode, command); errorMessages.setCommandOutput(receiver.getCommandOutput()); errorMessages.makeException(); - return errorMessages; } - + public String getEndLine() { return endLine; } - + public String getCommandOutput() { return commandOutput; } - + public String[] getResultLineStrings() { String strs = commandOutput.toString(); if ( StringUtil.isEmpty(strs) ) { return new String[0]; } - String [] str = StringUtil.split( strs, System.getProperty("line.separator") ); - + String[] str = StringUtil.split( strs, SEPARATOR ); return str; } - + private int parseExitcode(String line) { int exitcode = -1; if ( line.startsWith(TizenPlatformConstants.CMD_RESULT_PREFIX) ) { @@ -180,8 +170,23 @@ public class SdbCommand { } return exitcode; } - + private String makeCommandWithExitcode(String command) { return command + TizenPlatformConstants.CMD_SUFFIX; } + + public boolean isShowCommand() { + return showCommand; + } + + public void setShowCommand(boolean showCommand) { + this.showCommand = showCommand; + } + + private void print(String message) { + logger.debug(message); + if ( isShowCommand() && console != null ) { + console.println(message); + } + } } -- 2.7.4