#define APP2EXT_SUCCESS 0
#define OWNER_ROOT 0
+#define REGULAR_USER 5000
#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
#define MMC_PATH tzplatform_mkpath(TZ_SYS_MEDIA, "SDCardA1")
#define APP2SD_PATH tzplatform_mkpath(TZ_SYS_MEDIA, "SDCardA1/app2sd")
#define DIR_PERMS (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
int _is_global(uid_t uid);
+
char *_app2sd_get_encoded_name(const char *pkgid, uid_t uid);
+int _app2sd_delete_directory(const char *dirname);
+
#ifdef __cplusplus
}
#endif
return new_name;
}
+
+int _app2sd_delete_directory(const char *dirname)
+{
+ DIR *dp = NULL;
+ struct dirent ep;
+ struct dirent *er = NULL;
+ char abs_filename[FILENAME_MAX] = { 0, };
+ int ret = 0;
+
+ dp = opendir(dirname);
+ if (dp != NULL) {
+ while (readdir_r(dp, &ep, &er) == 0 && er != NULL) {
+ struct stat stFileInfo;
+
+ snprintf(abs_filename, FILENAME_MAX, "%s/%s", dirname,
+ ep.d_name);
+
+ if (lstat(abs_filename, &stFileInfo) < 0) {
+ perror(abs_filename);
+ (void)closedir(dp);
+ return -1;
+ }
+
+ if (S_ISDIR(stFileInfo.st_mode)) {
+ if (strcmp(ep.d_name, ".")
+ && strcmp(ep.d_name, "..")) {
+ ret = _app2sd_delete_directory(abs_filename);
+ if (ret < 0) {
+ (void)closedir(dp);
+ return -1;
+ }
+ }
+ } else {
+ ret = remove(abs_filename);
+ if (ret < 0) {
+ (void)closedir(dp);
+ return -1;
+ }
+ }
+ }
+ (void)closedir(dp);
+ ret = remove(dirname);
+ if (ret < 0)
+ return -1;
+ } else {
+ _W("couldn't open the directory[%s]", dirname);
+ }
+ return 0;
+}
APP2EXT_ERROR_STRCMP_FAILED,
APP2EXT_ERROR_INVALID_PACKAGE,
APP2EXT_ERROR_CREATE_DIR_ENTRY,
- APP2EXT_ERROR_PASSWORD_GENERATION,
APP2EXT_ERROR_COPY_DIRECTORY,
APP2EXT_ERROR_INVALID_CASE,
APP2EXT_ERROR_SYMLINK_ALREADY_EXISTS,
} app2ext_error;
/**
- * @brief :This function type is for a function that is implemented by plugin
+ * @brief : This function type is for a function that is implemented by plugin
* and called before application is to be installed.
*
- * @param[in] appname application package name which is to be installed
- * @param[in] dir_list directory structure of the application
+ * @param[in] appname application package name which is to be installed
+ * @param[in] dir_list directory structure of the application
* This should be polulated by the package manager
* before calling pre_install and should be freed after
* pre_install returns.
* which has members Name(dirname) and Type (RO/RW)
* For eg for rpm the dir_list should be populated with
* nodes like : (lib, APP2EXT_DIR_RO), (res, APP2EXT_DIR_RO),
- (bin, APP2EXT_DIR_RO), (data, APP2EXT_DIR_RW)
- * @param[in] size Size of the application
- * @return 0 if success, error code(>0) if fail
+ * (bin, APP2EXT_DIR_RO), (data, APP2EXT_DIR_RW)
+ * @param[in] size Size of the application
+ * @return 0 if success, error code(>0) if fail
*/
typedef int (*app2ext_client_usr_pre_install)(const char *appname, GList* dir_list,
int size, uid_t uid);
int size);
/**
- * @brief :This function type is for a function that is implemented by plugin
+ * @brief : This function type is for a function that is implemented by plugin
* and called after application installation.
*
- * @param[in] appname application package name which is to be installed
- * @param[in] install_status Installation status (Success/Failure)
- * [ Enum :APP2EXT_STATUS_SUCCESS,
- * APP2EXT_STATUS_FAILED]
- * @return 0 if success, error code(>0) if fail
+ * @param[in] appname application package name which is to be installed
+ * @param[in] install_status Installation status (Success/Failure)
+ * [ Enum :APP2EXT_STATUS_SUCCESS,
+ * APP2EXT_STATUS_FAILED]
+ * @return 0 if success, error code(>0) if fail
*/
typedef int (*app2ext_client_usr_post_install)(const char *appname,
app2ext_status install_status, uid_t uid);
app2ext_status install_status);
/**
- * @brief :This function type is for a function that is implemented by plugin
+ * @brief : This function type is for a function that is implemented by plugin
* and called before application upgrade.
*
- * @param[in] appname application package name which is to be upgraded
- * @param[in] dir_list directory structure of the application
+ * @param[in] appname application package name which is to be upgraded
+ * @param[in] dir_list directory structure of the application
* This should be polulated by the package manager
* before calling pre_upgrade and should be freed after
* pre_upgrade returns.
* which has members Name(dirname) and Type (RO/RW)
* For eg for rpm the dir_list should be populated with
* nodes like : (lib, APP2EXT_DIR_RO), (res, APP2EXT_DIR_RO),
- (bin, APP2EXT_DIR_RO), (data, APP2EXT_DIR_RW)
- * @param[in] size Size of the application
- * @return 0 if success, error code(>0) if fail
+ * (bin, APP2EXT_DIR_RO), (data, APP2EXT_DIR_RW)
+ * @param[in] size Size of the application
+ * @return 0 if success, error code(>0) if fail
*/
typedef int (*app2ext_client_usr_pre_upgrade)(const char *appname, GList* dir_list,
int size, uid_t uid);
int size);
/**
- * @brief :This function type is for a function that is implemented by plugin
+ * @brief : This function type is for a function that is implemented by plugin
* and called before application upgradation.
*
- * @param[in] appname application package name which is to be upgraded
- * @param[in] upgrade_status Upgrade status (Success/Failure)
- * [ Enum :APP2EXT_STATUS_SUCCESS,
- * APP2EXT_STATUS_FAILED]
- * @return 0 if success, error code(>0) if fail
+ * @param[in] appname application package name which is to be upgraded
+ * @param[in] upgrade_status Upgrade status (Success/Failure)
+ * [ Enum :APP2EXT_STATUS_SUCCESS,
+ * APP2EXT_STATUS_FAILED]
+ * @return 0 if success, error code(>0) if fail
*/
typedef int (*app2ext_client_usr_post_upgrade)(const char *appname,
app2ext_status upgrade_status, uid_t uid);
app2ext_status upgrade_status);
/**
- * @brief :This function type is for a function that is implemented by plugin
+ * @brief : This function type is for a function that is implemented by plugin
* and called before application uninstallation.
*
- * @param[in] appname application package name which is to be uninstalled
- * @return 0 if success, error code(>0) if fail
+ * @param[in] appname application package name which is to be uninstalled
+ * @return 0 if success, error code(>0) if fail
*/
typedef int (*app2ext_client_usr_pre_uninstall)(const char *appname, uid_t uid);
typedef int (*app2ext_client_pre_uninstall)(const char *appname);
/**
- * @brief :This function type is for a function that is implemented by plugin
+ * @brief : This function type is for a function that is implemented by plugin
* and called after application uninstallation.
*
- * @param[in] appname application package name which is to be uninstalled
- * @return 0 if success, error code(>0) if fail
+ * @param[in] appname application package name which is to be uninstalled
+ * @return 0 if success, error code(>0) if fail
*/
typedef int (*app2ext_client_usr_post_uninstall)(const char *appname, uid_t uid);
typedef int (*app2ext_client_post_uninstall)(const char *appname);
/**
- * @brief :This function type is for a function that is implemented by plugin
+ * @brief : This function type is for a function that is implemented by plugin
* and called when application is to be moved from extrenal memory
*to internal memory or vice versa.
*
- * @param[in] appname application package name which is to be moved
- * @param[in] dir_list directory structure of the application
+ * @param[in] appname application package name which is to be moved
+ * @param[in] dir_list directory structure of the application
* This should be polulated by the package manager
* before calling move and should be freed after
* move returns.
* which has members Name(dirname) and Type (RO/RW)
* For eg for rpm the dir_list should be populated with
* nodes like : (lib, APP2EXT_DIR_RO), (res, APP2EXT_DIR_RO),
- (bin, APP2EXT_DIR_RO), (data, APP2EXT_DIR_RW)
- * @param[in] move_type move type
- * [Enum: APP2EXT_MOVE_TO_EXT, APP2EXT_MOVE_TO_PHONE]
- * @return 0 if success, error code(>0) if fail
+ * (bin, APP2EXT_DIR_RO), (data, APP2EXT_DIR_RW)
+ * @param[in] move_type move type
+ * [Enum: APP2EXT_MOVE_TO_EXT, APP2EXT_MOVE_TO_PHONE]
+ * @return 0 if success, error code(>0) if fail
*/
typedef int (*app2ext_client_usr_move)(const char *appname, GList* dir_list,
app2ext_move_type move_type, uid_t uid);
app2ext_move_type move_type);
/**
- * @brief :This function type is for a function that is implemented by plugin
+ * @brief : This function type is for a function that is implemented by plugin
* and called to enable application before application launch.
*
- * @param[in] appname application package name which is to be enabled
- * @return 0 if success, error code(>0) if fail
+ * @param[in] appname application package name which is to be enabled
+ * @return 0 if success, error code(>0) if fail
*/
typedef int (*app2ext_client_usr_enable)(const char *appname, uid_t uid);
typedef int (*app2ext_client_enable)(const char *appname);
/**
- * @brief :This function type is for a function that is implemented by plugin
+ * @brief : This function type is for a function that is implemented by plugin
+ * and called to enable/disable entire application packages.
+ *
+ * @return 0 if success, error code(>0) if fail
+ */
+typedef int (*app2ext_client_enable_full_pkg)(void);
+typedef int (*app2ext_client_disable_full_pkg)(void);
+
+/**
+ * @brief : This function type is for a function that is implemented by plugin
* and called to disable application before application exit.
*
- * @param[in] appname application package name which is to be disabled
- * @return 0 if success, error code(>0) if fail
+ * @param[in] appname application package name which is to be disabled
+ * @return 0 if success, error code(>0) if fail
*/
typedef int (*app2ext_client_usr_disable)(const char *appname, uid_t uid);
typedef int (*app2ext_client_disable)(const char *appname);
/**
- * @brief :This function type is for a function that is implemented by plugin
+ * @brief : This function type is for a function that is implemented by plugin
* and called after application uninstallation.
*
- * @param[in] pkgid application package name which is to be uninstalled
- * @return 0 if success, error code(>0) if fail
+ * @param[in] pkgid application package name which is to be uninstalled
+ * @return 0 if success, error code(>0) if fail
*/
typedef int (*app2ext_client_usr_force_clean)(const char *pkgid, uid_t uid);
typedef int (*app2ext_client_force_clean)(const char *pkgid);
app2ext_client_force_clean client_force_clean;
app2ext_client_enable client_enable;
app2ext_client_disable client_disable;
+ app2ext_client_enable_full_pkg client_enable_full_pkg;
+ app2ext_client_disable_full_pkg client_disable_full_pkg;
app2ext_client_move client_move;
app2ext_client_usr_pre_install client_usr_pre_install;
/**
* This structure defines app2ext handle .Each storage type maps to a different plugin
- * type : storage type,
- * plugin_handle : plugin handle, need to close dlopen handle
- * interface : inteface with plugin library
+ * type : storage type,
+ * plugin_handle : plugin handle, need to close dlopen handle
+ * interface : inteface with plugin library
*/
typedef struct {
- app2ext_install_location type;
+ app2ext_install_location type;
void *plugin_handle;
- app2ext_interface interface;
+ app2ext_interface interface;
} app2ext_handle;
/**
* This structure defines directory details
- * name : directory name
- * type : permission (rw/ro)
+ * name : directory name
+ * type : permission (rw/ro)
*/
typedef struct {
char *name;
/**
* @brief : This API initializes the appropriate plugin based on storage type.
- * It should be called before installation/uninstallation/upgrade
- * @param[in] storage_type Location where package should be installed
- * [Ex: SD card, MicroUSB, Cloud]
- * @return app2ext_handle pointer if success, NULL if fail
+ * It should be called before installation/uninstallation/upgrade
+ * @param[in] storage_type Location where package should be installed
+ * [Ex: SD card, MicroUSB, Cloud]
+ * @return app2ext_handle pointer if success, NULL if fail
*
*/
API app2ext_handle *app2ext_init(int storage_type);
/**
* @brief : This API deinitializes the plugin
- * This should be called when use of the plugin is completed
- * @param[in] handle pointer to app2ext_handle which is to be deinitialized
- * @pre Initialization is done for the storage handle
- * @return 0 if success, error < 0 if fail
+ * This should be called when use of the plugin is completed
+ * @param[in] handle pointer to app2ext_handle which is to be deinitialized
+ * @pre Initialization is done for the storage handle
+ * @return 0 if success, error < 0 if fail
*
*/
API int app2ext_deinit(app2ext_handle *handle);
/**
* @brief : This API returns the application location by refering to package manager DB
- * This should be called to know location of an application package
- * @param[in] pkgid package id
- * @param[in] uid target user id of this instruction
- * @return APP2EXT_SD_CARD if pkg is in SD card,
- * APP2EXT_INTERNAL_MEM if pkg is in internal memory,
- * APP2EXT_NOT_INSTALLED if there is no valid pkg path
- * error < 0 if fail
+ * This should be called to know location of an application package
+ * @param[in] pkgid package id
+ * @param[in] uid target user id of this instruction
+ * @return APP2EXT_SD_CARD if pkg is in SD card,
+ * APP2EXT_INTERNAL_MEM if pkg is in internal memory,
+ * APP2EXT_NOT_INSTALLED if there is no valid pkg path
+ * error < 0 if fail
*@remarks see app2ext_install_location for more details
*/
API int app2ext_get_app_location(const char *pkgid);
/**
* @brief : This API enable the package which is located in external memory
- * @param[in] pkgid package id
- * @param[in] uid target user id of this instruction
- * @return error < 0 if pkg enable fail ,
+ * @param[in] pkgid package id
+ * @param[in] uid target user id of this instruction
+ * @return error < 0 if pkg enable fail
*/
API int app2ext_enable_external_pkg(const char *pkgid);
API int app2ext_usr_enable_external_pkg(const char *pkgid, uid_t uid);
/**
* @brief : This API disable the package which is located in external memory
- * @param[in] pkgid package id
- * @param[in] uid target user id of this instruction
- * @return error < 0 if pkg enable fail ,
+ * @param[in] pkgid package id
+ * @param[in] uid target user id of this instruction
+ * @return error < 0 if pkg disable fail
*/
API int app2ext_disable_external_pkg(const char *pkgid);
API int app2ext_usr_disable_external_pkg(const char *pkgid, uid_t uid);
/**
* @brief : This API clean the directory and symbolic link which are made by app2ext
- * @param[in] pkgid package id
- * @param[in] uid target user id of this instruction
- * @return error < 0 if pkg enable fail ,
+ * @param[in] pkgid package id
+ * @param[in] uid target user id of this instruction
+ * @return error < 0 if pkg clean fail
*/
API int app2ext_force_clean_pkg(const char *pkgid);
API int app2ext_usr_force_clean_pkg(const char *pkgid, uid_t uid);
+/**
+ * @brief : This API mount/unmount all entries which are located in external memory
+ * @return error < 0 if fail to start enable/disable
+ */
+API int app2ext_enable_external_full_pkg(void);
+API int app2ext_disable_external_full_pkg(void);
+
#ifdef __cplusplus
}
#endif
/**
* @brief : This API prepares the setup for installation in SD card.
* It should be called before actual installation is done.
- * @pre vfat type sd card must be present.
- * @post Installation is done by package installer.
- Encryption password is saved in db TZ_SYS_DB/.app2sd.db
+ * @pre vfat type sd card must be present.
+ * @post Installation is done by package installer.
+ * Encryption password is saved in db TZ_SYS_DB/.app2sd.db
* @param[in] appname application package name
* [Ex: com.samsung.calculator]
*This entry is parsed from application package control/manifest file.
* @remark None.
*/
int app2sd_client_usr_pre_app_install(const char *pkgid,
- GList* dir_list, int size, uid_t uid);
+ GList *dir_list, int size, uid_t uid);
int app2sd_client_pre_app_install(const char *pkgid,
- GList* dir_list, int size);
+ GList *dir_list, int size);
/**
* @brief : This API does post installation operations after
* @remark None.
*/
int app2sd_client_usr_pre_app_upgrade(const char *pkgid,
- GList* dir_list, int size, uid_t uid);
+ GList *dir_list, int size, uid_t uid);
int app2sd_client_pre_app_upgrade(const char *pkgid,
- GList* dir_list, int size);
+ GList *dir_list, int size);
/**
* @brief : This API does post upgradation operations after
* @remark None.
*/
int app2sd_client_usr_move_installed_app(const char *pkgid,
- GList* dir_list, app2ext_move_type move_type, uid_t uid);
+ GList *dir_list, app2ext_move_type move_type, uid_t uid);
int app2sd_client_move_installed_app(const char *pkgid,
- GList* dir_list, app2ext_move_type move_type);
+ GList *dir_list, app2ext_move_type move_type);
/**
* @brief : This API Enables the application in sd card
/**
* @brief : This is the plug-in load function.
- The plugin has to bind its functions to function pointers of storage handle
+ * The plugin has to bind its functions to function pointers of storage handle
* @param[in/out] st_interface Specifies the storage interface.
* @return None
*/
#include "app2ext_utils.h"
int app2sd_usr_pre_app_install(const char *pkgid,
- GList* dir_list, int size, uid_t uid);
+ GList *dir_list, int size, uid_t uid);
int app2sd_usr_post_app_install(const char *pkgid,
app2ext_status install_status, uid_t uid);
int app2sd_usr_pre_app_upgrade(const char *pkgid,
- GList* dir_list, int size, uid_t uid);
+ GList *dir_list, int size, uid_t uid);
int app2sd_usr_post_app_upgrade(const char *pkgid,
app2ext_status upgrade_status, uid_t uid);
int app2sd_usr_post_app_uninstall(const char *pkgid, uid_t uid);
int app2sd_usr_move_installed_app(const char *pkgid,
- GList* dir_list, app2ext_move_type move_type, uid_t uid);
+ GList *dir_list, app2ext_move_type move_type, uid_t uid);
int app2sd_usr_on_demand_setup_init(const char *pkgid, uid_t uid);
int app2sd_usr_force_clean(const char *pkgid, uid_t uid);
+int app2sd_enable_full_pkg(void);
+
+int app2sd_disable_full_pkg(void);
+
#ifdef __cplusplus
}
#endif
#include "app2sd_interface.h"
#define BUF_SIZE 256
-#define MEM_BUF_SIZE 5 /*Memory buffer size in MB*/
-#define PKG_BUF_SIZE 2 /*Memory buffer size in MB*/
+#define MEM_BUF_SIZE 5 /* Memory buffer size in MB */
+#define PKG_BUF_SIZE 2 /* Memory buffer size in MB */
/*Device entry defines*/
-#define DEV_MAJOR 7
+#define DEV_MAJOR 7
-#define FS_TYPE "ext4"
+#define FS_TYPE "ext4"
#define INTERNAL_STORAGE_PATH "/opt"
typedef enum mount_type_t {
/*Function to move the application from/to SD Card*/
int _app2sd_usr_move_app(const char *pkgid, app2ext_move_type move_cmd,
- GList* dir_list, uid_t uid);
-
-/*utility to delete the directory*/
-int _app2sd_delete_directory(const char *dirname);
+ GList *dir_list, uid_t uid);
/*utility to delete symbolic link*/
void _app2sd_delete_symlink(const char *dirname);
int _app2sd_initialize_db();
/*This function is used to get password from db*/
-char *_app2sd_get_password_from_db(const char *pkgid);
+char *_app2sd_get_password_from_db(const char *pkgid, uid_t uid);
+
+/*This function removes info from db */
+int _app2sd_remove_info_from_db(const char *pkgid, uid_t uid);
-/*This function removes password from db */
-int _app2sd_remove_password_from_db(const char *pkgid);
+/* This functions save info in db */
+int _app2sd_set_info_in_db(const char *pkgid, const char *passwd,
+ const char *loopback_device, uid_t uid);
-/* This functions saved password in db */
-int _app2sd_set_password_in_db(const char *pkgid, const char *passwd);
+int _app2sd_get_info_from_db(const char *filename, char **pkgid, uid_t *uid);
int _app2sd_force_clean(const char *pkgid, const char *application_path,
- const char *loopback_device);
+ const char *loopback_device, uid_t uid);
#endif
}
value = g_dbus_proxy_call_sync(proxy, method_name, param,
- G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ G_DBUS_CALL_FLAGS_NONE, G_MAXINT, NULL, &error);
if (error != NULL) {
_E("proxy call sync error(%s)", error->message);
g_error_free(error);
g_variant_builder_add(builder, "(si)", item->name, item->type);
}
+static int __app2sd_delete_temp_directories(const char *pkgid,
+ app2sd_cmd cmd, uid_t uid)
+{
+ int ret = 0;
+ char temp_path[FILENAME_MAX] = { 0, };
+
+ if (cmd != APP2SD_PRE_UPGRADE)
+ return APP2EXT_SUCCESS;
+
+ if (_is_global(uid)) {
+ snprintf(temp_path, FILENAME_MAX - 1, "%s/%s.new",
+ tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
+ } else {
+ tzplatform_set_user(uid);
+ snprintf(temp_path, FILENAME_MAX - 1, "%s/%s.new",
+ tzplatform_getenv(TZ_USER_APP), pkgid);
+ tzplatform_reset_user();
+ }
+
+ /* this will delete all files under temp_path */
+ ret = _app2sd_delete_directory(temp_path);
+ if (ret) {
+ _E("unable to delete (%s)", temp_path);
+ return APP2EXT_ERROR_DELETE_DIRECTORY;
+ }
+
+ return APP2EXT_SUCCESS;
+}
+
static int __app2sd_create_default_directories(const char *pkgid,
app2sd_cmd cmd, uid_t uid)
{
mode_t mode = DIR_PERMS;
char application_path[FILENAME_MAX] = { 0, };
char application_mmc_path[FILENAME_MAX] = { 0, };
+ char temp_path[FILENAME_MAX] = { 0, };
if (_is_global(uid)) {
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
}
if (cmd == APP2SD_PRE_UPGRADE) {
+ /* application_path for {pkgid}.new */
+ snprintf(temp_path, FILENAME_MAX - 1, "%s.new",
+ application_path);
+ ret = mkdir(temp_path, mode);
+ if (ret) {
+ if (errno != EEXIST) {
+ _E("create directory failed," \
+ " error no is (%d)", errno);
+ return APP2EXT_ERROR_CREATE_DIRECTORY;
+ }
+ }
+ /* application_mmc_path for {pkgid}.new */
+ snprintf(application_mmc_path, FILENAME_MAX - 1, "%s/.mmc",
+ temp_path);
+ ret = mkdir(application_mmc_path, mode);
+ if (ret) {
+ if (errno != EEXIST) {
+ _E("create directory failed," \
+ " error no is (%d)", errno);
+ return APP2EXT_ERROR_CREATE_DIRECTORY;
+ }
+ }
}
return APP2EXT_SUCCESS;
}
-int app2sd_client_usr_pre_app_install(const char *pkgid, GList* dir_list,
+int app2sd_client_usr_pre_app_install(const char *pkgid, GList *dir_list,
int size, uid_t uid)
{
int ret = 0;
return ret;
}
-int app2sd_client_pre_app_install(const char *pkgid, GList* dir_list,
+int app2sd_client_pre_app_install(const char *pkgid, GList *dir_list,
int size)
{
int ret = 0;
return ret;
}
-int app2sd_client_usr_pre_app_upgrade(const char *pkgid, GList* dir_list,
+int app2sd_client_usr_pre_app_upgrade(const char *pkgid, GList *dir_list,
int size, uid_t uid)
{
int ret = 0;
if (builder)
g_variant_builder_unref(builder);
+ ret = __app2sd_delete_temp_directories(pkgid,
+ APP2SD_PRE_UPGRADE, uid);
+
return ret;
}
-int app2sd_client_pre_app_upgrade(const char *pkgid, GList* dir_list,
+int app2sd_client_pre_app_upgrade(const char *pkgid, GList *dir_list,
int size)
{
int ret = 0;
return ret;
}
+int app2sd_client_enable_full_pkg(void)
+{
+ int ret = 0;
+
+ ret = __app2sd_call_server_method("EnableFullPkg", NULL);
+
+ return ret;
+}
+
+int app2sd_client_disable_full_pkg(void)
+{
+ int ret = 0;
+
+ ret = __app2sd_call_server_method("DisableFullPkg", NULL);
+
+ return ret;
+}
+
int app2sd_client_usr_on_demand_setup_init(const char *pkgid, uid_t uid)
{
int ret = 0;
return ret;
}
-int app2sd_client_usr_move_installed_app(const char *pkgid, GList* dir_list,
+int app2sd_client_usr_move_installed_app(const char *pkgid, GList *dir_list,
app2ext_move_type move_type, uid_t uid)
{
int ret = 0;
return ret;
}
-int app2sd_client_move_installed_app(const char *pkgid, GList* dir_list,
+int app2sd_client_move_installed_app(const char *pkgid, GList *dir_list,
app2ext_move_type move_type)
{
int ret = 0;
interface->client_force_clean = app2sd_client_force_clean;
interface->client_enable = app2sd_client_on_demand_setup_init;
interface->client_disable = app2sd_client_on_demand_setup_exit;
+ interface->client_enable_full_pkg = app2sd_client_enable_full_pkg;
+ interface->client_disable_full_pkg = app2sd_client_disable_full_pkg;
interface->client_move = app2sd_client_move_installed_app;
interface->client_usr_pre_install = app2sd_client_usr_pre_app_install;
return APP2EXT_SUCCESS;
}
-int app2sd_usr_pre_app_install(const char *pkgid, GList* dir_list, int size, uid_t uid)
+int app2sd_usr_pre_app_install(const char *pkgid, GList *dir_list, int size, uid_t uid)
{
int ret = 0;
int free_mmc_mem = 0;
}
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
- if (encoded_id == NULL) {
+ if (encoded_id == NULL)
return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
- }
+
if (_is_global(uid)) {
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
/* mount the loopback encrypted pseudo device on application
* installation path as with Read Write permission
*/
- ret =_app2sd_mount_app_content(application_path, pkgid,
+ ret = _app2sd_mount_app_content(application_path, pkgid,
device_node, MOUNT_TYPE_RW, dir_list,
APP2SD_PRE_INSTALL, uid);
if (ret) {
sync();
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
- if (encoded_id == NULL) {
+ if (encoded_id == NULL)
return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
- }
+
if (_is_global(uid)) {
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
/* get the associated device node for SD card applicationer */
device_name = _app2sd_find_associated_device_node(loopback_device);
- if (NULL == device_name) {
+ if (NULL == device_name)
return APP2EXT_ERROR_FIND_ASSOCIATED_DEVICE_NODE;
- }
ret = _app2sd_unmount_app_content(application_path);
if (ret) {
_E("unable to delete the loopback device from the SD Card");
return APP2EXT_ERROR_DELETE_LOOPBACK_DEVICE;
}
- ret = _app2sd_remove_password_from_db(pkgid);
-
+ ret = _app2sd_remove_info_from_db(pkgid, uid);
if (ret)
- _E("unable to delete the password");
+ _E("unable to delete info");
ret = _app2sd_delete_directory(application_path);
if (ret)
}
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
- if (encoded_id == NULL) {
+ if (encoded_id == NULL)
return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
- }
+
/* check app entry is there in sd card or not. */
if (_is_global(uid)) {
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
}
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
- if (encoded_id == NULL) {
+ if (encoded_id == NULL)
return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
- }
+
/* check app entry is there in sd card or not. */
if (_is_global(uid)) {
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
}
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
- if (encoded_id == NULL) {
+ if (encoded_id == NULL)
return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
- }
+
if (_is_global(uid)) {
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
}
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
- if (encoded_id == NULL) {
+ if (encoded_id == NULL)
return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
- }
+
if (_is_global(uid)) {
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
goto END;
}
- ret = _app2sd_remove_password_from_db(pkgid);
+ ret = _app2sd_remove_info_from_db(pkgid, uid);
if (ret) {
- _E("cannot remove password from db");
+ _E("cannot remove info from db");
ret = APP2EXT_ERROR_SQLITE_REGISTRY;
goto END;
}
return ret;
}
-int app2sd_usr_move_installed_app(const char *pkgid, GList* dir_list,
+int app2sd_usr_move_installed_app(const char *pkgid, GList *dir_list,
app2ext_move_type move_type, uid_t uid)
{
int ret = 0;
return APP2EXT_SUCCESS;
}
-int app2sd_usr_pre_app_upgrade(const char *pkgid, GList* dir_list,
+int app2sd_usr_pre_app_upgrade(const char *pkgid, GList *dir_list,
int size, uid_t uid)
{
int ret = APP2EXT_SUCCESS;
int reqd_disk_size = size + ceil(size * 0.2);
/* validate function arguments*/
- if (pkgid == NULL || dir_list == NULL || size<=0) {
+ if (pkgid == NULL || dir_list == NULL || size <= 0) {
_E("invalid function arguments");
return APP2EXT_ERROR_INVALID_ARGUMENTS;
}
}
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
- if (encoded_id == NULL) {
+ if (encoded_id == NULL)
return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
- }
+
if (_is_global(uid)) {
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
_E("memory alloc failed");
return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
}
- snprintf(temp_pkgid, len, "%s.new", pkgid);
+ snprintf(temp_pkgid, len + 1, "%s.new", pkgid);
if (_is_global(uid)) {
len = strlen(tzplatform_getenv(TZ_SYS_RW_APP)) + strlen(temp_pkgid) + 1;
free(temp_pkgid);
return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
}
- snprintf(temp_application_path, len, "%s/%s",
+ snprintf(temp_application_path, len + 1, "%s/%s",
tzplatform_getenv(TZ_SYS_RW_APP), temp_pkgid);
temp_encoded_id = _app2sd_get_encoded_name((const char *)temp_pkgid, uid);
free(temp_encoded_id);
return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
}
- snprintf(temp_loopback_device, len, "%s/%s",
+ snprintf(temp_loopback_device, len + 1, "%s/%s",
APP2SD_PATH, temp_encoded_id);
free(temp_encoded_id);
} else {
free(temp_pkgid);
return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
}
- snprintf(temp_application_path, len, "%s/%s",
+ snprintf(temp_application_path, len + 1, "%s/%s",
tzplatform_getenv(TZ_USER_APP), temp_pkgid);
- temp_encoded_id = _app2sd_get_encoded_name((const char*)temp_pkgid, uid);
+ temp_encoded_id = _app2sd_get_encoded_name((const char *)temp_pkgid, uid);
if (temp_encoded_id == NULL) {
free(temp_pkgid);
free(temp_application_path);
free(temp_encoded_id);
return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
}
- snprintf(temp_loopback_device, len, "%s/%s",
+ snprintf(temp_loopback_device, len + 1, "%s/%s",
APP2SD_PATH, temp_encoded_id);
free(temp_encoded_id);
tzplatform_reset_user();
}
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
- if (encoded_id == NULL) {
+ if (encoded_id == NULL)
return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
- }
+
if (_is_global(uid)) {
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
/* get the associated device node for SD card applicationer */
device_name = _app2sd_find_associated_device_node(loopback_device);
- if (NULL == device_name) {
+ if (NULL == device_name)
return APP2EXT_ERROR_FIND_ASSOCIATED_DEVICE_NODE;
- }
ret = _app2sd_unmount_app_content(application_path);
if (ret) {
sync();
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
- if (encoded_id == NULL) {
+ if (encoded_id == NULL)
return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
- }
+
if (_is_global(uid)) {
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
}
free(encoded_id);
- ret = _app2sd_force_clean(pkgid, application_path, loopback_device);
+ ret = _app2sd_force_clean(pkgid, application_path, loopback_device, uid);
+
+ return ret;
+}
+
+int app2sd_enable_full_pkg(void)
+{
+ int ret = APP2EXT_SUCCESS;
+ int rc = 0;
+ char buf[FILENAME_MAX] = { 0, };
+ char loopback_device[FILENAME_MAX] = { 0, };
+ DIR *dir = NULL;
+ struct dirent entry;
+ struct dirent *result = NULL;
+ char *pkgid = NULL;
+ uid_t uid = 0;
+
+ dir = opendir(APP2SD_PATH);
+ if (!dir) {
+ if (strerror_r(errno, buf, sizeof(buf)) == 0)
+ _E("failed to opendir (%s)", buf);
+ return APP2EXT_ERROR_OPEN_DIR;
+ }
+
+ ret = _app2sd_initialize_db();
+ if (ret) {
+ _E("app2sd db initialize failed");
+ return APP2EXT_ERROR_SQLITE_REGISTRY;
+ }
+
+ for (rc = readdir_r(dir, &entry, &result);
+ rc == 0 && result != NULL;
+ rc = readdir_r(dir, &entry, &result)) {
+ if (strcmp(entry.d_name, ".") == 0 ||
+ strcmp(entry.d_name, "..") == 0)
+ continue;
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
+ APP2SD_PATH, entry.d_name);
+ ret = _app2sd_get_info_from_db(loopback_device,
+ &pkgid, &uid);
+ if (ret) {
+ _E("failed to get info from db");
+ break;;
+ }
+ if (pkgid && uid > 0) {
+ _D("pkgid(%s), uid(%d)", pkgid, uid);
+ ret = app2sd_usr_on_demand_setup_init(pkgid, uid);
+ if (ret) {
+ _E("error(%d)", ret);
+ break;
+ }
+ }
+ if (pkgid) {
+ free(pkgid);
+ pkgid = NULL;
+ }
+ }
+
+ if (pkgid) {
+ free(pkgid);
+ pkgid = NULL;
+ }
+ closedir(dir);
+
+ return ret;
+}
+
+int app2sd_disable_full_pkg(void)
+{
+ int ret = APP2EXT_SUCCESS;
+ int rc = 0;
+ char buf[FILENAME_MAX] = { 0, };
+ char loopback_device[FILENAME_MAX] = { 0, };
+ DIR *dir = NULL;
+ struct dirent entry;
+ struct dirent *result = NULL;
+ char *pkgid = NULL;
+ uid_t uid = 0;
+
+ dir = opendir(APP2SD_PATH);
+ if (!dir) {
+ if (strerror_r(errno, buf, sizeof(buf)) == 0)
+ _E("failed to opendir (%s)", buf);
+ return APP2EXT_ERROR_OPEN_DIR;
+ }
+
+ ret = _app2sd_initialize_db();
+ if (ret) {
+ _E("app2sd db initialize failed");
+ return APP2EXT_ERROR_SQLITE_REGISTRY;
+ }
+
+ for (rc = readdir_r(dir, &entry, &result);
+ rc == 0 && result != NULL;
+ rc = readdir_r(dir, &entry, &result)) {
+ if (strcmp(entry.d_name, ".") == 0 ||
+ strcmp(entry.d_name, "..") == 0)
+ continue;
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
+ APP2SD_PATH, entry.d_name);
+ ret = _app2sd_get_info_from_db(loopback_device,
+ &pkgid, &uid);
+ if (ret) {
+ _E("failed to get info from db");
+ break;
+ }
+ if (pkgid && uid > 0) {
+ _D("pkgid(%s), uid(%d)", pkgid, uid);
+ ret = app2sd_usr_on_demand_setup_exit(pkgid, uid);
+ if (ret) {
+ _E("error(%d)", ret);
+ break;
+ }
+ }
+ if (pkgid) {
+ free(pkgid);
+ pkgid = NULL;
+ }
+ }
+
+ if (pkgid) {
+ free(pkgid);
+ pkgid = NULL;
+ }
+ closedir(dir);
return ret;
}
#include "app2sd_internals.h"
-static int _app2sd_make_directory(const char* path, uid_t uid)
+static int _app2sd_make_directory(const char *path, uid_t uid)
{
int ret = 0;
int fd = -1;
return NULL;
}
memset(ret_result, '\0', strlen(result) + 1);
- if (strlen(result) > 0) {
+ if (strlen(result) > 0)
memcpy(ret_result, result, strlen(result) - 1);
- }
+
free(result);
result = NULL;
return NULL;
}
- if ((passwd = _app2sd_get_password_from_db(pkgid)) == NULL) {
+ if ((passwd = _app2sd_get_password_from_db(pkgid, uid)) == NULL) {
passwd = (char *)_app2sd_generate_password(pkgid);
if (NULL == passwd) {
_E("unable to generate password");
return NULL;
} else {
- if ((ret = _app2sd_set_password_in_db(pkgid,
- passwd)) < 0) {
- _E("unable to save password");
+ if ((ret = _app2sd_set_info_in_db(pkgid,
+ passwd, loopback_device, uid)) < 0) {
+ _E("unable to save info");
free(passwd);
passwd = NULL;
return NULL;
char *_app2sd_do_loopback_duplicate_encryption_setup(const char *pkgid,
const char *temp_pkgid, const char *temp_loopback_device,
- uid_t uid)
+ char *passwd, uid_t uid)
{
- int ret = APP2EXT_SUCCESS;
- char *passwd = NULL;
char *result = NULL;
char *device_node = NULL;
if (pkgid == NULL || temp_pkgid == NULL ||
- temp_loopback_device == NULL) {
+ temp_loopback_device == NULL || passwd == NULL) {
_E("invalid argument");
return NULL;
}
- /* get password for loopback encryption */
- ret = _app2sd_initialize_db();
- if (ret) {
- _E("app2sd db initialize failed");
- return NULL;
- }
-
- if ((passwd = _app2sd_get_password_from_db(pkgid)) == NULL) {
- passwd = (char *)_app2sd_generate_password(pkgid);
- if (NULL == passwd) {
- _E("unable to generate password");
- return NULL;
- } else {
- if ((ret = _app2sd_set_password_in_db(pkgid,
- passwd)) < 0) {
- _E("unable to save password");
- free(passwd);
- passwd = NULL;
- return NULL;
- }
- }
- }
-
/* get free device node*/
device_node = _app2sd_create_loopdevice_node();
if (NULL == device_node) {
- free(passwd);
- passwd = NULL;
_E("unable to find free loopback node");
return NULL;
}
temp_loopback_device, passwd);
if (result == NULL) {
_E("encryption failed");
- free(passwd);
- passwd = NULL;
return NULL;
} else {
if (strlen(result) == 0) {
free(result);
result = NULL;
- free(passwd);
- passwd = NULL;
return device_node;
} else {
_E("error is (%s)", result);
free(result);
result = NULL;
- free(passwd);
- passwd = NULL;
return NULL;
}
}
int ret = APP2EXT_SUCCESS;
char *result = NULL;
char *dev_node = NULL;
- while(1) {
+ while (1) {
if ((dev_node =
_app2sd_find_associated_device_node(loopback_device))
== NULL) {
snprintf(command, FILENAME_MAX - 1, "of=%s", loopback_device);
snprintf(buff, BUF_SIZE - 1, "count=%d", size);
- const char *argv1[] =
- { "dd", "if=/dev/zero", command, "bs=1M", buff, NULL };
+ const char *argv1[] = { "dd", "if=/dev/zero",
+ command, "bs=1M", buff, NULL };
if ((fp = fopen(loopback_device, "r+")) != NULL) {
_W("encrypted file already exists (%s)",
ret = unlink(loopback_device);
if (ret) {
if (errno == ENOENT) {
- _E("unable to access file (%s)", loopback_device);
+ _W("unable to access file (%s)", loopback_device);
} else {
_E("unable to delete (%s)", loopback_device);
return APP2EXT_ERROR_DELETE_LOOPBACK_DEVICE;
}
}
- return ret;
+ return APP2EXT_SUCCESS;
}
int _app2sd_create_file_system(const char *device_path)
}
static int _app2sd_create_directory_entry(const char *application_path,
- const char *pkgid, GList* dir_list, uid_t uid)
+ const char *pkgid, GList *dir_list, uid_t uid)
{
int ret = APP2EXT_SUCCESS;
GList *list = NULL;
- app2ext_dir_details* dir_detail = NULL;
+ app2ext_dir_details *dir_detail = NULL;
list = g_list_first(dir_list);
while (list) {
&& dir_detail->type == APP2EXT_DIR_RO) {
ret = _app2sd_create_dir_with_link(application_path,
pkgid, dir_detail->name, uid);
- if (ret) {
+ if (ret)
return ret;
- }
}
list = g_list_next(list);
}
}
int _app2sd_mount_app_content(const char *application_path, const char *pkgid,
- const char *dev, int mount_type, GList* dir_list,
+ const char *dev, int mount_type, GList *dir_list,
app2sd_cmd cmd, uid_t uid)
{
int ret = APP2EXT_SUCCESS;
return ret;
}
-int _app2sd_move_app_to_external(const char *pkgid, GList* dir_list, uid_t uid)
+int _app2sd_move_app_to_external(const char *pkgid, GList *dir_list, uid_t uid)
{
int ret = APP2EXT_SUCCESS;
mode_t mode = DIR_PERMS;
int free_mmc_mem = 0;
FILE *fp = NULL;
GList *list = NULL;
- app2ext_dir_details* dir_detail = NULL;
- char err_buf[1024] = {0,};
+ app2ext_dir_details *dir_detail = NULL;
+ char err_buf[1024] = { 0,};
char *encoded_id = NULL;
/* check whether MMC is present or not */
}
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
- if (encoded_id == NULL) {
+ if (encoded_id == NULL)
return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
- }
+
snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
APP2SD_PATH, encoded_id);
free(encoded_id);
_W("Already %s entry is present in the SD Card, " \
"delete entry and go on without return", pkgid);
fclose(fp);
- _app2sd_force_clean(pkgid, application_path, loopback_device);
+ _app2sd_force_clean(pkgid, application_path, loopback_device, uid);
}
snprintf(application_mmc_path, FILENAME_MAX - 1, "%s/.mmc",
list = g_list_next(list);
}
- reqd_size = ((total_size) / ( 1024 * 1024)) + 2;
+ reqd_size = ((total_size) / (1024 * 1024)) + 2;
reqd_disk_size = reqd_size + ceil(reqd_size * 0.2);
/* find avialable free memory in the MMC card */
return APP2EXT_SUCCESS;
}
-int _app2sd_move_app_to_internal(const char *pkgid, GList* dir_list, uid_t uid)
+int _app2sd_move_app_to_internal(const char *pkgid, GList *dir_list, uid_t uid)
{
int ret = APP2EXT_SUCCESS;
mode_t mode = DIR_PERMS;
char *device_node = NULL;
FILE *fp = NULL;
GList *list = NULL;
- app2ext_dir_details* dir_detail = NULL;
+ app2ext_dir_details *dir_detail = NULL;
int reqd_size = 0;
int free_internal_mem = 0;
struct statvfs buf = {0,};
}
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
- if (encoded_id == NULL) {
+ if (encoded_id == NULL)
return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
- }
+
snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
APP2SD_PATH, encoded_id);
free(encoded_id);
memset((void *)&buf, '\0', sizeof(struct statvfs));
ret = statvfs(INTERNAL_STORAGE_PATH, &buf);
- if (0 == ret){
+ if (0 == ret) {
temp = (buf.f_bsize * buf.f_bavail) / (1024 * 1024);
free_internal_mem = (int)temp;
} else {
return APP2EXT_ERROR_DELETE_DIRECTORY;
}
+ /* remove passwrd from DB */
+ ret = _app2sd_initialize_db();
+ if (ret)
+ _E("app2sd db initialize failed");
+
+ ret = _app2sd_remove_info_from_db(pkgid, uid);
+ if (ret)
+ _E("cannot remove info from db");
+
return APP2EXT_SUCCESS;
}
int _app2sd_usr_move_app(const char *pkgid, app2ext_move_type move_type,
- GList* dir_list, uid_t uid)
+ GList *dir_list, uid_t uid)
{
int ret = APP2EXT_SUCCESS;
return ret;
}
-int _app2sd_copy_ro_content(const char *src, const char *dest, GList* dir_list)
+int _app2sd_copy_ro_content(const char *src, const char *dest, GList *dir_list)
{
char path[FILENAME_MAX] = { 0, };
int ret = APP2EXT_SUCCESS;
GList *list = NULL;
- app2ext_dir_details* dir_detail = NULL;
+ app2ext_dir_details *dir_detail = NULL;
list = g_list_first(dir_list);
while (list) {
const char *temp_pkgid,
const char *temp_application_path,
const char *temp_loopback_device,
- GList* dir_list, char *dev_node, int size,
+ GList *dir_list, char *dev_node, int size,
uid_t uid)
{
int ret = 0;
char *devi = NULL;
int err_res = 0;
char *result = NULL;
+ char *passwd = NULL;
/* create a new loopback device */
ret = _app2sd_create_loopback_device(temp_pkgid,
return ret;
}
+ /* get password for loopback encryption */
+ ret = _app2sd_initialize_db();
+ if (ret) {
+ _E("app2sd db initialize failed");
+ return APP2EXT_ERROR_DB_INITIALIZE;
+ }
+
+ if ((passwd = _app2sd_get_password_from_db(pkgid, uid)) == NULL) {
+ passwd = (char *)_app2sd_generate_password(pkgid);
+ if (NULL == passwd) {
+ _E("unable to generate password");
+ return APP2EXT_ERROR_PASSWD_GENERATION;
+ } else {
+ if ((ret = _app2sd_set_info_in_db(pkgid,
+ passwd, loopback_device, uid)) < 0) {
+ _E("unable to save info");
+ free(passwd);
+ passwd = NULL;
+ return APP2EXT_ERROR_SQLITE_REGISTRY;
+ }
+ }
+ }
+
/* perform loopback encryption setup */
dev_node = _app2sd_do_loopback_duplicate_encryption_setup(pkgid,
- temp_pkgid, temp_loopback_device, uid);
+ temp_pkgid, temp_loopback_device, passwd, uid);
if (!dev_node) {
_E("losetup failed, device node is (%s)", dev_node);
_app2sd_delete_loopback_device(loopback_device);
- _E("create ext filesystem failed");
+ free(passwd);
+ passwd = NULL;
return APP2EXT_ERROR_DO_LOSETUP;
}
+ free(passwd);
+ passwd = NULL;
_D("duplicate setup SUCCESS");
/* check whether loopback device is associated with
const char *temp_pkgid,
const char *temp_loopback_device,
const char *temp_application_path,
- int size, GList* dir_list,
+ int size, GList *dir_list,
uid_t uid)
{
int ret = 0;
}
ret = _app2sd_remove_loopback_encryption_setup(loopback_device);
- if (ret) {
+ if (ret)
_E("unable to remove loopback setup");
- err_res = APP2EXT_ERROR_DELETE_LOOPBACK_DEVICE;
- }
+
+ ret = _app2sd_remove_loopback_encryption_setup(temp_loopback_device);
+ if (ret)
+ _E("unable to remove loopback setup");
+
+ _app2sd_delete_loopback_device(temp_loopback_device);
+
+ ret = _app2sd_delete_directory(temp_application_path);
+ if (ret)
+ _E("unable to delete (%s)", temp_application_path);
return err_res;
}
int _app2sd_force_clean(const char *pkgid, const char *application_path,
- const char *loopback_device)
+ const char *loopback_device, uid_t uid)
{
int ret = APP2EXT_SUCCESS;
/* unmount the loopback encrypted pseudo device from the application installation path */
ret = _app2sd_unmount_app_content(application_path);
- if (ret) {
+ if (ret)
_E("unable to unmount the app content (%d)", ret);
- }
/* detach the loopback encryption setup for the application */
ret = _app2sd_remove_all_loopback_encryption_setups(loopback_device);
- if (ret) {
+ if (ret)
_E("unable to detach the loopback encryption setup for the application");
- }
/* delete the loopback device from the SD card */
ret = _app2sd_delete_loopback_device(loopback_device);
- if (ret) {
+ if (ret)
_E("unable to detach the loopback encryption setup for the application");
- }
/* delete symlink */
_app2sd_delete_symlink(application_path);
/* remove passwrd from DB */
ret = _app2sd_initialize_db();
- if (ret) {
+ if (ret)
_E("app2sd db initialize failed");
- }
- ret = _app2sd_remove_password_from_db(pkgid);
- if (ret) {
- _E("cannot remove password from db");
- }
+
+ ret = _app2sd_remove_info_from_db(pkgid, uid);
+ if (ret)
+ _E("cannot remove info from db");
+
return ret;
}
/*sqlite db code*/
#define APP2SD_DB_FILE tzplatform_mkpath(TZ_SYS_DB, ".app2sd.db")
sqlite3 *app2sd_db;
-#define QUERY_CREATE_TABLE_APP2SD "create table app2sd \
- (pkgid text primary key,\
- password text\
- )"
+#define QUERY_CREATE_TABLE_APP2SD "CREATE TABLE IF NOT EXISTS app2sd_info " \
+ "(pkgid TEXT PRIMARY KEY NOT NULL, password TEXT NOT NULL, " \
+ "filename TEXT NOT NULL, uid INTEGER)"
int _app2sd_initialize_db()
{
char *error_message = NULL;
int ret;
- FILE * fp = NULL;
+ FILE *fp = NULL;
fp = fopen(APP2SD_DB_FILE, "r");
if (fp != NULL) {
return 0;
}
-int _app2sd_set_password_in_db(const char *pkgid, const char *passwd)
+static int _app2sd_check_existing_info(const char *pkgid, uid_t uid)
+{
+ char *query = NULL;
+ const char *val = NULL;
+ sqlite3_stmt *stmt = NULL;
+ int ret = 0;
+
+ query = sqlite3_mprintf("select count(*) from app2sd_info " \
+ "where pkgid=%Q and uid=%d", pkgid, uid);
+
+ ret = sqlite3_prepare_v2(app2sd_db, query, strlen(query), &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ _E("prepare failed (%s)", sqlite3_errmsg(app2sd_db));
+ sqlite3_free(query);
+ return -1;
+ }
+
+ if (sqlite3_step(stmt) != SQLITE_ROW) {
+ _E("failed to step");
+ sqlite3_finalize(stmt);
+ return -1;
+ }
+
+ val = (const char *)sqlite3_column_text(stmt, 0);
+ ret = atoi(val);
+ sqlite3_finalize(stmt);
+
+ return ret;
+}
+
+int _app2sd_set_info_in_db(const char *pkgid, const char *passwd,
+ const char *loopback_device, uid_t uid)
{
char *error_message = NULL;
char *query = NULL;
+ int ret = 0;
- query = sqlite3_mprintf("insert into app2sd" \
- "(pkgid, password) values (%Q, %Q)", pkgid, passwd);
+ ret = _app2sd_check_existing_info(pkgid, uid);
+ if (ret < 0) {
+ _E("failed to get existing info");
+ return APP2EXT_ERROR_SQLITE_REGISTRY;
+ }
- if (SQLITE_OK != sqlite3_exec(app2sd_db, query, NULL, NULL,
- &error_message)) {
- _E("don't execute query = (%s), error message = (%s)",
+ if (ret == 0)
+ query = sqlite3_mprintf("insert into app2sd_info " \
+ "(pkgid, password, filename, uid) values (%Q, %Q, %Q, %d)",
+ pkgid, passwd, loopback_device, uid);
+ else
+ query = sqlite3_mprintf("update app2sd_info " \
+ "set password=%Q, filename=%Q where pkgid=%Q and uid=%d",
+ passwd, loopback_device, pkgid, uid);
+
+ ret = sqlite3_exec(app2sd_db, query, NULL, NULL, &error_message);
+ if (ret != SQLITE_OK) {
+ _E("failed to execute query(%s), error message(%s)",
query, error_message);
sqlite3_free(query);
return APP2EXT_ERROR_SQLITE_REGISTRY;
return APP2EXT_SUCCESS;
}
-int _app2sd_remove_password_from_db(const char *pkgid)
+int _app2sd_remove_info_from_db(const char *pkgid, uid_t uid)
{
char *error_message = NULL;
char *query = NULL;
+ int ret = 0;
+
+ query = sqlite3_mprintf("delete from app2sd_info " \
+ "where pkgid=%Q and uid=%d", pkgid, uid);
+
+ ret = sqlite3_exec(app2sd_db, query, NULL, NULL, &error_message);
+ if (ret != SQLITE_OK) {
+ _E("failed to execute query(%s), error message(%s)",
+ query, error_message);
+ sqlite3_free(query);
+ return APP2EXT_ERROR_SQLITE_REGISTRY;
+ }
+ sqlite3_free(query);
+
+ return APP2EXT_SUCCESS;
+}
+
+int _app2sd_get_info_from_db(const char *filename, char **pkgid, uid_t *uid)
+{
+ char *query = NULL;
+ sqlite3_stmt *stmt = NULL;
+ int ret = APP2EXT_SUCCESS;
- query = sqlite3_mprintf("delete from app2sd" \
- " where pkgid=%Q", pkgid);
+ _D("filename(%s)", filename);
+ query = sqlite3_mprintf("select * from app2sd_info " \
+ "where filename=%Q", filename);
- if (SQLITE_OK != sqlite3_exec(app2sd_db, query, NULL,
- NULL, &error_message)) {
- _E("don't execute query = (%s), "
- "error message = (%s)", query, error_message);
+ ret = sqlite3_prepare_v2(app2sd_db, query, strlen(query), &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ _E("prepare failed (%s)", sqlite3_errmsg(app2sd_db));
sqlite3_free(query);
+ *pkgid = NULL;
+ *uid = 0;
return APP2EXT_ERROR_SQLITE_REGISTRY;
}
+ ret = sqlite3_step(stmt);
+ if (ret != SQLITE_ROW || ret == SQLITE_DONE) {
+ _W("no records found");
+ ret = APP2EXT_SUCCESS;
+ goto FINISH_OFF;
+ }
+
+ *pkgid = strdup((const char *)sqlite3_column_text(stmt, 0));
+ if (*pkgid == NULL) {
+ _E("out of memory");
+ ret = APP2EXT_ERROR_SQLITE_REGISTRY;
+ goto FINISH_OFF;
+ }
+
+ *uid = sqlite3_column_int(stmt, 3);
+ if (*uid != GLOBAL_USER && *uid < REGULAR_USER) {
+ _E("invalid uid");
+ ret = APP2EXT_ERROR_SQLITE_REGISTRY;
+ goto FINISH_OFF;
+ }
+
+ if (SQLITE_OK != sqlite3_finalize(stmt)) {
+ _E("error : sqlite3_finalize");
+ ret = APP2EXT_ERROR_SQLITE_REGISTRY;
+ goto FINISH_OFF;
+ }
sqlite3_free(query);
return APP2EXT_SUCCESS;
+
+FINISH_OFF:
+ if (*pkgid) {
+ free(*pkgid);
+ *pkgid = NULL;
+ }
+ *uid = 0;
+
+ sqlite3_finalize(stmt);
+ sqlite3_free(query);
+
+ return ret;
}
-char *_app2sd_get_password_from_db(const char *pkgid)
+char *_app2sd_get_password_from_db(const char *pkgid, uid_t uid)
{
char *query = NULL;
char *passwd = NULL;
- const char *tail = NULL;
sqlite3_stmt *stmt = NULL;
- int rc = 0;
+ int ret = 0;
- query = sqlite3_mprintf("select * from app2sd" \
- " where pkgid=%Q", pkgid);
+ query = sqlite3_mprintf("select * from app2sd_info " \
+ "where pkgid=%Q and uid=%d", pkgid, uid);
- if (SQLITE_OK != sqlite3_prepare(app2sd_db, query,
- strlen(query), &stmt, &tail)) {
- _E("sqlite3_prepare error");
+ ret = sqlite3_prepare_v2(app2sd_db, query, strlen(query), &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ _E("prepare failed (%s)", sqlite3_errmsg(app2sd_db));
sqlite3_free(query);
return NULL;
}
- rc = sqlite3_step(stmt);
- if (rc != SQLITE_ROW || rc == SQLITE_DONE) {
- _E("no records found");
+ ret = sqlite3_step(stmt);
+ if (ret != SQLITE_ROW || ret == SQLITE_DONE) {
+ _W("no records found");
goto FINISH_OFF;
}
passwd = malloc(PASSWORD_LENGTH + 1);
goto FINISH_OFF;
}
- strncpy(passwd, (const char*)sqlite3_column_text(stmt, 1),
+ strncpy(passwd, (const char *)sqlite3_column_text(stmt, 1),
PASSWORD_LENGTH);
if (passwd == NULL) {
_E("data is NULL");
return passwd;
FINISH_OFF:
- rc = sqlite3_finalize(stmt);
- if (rc != SQLITE_OK) {
- _E("sqlite3_finalize failed(%d)", rc);
- }
- sqlite3_free(query);
-
if (passwd)
free(passwd);
+ sqlite3_finalize(stmt);
+ sqlite3_free(query);
+
return NULL;
}
return 0;
}
-int _app2sd_delete_directory(const char *dirname)
-{
- DIR *dp = NULL;
- struct dirent ep;
- struct dirent *er = NULL;
- char abs_filename[FILENAME_MAX] = { 0, };
- int ret = 0;
-
- dp = opendir(dirname);
- if (dp != NULL) {
- while (readdir_r(dp, &ep, &er) == 0 && er != NULL) {
- struct stat stFileInfo;
-
- snprintf(abs_filename, FILENAME_MAX, "%s/%s", dirname,
- ep.d_name);
-
- if (lstat(abs_filename, &stFileInfo) < 0) {
- perror(abs_filename);
- (void)closedir(dp);
- return -1;
- }
-
- if (S_ISDIR(stFileInfo.st_mode)) {
- if (strcmp(ep.d_name, ".")
- && strcmp(ep.d_name, "..")) {
- ret = _app2sd_delete_directory(abs_filename);
- if (ret <0) {
- (void)closedir(dp);
- return -1;
- }
- }
- } else {
- ret = remove(abs_filename);
- if (ret <0) {
- (void)closedir(dp);
- return -1;
- }
- }
- }
- (void)closedir(dp);
- ret = remove(dirname);
- if (ret <0)
- return -1;
- } else {
- _W("couldn't open the directory[%s]", dirname);
- }
- return 0;
-}
-
void _app2sd_delete_symlink(const char *dirname)
{
int ret = 0;
/*get realpath find symlink to ".mmc" and unlink it*/
snprintf(abs_filename, FILENAME_MAX, "%s/%s", dirname, ep.d_name);
char *path = realpath(abs_filename, mmc_path);
- if(!path){
+ if (!path)
_E("realpath failed");
- }
- if (strstr(mmc_path,".mmc")) {
+ if (strstr(mmc_path, ".mmc")) {
_E("force unlink [%s]", abs_filename);
if (unlink(abs_filename)) {
- if (errno == ENOENT) {
+ if (errno == ENOENT)
_E("Unable to access file %s", abs_filename);
- } else {
+ else
_E("Unable to delete %s", abs_filename);
- }
}
}
/*delete ".mmc" folder*/
snprintf(abs_filename, FILENAME_MAX, "%s/.mmc", dirname);
ret = remove(abs_filename);
- if (ret == -1) {
+ if (ret == -1)
return;
- }
} else {
_E("couldn't open the directory[%s]", dirname);
}
const char *loopback_device, char *passwd)
{
/* TODO : change to dm-crypt */
- const char *argv[] =
- { "/sbin/losetup", device, loopback_device, NULL };
+ const char *argv[] = { "/sbin/losetup", device,
+ loopback_device, NULL };
pid_t pid = 0;
int my_pipe[2] = { 0, };
char buf[FILENAME_MAX] = { 0, };
char *ret_result = NULL;
int result = 0;
- char err_buf[1024] = {0,};
+ char err_buf[1024] = { 0,};
if (pipe(my_pipe) < 0) {
fprintf(stderr, "Unable to create pipe\n");
while (line) {
if (strstr(line, loopback_device) != NULL) {
_D("found: (%s)", line);
- if (ret_result) {
+ if (ret_result)
_D("duplicated device");
- } else {
+ else
ret_result = strdup(line);
- }
}
line = strtok_r(NULL, "\n", &save_str);
}
return ret_result;
}
-/*@_app2sd_generate_password
+/*
* This is a simple password generator
* return: On success, it will return the password, else NULL.
*/
int j = appname_len;
unsigned int seed;
- /* Length of the password */
- ret_result = (char*)malloc(PASSWD_LEN + 1);
+ /* length of the password */
+ ret_result = (char *)malloc(PASSWD_LEN + 1);
if (NULL == ret_result) {
_E("unable to allocate memory");
return NULL;
uid = __app2sd_get_sender_unixinfo(conn, sender_name,
"GetConnectionUnixUser");
- if (uid < 0) {
+ if (uid < 0)
_E("failed to get uid");
- }
_D("sender_name(%s), uid(%d)", sender_name, uid);
" <arg type='i' name='uid' direction='in'/>"
" <arg type='i' name='result' direction='out'/>"
" </method>"
+" <method name='EnableFullPkg'>"
+" <arg type='i' name='result' direction='out'/>"
+" </method>"
+" <method name='DisableFullPkg'>"
+" <arg type='i' name='result' direction='out'/>"
+" </method>"
" </interface>"
"</node>";
g_dbus_method_invocation_return_value(invocation, param);
}
-static void _app2sd_server_ondemand_force_clean(GDBusConnection *connection, const gchar *sender,
+static void _app2sd_server_force_clean(GDBusConnection *connection, const gchar *sender,
GVariant *parameters, GDBusMethodInvocation *invocation, uid_t sender_uid)
{
GVariant *param = NULL;
g_dbus_method_invocation_return_value(invocation, param);
}
+static void _app2sd_server_enable_full_pkg(GDBusConnection *connection, const gchar *sender,
+ GVariant *parameters, GDBusMethodInvocation *invocation, uid_t sender_uid)
+{
+ GVariant *param = NULL;
+ int result = APP2EXT_SUCCESS;
+ int ret = 0;
+
+ _D("sender_uid(%d)", sender_uid);
+
+ if (sender_uid >= REGULAR_USER) {
+ _E("Not permitted user!");
+ _app2sd_server_return_method_error(invocation,
+ APP2EXT_ERROR_OPERATION_NOT_PERMITTED);
+ return;
+ }
+
+ ret = app2sd_enable_full_pkg();
+ if (ret) {
+ _E("error(%d)", ret);
+ result = ret;
+ }
+
+ param = g_variant_new("(i)", result);
+ g_dbus_method_invocation_return_value(invocation, param);
+}
+
+static void _app2sd_server_disable_full_pkg(GDBusConnection *connection, const gchar *sender,
+ GVariant *parameters, GDBusMethodInvocation *invocation, uid_t sender_uid)
+{
+ GVariant *param = NULL;
+ int result = APP2EXT_SUCCESS;
+ int ret = 0;
+
+ _D("sender_uid(%d)", sender_uid);
+
+ if (sender_uid >= REGULAR_USER) {
+ _E("Not permitted user!");
+ _app2sd_server_return_method_error(invocation,
+ APP2EXT_ERROR_OPERATION_NOT_PERMITTED);
+ return;
+ }
+
+ ret = app2sd_disable_full_pkg();
+ if (ret) {
+ _E("error(%d)", ret);
+ result = ret;
+ }
+
+ param = g_variant_new("(i)", result);
+ g_dbus_method_invocation_return_value(invocation, param);
+}
+
static void handle_method_call(GDBusConnection *connection,
const gchar *sender, const gchar *object_path,
const gchar *interface_name, const gchar *method_name,
_app2sd_server_move_installed_app(connection, sender,
parameters, invocation, sender_uid);
} else if (g_strcmp0(method_name, "ForceClean") == 0) {
- _app2sd_server_ondemand_force_clean(connection, sender,
+ _app2sd_server_force_clean(connection, sender,
+ parameters, invocation, sender_uid);
+ } else if (g_strcmp0(method_name, "EnableFullPkg") == 0) {
+ _app2sd_server_enable_full_pkg(connection, sender,
+ parameters, invocation, sender_uid);
+ } else if (g_strcmp0(method_name, "DisableFullPkg") == 0) {
+ _app2sd_server_disable_full_pkg(connection, sender,
parameters, invocation, sender_uid);
}
_E("invalid function arguments");
return NULL;
}
- if (storage_type != APP2EXT_SD_CARD ) {
+ if (storage_type != APP2EXT_SD_CARD) {
_E("storage type currently not supported");
return NULL;
}
int app2ext_deinit(app2ext_handle *handle)
{
/* validate the function parameter recieved */
- if (handle == NULL || handle->plugin_handle == NULL){
+ if (handle == NULL || handle->plugin_handle == NULL) {
_E("invalid function arguments");
return -1;
}
tzplatform_reset_user();
}
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
- if (encoded_id == NULL) {
+ if (encoded_id == NULL)
return -1;
- }
+
snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
APP2SD_PATH, encoded_id);
free(encoded_id);
int app2ext_usr_enable_external_pkg(const char *pkgid, uid_t uid)
{
FILE *fp = NULL;
- app2ext_handle *app2_handle = NULL;
+ app2ext_handle *handle = NULL;
char loopback_device[FILENAME_MAX] = { 0, };
char *encoded_id = NULL;
}
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
- if (encoded_id == NULL) {
+ if (encoded_id == NULL)
return -1;
- }
+
snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
APP2SD_PATH, encoded_id);
free(encoded_id);
fclose(fp);
fp = NULL;
- app2_handle = app2ext_init(APP2EXT_SD_CARD);
- if (app2_handle == NULL) {
+ handle = app2ext_init(APP2EXT_SD_CARD);
+ if (handle == NULL) {
_E("app2ext init failed");
return -1;
}
- app2_handle->interface.client_usr_enable(pkgid, uid);
- app2ext_deinit(app2_handle);
+ handle->interface.client_usr_enable(pkgid, uid);
+ app2ext_deinit(handle);
}
return 0;
int app2ext_usr_disable_external_pkg(const char *pkgid, uid_t uid)
{
FILE *fp = NULL;
- app2ext_handle *app2_handle = NULL;
+ app2ext_handle *handle = NULL;
char loopback_device[FILENAME_MAX] = { 0, };
char *encoded_id = NULL;
}
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
- if (encoded_id == NULL) {
+ if (encoded_id == NULL)
return -1;
- }
+
snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
APP2SD_PATH, encoded_id);
free(encoded_id);
fclose(fp);
fp = NULL;
- app2_handle = app2ext_init(APP2EXT_SD_CARD);
- if (app2_handle == NULL) {
+ handle = app2ext_init(APP2EXT_SD_CARD);
+ if (handle == NULL) {
_E("app2ext init failed");
return -1;
}
- app2_handle->interface.client_usr_disable(pkgid, uid);
- app2ext_deinit(app2_handle);
+ handle->interface.client_usr_disable(pkgid, uid);
+ app2ext_deinit(handle);
}
return 0;
return ret;
}
+int app2ext_enable_external_full_pkg(void)
+{
+ int ret = 0;
+ app2ext_handle *handle = NULL;
+
+ if (getuid() >= REGULAR_USER)
+ return 0;
+
+ handle = app2ext_init(APP2EXT_SD_CARD);
+ if (handle == NULL) {
+ _E("app2ext init failed");
+ return -1;
+ }
+
+ ret = handle->interface.client_enable_full_pkg();
+ if (ret != 0)
+ _E("failed to enable entire pkgs");
+
+ app2ext_deinit(handle);
+
+ return 0;
+}
+
+int app2ext_disable_external_full_pkg(void)
+{
+ int ret = 0;
+ app2ext_handle *handle = NULL;
+
+ if (getuid() >= REGULAR_USER)
+ return 0;
+
+ handle = app2ext_init(APP2EXT_SD_CARD);
+ if (handle == NULL) {
+ _E("app2ext init failed");
+ return -1;
+ }
+
+ ret = handle->interface.client_disable_full_pkg();
+ if (ret != 0)
+ _E("failed to disable entire pkgs");
+
+ app2ext_deinit(handle);
+
+ return 0;
+}
+
int app2ext_usr_force_clean_pkg(const char *pkgid, uid_t uid)
{
- app2ext_handle *app2_handle = NULL;
+ app2ext_handle *handle = NULL;
/* validate the function parameter received */
if (pkgid == NULL || uid < 0) {
return -1;
}
- app2_handle = app2ext_init(APP2EXT_SD_CARD);
- if (app2_handle == NULL) {
+ handle = app2ext_init(APP2EXT_SD_CARD);
+ if (handle == NULL) {
_E("app2ext init failed");
return -1;
}
- app2_handle->interface.client_usr_force_clean(pkgid, uid);
- app2ext_deinit(app2_handle);
+ handle->interface.client_usr_force_clean(pkgid, uid);
+ app2ext_deinit(handle);
return 0;
}
char pkg_ro_content_rpm[3][5] = { "bin", "res", "lib" };
-#define COUNT_OF_ERROR_LIST 50
+#define COUNT_OF_ERROR_LIST 49
char error_list[COUNT_OF_ERROR_LIST][100] = {
"SUCCESS",
"APP2EXT_ERROR_UNKNOWN",
"APP2EXT_ERROR_STRCMP_FAILED",
"APP2EXT_ERROR_INVALID_PACKAGE",
"APP2EXT_ERROR_CREATE_DIR_ENTRY",
- "APP2EXT_ERROR_PASSWORD_GENERATION",
"APP2EXT_ERROR_COPY_DIRECTORY",
"APP2EXT_ERROR_INVALID_CASE",
"APP2EXT_ERROR_SYMLINK_ALREADY_EXISTS",
printf("<ENABLE(mount)/DISABLE(umount) TEST W/ Installed PKG>\n");
printf("(at target_user)$test_app2ext --enable\n");
printf("(at target_user)$test_app2ext --disable\n");
+ printf("(at target_user)$test_app2ext --enable-full\n");
+ printf("(at target_user)$test_app2ext --disable-full\n");
printf("------------------------------------------------\n");
printf("**************************************************\n");
printf("\n");
#define OPTVAL_GET_LOCATION 1007
#define OPTVAL_ENABLE_APP 1008
#define OPTVAL_DISABLE_APP 1009
-#define OPTVAL_USAGE 1010
+#define OPTVAL_ENABLE_FULL 1010
+#define OPTVAL_DISABLE_FULL 1011
+#define OPTVAL_USAGE 1012
/* Supported options */
const struct option long_opts[] = {
- { "pre-install", 0, NULL, OPTVAL_PRE_INSTALL },
- { "post-install", 0, NULL, OPTVAL_POST_INSTALL },
+ { "pre-install", 0, NULL, OPTVAL_PRE_INSTALL },
+ { "post-install", 0, NULL, OPTVAL_POST_INSTALL },
{ "pre-uninstall", 0, NULL, OPTVAL_PRE_UNINSTALL },
{ "post-uninstall", 0, NULL, OPTVAL_POST_UNINSTALL },
{ "pre-upgrade", 0, NULL, OPTVAL_PRE_UPGRADE },
{ "getlocation", 0, NULL, OPTVAL_GET_LOCATION },
{ "enable", 0, NULL, OPTVAL_ENABLE_APP },
{ "disable", 0, NULL, OPTVAL_DISABLE_APP },
+ { "enable-full", 0, NULL, OPTVAL_ENABLE_FULL },
+ { "disable-full", 0, NULL, OPTVAL_DISABLE_FULL },
{ "help", 0, NULL, OPTVAL_USAGE },
{ "usage", 0, NULL, OPTVAL_USAGE },
{ 0, 0, 0, 0 } /* sentinel */
};
-void clear_dir_list(GList* dir_list)
+void clear_dir_list(GList *dir_list)
{
GList *list = NULL;
- app2ext_dir_details* dir_detail = NULL;
+ app2ext_dir_details *dir_detail = NULL;
if (dir_list) {
list = g_list_first(dir_list);
while (list) {
dir_detail = (app2ext_dir_details *)list->data;
- if (dir_detail && dir_detail->name) {
+ if (dir_detail && dir_detail->name)
free(dir_detail->name);
- }
+
list = g_list_next(list);
}
g_list_free(dir_list);
}
}
-GList * populate_dir_details()
+GList *populate_dir_details()
{
GList *dir_list = NULL;
GList *list = NULL;
int i;
for (i = 0; i < 3; i++) {
- dir_detail = (app2ext_dir_details*)calloc(1, sizeof(app2ext_dir_details));
+ dir_detail = (app2ext_dir_details *)calloc(1, sizeof(app2ext_dir_details));
if (dir_detail == NULL) {
printf("memory allocation failed\n");
goto FINISH_OFF;
}
- dir_detail->name = (char*)calloc(1, sizeof(char) * (strlen(pkg_ro_content_rpm[i]) + 2));
+ dir_detail->name = (char *)calloc(1, sizeof(char) * (strlen(pkg_ro_content_rpm[i]) + 2));
if (dir_detail->name == NULL) {
printf("memory allocation failed\n");
free(dir_detail);
static void print_error_code(const char *func_name, int ret)
{
- if (ret < 0 || ret > COUNT_OF_ERROR_LIST - 1) {
+ if (ret < 0 || ret > COUNT_OF_ERROR_LIST - 1)
printf("%s failed : unknown error(%d)\n", func_name, ret);
- } else {
+ else
printf("%s return(%s)\n", func_name, error_list[ret]);
- }
}
static int pre_app_install()
/* size : in MB */
ret = get_unzip_size(TEST_PKGNAME_PATH, &size_byte);
- if (ret < 0 || size_byte == 0) {
+ if (ret < 0 || size_byte == 0)
printf("wrong pkg size, ret(%d), size_byte(%llu)\n", ret, size_byte);
- }
+
size_mega = size_byte / (1024 * 1024) + 1;
printf("get pkg size : (%d)MB\n", size_mega);
return ret;
}
+static int fullpkg_enable()
+{
+ int ret = -1;
+
+ ret = handle->interface.client_enable_full_pkg();
+ print_error_code(__func__, ret);
+
+ return ret;
+}
+
+static int fullpkg_disable()
+{
+ int ret = -1;
+
+ ret = handle->interface.client_disable_full_pkg();
+ print_error_code(__func__, ret);
+
+ return ret;
+}
+
static int pre_app_uninstall()
{
int ret = -1;
/* size : in MB */
ret = get_unzip_size(TEST_PKGNAME_PATH, &size_byte);
- if (ret < 0 || size_byte == 0) {
+ if (ret < 0 || size_byte == 0)
printf("wrong pkg size, ret(%d), size_byte(%llu)\n", ret, size_byte);
- }
+
size_mega = size_byte / (1024 * 1024) + 1;
printf("get pkg size : (%d)MB\n", size_mega);
int ret = -1;
ret = app2ext_usr_get_app_location(TEST_PKGNAME, getuid());
- if (ret == APP2EXT_SD_CARD) {
+ if (ret == APP2EXT_SD_CARD)
printf("pkg is in sd card\n");
- } else if (ret == APP2EXT_INTERNAL_MEM) {
+ else if (ret == APP2EXT_INTERNAL_MEM)
printf("pkg is in internal memory\n");
- } else {
+ else
printf("pkg is not installed\n");
- }
}
int main(int argc, char **argv)
case OPTVAL_DISABLE_APP:
app_disable();
break;
+ case OPTVAL_ENABLE_FULL:
+ fullpkg_enable();
+ break;
+ case OPTVAL_DISABLE_FULL:
+ fullpkg_disable();
+ break;
case OPTVAL_USAGE:
default:
usage();