import org.slf4j.LoggerFactory;
import org.tizen.common.TizenPlatformConstants;
import org.tizen.common.core.application.InstallPathConfig;
+import org.tizen.common.core.application.ProfileInfo;
import org.tizen.common.util.DialogUtil;
import org.tizen.common.util.FileUtil;
import org.tizen.common.util.IOUtil;
IExtensionRegistry x = RegistryFactory.getRegistry();
IConfigurationElement[] ces = x.getConfigurationElementsFor(ID_DEBUGTOOLS_EXTENSION);
+ ProfileInfo profileInfoForODI = InstallPathConfig.getProfileInfo(device);
try {
for ( IConfigurationElement ce : ces ) {
if (ce.getName().equals("tools")) {
verbose("a extension ('" + packagename + "') is loaded." );
String description = ce.getAttribute("description");
DebugTool dt = null;
- dt = makeDebugTool(InstallPathConfig.getCommonPlatformPath(), sourcepath, packagename, description);
- if ( dt == null ) {
- dt = makeDebugTool(InstallPathConfig.getPlatformVersionPath(), sourcepath, packagename, description);
+
+ // First, finds a tool for ODI by using platformInfoForODI.
+ // If cannot find the tool, finds the tool from common platform directory.
+ if ( profileInfoForODI != null ) {
+ dt = makeDebugTool(profileInfoForODI.getLatestPlatformPath(), sourcepath, packagename, description);
}
if ( dt != null ) {
toolLists.add(dt);
}
+ else {
+ dt = makeDebugTool(InstallPathConfig.getCommonPlatformPath(), sourcepath, packagename, description);
+ if ( dt != null ) {
+ toolLists.add(dt);
+ }
+ }
}
}
} catch (Throwable e) {
import java.util.Map;
import java.util.Properties;
import java.util.Scanner;
+import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tizen.common.util.HostUtil;
import org.tizen.common.util.OSChecker;
import org.tizen.common.util.StringUtil;
+import org.tizen.sdblib.IDevice;
import org.tizen.sdblib.util.IOUtil;
private static final String DIR_SDK_DATA = "tizen-sdk-data";
private static final String DIR_CHECKER = "checker";
private static final String DIR_DOCUMENTS = "documents";
- // PLATFORM directory format: <platform><majorNumber>.<minorNumber>
- private static final String REG_PROFILE = "[a-zA-Z]+";
+ // PLATFORM directory format: <platform>-<majorNumber>.<minorNumber>
+ private static final String REG_PROFILE = "[a-zA-Z\\-]+";
private static final String REG_VERSION = "(((\\d)|([1-9]\\d{2,}))\\.)((\\d)|([1-9]\\d{2,}))";
private static final String PLATFORM_SEPARATOR = "-";
private static final String REG_DIR_PLATFORM = REG_PROFILE + PLATFORM_SEPARATOR + REG_VERSION;
* Returns version of given {@code platform} or null.
*/
public static String getVersion(String platform) {
- if ( platform.matches(REG_DIR_PLATFORM) ) {
- return platform.replaceFirst(REG_PROFILE + PLATFORM_SEPARATOR, "");
- }
- else {
- return null;
+ String[] platformSplit = platform.split(PLATFORM_SEPARATOR);
+ if ( platformSplit.length > 1 ) {
+ if ( platformSplit[platformSplit.length-1].matches(REG_VERSION) ) {
+ return platformSplit[platformSplit.length-1];
+ }
}
+
+ return null;
}
/**
* Returns profile of given {@code platform} or null.
*/
public static String getProfile(String platform) {
- if ( platform.matches(REG_DIR_PLATFORM) ) {
- return platform.replaceAll( PLATFORM_SEPARATOR + REG_VERSION, "");
+ int index = platform.lastIndexOf(PLATFORM_SEPARATOR);
+ // platform must contain a version
+ // So, "mobile" is not supported
+ if ( index <= 0 ) {
+ return null;
}
- else {
+ String profile = platform.substring(0, index);
+
+ if ( InstallPathConfig.getVersion(platform) == null ) {
return null;
}
+
+ if ( profile.matches(REG_PROFILE) ) {
+ return profile;
+ }
+
+ return null;
}
/**
return path + File.separator + DIR_SAMPLES;
}
}
+
+ /**
+ * This method returns one of installed profileInfos which matches platformInfo of {@code device}.<br>
+ * If the device's platform information doesn't match installed profiles,<br>
+ * returns one of installed profileInfos that is lower than the device's platform version and version of the most contiguous with platform version.<br>
+ * Nevertheless, if the platformInfo cannot be found,<br>
+ * returns platformInfo that is the highest version in installed profileInfos.<br>
+ *
+ * Otherwise, returns null.
+ */
+ public static ProfileInfo getProfileInfo(IDevice device) {
+ ProfileInfo devicePlatformInfo = ProfileInfo.getProfileInfo(device);
+ if ( devicePlatformInfo == null ) {
+ return null;
+ }
+
+ String deviceProfile = devicePlatformInfo.getProfile();
+ String deviceVersion = devicePlatformInfo.getLatestPlatformVersion();
+ double intDeviceVersion = Double.parseDouble(deviceVersion);
+ double tempVersion = -1;
+ double validVersion = -1;
+ double highestVersion = -1;
+ String validPath = "";
+ String highestPath = "";
+
+ List<ProfileInfo> profileInfoList = InstallPathConfig.getProfileInfos();
+ for ( ProfileInfo profileInfo : profileInfoList ) {
+ if ( deviceProfile.equals(profileInfo.getProfile()) ) {
+ Set<String> versionSet = profileInfo.getVersions();
+ for ( String version : versionSet ) {
+ if ( deviceVersion.equals(version) ) {
+ return devicePlatformInfo;
+ }
+ else {
+ tempVersion = Double.parseDouble(version);
+ if ( intDeviceVersion > tempVersion && validVersion < tempVersion ){
+ validVersion = tempVersion;
+ validPath = profileInfo.getPlatformPath(version);
+ }
+
+ if ( highestVersion < tempVersion ) {
+ highestVersion = tempVersion;
+ highestPath = profileInfo.getPlatformPath(version);
+ }
+ }
+ }
+ // If the device's platform information doesn't match host's profiles,
+ // returns profileInfo that is lower than the device's platform version and version of the most contiguous with platform version
+ if ( validVersion != -1 ) {
+ return new ProfileInfo(deviceProfile, String.valueOf(validVersion), validPath);
+ }
+ else {
+ return new ProfileInfo(deviceProfile, String.valueOf(highestVersion), highestPath);
+ }
+ }
+ }
+
+ return null;
+ }
public static String getLibraryPath() {
return getSDKPath() + File.separator + DIR_LIBRARY;
import java.util.Map;
import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.tizen.sdblib.IDevice;
+import org.tizen.sdblib.PlatformInfo;
+
/**
* This class represents information of the platform path.
*
* @author Gun Kim<gune.kim@samsung.com>
*/
public class ProfileInfo {
+ private static final Logger logger = LoggerFactory.getLogger(ProfileInfo.class);
private String profile;
// the versions's key means a profile's version,
// and its value means path that the version's profile is installed under the path.
public String toString() {
return "ProfileInfo [profile=" + profile + ", versions=" + versions +"]";
}
+
+
+ /**
+ * Returns a platform name of the {@code device}.
+ */
+ public static String getPlatformName(IDevice device) {
+ try {
+ return getProfileInfo(device).getLatestPlatformName();
+ } catch (Exception e) {
+ logger.error("cannot get device information - " + device, e);
+ return "";
+ }
+ }
+
+ // TODO: The profile format may be changed by platform's policy.
+ // If it is changed, this code must change.
+ /**
+ * Returns a platform information of the {@link IDevice}.
+ */
+ public static ProfileInfo getProfileInfo(IDevice device) {
+ try {
+ PlatformInfo platformInfo = device.getPlatformInfo();
+ String versionSplit[] = platformInfo.getPlatformVersion().split("\\.");
+ String major = versionSplit[0];
+ String minor = versionSplit[1];
+ String path = null;
+
+ String version = major + "." + minor;
+ String profile = platformInfo.getProfileName().split("-")[0];
+
+ ProfileInfo profileInfo = InstallPathConfig.getProfileInfo(profile);
+ if ( profileInfo != null ) {
+ path = profileInfo.getPlatformPath(version);
+ }
+
+ return new ProfileInfo(profile, version, path);
+ } catch (Exception e) {
+ logger.error("cannot get device information - " + device, e);
+ return null;
+ }
+ }
}