int VolumeManager::cleanupAsec(Volume *v, bool force) { // Continue for the primary storage (VOL_PROVIDES_ASEC) and for the // external apps volume (VOL_EXTERNAL_APPS) if app moving is enabled if ((v->getFlags() & VOL_PROVIDES_ASEC) == 0 && ((v->getFlags() & VOL_EXTERNAL_APPS) == 0 || !v->isExternalAppsEnabled())) { return 0; } int rc = 0; char asecFileName[255]; AsecIdCollection removeAsec; AsecIdCollection removeObb; for (AsecIdCollection::iterator it = mActiveContainers->begin(); it != mActiveContainers->end(); ++it) { ContainerData* cd = *it; if (cd->type == ASEC) { if (findAsec(cd->id, asecFileName, sizeof(asecFileName))) { SLOGE("Couldn't find ASEC %s; cleaning up", cd->id); removeAsec.push_back(cd); } else { SLOGD("Found ASEC at path %s", asecFileName); if (!strncmp(asecFileName, Volume::SEC_ASECDIR_EXT, strlen(Volume::SEC_ASECDIR_EXT))) { removeAsec.push_back(cd); } } } else if (cd->type == OBB) { if (v == getVolumeForFile(cd->id)) { removeObb.push_back(cd); } } else { SLOGE("Unknown container type %d!", cd->type); } } for (AsecIdCollection::iterator it = removeAsec.begin(); it != removeAsec.end(); ++it) { ContainerData *cd = *it; SLOGI("Unmounting ASEC %s (dependent on %s)", cd->id, v->getLabel()); if (unmountAsec(cd->id, force)) { SLOGE("Failed to unmount ASEC %s (%s)", cd->id, strerror(errno)); rc = -1; } } for (AsecIdCollection::iterator it = removeObb.begin(); it != removeObb.end(); ++it) { ContainerData *cd = *it; SLOGI("Unmounting OBB %s (dependent on %s)", cd->id, v->getLabel()); if (unmountObb(cd->id, force)) { SLOGE("Failed to unmount OBB %s (%s)", cd->id, strerror(errno)); rc = -1; } } return rc; }
int VolumeManager::cleanupAsec(Volume *v, bool force) { int rc = unmountAllAsecsInDir(Volume::SEC_ASECDIR_EXT); AsecIdCollection toUnmount; // Find the remaining OBB files that are on external storage. for (AsecIdCollection::iterator it = mActiveContainers->begin(); it != mActiveContainers->end(); ++it) { ContainerData* cd = *it; if (cd->type == ASEC) { // nothing } else if (cd->type == OBB) { if (v == getVolumeForFile(cd->id)) { toUnmount.push_back(cd); } } else { SLOGE("Unknown container type %d!", cd->type); } } for (AsecIdCollection::iterator it = toUnmount.begin(); it != toUnmount.end(); ++it) { ContainerData *cd = *it; SLOGI("Unmounting ASEC %s (dependant on %s)", cd->id, v->getMountpoint()); if (unmountObb(cd->id, force)) { SLOGE("Failed to unmount OBB %s (%s)", cd->id, strerror(errno)); rc = -1; } } return rc; }