From 59e8e1969c6543cc9375b1a4372ef2e3e8afa183 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Thu, 10 Feb 2011 17:40:04 +0100 Subject: Add hw.keyboard.lid This is used to control the lid switch virtual device. + Add support for a "version " field to the skin format. This will later be used for skin format #3. + Fix a bug where string hw properties didn't work/compile Change-Id: I678a0988d2cd24169dd0c2ece96e7ab0b2822104 --- android/avd/hardware-properties.ini | 10 ++++++++++ android/avd/hw-config-defs.h | 7 +++++++ android/avd/info.c | 8 ++++---- android/skin/file.c | 20 ++++++++++++++++---- android/skin/file.h | 1 + android/utils/ini.c | 9 ++++++--- android/utils/ini.h | 9 +++------ 7 files changed, 47 insertions(+), 17 deletions(-) (limited to 'android') diff --git a/android/avd/hardware-properties.ini b/android/avd/hardware-properties.ini index a936603..89acf9f 100644 --- a/android/avd/hardware-properties.ini +++ b/android/avd/hardware-properties.ini @@ -53,6 +53,16 @@ default = yes abstract = Keyboard support description = Whether the device has a QWERTY keyboard. +# Keyboard lid support +# (I.e. can the qwerty keyboard be closed/hidden or opened/visible) +# this will be ignored if hw.keyboard is false +# +name = hw.keyboard.lid +type = boolean +default = yes +abstract = Keyboard lid support +description = Whether the QWERTY keyboard can be opened/closed. + # DPad keys name = hw.dPad type = boolean diff --git a/android/avd/hw-config-defs.h b/android/avd/hw-config-defs.h index 5f97a25..4afc4d7 100644 --- a/android/avd/hw-config-defs.h +++ b/android/avd/hw-config-defs.h @@ -46,6 +46,13 @@ HWCFG_BOOL( "Whether the device has a QWERTY keyboard.") HWCFG_BOOL( + hw_keyboard_lid, + "hw.keyboard.lid", + "yes", + "Keyboard lid support", + "Whether the QWERTY keyboard can be opened/closed.") + +HWCFG_BOOL( hw_dPad, "hw.dPad", "yes", diff --git a/android/avd/info.c b/android/avd/info.c index 7aa3b22..e3d38bb 100644 --- a/android/avd/info.c +++ b/android/avd/info.c @@ -268,7 +268,7 @@ _getSearchPaths( AvdInfo* i ) if (p >= end) continue; - path = iniFile_getString( i->configIni, temp ); + path = iniFile_getString( i->configIni, temp, NULL ); if (path != NULL) { DD(" found image search path: %s", path); if (!path_is_absolute(path)) { @@ -331,7 +331,7 @@ _getRootIni( AvdInfo* i ) static int _getContentPath( AvdInfo* i ) { - i->contentPath = iniFile_getString(i->rootIni, ROOT_PATH_KEY); + i->contentPath = iniFile_getString(i->rootIni, ROOT_PATH_KEY, NULL); if (i->contentPath == NULL) { derror("bad config: %s", @@ -986,7 +986,7 @@ _getSkin( AvdInfo* i, AvdInfoParams* params ) if (params->skinName) { skinName = ASTRDUP(params->skinName); } else { - skinName = iniFile_getString( i->configIni, SKIN_PATH ); + skinName = iniFile_getString( i->configIni, SKIN_PATH, NULL ); explicitSkin = 0; } @@ -1089,7 +1089,7 @@ _getSDCardPath( AvdInfo* i, AvdInfoParams* params ) if (params->forcePaths[AVD_IMAGE_SDCARD] != NULL) return; - path = iniFile_getString(i->configIni, SDCARD_PATH); + path = iniFile_getString(i->configIni, SDCARD_PATH, NULL); if (path == NULL) return; diff --git a/android/skin/file.c b/android/skin/file.c index 5947ad9..dddc279 100644 --- a/android/skin/file.c +++ b/android/skin/file.c @@ -609,6 +609,7 @@ skin_file_load_from_v1( SkinFile* file, AConfig* aconfig, const char* basepat *ptail = layout; ptail = &layout->next; } + file->version = 1; return 0; } @@ -662,6 +663,7 @@ skin_file_load_from_v2( SkinFile* file, AConfig* aconfig, const char* basepat if (file->layouts == NULL) return -1; + file->version = 2; return 0; } @@ -671,19 +673,29 @@ skin_file_create_from_aconfig( AConfig* aconfig, const char* basepath ) SkinFile* file; ANEW0(file); + if ( aconfig_find(aconfig, "parts") != NULL) { if (skin_file_load_from_v2( file, aconfig, basepath ) < 0) { - skin_file_free( file ); - file = NULL; + goto BAD_FILE; + } + file->version = aconfig_int(aconfig, "version", 2); + /* The file version must be 1 or higher */ + if (file->version <= 0) { + dprint( "## WARNING: invalid skin version: %d", file->version); + goto BAD_FILE; } } else { if (skin_file_load_from_v1( file, aconfig, basepath ) < 0) { - skin_file_free( file ); - file = NULL; + goto BAD_FILE; } + file->version = 1; } return file; + +BAD_FILE: + skin_file_free( file ); + return NULL; } void diff --git a/android/skin/file.h b/android/skin/file.h index 4e3a8fc..21922e6 100644 --- a/android/skin/file.h +++ b/android/skin/file.h @@ -99,6 +99,7 @@ extern SkinDisplay* skin_layout_get_display( SkinLayout* layout ); extern SkinRotation skin_layout_get_dpad_rotation( SkinLayout* layout ); typedef struct SkinFile { + int version; /* 1, 2 or 3 */ SkinPart* parts; SkinLayout* layouts; int num_parts; diff --git a/android/utils/ini.c b/android/utils/ini.c index 1a1449c..a5914dd 100644 --- a/android/utils/ini.c +++ b/android/utils/ini.c @@ -326,12 +326,15 @@ iniFile_saveToFile( IniFile* f, const char* filepath ) } char* -iniFile_getString( IniFile* f, const char* key ) +iniFile_getString( IniFile* f, const char* key, const char* defaultValue ) { const char* val = iniFile_getValue(f, key); - if (!val) - return NULL; + if (!val) { + if (!defaultValue) + return NULL; + val= defaultValue; + } return ASTRDUP(val); } diff --git a/android/utils/ini.h b/android/utils/ini.h index 77d760f..5730ee0 100644 --- a/android/utils/ini.h +++ b/android/utils/ini.h @@ -48,9 +48,10 @@ int iniFile_getPairCount( IniFile* f ); */ const char* iniFile_getValue( IniFile* f, const char* key ); -/* returns a copy of the value of a given key, or NULL +/* returns a copy of the value of a given key, or NULL if defaultValue is NULL. + * caller must free() it. */ -char* iniFile_getString( IniFile* f, const char* key ); +char* iniFile_getString( IniFile* f, const char* key, const char* defaultValue ); /* returns an integer value, or a default in case the value string is * missing or badly formatted @@ -67,10 +68,6 @@ int64_t iniFile_getInt64( IniFile* f, const char* key, int64_t defaultValue ) */ double iniFile_getDouble( IniFile* f, const char* key, double defaultValue ); -/* returns a copy of a given key's value, if any, or NULL if it is missing - * caller must call free() to release it */ -char* iniFile_getString( IniFile* f, const char* key ); - /* parses a key value as a boolean. Accepted values are "1", "0", "yes", "YES", * "no" and "NO". Returns either 1 or 0. * note that the default value must be provided as a string too -- cgit v1.1