org.tizen.common.file.filter,
org.tizen.common.rds,
org.tizen.common.rds.ui.preference,
+ org.tizen.common.sdb.command,
+ org.tizen.common.sdb.command.message,
org.tizen.common.ui,
org.tizen.common.ui.dialog,
org.tizen.common.ui.page.preference,
import org.eclipse.osgi.util.NLS;
import org.tizen.common.CommonPlugin;
import org.tizen.common.TizenPlatformConstants;
+import org.tizen.common.sdb.command.SdbCommand;
+import org.tizen.common.sdb.command.message.PkgcmdErrorType;
import org.tizen.common.ui.view.console.ConsoleManager;
import org.tizen.common.util.ISdbCommandHelper;
import org.tizen.common.util.StringUtil;
}
protected void postInstall() throws CoreException {
- String installCommand = String.format(TizenPlatformConstants.PKG_TOOL_INSTALL_COMMAND, pkgType.toLowerCase(), strAppInstallPath) + TizenPlatformConstants.CMD_SUFFIX;
+ SdbCommand sdbCommand = new SdbCommand(device, console);
try {
- tizenCommand.runCommand(installCommand, true, TizenPlatformConstants.CMD_SUCCESS);
+ String installCommand = String.format(TizenPlatformConstants.PKG_TOOL_INSTALL_COMMAND, pkgType.toLowerCase(), strAppInstallPath);
+ sdbCommand.runCommand(installCommand, new PkgcmdErrorType());
} catch (Exception e) {
newCoreException(RdsDeployer.makeRdsLog(RdsMessages.CANNOT_INSTALL), e);
}
--- /dev/null
+/*
+* Common
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* Kangho Kim <kh5325.kim@samsung.com>
+* Gun Kim <gune.kim@samsung.com>
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* Contributors:
+* - S-Core Co., Ltd
+*
+*/
+
+package org.tizen.common.sdb.command;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.tizen.common.TizenPlatformConstants;
+import org.tizen.common.sdb.command.message.CommandErrorException;
+import org.tizen.common.sdb.command.message.CommandErrorType;
+import org.tizen.common.ui.view.console.ConsoleManager;
+import org.tizen.common.util.StringUtil;
+import org.tizen.sdblib.IDevice;
+import org.tizen.sdblib.MultiLineReceiver;
+import org.tizen.sdblib.SdbCommandRejectedException;
+import org.tizen.sdblib.ShellCommandUnresponsiveException;
+import org.tizen.sdblib.TimeoutException;
+
+
+public class SdbCommand {
+ public static final int DEFAULT_TIMEOUT = 60000;
+ private IDevice device = null;
+ private ConsoleManager console = null;
+ private String endLine = "";
+ private String commandOutput = "";
+
+ public SdbCommand(IDevice device) {
+ this(device, null);
+ }
+
+ public SdbCommand(IDevice device, ConsoleManager console) {
+ this.device = device;
+ this.console = console;
+ }
+
+ public void runCommand(String command ) throws Exception {
+ if (console != null) {
+ console.println("$ " + command);
+ }
+
+ CommandOuputReceiver receiver = new CommandOuputReceiver();
+
+ device.executeShellCommand(command, receiver);
+
+ this.endLine = receiver.getEndLine();
+ this.commandOutput = receiver.getCommandOutput();
+ }
+
+ 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);
+ }
+
+ CommandOuputReceiver receiver = new CommandOuputReceiver();
+ device.executeShellCommand( makeCommandWithExitcode(command), receiver, timeout);
+
+ 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;
+ }
+
+ private int parseExitcode(String line) {
+ int exitcode = -1;
+ if ( line.startsWith(TizenPlatformConstants.CMD_RESULT_PREFIX) ) {
+ exitcode = Integer.parseInt( StringUtil.getOnlyNumerics(line));
+ }
+ return exitcode;
+ }
+
+ private String makeCommandWithExitcode(String command) {
+ return command + TizenPlatformConstants.CMD_SUFFIX;
+ }
+
+ private final class CommandOuputReceiver extends MultiLineReceiver {
+ private StringBuilder commandOutput = new StringBuilder(256);
+ private String endLine = null;
+
+ public CommandOuputReceiver() {
+ super();
+ setTrimLine(false);
+ }
+
+ @Override
+ public void processNewLines(String[] lines) {
+ for( String line: lines ) {
+ if (console != null) {
+ console.println(line);
+ }
+ commandOutput.append(line);
+ commandOutput.append(File.separatorChar);
+ }
+ endLine = lines[lines.length - 1];
+ }
+
+ public String getCommandOutput() {
+ return commandOutput.toString();
+ }
+
+ public String getEndLine() {
+ return endLine;
+ }
+ }
+}
--- /dev/null
+/*
+* Common
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* Kangho Kim <kh5325.kim@samsung.com>
+* Gun Kim <gune.kim@samsung.com>
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* Contributors:
+* - S-Core Co., Ltd
+*
+*/
+
+package org.tizen.common.sdb.command.message;
+
+public class CommandErrorException extends Exception{
+
+ private static final long serialVersionUID = 1L;
+
+
+ public CommandErrorException() {
+ super();
+ }
+
+ public CommandErrorException(String msg) {
+ super(msg);
+ }
+
+ public CommandErrorException(String msg, Throwable t) {
+ super(msg, t);
+ }
+
+ public CommandErrorException(Throwable t) {
+ super(t);
+ }
+}
--- /dev/null
+/*
+* Common
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* Kangho Kim <kh5325.kim@samsung.com>
+* Gun Kim <gune.kim@samsung.com>
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* Contributors:
+* - S-Core Co., Ltd
+*
+*/
+
+package org.tizen.common.sdb.command.message;
+
+public interface CommandErrorType {
+ public boolean findErrorType(int exitCode, String command);
+ public String getMessage();
+ public int getExitCode();
+ public void setCommand(String command);
+ public void setCommandOutput(String commandOutput);
+ public void makeException() throws CommandErrorException;
+}
--- /dev/null
+/*
+* Common
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* Kangho Kim <kh5325.kim@samsung.com>
+* Gun Kim <gune.kim@samsung.com>
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* Contributors:
+* - S-Core Co., Ltd
+*
+*/
+
+package org.tizen.common.sdb.command.message;
+
+import org.eclipse.osgi.util.NLS;
+
+public class PkgcmdErrorMessages {
+ static {
+ NLS.initializeMessages(PkgcmdErrorMessages.class.getName(), PkgcmdErrorMessages.class);
+ }
+
+
+ public static String MESSAGE_FORMAT;
+ public static String ERROR_PACKAGE_NOT_FOUND;
+ public static String ERROR_PACKAGE_INVALID;
+ public static String ERROR_PACKAGE_LOWER_VARSION;
+ public static String ERROR_PACKAGE_EXECUTABLE_NOT_FOUND;
+ public static String ERROR_MANIFEST_NOT_FOUND;
+ public static String ERROR_MANIFEST_INVALID;
+ public static String ERROR_CONFIG_NOT_FOUND;
+ public static String ERROR_CONFIG_INVALID;
+ public static String ERROR_SIGNATURE_NOT_FOUND;
+ public static String ERROR_SIGNATURE_INVALID;
+ public static String ERROR_SIGNATURE_VERIFICATION_FAILED;
+ public static String ERROR_ROOT_CERTIFICATE_NOT_FOUND;
+ public static String ERROR_CERTIFICATE_INVALID;
+ public static String ERROR_CERTIFICATE_CHAIN_VERIFICATION_FAILED;
+ public static String ERROR_CERTIFICATE_EXPIRED;
+ public static String ERROR_INVALID_PRIVILEGE;
+ 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;
+
+}
--- /dev/null
+MESSAGE_FORMAT=\nError code: %s\nError message: %s\nCommand: %s\nManagement: %s\n
+
+ERROR_PACKAGE_NOT_FOUND=Check package components in Project Explorer.
+ERROR_PACKAGE_INVALID=Check package components in Project Explorer.
+ERROR_PACKAGE_LOWER_VARSION=RDS does not support installation for the lower version. If you want to install the lower version, please turn off RDS.
+ERROR_PACKAGE_EXECUTABLE_NOT_FOUND=Check "Right Click" in Project Explorer > Build Configurations.
+ERROR_MANIFEST_NOT_FOUND=Check manifest.xml in Project Explorer.
+ERROR_MANIFEST_INVALID=Check manifest.xml in manifest editor.
+ERROR_CONFIG_NOT_FOUND=Check config.xml in Project Explorer.
+ERROR_CONFIG_INVALID=Check manifest.xml in config editor.
+ERROR_SIGNATURE_NOT_FOUND=Check author certificates in Preferences > Tizen SDK > Secure Profiles > Profile items.
+ERROR_SIGNATURE_INVALID=Check author certificates in Preferences > Tizen SDK > Secure Profiles > Profile items.
+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_EXPIRED=Check the system time in device or emulator.
+ERROR_INVALID_PRIVILEGE=Check privilege strings in manifest editor > Privileges > Privileges.
+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=Unknown error
\ No newline at end of file
--- /dev/null
+/*
+* Common
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* Kangho Kim <kh5325.kim@samsung.com>
+* Gun Kim <gune.kim@samsung.com>
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* Contributors:
+* - S-Core Co., Ltd
+*
+*/
+
+package org.tizen.common.sdb.command.message;
+
+import org.tizen.common.util.StringUtil;
+
+public class PkgcmdErrorType implements CommandErrorType {
+ private final static String ERROR_MESSAGE_TEMPLATE = "error message: ";
+
+ private ErrorMessageType errorType;
+ private String errorMessage = "";
+ private String command;
+ private String commandOutput;
+
+ @Override
+ public boolean findErrorType(int exitCode, String command) {
+ errorType = ErrorMessageType.getErrorType(exitCode);
+
+ if ( errorType == null ) {
+ return false;
+ }
+ else {
+ this.command = command;
+ return true;
+ }
+ }
+
+ @Override
+ public String getMessage() {
+ if (errorType == null ) {
+ return null;
+ }
+ else {
+ return String.format(PkgcmdErrorMessages.MESSAGE_FORMAT, errorType.name(), errorMessage, command, errorType.getManagement() );
+ }
+ }
+
+ @Override
+ public int getExitCode() {
+ if (errorType == null ) {
+ return -1;
+ }
+ return errorType.getExitCode();
+ }
+
+ @Override
+ public void setCommand(String command) {
+ this.command = command;
+ }
+
+ @Override
+ public void setCommandOutput(String commandOutput) {
+ this.commandOutput = commandOutput;
+ if ( this.commandOutput == null ) {
+ this.errorMessage = "";
+ }
+ else {
+ this.errorMessage = parseErrorMessage();
+ }
+ }
+
+ @Override
+ public void makeException() throws CommandErrorException{
+ if (errorType == null ) {
+ throw new CommandErrorException(PkgcmdErrorMessages.ERROR_UNKNOWN);
+ }
+ else if (ErrorMessageType.SUCCESS.equals(errorType)) {
+
+ }
+ else {
+ throw new CommandErrorException(getMessage());
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getMessage();
+ }
+
+ private String parseErrorMessage( ) {
+ int startIdx = commandOutput.indexOf(ERROR_MESSAGE_TEMPLATE);
+ int endIdx = commandOutput.indexOf("\n", startIdx);
+
+ if ( startIdx == -1 || endIdx == -1) {
+ return null;
+ }
+ else {
+ return commandOutput.substring(startIdx, endIdx);
+ }
+ }
+
+ enum ErrorMessageType {
+ SUCCESS(0, null),
+ PACKAGE_NOT_FOUND(1, PkgcmdErrorMessages.ERROR_PACKAGE_NOT_FOUND),
+ PACKAGE_INVALID(2, PkgcmdErrorMessages.ERROR_PACKAGE_INVALID),
+ PACKAGE_LOWER_VERSION(3, PkgcmdErrorMessages.ERROR_PACKAGE_LOWER_VARSION),
+ PACKAGE_EXECUTABLE_NOT_FOUND(4, PkgcmdErrorMessages.ERROR_PACKAGE_EXECUTABLE_NOT_FOUND),
+ MANIFEST_NOT_FOUND(11, PkgcmdErrorMessages.ERROR_MANIFEST_NOT_FOUND),
+ MANIFEST_INVALID(12, PkgcmdErrorMessages.ERROR_MANIFEST_INVALID),
+ CONFIG_NOT_FOUND(13, PkgcmdErrorMessages.ERROR_CONFIG_NOT_FOUND),
+ CONFIG_INVALID(14, PkgcmdErrorMessages.ERROR_CONFIG_INVALID),
+ SIGNATURE_NOT_FOUND(21, PkgcmdErrorMessages.ERROR_SIGNATURE_NOT_FOUND),
+ SIGNATURE_INVALID(22, PkgcmdErrorMessages.ERROR_SIGNATURE_INVALID),
+ SIGNATURE_VERIFICATION_FAILED(23, PkgcmdErrorMessages.ERROR_SIGNATURE_VERIFICATION_FAILED),
+ ROOT_CERTIFICATE_NOT_FOUND(31, PkgcmdErrorMessages.ERROR_ROOT_CERTIFICATE_NOT_FOUND),
+ CERTIFICATE_INVALID(32, PkgcmdErrorMessages.ERROR_CERTIFICATE_INVALID),
+ 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),
+ 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);
+
+ private int exitCode;
+ private String management;
+
+ private ErrorMessageType(int exitCode, String management) {
+ this.exitCode = exitCode;
+ this.management = management;
+ }
+
+ public String getManagement() {
+ return management;
+ }
+
+ public String toString() {
+ return name();
+ }
+
+ public int getExitCode() {
+ return exitCode;
+ }
+
+ public static ErrorMessageType getErrorType(int exitCode) {
+ for ( ErrorMessageType message : ErrorMessageType.values() ) {
+ if ( message.getExitCode() == exitCode ) {
+ return message;
+ }
+ }
+ // unknown exitcode
+ return null;
+ }
+ }
+}
\ No newline at end of file