4 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
24 #include <sys/types.h>
28 #include "SS_ImageUpdate.h"
29 #include "SS_Engine_Errors.h"
30 #include "SS_Common.h"
34 #include "fota_common.h"
36 void SS_Progress(void *pbUserData, SS_UINT32 uPercent)
38 LOG("Progress before\n");
39 LOGL(LOG_SSENGINE, "Progress.. (%u %%)\n", uPercent);
40 LOG("Progress after:\n");
41 ((ua_data_t *) pbUserData)->ui_progress(pbUserData, uPercent);
44 /* Prints a string like the C printf() function */
45 SS_UINT32 SS_Trace(const char *aFormat, ...)
48 LOGL(LOG_SSENGINE, aFormat);
53 va_start(list, aFormat);
54 vsnprintf(temp, sizeof(temp), aFormat, list);
57 LOGL(LOG_SSENGINE, "%s", temp);
62 long SS_FSTrace(const unsigned short *aFormat, ...)
66 va_start(list, aFormat);
67 vprintf((const char *)aFormat, list);
73 long SS_ResetTimerA(void)
75 //LOG("%s \n", __func__);
80 long SS_GetDelta(void *pbUserData, unsigned char *pbBuffer, SS_UINT32 dwStartAddressOffset, SS_UINT32 dwSize)
82 int ret = S_SS_SUCCESS;
87 ua_data_t *ua_data = (ua_data_t *) pbUserData;
88 ua_part_info_t *ua_partition = ua_data->parti_info;
89 ua_update_data_t *ua_update_data = ua_data->update_data;
91 LOGL(LOG_SSENGINE, "SS_GetDelta offset 0x%x(%u), size 0x%x(%u)\n",
92 dwStartAddressOffset, dwStartAddressOffset, dwSize, dwSize);
94 itemOffset = tar_get_item_offset(ua_update_data->ua_delta_path, ua_partition->ua_subject_name);
96 return E_SS_OPENFILE_ONLYR;
98 fp = fopen(ua_update_data->ua_delta_path, "r");
100 LOGL(LOG_SSENGINE, "open file %s failed.\n", ua_update_data->ua_delta_path);
101 return E_SS_OPENFILE_ONLYR;
104 if (fseek(fp, itemOffset + dwStartAddressOffset, 0) == -1)
105 ret = E_SS_READ_ERROR;
107 readCount = fread(pbBuffer, 1, dwSize, fp);
108 if (readCount != dwSize) {
109 LOGL(LOG_SSENGINE, "error in read size\n");
110 ret = E_SS_READ_ERROR;