SET(PROJECT_NAME "ode-fota")
-PKG_CHECK_MODULES(FOTA_DEPS REQUIRED klay-static blkid)
+PKG_CHECK_MODULES(FOTA_DEPS REQUIRED vconf klay-static blkid)
SET(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/fota.cpp
${ODE_SERVER}/upgrade-support.cpp
#include <fcntl.h>
#include <errno.h>
+#include <vconf.h>
#include <klay/error.h>
#include <klay/exception.h>
#include <klay/filesystem.h>
start = true;
- for (int retry = 0; retry < 32; retry++) {
- try {
- ext4CryptoBlkDev.forceCleanUp();
- } catch (runtime::Exception &e) {
- continue;
+ // Since the vconf value for crypto status is different before and after tizen 5.0,
+ // check the version of tizen platform using the vconf value.
+ char *value = ::vconf_get_str(VCONFKEY_ODE_CRYPTO_STATE);
+ if (value == NULL)
+ throw runtime::Exception("Failed to get a vconf value.");
+
+ bool needCleanUp = strcmp(value, "encrypted") == 0 ? true : false;
+ ::free(value);
+
+ // The forceCleanUp is unnecessary after tizen 5.0.
+ // But leave this for tizen 4.0.
+ if (needCleanUp) {
+ for (int retry = 0; retry < 32; retry++) {
+ try {
+ ext4CryptoBlkDev.forceCleanUp();
+ } catch (runtime::Exception &e) {
+ continue;
+ }
+ break;
}
- break;
}
+
INFO(SINK, "Crypto Engine : checked target device");
std::function<bool(blkcnt_t)> isTarget;
// read totalBlockCount
device.lseek(ODE_SUPERBLOCK_OFFSET + 4, SEEK_SET);
device.read(&totalBlockCount, 4);
+ if (totalBlockCount == 0)
+ throw runtime::Exception("Invalid totalBlockCount");
// read firstDataBlock
device.lseek(ODE_SUPERBLOCK_OFFSET + 20, SEEK_SET);