*/
API int app2ext_disable_external_pkg(const char *pkgid);
+/**
+ * @brief : This API enable the directory which has package that is located in external memory
+ * @return error < 0 if pkg enable fail ,
+ @code
+ #include <app2ext_interface.h>
+int ret = -1;
+
+ret = app2ext_enable_external_dir();
+if (ret < 0) {
+ printf("\n app2sd dir is not enabled ");
+} else {
+ printf("\n app2sd dir is enabled ");
+}
+ @endcode
+ */
+API int app2ext_enable_external_dir(void);
+
+/**
+ * @brief : This API disable the directory which has package that is located in external memory
+ * @return error < 0 if pkg enable fail ,
+ @code
+ #include <app2ext_interface.h>
+int ret = -1;
+
+ret = app2ext_enable_external_dir();
+if (ret < 0) {
+ printf("\n app2sd dir is not enabled ");
+} else {
+ printf("\n app2sd dir is enabled ");
+}
+ @endcode
+ */
+API int app2ext_disable_external_dir(void);
+
#ifdef __cplusplus
}
#endif
Name: app2sd
Summary: Application installation on external memory
-Version: 0.5.23
+Version: 0.5.24
Release: 1
Group: Application Framework/Application Installer
License: Apache-2.0
%{_libdir}/libapp2ext.so.*
%{_libdir}/libapp2sd.so*
+
%files devel
%manifest %{name}.manifest
%defattr(-,root,root,-)
app2ext_move_type move_type)
{
int ret = 0;
+ int pkgmgrinfo_ret = 0;
/*Validate function arguments*/
if (pkgid == NULL || dir_list == NULL
goto END;
}
+ /*If move is completed, then update installed storage to pkgmgr_parser db*/
+ pkgmgrinfo_pkginfo_h info_handle = NULL;
+ pkgmgrinfo_installed_storage storage = PMINFO_INTERNAL_STORAGE;
+ pkgmgrinfo_ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &info_handle);
+ if (pkgmgrinfo_ret < 0) {
+ app2ext_print("App2Sd Error : pkgmgrinfo_pkginfo_get_pkginfo[%s] fail.. \n", pkgid);
+ }
+ pkgmgrinfo_ret = pkgmgrinfo_pkginfo_get_installed_storage(info_handle, &storage);
+ if (pkgmgrinfo_ret < 0) {
+ app2ext_print("App2Sd Error : pkgmgrinfo_pkginfo_get_installed_storage[%s] fail.. \n", pkgid);
+ }
+
+ if ((move_type == APP2EXT_MOVE_TO_EXT && storage == PMINFO_EXTERNAL_STORAGE)
+ || (move_type == APP2EXT_MOVE_TO_PHONE && storage == PMINFO_INTERNAL_STORAGE)) {
+ ret = APP2EXT_ERROR_PKG_EXISTS;
+ app2ext_print("App2Sd Error : PKG_EXISTS in [%d]STORAGE\n", storage);
+ pkgmgrinfo_pkginfo_destroy_pkginfo(info_handle);
+ goto END;
+ } else {
+ app2ext_print("App2Sd Error : okokkokin [%d]STORAGE\n", storage);
+ }
+ pkgmgrinfo_pkginfo_destroy_pkginfo(info_handle);
+
ret = _app2sd_move_app(pkgid, move_type, dir_list);
if (ret) {
app2ext_print("App2Sd Error : Unable to move application\n");
}
/*If move is completed, then update installed storage to pkgmgr_parser db*/
- int rt = 0;
pkgmgrinfo_pkgdbinfo_h handle = NULL;
- rt = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
- if (rt < 0) {
+ pkgmgrinfo_ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
+ if (pkgmgrinfo_ret < 0) {
app2ext_print("App2Sd Error : pkgmgrinfo_create_pkgdbinfo[%s] fail.. \n", pkgid);
}
if (move_type == APP2EXT_MOVE_TO_EXT) {
- rt = pkgmgrinfo_set_installed_storage_to_pkgdbinfo(handle, INSTALL_EXTERNAL);
- if (rt < 0) {
+ pkgmgrinfo_ret = pkgmgrinfo_set_installed_storage_to_pkgdbinfo(handle, INSTALL_EXTERNAL);
+ if (pkgmgrinfo_ret < 0) {
app2ext_print("App2Sd Error : fail to update installed location to db[%s, %s]\n", pkgid, INSTALL_EXTERNAL);
}
} else {
- rt = pkgmgrinfo_set_installed_storage_to_pkgdbinfo(handle, INSTALL_INTERNAL);
- if (rt < 0) {
+ pkgmgrinfo_ret = pkgmgrinfo_set_installed_storage_to_pkgdbinfo(handle, INSTALL_INTERNAL);
+ if (pkgmgrinfo_ret < 0) {
app2ext_print("App2Sd Error : fail to update installed location to db[%s, %s]\n", pkgid, INSTALL_INTERNAL);
}
}
- rt =pkgmgrinfo_save_pkgdbinfo(handle);
- if (rt < 0) {
+ pkgmgrinfo_ret =pkgmgrinfo_save_pkgdbinfo(handle);
+ if (pkgmgrinfo_ret < 0) {
app2ext_print("pkgmgrinfo_save_pkgdbinfo[%s] failed\n", pkgid);
}
- rt =pkgmgrinfo_destroy_pkgdbinfo(handle);
- if (rt < 0) {
+ pkgmgrinfo_ret =pkgmgrinfo_destroy_pkgdbinfo(handle);
+ if (pkgmgrinfo_ret < 0) {
app2ext_print("pkgmgrinfo_destroy_pkgdbinfo failed\n");
}
/*check whether application is in external memory or not */
fp = fopen(mmc_path, "r+");
if (fp != NULL) {
- const char *argv[] = { "/bin/rm", "-rf", mmc_path, NULL };
app2ext_print
("Already %s entry is present in the SD Card, delete entry and go on without return\n",
pkgid);
fclose(fp);
// return APP2EXT_ERROR_ALREADY_FILE_PRESENT;
- ret = _xsystem(argv);
- if (ret) {
- app2ext_print
- ("delete fail[%s]\n",
- mmc_path);
- }
}
snprintf(app_mmc_path, FILENAME_MAX,
app2ext_print
("App2sd Error: Unable to create directory for archiving, error no is %d\n",
errno);
- return APP2EXT_ERROR_CREATE_DIRECTORY;
+// return APP2EXT_ERROR_CREATE_DIRECTORY;
}
}
if (ret) {
app2ext_print
("App2Sd Error : loopback node creation failed\n");
- return APP2EXT_ERROR_CREATE_DEVICE;
+// return APP2EXT_ERROR_CREATE_DEVICE;
}
/*Perform Loopback encryption setup */
device_node =
("App2Sd Error : unable to copy from %s to %s \n",
path,
app_archive_path);
- return
- APP2EXT_ERROR_MOVE;
+// return APP2EXT_ERROR_MOVE;
}
}
}
app_mmc_path,
strerror
(errno));
- return
- APP2EXT_ERROR_MOVE;
+// return APP2EXT_ERROR_MOVE;
}
}
ret =
app2ext_print
("App2Sd Error : unable to delete %s \n",
app_archive_path);
- return APP2EXT_ERROR_DELETE_DIRECTORY;
+// return APP2EXT_ERROR_DELETE_DIRECTORY;
}
ret = _app2sd_apply_mmc_smack(pkgid, dir_list, pkgid);
app2ext_print
("App2Sd Error : unable to create directory%s\n",
app_archive_path);
- return APP2EXT_ERROR_CREATE_DIRECTORY;
+// return APP2EXT_ERROR_CREATE_DIRECTORY;
}
app_archive_path,
strerror
(errno));
- return
- APP2EXT_ERROR_MOVE;
+// return APP2EXT_ERROR_MOVE;
}
}
path);
} else {
app2ext_print
- ("App2Sd Error : unable to remove the symbolic link file %s\n",
+ ("App2Sd Error : unable to remove the symbolic link file %s, it is already unlinked!!!\n",
path);
- return
- APP2EXT_ERROR_DELETE_LINK_FILE;
+// return APP2EXT_ERROR_DELETE_LINK_FILE;
}
}
app_path,
strerror
(errno));
- return
- APP2EXT_ERROR_MOVE;
+// return APP2EXT_ERROR_MOVE;
}
}
}
app2ext_print
("App2Sd Error : unable to delete %s \n",
app_mmc_path);
- return APP2EXT_ERROR_DELETE_DIRECTORY;
+// return APP2EXT_ERROR_DELETE_DIRECTORY;
}
ret = _app2sd_delete_directory(app_archive_path);
if (ret) {
app2ext_print
("App2Sd Error : unable to delete %s \n",
app_archive_path);
- return APP2EXT_ERROR_DELETE_DIRECTORY;
+// return APP2EXT_ERROR_DELETE_DIRECTORY;
}
ret = _app2sd_apply_app_smack(pkgid, dir_list, pkgid);
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
+#include <dirent.h>
#define APP2EXT_SD_PLUGIN_PATH LIBPREFIX "/libapp2sd.so"
}
return 0;
}
+
+int app2ext_enable_external_dir(void)
+{
+ int ret = 0;
+ DIR *dir = NULL;
+ char buf[FILENAME_MAX] = { 0, };
+ struct dirent entry, *result;
+
+ dir = opendir(APP2SD_PATH);
+ if (!dir) {
+ if (strerror_r(errno, buf, sizeof(buf)) == 0)
+ app2ext_print("App2Ext Error :Failed to access the because %s", buf);
+ return -1;
+ }
+
+ for (ret = readdir_r(dir, &entry, &result); ret == 0 && result != NULL; ret = readdir_r(dir, &entry, &result)) {
+ ret = app2ext_enable_external_pkg(entry.d_name);
+ if (ret != 0)
+ app2ext_print("App2Ext Error : fail enable pkg[%s]\n", entry.d_name);
+ }
+
+ closedir(dir);
+ return 0;
+}
+
+int app2ext_disable_external_dir(void)
+{
+ int ret = 0;
+ DIR *dir = NULL;
+ char buf[FILENAME_MAX] = { 0, };
+ struct dirent entry, *result;
+
+ dir = opendir(APP2SD_PATH);
+ if (!dir) {
+ if (strerror_r(errno, buf, sizeof(buf)) == 0)
+ app2ext_print("App2Ext Error :Failed to access the because %s", buf);
+ return -1;
+ }
+
+ for (ret = readdir_r(dir, &entry, &result); ret == 0 && result != NULL; ret = readdir_r(dir, &entry, &result)) {
+ ret = app2ext_disable_external_pkg(entry.d_name);
+ if (ret != 0)
+ app2ext_print("App2Ext Error : fail disable pkg[%s]\n", entry.d_name);
+ }
+
+ closedir(dir);
+ return 0;
+}