aboutsummaryrefslogtreecommitdiffstats
path: root/android
diff options
context:
space:
mode:
Diffstat (limited to 'android')
-rw-r--r--android/avd/info.c45
-rw-r--r--android/avd/info.h7
-rw-r--r--android/main-common.c2
-rw-r--r--android/main.c50
4 files changed, 49 insertions, 55 deletions
diff --git a/android/avd/info.c b/android/avd/info.c
index fa32c24..aad316a 100644
--- a/android/avd/info.c
+++ b/android/avd/info.c
@@ -1130,8 +1130,6 @@ static int
_avdInfo_getImagePaths(AvdInfo* i, AvdInfoParams* params )
{
int wipeData = (params->flags & AVDINFO_WIPE_DATA) != 0;
- int wipeCache = (params->flags & AVDINFO_WIPE_CACHE) != 0;
- int noCache = (params->flags & AVDINFO_NO_CACHE) != 0;
int noSdCard = (params->flags & AVDINFO_NO_SDCARD) != 0;
int noSnapshots = (params->flags & AVDINFO_NO_SNAPSHOTS) != 0;
@@ -1186,24 +1184,6 @@ _avdInfo_getImagePaths(AvdInfo* i, AvdInfoParams* params )
imageLoader_lock( l, 0 );
}
- /* the cache partition: unless the user doesn't want one,
- * we're going to create it in the content directory
- */
- if (!noCache) {
- imageLoader_set (l, AVD_IMAGE_CACHE);
- imageLoader_load(l, IMAGE_OPTIONAL |
- IMAGE_EMPTY_IF_MISSING );
-
- if (wipeCache) {
- if (path_empty_file(l->pPath[0]) < 0) {
- derror("cannot wipe %s image at %s: %s",
- l->imageText, l->pPath[0],
- strerror(errno));
- exit(2);
- }
- }
- }
-
/* the SD Card image. unless the user doesn't want to, we're
* going to mount it if available. Note that if the image is
* already used, we must ignore it.
@@ -1314,7 +1294,6 @@ static int
_avdInfo_getBuildImagePaths( AvdInfo* i, AvdInfoParams* params )
{
int wipeData = (params->flags & AVDINFO_WIPE_DATA) != 0;
- int noCache = (params->flags & AVDINFO_NO_CACHE) != 0;
int noSdCard = (params->flags & AVDINFO_NO_SDCARD) != 0;
int noSnapshots = (params->flags & AVDINFO_NO_SNAPSHOTS) != 0;
@@ -1386,18 +1365,6 @@ _avdInfo_getBuildImagePaths( AvdInfo* i, AvdInfoParams* params )
/* force the system image to read-only status */
l->pState[0] = IMAGE_STATE_READONLY;
- /** cache partition handling
- **/
- if (!noCache) {
- imageLoader_set (l, AVD_IMAGE_CACHE);
-
- /* if the user provided one cache image, lock & use it */
- if ( params->forcePaths[l->id] != NULL ) {
- imageLoader_load(l, IMAGE_REQUIRED |
- IMAGE_IGNORE_IF_LOCKED);
- }
- }
-
/** SD Card image
**/
if (!noSdCard) {
@@ -1547,6 +1514,18 @@ avdInfo_getRamdiskPath( AvdInfo* i )
return _avdInfo_getContentOrSdkFilePath(i, imageName);
}
+char* avdInfo_getCachePath( AvdInfo* i )
+{
+ const char* imageName = _imageFileNames[ AVD_IMAGE_CACHE ];
+ return _avdInfo_getContentFilePath(i, imageName);
+}
+
+char* avdInfo_getDefaultCachePath( AvdInfo* i )
+{
+ const char* imageName = _imageFileNames[ AVD_IMAGE_CACHE ];
+ return _getFullFilePath(i->contentPath, imageName);
+}
+
char*
avdInfo_getSystemInitImagePath( AvdInfo* i )
{
diff --git a/android/avd/info.h b/android/avd/info.h
index d00e9c6..9410653 100644
--- a/android/avd/info.h
+++ b/android/avd/info.h
@@ -137,6 +137,13 @@ const char* avdInfo_getName( AvdInfo* i );
char* avdInfo_getKernelPath( AvdInfo* i );
char* avdInfo_getRamdiskPath( AvdInfo* i );
+/* This function returns NULL if the cache image file cannot be found.
+ * Use avdInfo_getDefaultCachePath() to retrieve the default path
+ * if you intend to create the partition file there.
+ */
+char* avdInfo_getCachePath( AvdInfo* i );
+char* avdInfo_getDefaultCachePath( AvdInfo* i );
+
char* avdInfo_getSystemInitImagePath( AvdInfo* i );
char* avdInfo_getDataInitImagePath( AvdInfo* i );
diff --git a/android/main-common.c b/android/main-common.c
index 24ad808..bcd5248 100644
--- a/android/main-common.c
+++ b/android/main-common.c
@@ -939,7 +939,6 @@ AvdInfo* createAVD(AndroidOptions* opts, int* inAndroidBuild)
*/
_forceAvdImagePath(AVD_IMAGE_INITSYSTEM, opts->system, "system", 1);
_forceAvdImagePath(AVD_IMAGE_USERDATA, opts->data, "user data", 0);
- _forceAvdImagePath(AVD_IMAGE_CACHE, opts->cache, "cache", 0);
_forceAvdImagePath(AVD_IMAGE_SDCARD, opts->sdcard, "SD Card", 0);
_forceAvdImagePath(AVD_IMAGE_SNAPSHOTS, opts->snapstorage, "snapshots", 0);
@@ -1050,7 +1049,6 @@ updateHwConfigFromAVD(AndroidHwConfig* hwConfig,
_update_hwconfig_path(&hwConfig->disk_systemPartition_path, avd, AVD_IMAGE_USERSYSTEM);
_update_hwconfig_path(&hwConfig->disk_dataPartition_path, avd, AVD_IMAGE_INITDATA);
_update_hwconfig_path(&hwConfig->disk_sdCard_path, avd, AVD_IMAGE_SDCARD);
- _update_hwconfig_path(&hwConfig->disk_cachePartition_path, avd, AVD_IMAGE_CACHE);
_update_hwconfig_path(&hwConfig->disk_snapshots_path, avd, AVD_IMAGE_SNAPSHOTS);
if (opts->partition_size) {
diff --git a/android/main.c b/android/main.c
index e8bdac9..dad5d69 100644
--- a/android/main.c
+++ b/android/main.c
@@ -121,7 +121,6 @@ int main(int argc, char **argv)
int radio_serial = 0;
int qemud_serial = 0;
int shell_serial = 0;
- unsigned cachePartitionSize = 0;
AndroidHwConfig* hw;
AvdInfo* avd;
@@ -447,30 +446,41 @@ int main(int argc, char **argv)
args[n++] = "-nand";
args[n++] = strdup(tmp);
- if (hw->disk_cachePartition) {
- // TODO: This should go to core
- opts->cache = (char*) avdInfo_getImageFile(avd, AVD_IMAGE_CACHE);
- cachePartitionSize = hw->disk_cachePartition_size;
+ /** CACHE PARTITION **/
+
+ if (opts->no_cache) {
+ /* No cache partition at all */
+ hw->disk_cachePartition = 0;
}
- else if (opts->cache) {
- dwarning( "Emulated hardware doesn't support a cache partition" );
- opts->cache = NULL;
- opts->no_cache = 1;
+ else if (!hw->disk_cachePartition) {
+ if (opts->cache) {
+ dwarning( "Emulated hardware doesn't support a cache partition. -cache option ignored!" );
+ opts->cache = NULL;
+ }
}
+ else
+ {
+ if (!opts->cache) {
+ /* Find the current cache partition file */
+ opts->cache = avdInfo_getCachePath(avd);
+ if (opts->cache == NULL) {
+ /* The file does not exists, we will force its creation
+ * if we are not in the Android build system. Otherwise,
+ * a temporary file will be used.
+ */
+ if (!avdInfo_inAndroidBuild(avd)) {
+ opts->cache = avdInfo_getDefaultCachePath(avd);
+ }
+ }
+ }
- if (opts->cache) {
- /* use a specific cache file */
- sprintf(tmp, "cache,size=0x%0x,file=%s", cachePartitionSize, opts->cache);
- args[n++] = "-nand";
- args[n++] = strdup(tmp);
- }
- else if (!opts->no_cache) {
- /* create a temporary cache partition file */
- sprintf(tmp, "cache,size=0x%0x", cachePartitionSize);
- args[n++] = "-nand";
- args[n++] = strdup(tmp);
+ if (opts->cache) {
+ hw->disk_cachePartition_path = ASTRDUP(opts->cache);
+ }
}
+ /** SD CARD PARTITION */
+
// TODO: This should go to core
if (hw->hw_sdCard != 0)
opts->sdcard = (char*) avdInfo_getImageFile(avd, AVD_IMAGE_SDCARD);