package org.tizen.sdblib;
+import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.io.InputStreamReader;
import org.tizen.sdblib.SyncService.SyncResult;
public FileListingService getFileListingService() {
return new FileListingService(this);
}
+
+ @Override
+ public void executeLaunchCommand(IShellOutputReceiver receiver, String options) throws IOException {
+ executeCommand("launch", receiver, options);
+ }
+
+ public void executeCommand(String command, IShellOutputReceiver receiver, String options) throws IOException {
+ SmartDevelopmentBridge sdb = SmartDevelopmentBridge.getBridge();
+ if (sdb == null)
+ return;
+ String sdbPath = sdb.getSdbOsLocation();
+ if (sdbPath == null)
+ return;
+ if (mSerialNumber == null)
+ return;
+ if (command == null || command.isEmpty())
+ return;
+
+ String sdbShellCmd = sdbPath + " -s " + mSerialNumber + " " + command + ((options != null) ? " " + options : "");
+ Process pSdb = Runtime.getRuntime().exec(sdbShellCmd);
+ sdbShellProcess = new SdbShellProcess(pSdb, command);
+ BufferedReader stdInput = null;
+ BufferedReader stdError = null;
+ try {
+ stdInput = new BufferedReader(new InputStreamReader(sdbShellProcess.getInputStream()));
+ stdError = new BufferedReader(new InputStreamReader(sdbShellProcess.getErrorStream()));
+ String s = null;
+ while ((s = stdInput.readLine()) != null) {
+ if (receiver != null && receiver.isCancelled()) {
+ break;
+ }
+ byte[] bytes = s.getBytes();
+ if (receiver != null) {
+ receiver.addOutput(s.getBytes(), 0, bytes.length);
+ }
+ }
+ while ((s = stdError.readLine()) != null) {
+ if (receiver != null && receiver.isCancelled()) {
+ break;
+ }
+ byte[] bytes = s.getBytes();
+ if (receiver != null) {
+ receiver.addOutput(s.getBytes(), 0, bytes.length);
+ }
+ }
+ } finally {
+ if ( stdInput != null ) {
+ try {
+ stdInput.close();
+ } catch (Exception e) {
+ }
+ }
+ if ( stdError != null ) {
+ try {
+ stdError.close();
+ } catch (Exception e) {
+ }
+ }
+ if (receiver != null)
+ receiver.flush();
+ }
+ }
public SdbShellProcess executeShellCommand(String command) throws IOException {
return (SdbShellProcess) executeShellCommand(command, true);
* @see SdbShellProcess
*/
SdbShellProcess executeShellCommand(String command) throws IOException;
-
+
/**
* Executes a shell command to the device promptly and return SdbShellProcess
*
int maxTimeToOutputResponse)
throws TimeoutException, SdbCommandRejectedException, ShellCommandUnresponsiveException,
IOException;
+
+ /**
+ * Executes a sdb launch command on the device, and sends the result to a <var>receiver</var>.
+ *
+ * @param receiver the {@link IShellOutputReceiver} that will receives the output of the command
+ * @param options arguments of the launch command
+ * @throws IOException in case of I/O error on the connection
+ */
+ public void executeLaunchCommand(IShellOutputReceiver receiver, String options) throws IOException;
/**
* Runs the event log service and outputs the event log to the {@link LogReceiver}.
public static final String PKG_TOOL_TERMINATE_COMMAND;
public static final String PKG_TOOL_REINSTALL_COMMAND;
public static final String PKG_TOOL_INSTALL_PATH_COMMAND;
+ public static final String PKG_TOOL_ROAPP_CHECK_COMMAND;
public static final String REMOVE_FILE_COMMAND;
public static final String DLOGUTIL_CMD;
+ public static final String ROAPP_RESULT;
+ public static final String RWAPP_RESULT;
// Definitions for RDS
public static final String RDS_PUSH_DIRECTORY_COMMAND = "mkdir -p -m 755 \"%s\""+ TizenPlatformConstants.CMD_SUFFIX;
PKG_TOOL_TERMINATE_COMMAND = PKG_TOOL + " -k -t %s -n %s";
// Check org.tizen.sdblib.Device.PKG_TOOL_INSTALL_PATH_COMMAND constant
PKG_TOOL_INSTALL_PATH_COMMAND = PKG_TOOL + " -a";
+ PKG_TOOL_ROAPP_CHECK_COMMAND = "/usr/bin/pkginfo --pkg %s | grep -i Removable";
+ ROAPP_RESULT = "Removable: 0";
+ RWAPP_RESULT = "Removable: 1";
+
REMOVE_FILE_COMMAND = "rm -rf %s";
// Should be absolute path
if ( file != null ) {
try {
pushFile(file.getCanonicalPath(), strAppInstallPath + "/" + file.getName());
+ command = RdsDeployer.makeRdsLog(NLS.bind(RdsMessages.RDS_PUSH_LOG, file.getCanonicalPath(), strAppInstallPath + "/" + file.getName()));
printInfo( command );
} catch (Exception e) {
newCoreException(RdsDeployer.makeRdsLog(RdsMessages.RDS_PUSH_ERROR), e);
import org.tizen.sdblib.IDevice;
import org.tizen.sdblib.SdbCommandRejectedException;
import org.tizen.sdblib.ShellCommandUnresponsiveException;
+import org.tizen.sdblib.SmartDevelopmentBridge;
import org.tizen.sdblib.TimeoutException;
this.endLine = receiver.getEndLine();
this.commandOutput = receiver.getCommandOutput();
}
+
+ public void runLaunchCommand(String command) throws IOException {
+ runLaunchCommand(command, true);
+ }
+
+ public Process runLaunchCommand(String command, boolean isBlock) throws IOException {
+ Process process = null;
+ if (console != null) {
+ console.println("$ sdb launch " + command);
+ }
+
+ if ( isBlock ) {
+ device.executeLaunchCommand(receiver, command);
+
+ this.endLine = receiver.getEndLine();
+ this.commandOutput = receiver.getCommandOutput();
+ }
+ else {
+ SmartDevelopmentBridge sdb = SmartDevelopmentBridge.getBridge();
+ if (sdb == null) {
+ throw new IOException("Cannot find sdb command");
+ }
+ String sdbPath = sdb.getSdbOsLocation();
+ if (sdbPath == null) {
+ throw new IOException("Cannot find sdb command");
+ }
+ process = Runtime.getRuntime().exec(sdbPath + " launch " + command);
+ }
+
+ return process;
+ }
public CommandErrorType runCommand(String command, CommandErrorType messages ) throws CommandErrorException, TimeoutException, SdbCommandRejectedException, ShellCommandUnresponsiveException, IOException {
return runCommand(command, messages, DEFAULT_TIMEOUT);
}
device.executeShellCommand( makeCommandWithExitcode(command), receiver, timeout);
-
+ this.endLine = receiver.getEndLine();
+ this.commandOutput = receiver.getCommandOutput();
+
String endLine = receiver.getEndLine();
int exitcode = parseExitcode(endLine);
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") );
+
+ return str;
+ }
+
private int parseExitcode(String line) {
int exitcode = -1;
if ( line.startsWith(TizenPlatformConstants.CMD_RESULT_PREFIX) ) {
public static String ERROR_CERTIFICATE_CHAIN_VERIFICATION_FAILED;
public static String ERROR_CERTIFICATE_EXPIRED;
public static String ERROR_INVALID_PRIVILEGE;
+ public static String ERROR_PRIVILEGE_LEVEL_VIOLATION;
public static String ERROR_MENU_ICON_NOT_FOUND;
public static String ERROR_FATAL_ERROR;
public static String ERROR_OUT_OF_STORAGE;
public static String ERROR_OUT_OF_MEMORY;
- public static String ERROR_UNKNOWN;
+ public static String ERROR_ARGUMENT_INVALID;
//web app error messages.
public static String ERROR_WEB_PACKAGE_ALREADY_INSTALLED;
public static String ERROR_WEB_UNINSTALLATION_FAILED;
public static String ERROR_WEB_PLUGIN_INSTALLATION_FAILED;
+ public static String ERROR_UNKNOWN;
+
}
ERROR_SIGNATURE_VERIFICATION_FAILED=Check whether the package is modified illegally.
ERROR_ROOT_CERTIFICATE_NOT_FOUND=Insert root certificate into device or emulator.
ERROR_CERTIFICATE_INVALID=Check author certificates in Preferences > Tizen SDK > Secure Profiles > Profile items.
-ERROR_CERTIFICATE_CHAIN_VERIFICATION_FAILED=Check author certificates in Preferences > Tizen SDK > Secure Profiles > Profile items.
+ERROR_CERTIFICATE_CHAIN_VERIFICATION_FAILED=Check whether your device`s date and time is current. If the time is wrong, certificate expiration will be happened.\n\
+ Check author certificates in Preferences > Tizen SDK > Secure Profiles > Profile items.
ERROR_CERTIFICATE_EXPIRED=Check the system time in device or emulator.
ERROR_INVALID_PRIVILEGE=Check privilege strings in manifest editor > Privileges > Privileges.
+ERROR_PRIVILEGE_LEVEL_VIOLATION=Refer to Help contents > Getting Started with Tizen > Overview > Privilege.
ERROR_MENU_ICON_NOT_FOUND=Select a menu icon in manifest editor > Basic tab > Icon > MainMenu.
ERROR_FATAL_ERROR=Installation or uninstallation is not working temporarily.
ERROR_OUT_OF_STORAGE=Guarantee storage for installation in device or emulator.
ERROR_OUT_OF_MEMORY=Restart device or emulator.
-ERROR_UNKNOWN=\nUnknown error\n\nSee the error log for more details.
+ERROR_ARGUMENT_INVALID=Check the parameters of pkgcmd command.
# web app error messages
ERROR_WEB_PACKAGE_ALREADY_INSTALLED=If you want to reinstall, please uninstall the application in target.
ERROR_WEB_INSTALL_OSP_SERVICE=Check the service application in Project Explorer.
ERROR_WEB_NOT_DEVELOPER_MODE=You don't have permission to access.
ERROR_WEB_UNINSTALLATION_FAILED=Check the application's ID what you want to uninstall.
-ERROR_WEB_PLUGIN_INSTALLATION_FAILED=Web runtime initialization is failed(plugins installation).
\ No newline at end of file
+ERROR_WEB_PLUGIN_INSTALLATION_FAILED=Web runtime initialization is failed(plugins installation).
+
+ERROR_UNKNOWN=\nUnknown error\n\nSee the error log for more details.
private String parseErrorMessage( ) {
int startIdx = commandOutput.indexOf(ERROR_MESSAGE_TEMPLATE);
- int endIdx = commandOutput.indexOf("\n", startIdx);
+ int endIdx = commandOutput.indexOf(System.getProperty("line.separator"), startIdx);
if ( startIdx == -1 || endIdx == -1) {
return "";
}
else {
- return commandOutput.substring(startIdx, endIdx);
+ return commandOutput.substring(startIdx + ERROR_MESSAGE_TEMPLATE.length(), endIdx);
}
}
CERTIFICATE_CHAIN_VERIFICATION_FAILED(33, PkgcmdErrorMessages.ERROR_CERTIFICATE_CHAIN_VERIFICATION_FAILED),
CERTIFICATE_EXPIRED(34, PkgcmdErrorMessages.ERROR_CERTIFICATE_EXPIRED),
INVALID_PRIVILEGE(41, PkgcmdErrorMessages.ERROR_INVALID_PRIVILEGE),
+ PRIVILEGE_LEVEL_VIOLATION(42, PkgcmdErrorMessages.ERROR_PRIVILEGE_LEVEL_VIOLATION),
MENU_ICON_NOT_FOUND(51, PkgcmdErrorMessages.ERROR_MENU_ICON_NOT_FOUND),
FATAL_ERROR(61, PkgcmdErrorMessages.ERROR_FATAL_ERROR),
OUT_OF_STORAGE(62, PkgcmdErrorMessages.ERROR_OUT_OF_STORAGE),
OUT_OF_MEMORY(63, PkgcmdErrorMessages.ERROR_OUT_OF_MEMORY),
+ ARGUMENT_INVALID(64, PkgcmdErrorMessages.ERROR_ARGUMENT_INVALID),
//web app error messages.
WEB_PACKAGE_ALREADY_INSTALLED(121, PkgcmdErrorMessages.ERROR_WEB_PACKAGE_ALREADY_INSTALLED),
console.println(line);
}
commandOutput.append(line);
- commandOutput.append(File.separatorChar);
+ commandOutput.append(System.getProperty("line.separator"));
}
endLine = lines[lines.length - 1];
}
}
commandOutput.append(line);
- commandOutput.append(File.separatorChar);
+ commandOutput.append(System.getProperty("line.separator"));
}
endLine = lines[lines.length - 1];
}