#include<stdlib.h>
#include<string.h>
#include<inttypes.h>
+#include <stdbool.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/statfs.h>
return ulResult;
}
-int SS_IMGVerfiyPartition(ua_dataSS_t * ua_dataSS)
+int SS_IMGVerfiyPartition(ua_dataSS_t * ua_dataSS, bool ab_update)
{
int ulResult = S_SS_SUCCESS;
uint8_t source_sha1[SHA_DIGEST_SIZE];
return E_SS_FAILURE;
}
- //We verify twice the image size for BACKUP source, not on Partition. As Patch will be created on RAM
- SS_GetAvailableFreeSpace(SS_COMMON_WORKSPACE, &free_space);
- if ((free_space) < (2 * ua_dataSS->update_cfg->target_img_size)) {
- LOGE("Not enough free space [%d] for twice max size [%d]\n", free_space,
- (2 * ua_dataSS->update_cfg->target_img_size));
- SS_SetUpgradeState(E_SS_FSMEMORYERROR);
- return E_SS_FAILURE;
+ if (!ab_update) {
+ //We verify twice the image size for BACKUP source, not on Partition. As Patch will be created on RAM
+ SS_GetAvailableFreeSpace(SS_COMMON_WORKSPACE, &free_space);
+ if ((free_space) < (2 * ua_dataSS->update_cfg->target_img_size)) {
+ LOGE("Not enough free space [%d] for twice max size [%d]\n", free_space,
+ (2 * ua_dataSS->update_cfg->target_img_size));
+ SS_SetUpgradeState(E_SS_FSMEMORYERROR);
+ return E_SS_FAILURE;
+ }
}
if (ParseSha1(ua_dataSS->update_cfg->soure_sha1, source_sha1) != 0) {
return E_SS_FAILURE;
}
- SS_CalculateFileSha(ua_dataSS->parti_info->ua_blk_name, ua_dataSS->update_cfg->soure_img_size, calculated_sha1);
+ /*
+ * If ab_update is set it means it is a DELTA_IMG_AB update, where the patch
+ * is applied to data directly read from a partition in the previous slot
+ */
+ const char *src_blk_name;
+ if (ab_update)
+ src_blk_name = ua_dataSS->parti_info->ua_blk_name_previous;
+ else
+ src_blk_name = ua_dataSS->parti_info->ua_blk_name;
+
+ SS_CalculateFileSha(src_blk_name, ua_dataSS->update_cfg->soure_img_size, calculated_sha1);
if (memcmp(calculated_sha1, source_sha1, SHA_DIGEST_SIZE) == 0) {
- LOGL(LOG_SSENGINE, "SS_IMGVerfiyPartition - SHA matches with source [%s] \n",
- ua_dataSS->parti_info->ua_blk_name);
+ LOGL(LOG_SSENGINE, "SS_IMGVerfiyPartition - SHA matches with source [%s] \n", src_blk_name);
} else { // Need not compare with Target sha as once upgraded, it should NOT verify same partition again.
unsigned char actualShaBuffer[41] = { 0, };
hex_digest(calculated_sha1, actualShaBuffer, SHA_DIGEST_SIZE);
LOGE("SS_IMGVerfiyPartition - SHA mismatch with SRC [%s] Expected [%s] Actual [%s]\n",
- ua_dataSS->parti_info->ua_blk_name, ua_dataSS->update_cfg->soure_sha1, actualShaBuffer);
+ src_blk_name, ua_dataSS->update_cfg->soure_sha1, actualShaBuffer);
SS_SetUpgradeState(E_SS_IMGSRCCURRUPTED);
ulResult = E_SS_FAILURE;
}
#ifndef _SS_UPI_H_
#define _SS_UPI_H_
+#include <stdbool.h>
#define DISPLAYRESOLUTION_SIZE 50
const char *new_path, const char *patchname, const char *sha1src, const char *sha1trg, int type,
char *patchpath_name);
extern int SS_IMGUpdatemain(ua_dataSS_t * ua_dataSS, int update_type);
-extern int SS_IMGVerfiyPartition(ua_dataSS_t * ua_dataSS);
+extern int SS_IMGVerfiyPartition(ua_dataSS_t * ua_dataSS, bool ab_update);
extern int SS_FSUpdatemain(ua_dataSS_t * ua_dataSS, int part_idx);
extern int SS_FSVerifyPartition(ua_dataSS_t * ua_dataSS, int part_idx);
extern int SS_UpdateDeltaIMG(ua_dataSS_t * ua_dataSS, int (*write_to_blkdev) (char *, int, int, char *));