#include <sys/wait.h>
#include <pkgmgr-info.h>
+#define MAX_BUF_LEN 1024
+#define APP2SD_TMP_PATH "/opt/usr/apps/tmp"
+
int app2sd_pre_app_install(const char *pkgid, GList* dir_list,
int size)
{
app2ext_move_type move_type)
{
int ret = 0;
+ char device_path[MAX_BUF_LEN] = {'\0', };
+ FILE* file = NULL;
+ int fd = 0;
+ char buf[MAX_BUF_LEN] = {'\0'};
/*Validate function arguments*/
if (pkgid == NULL || dir_list == NULL
|| move_type < APP2EXT_MOVE_TO_EXT
|| move_type > APP2EXT_MOVE_TO_PHONE) {
app2ext_print("App2Sd Error : Invalid function arguments\n");
- return APP2EXT_ERROR_INVALID_ARGUMENTS;
+ ret = APP2EXT_ERROR_INVALID_ARGUMENTS;
+ goto END;
}
ret = _app2sd_move_app(pkgid, move_type, dir_list);
if (ret) {
app2ext_print("App2Sd Error : Unable to move application\n");
- return ret;
+ goto END;
}
/*If move is completed, then update installed storage to pkgmgr_parser db*/
app2ext_print("pkgmgrinfo_destroy_pkgdbinfo failed\n");
}
+END:
+ snprintf(device_path, MAX_BUF_LEN, "%s/%s", APP2SD_TMP_PATH, pkgid);
+
+ file = fopen(device_path, "w");
+ if (file == NULL) {
+ app2ext_print("fopen failed\n");
+ }
+
+ snprintf(buf, MAX_BUF_LEN - 1, "%d\n", ret);
+ fwrite(buf, 1, strlen(buf), file);
+
+ if (file != NULL) {
+ fflush(file);
+ fd = fileno(file);
+ fsync(fd);
+ fclose(file);
+ }
+
return ret;
}