import org.tizen.emulator.skin.config.EmulatorConfig;
import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
import org.tizen.emulator.skin.config.EmulatorConfig.ConfigPropertiesConstants;
+import org.tizen.emulator.skin.config.EmulatorConfig.SkinInfoConstants;
import org.tizen.emulator.skin.config.EmulatorConfig.SkinPropertiesConstants;
import org.tizen.emulator.skin.dbi.EmulatorUI;
import org.tizen.emulator.skin.exception.JaxbException;
*
*/
public class EmulatorSkinMain {
-
+ public static final String SKIN_INFO_FILE_NAME = "info.ini";
public static final String SKIN_PROPERTIES_FILE_NAME = ".skin.properties";
public static final String CONFIG_PROPERTIES_FILE_NAME = ".skinconfig.properties";
public static final String DBI_FILE_NAME = "default.dbi";
try {
+ /* get vm path from startup argument */
String vmPath = getVmPath( args );
if ( StringUtil.isEmpty( vmPath ) ) {
throw new IllegalArgumentException( ArgsConstants.VM_PATH + " in arguments is null." );
logger.info( "!!! Start Emualtor Skin !!!" );
/* startup arguments parsing */
- Map<String, String> argsMap = parsArgs( args );
+ Map<String, String> argsMap = parsArgs(args);
+
+ /* emulator resolution */
+ int resolutionW = Integer.parseInt(
+ argsMap.get(ArgsConstants.RESOLUTION_WIDTH));
+ int resolutionH = Integer.parseInt(
+ argsMap.get(ArgsConstants.RESOLUTION_HEIGHT));
+
+ /* get skin path from startup argument */
+ String skinPath = ImageRegistry.getSkinPath(
+ (String) argsMap.get(ArgsConstants.SKIN_PATH), resolutionW, resolutionH);
+
+ /* set skin information */
+ String skinInfoFilePath = skinPath + File.separator + SKIN_INFO_FILE_NAME;
+ Properties skinInfo = loadProperties(skinInfoFilePath, false);
+ if (null == skinInfo) {
+ logger.severe("Fail to load skin information file.");
+
+ Shell temp = new Shell(Display.getDefault());
+ MessageBox messageBox = new MessageBox( temp, SWT.ICON_ERROR );
+ messageBox.setText("Emulator");
+ messageBox.setMessage("Fail to load \"" + SKIN_INFO_FILE_NAME + "\" file\n" +
+ "Check if the file is corrupted or missing from the following path.\n" +
+ skinPath);
+ messageBox.open();
+ temp.dispose();
+
+ System.exit(-1);
+ } else {
+ logger.info("skin info:" + skinInfo);
+ }
+
+ SkinMode skinMode = SkinMode.STANDARD;
+ if (skinInfo.getProperty(SkinInfoConstants.RESOLUTION_WIDTH).equalsIgnoreCase("all") ||
+ skinInfo.getProperty(SkinInfoConstants.RESOLUTION_HEIGHT).equalsIgnoreCase("all")) {
+ skinMode = SkinMode.GENERAL;
+ }
/* set emulator window skin property */
String skinPropFilePath = vmPath + File.separator + SKIN_PROPERTIES_FILE_NAME;
EmulatorConfig.validateSkinProperties(skinProperties);
EmulatorConfig.validateSkinConfigProperties(configProperties);
- /* emulator resolution */
- int resolutionW = Integer.parseInt(
- argsMap.get(ArgsConstants.RESOLUTION_WIDTH));
- int resolutionH = Integer.parseInt(
- argsMap.get(ArgsConstants.RESOLUTION_HEIGHT));
-
- /* get skin path from startup argument */
- String argSkinPath = (String) argsMap.get(ArgsConstants.SKIN_PATH);
-
- /* determine skin mode */
- SkinMode skinMode = SkinMode.getValue(argsMap.get(ArgsConstants.SKIN_MODE));
- logger.info("skin mode is " + skinMode);
-
/* load dbi file */
- EmulatorUI dbiContents = loadDbi(argSkinPath, skinMode, resolutionW, resolutionH);
+ EmulatorUI dbiContents = loadDbi(skinPath);
if ( null == dbiContents ) {
logger.severe( "Fail to load dbi file." );
- Shell temp = new Shell( Display.getDefault());
+ Shell temp = new Shell(Display.getDefault());
MessageBox messageBox = new MessageBox( temp, SWT.ICON_ERROR );
messageBox.setText( "Emulator" );
messageBox.setMessage( "Fail to load \"" + DBI_FILE_NAME + "\" file\n" +
"Check if the file is corrupted or missing from the following path.\n" +
- argSkinPath );
+ skinPath);
messageBox.open();
temp.dispose();
}
- private static EmulatorUI loadDbi(String argSkinPath, SkinMode skinMode,
- int resolutionW, int resolutionH) {
- String skinPath =
- ImageRegistry.getSkinPath(argSkinPath, skinMode, resolutionW, resolutionH) +
- File.separator + DBI_FILE_NAME;
- logger.info("load dbi file from " + skinPath);
+ private static EmulatorUI loadDbi(String skinPath) {
+ String dbiPath = skinPath + File.separator + DBI_FILE_NAME;
+ logger.info("load dbi file from " + dbiPath);
FileInputStream fis = null;
EmulatorUI emulatorUI = null;
try {
- fis = new FileInputStream( skinPath );
+ fis = new FileInputStream(dbiPath);
logger.info( "============ dbi contents ============" );
byte[] bytes = IOUtil.getBytes( fis );
logger.info( new String( bytes, "UTF-8" ) );
private Logger logger = SkinLogger.getSkinLogger( ImageRegistry.class ).getLogger();
- public static final String SKIN_FOLDER = "skins";
- public static final String IMAGE_FOLDER_PREFIX = "emul-";
+ public static final String SKINS_FOLDER = "skins";
+ public static final String GENERAL_FOLDER = "emul-general";
public static final String ICON_FOLDER = "icons";
public enum ImageType {
}
- public static String getSkinPath(String argSkinPath, SkinMode skinMode,
+ public static String getSkinPath(String argSkinPath,
int resolutionX, int resolutionY) {
/* When emulator has a invalid skin path,
emulator uses default skin path instead of it */
- String defaultSkinPath =
- ".." + File.separator + SKIN_FOLDER + File.separator +
- ((skinMode == SkinMode.GENERAL) ?
- "emul-general" :
- IMAGE_FOLDER_PREFIX + resolutionX + "x" + resolutionY);
+ String defaultSkinPath = ".." + //TODO:
+ File.separator + SKINS_FOLDER + File.separator + GENERAL_FOLDER;
if (argSkinPath == null) {
return defaultSkinPath;
return null;
}
- String skinPath = getSkinPath(argSkinPath, null, resolutionWidth, resolutionHeight);
+ String skinPath = getSkinPath(argSkinPath, resolutionWidth, resolutionHeight);
logger.info("get image data of skin from " + skinPath);
RotationType targetRotation = SkinRotation.getRotation( id );