* [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,
+typedef int (*app2ext_client_usr_pre_move)(const char *appname, GList* dir_list,
app2ext_move_type move_type, uid_t uid);
-typedef int (*app2ext_client_move)(const char *appname, GList* dir_list,
+typedef int (*app2ext_client_pre_move)(const char *appname, GList* dir_list,
+ app2ext_move_type move_type);
+typedef int (*app2ext_client_usr_post_move)(const char *appname,
+ app2ext_move_type move_type, uid_t uid);
+typedef int (*app2ext_client_post_move)(const char *appname,
app2ext_move_type move_type);
/**
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_pre_move client_pre_move;
+ app2ext_client_post_move client_post_move;
app2ext_client_usr_pre_install client_usr_pre_install;
app2ext_client_usr_post_install client_usr_post_install;
app2ext_client_usr_force_clean client_usr_force_clean;
app2ext_client_usr_enable client_usr_enable;
app2ext_client_usr_disable client_usr_disable;
- app2ext_client_usr_move client_usr_move;
+ app2ext_client_usr_pre_move client_usr_pre_move;
+ app2ext_client_usr_post_move client_usr_post_move;
} app2ext_interface;
/**
Name: app2sd
Summary: Application installation on external memory
-Version: 0.5.42
+Version: 0.5.43
Release: 1
Group: Application Framework/Package Management
License: Apache-2.0
[Service]
ExecStart=@PREFIX@/bin/app2sd-server
CapabilityBoundingSet=~CAP_MAC_ADMIN
+CapabilityBoundingSet=~CAP_MAC_OVERRIDE
* @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.
* @param[in] dir_list directory structure of the application
* @param[in] size size of memory required by application(in MB).
* @brief : This API does post installation operations after
* the installation in SD card
* @param[in] appname application package name
- * [Ex: com.samsung.calculator]
* @param[in] install_status Status of installation of package
*[ enum app2ext_status].If package installation failed then
* install_status= APP2EXT_STATUS_FAILURE else if installation
* @pre vfat type sd card must be present.
* @post Upgradation is done by package installer.
* @param[in] appname application package name
- * [Ex: com.samsung.calculator]
* @param[in] dir_list directory structure of the application
* @param[in] size size of memory required by application(in MB).
*This entry is parsed from application package control/manifest file.
* @brief : This API does post upgradation operations after
* the installation in SD card
* @param[in] appname application package name
- * [Ex: com.samsung.calculator]
* @param[in] install_status Status of installation of package
*[ enum app2extl_status].If package upgradation failed then
* upgrade_status= APP2EXT_STATUS_FAILURE else if upgradation
* @pre Package must be installed in sdcard.
* @post Package is uninstalled by the package installer.
* @param[in] appname application package name
- * [Ex: com.samsung.calculator]
* @return 0 if success, error code(>0) if fail
* @remark None.
*/
* @pre Package must be uninstalled .
* @post Encryption password is removed from sqlite db.
* @param[in] appname application package name
- * [Ex: com.samsung.calculator]
* @return 0 if success, error code(>0) if fail
* @remark None.
*/
int app2sd_client_post_app_uninstall(const char *pkgid);
/**
- * @brief : This API moves the package from sd card
+ * @brief : This API prepare the move of the package from sd card
to internal memory and vice versa.
* @param[in] pkgid application package id
- * [Ex: com.samsung.calculator]
* @param[in] move_type Move type[enum app2ext_move_type]
* [sd card to internal/internal to sd card]
* @param[in] dir_list directory structure of the application
* @return 0 if success, error code(>0) if fail
* @remark None.
*/
-int app2sd_client_usr_move_installed_app(const char *pkgid,
+int app2sd_client_usr_pre_move_installed_app(const char *pkgid,
GList *dir_list, app2ext_move_type move_type, uid_t uid);
-int app2sd_client_move_installed_app(const char *pkgid,
+int app2sd_client_pre_move_installed_app(const char *pkgid,
GList *dir_list, app2ext_move_type move_type);
/**
+ * @brief : This API remove the resources created during the move.
+ * @param[in] pkgid application package id
+ * @param[in] move_type Move type[enum app2ext_move_type]
+ * [sd card to internal/internal to sd card]
+ * @return 0 if success, error code(>0) if fail
+ * @remark None.
+ */
+int app2sd_client_usr_post_move_installed_app(const char *pkgid,
+ app2ext_move_type move_type, uid_t uid);
+int app2sd_client_post_move_installed_app(const char *pkgid,
+ app2ext_move_type move_type);
+
+/**
* @brief : This API Enables the application in sd card
for use. This API should be called by AUL.
* @param[in] pkgid application package id
-* [Ex: com.samsung.calculator]
* @pre Package must be installed
* @post application is enabled in SD card.
* @return 0 if success, error code(>0) if fail
. This API should be called by Launchpad callback which will be registered
during app launch for exit action of the application
* @param[in] pkgid application package id
-* [Ex: com.samsung.calculator]
* @pre Package must be installed and enabled
* and application must be running in SD card
* @post application is disabked in SD card.
int app2sd_usr_post_app_uninstall(const char *pkgid, uid_t uid);
-int app2sd_usr_move_installed_app(const char *pkgid,
+int app2sd_usr_pre_move_installed_app(const char *pkgid,
GList *dir_list, app2ext_move_type move_type, uid_t uid);
+int app2sd_usr_post_move_installed_app(const char *pkgid,
+ app2ext_move_type move_type, uid_t uid);
+
int app2sd_usr_on_demand_setup_init(const char *pkgid, uid_t uid);
int app2sd_usr_on_demand_setup_exit(const char *pkgid, uid_t uid);
return ret;
}
-int app2sd_client_usr_move_installed_app(const char *pkgid, GList *dir_list,
+int app2sd_client_usr_pre_move_installed_app(const char *pkgid, GList *dir_list,
app2ext_move_type move_type, uid_t uid)
{
int ret = 0;
if (move_type == APP2EXT_MOVE_TO_EXT)
cmd = APP2SD_MOVE_APP_TO_MMC;
- ret = __app2sd_create_default_directories(pkgid, cmd, uid);
- if (ret)
- return ret;
+ if (cmd == APP2SD_MOVE_APP_TO_MMC) {
+ ret = __app2sd_create_default_directories(pkgid, cmd, uid);
+ if (ret)
+ return ret;
+ }
builder = g_variant_builder_new(G_VARIANT_TYPE("a(si)"));
g_list_foreach(dir_list, __app2sd_create_dir_list_builder, builder);
param = g_variant_new("(sia(si)i)", pkgid, move_type, builder, uid);
- ret = __app2sd_call_server_method("MoveInstalledApp", param);
+ ret = __app2sd_call_server_method("PreMoveInstalledApp", param);
if (builder)
g_variant_builder_unref(builder);
return ret;
}
-int app2sd_client_move_installed_app(const char *pkgid, GList *dir_list,
+int app2sd_client_pre_move_installed_app(const char *pkgid, GList *dir_list,
app2ext_move_type move_type)
{
int ret = 0;
- ret = app2sd_client_usr_move_installed_app(pkgid,
+ ret = app2sd_client_usr_pre_move_installed_app(pkgid,
dir_list, move_type, getuid());
return ret;
}
+int app2sd_client_usr_post_move_installed_app(const char *pkgid,
+ app2ext_move_type move_type, uid_t uid)
+{
+ int ret = 0;
+ GVariant *param = NULL;
+
+ /* validate the function parameter recieved */
+ if (pkgid == NULL || move_type < APP2EXT_MOVE_TO_EXT
+ || move_type > APP2EXT_MOVE_TO_PHONE) {
+ _E("invalid function arguments");
+ return APP2EXT_ERROR_INVALID_ARGUMENTS;
+ }
+
+ param = g_variant_new("(sii)", pkgid, move_type, uid);
+ ret = __app2sd_call_server_method("PostMoveInstalledApp", param);
+
+ return ret;
+}
+int app2sd_client_post_move_installed_app(const char *pkgid,
+ app2ext_move_type move_type)
+{
+ int ret = 0;
+
+ ret = app2sd_client_usr_post_move_installed_app(pkgid,
+ move_type, getuid());
+
+ return ret;
+}
+
void app2ext_on_load(app2ext_interface *interface)
{
/* Plug-in Binding.*/
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_pre_move = app2sd_client_pre_move_installed_app;
+ interface->client_post_move = app2sd_client_post_move_installed_app;
interface->client_usr_pre_install = app2sd_client_usr_pre_app_install;
interface->client_usr_post_install = app2sd_client_usr_post_app_install;
interface->client_usr_force_clean = app2sd_client_usr_force_clean;
interface->client_usr_enable = app2sd_client_usr_on_demand_setup_init;
interface->client_usr_disable = app2sd_client_usr_on_demand_setup_exit;
- interface->client_usr_move = app2sd_client_usr_move_installed_app;
+ interface->client_usr_pre_move = app2sd_client_usr_pre_move_installed_app;
+ interface->client_usr_post_move = app2sd_client_usr_post_move_installed_app;
}
return ret;
}
-int app2sd_usr_move_installed_app(const char *pkgid, GList *dir_list,
- app2ext_move_type move_type, uid_t uid)
+int app2sd_usr_pre_move_installed_app(const char *pkgid,
+ GList *dir_list, app2ext_move_type move_type, uid_t uid)
{
int ret = 0;
int pkgmgr_ret = 0;
return APP2EXT_SUCCESS;
}
+int app2sd_usr_post_move_installed_app(const char *pkgid,
+ app2ext_move_type move_type, uid_t uid)
+{
+ int ret = 0;
+ char application_path[FILENAME_MAX] = { 0, };
+ char loopback_device[FILENAME_MAX] = { 0, };
+ char *encoded_id = NULL;
+
+ /* validate function arguments */
+ if (pkgid == NULL || move_type < APP2EXT_MOVE_TO_EXT
+ || move_type > APP2EXT_MOVE_TO_PHONE) {
+ _E("invalid function arguments");
+ return APP2EXT_ERROR_INVALID_ARGUMENTS;
+ }
+
+ if (move_type == APP2EXT_MOVE_TO_PHONE)
+ return APP2EXT_SUCCESS;
+
+ /* check whether MMC is present or not */
+ ret = _app2sd_check_mmc_status();
+ if (ret) {
+ _E("MMC not preset OR Not ready(%d)", ret);
+ return APP2EXT_ERROR_MMC_STATUS;
+ }
+
+ encoded_id = _app2sd_get_encoded_name(pkgid, uid);
+ 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);
+ if (_is_global(uid)) {
+ snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
+ tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
+ } else {
+ tzplatform_set_user(uid);
+ snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
+ tzplatform_getenv(TZ_USER_APP), pkgid);
+ tzplatform_reset_user();
+ }
+
+ ret = _app2sd_unmount_app_content(application_path);
+ if (ret)
+ _E("unmount error (%d)", ret);
+
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+ ret = _app2sd_dmcrypt_close_device(pkgid, uid);
+ if (ret)
+ _E("close dmcrypt device error(%d)", ret);
+#else
+ ret = _app2sd_remove_loopback_encryption_setup(loopback_device);
+ if (ret)
+ _E("unable to detach loopback setup for (%s)",
+ loopback_device);
+#endif
+
+ sync();
+ return APP2EXT_SUCCESS;
+}
+
int app2sd_usr_pre_app_upgrade(const char *pkgid, GList *dir_list,
int size, uid_t uid)
{
break;
}
- if (cmd == APP2SD_PRE_UNINSTALL || cmd == APP2SD_PRE_UPGRADE) {
+ if (cmd == APP2SD_PRE_UNINSTALL || cmd == APP2SD_MOVE_APP_TO_PHONE ||
+ cmd == APP2SD_PRE_UPGRADE) {
/* delete lost+found dir */
snprintf(temp_path, FILENAME_MAX - 1, "%s/lost+found",
application_mmc_path);
goto ERR;
}
- /* re-mount the loopback encrypted pseudo device on application installation path
- * as with Read Only permission
- */
- ret = _app2sd_unmount_app_content(application_path);
- if (ret)
- _E("unmount error (%d)", ret);
-
-#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
- ret = _app2sd_dmcrypt_close_device(pkgid, uid);
- if (ret)
- _E("close dmcrypt device error(%d)", ret);
-#else
- ret = _app2sd_remove_loopback_encryption_setup(loopback_device);
- if (ret)
- _E("unable to detach loopback setup for (%s)",
- loopback_device);
-#endif
-
sync();
return APP2EXT_SUCCESS;
" <arg type='i' name='uid' direction='in'/>"
" <arg type='i' name='result' direction='out'/>"
" </method>"
-" <method name='MoveInstalledApp'>"
+" <method name='PreMoveInstalledApp'>"
" <arg type='s' name='pkgid' direction='in'/>"
" <arg type='i' name='move_type' direction='in'/>"
" <arg type='a(si)' name='dir_list' direction='in'/>"
" <arg type='i' name='uid' direction='in'/>"
" <arg type='i' name='result' direction='out'/>"
" </method>"
+" <method name='PostMoveInstalledApp'>"
+" <arg type='s' name='pkgid' direction='in'/>"
+" <arg type='i' name='move_type' direction='in'/>"
+" <arg type='i' name='uid' direction='in'/>"
+" <arg type='i' name='result' direction='out'/>"
+" </method>"
" <method name='ForceClean'>"
" <arg type='s' name='pkgid' direction='in'/>"
" <arg type='i' name='uid' direction='in'/>"
g_dbus_method_invocation_return_value(invocation, param);
}
-static void _app2sd_server_move_installed_app(GDBusConnection *connection, const gchar *sender,
- GVariant *parameters, GDBusMethodInvocation *invocation, uid_t sender_uid)
+static void _app2sd_server_pre_move_installed_app(GDBusConnection *connection,
+ const gchar *sender, GVariant *parameters,
+ GDBusMethodInvocation *invocation, uid_t sender_uid)
{
GVariant *param = NULL;
int result = APP2EXT_SUCCESS;
g_variant_iter_free(iter);
dir_list = g_list_first(list);
- ret = app2sd_usr_move_installed_app(pkgid, dir_list, move_type, target_uid);
+ ret = app2sd_usr_pre_move_installed_app(pkgid, dir_list, move_type, target_uid);
+ if (ret) {
+ _E("pre_move error(%d)", ret);
+ result = ret;
+ }
+
+ param = g_variant_new("(i)", result);
+ g_dbus_method_invocation_return_value(invocation, param);
+}
+
+static void _app2sd_server_post_move_installed_app(GDBusConnection *connection,
+ const gchar *sender, GVariant *parameters,
+ GDBusMethodInvocation *invocation, uid_t sender_uid)
+{
+ GVariant *param = NULL;
+ int result = APP2EXT_SUCCESS;
+ int move_type;
+ char *pkgid = NULL;
+ int ret = 0;
+ uid_t target_uid = -1;
+
+ g_variant_get(parameters, "(&sii)", &pkgid, &move_type, &target_uid);
+
+ _D("pkgid(%s), move_type(%d),sender_uid(%d), target_uid(%d)",
+ pkgid, move_type, sender_uid, target_uid);
+
+ if (sender_uid != 0 && sender_uid != target_uid) {
+ _E("Not permitted user!");
+ _app2sd_server_return_method_error(invocation,
+ APP2EXT_ERROR_OPERATION_NOT_PERMITTED);
+ return;
+ }
+
+ ret = app2sd_usr_post_move_installed_app(pkgid, move_type, target_uid);
if (ret) {
- _E("usr_move error(%d)", ret);
+ _E("post_move error(%d)", ret);
result = ret;
}
} else if (g_strcmp0(method_name, "OndemandSetupExit") == 0) {
_app2sd_server_ondemand_setup_exit(connection, sender,
parameters, invocation, sender_uid);
- } else if (g_strcmp0(method_name, "MoveInstalledApp") == 0) {
- _app2sd_server_move_installed_app(connection, sender,
+ } else if (g_strcmp0(method_name, "PreMoveInstalledApp") == 0) {
+ _app2sd_server_pre_move_installed_app(connection, sender,
+ parameters, invocation, sender_uid);
+ } else if (g_strcmp0(method_name, "PostMoveInstalledApp") == 0) {
+ _app2sd_server_post_move_installed_app(connection, sender,
parameters, invocation, sender_uid);
} else if (g_strcmp0(method_name, "ForceClean") == 0) {
_app2sd_server_force_clean(connection, sender,
if (ret == APP2EXT_SD_CARD) {
printf("pkg %s is in sd card\n", TEST_PKGNAME);
printf("pkg %s will be moved to internal memory\n", TEST_PKGNAME);
- ret = handle->interface.client_move(TEST_PKGNAME,
+ ret = handle->interface.client_pre_move(TEST_PKGNAME,
dir_list, APP2EXT_MOVE_TO_PHONE);
print_error_code(__func__, ret);
+ ret = handle->interface.client_post_move(TEST_PKGNAME,
+ APP2EXT_MOVE_TO_PHONE);
+ print_error_code(__func__, ret);
ret_check = app2ext_usr_get_app_location(TEST_PKGNAME, getuid());
if (ret_check == APP2EXT_INTERNAL_MEM)
printf("pkg %s is moved to internal memory\n", TEST_PKGNAME);
} else if (ret == APP2EXT_INTERNAL_MEM) {
printf("pkg %s is in internal memory\n", TEST_PKGNAME);
printf("pkg %s will be moved to sd card\n", TEST_PKGNAME);
- ret = handle->interface.client_move(TEST_PKGNAME,
+ ret = handle->interface.client_pre_move(TEST_PKGNAME,
dir_list, APP2EXT_MOVE_TO_EXT);
print_error_code(__func__, ret);
+ ret = handle->interface.client_post_move(TEST_PKGNAME,
+ APP2EXT_MOVE_TO_EXT);
+ print_error_code(__func__, ret);
ret_check = app2ext_usr_get_app_location(TEST_PKGNAME, getuid());
if (ret_check == APP2EXT_SD_CARD)
printf("pkg %s is moved to sd card\n", TEST_PKGNAME);