return 0;
}
-/* use this api only to check external related file existing,
- * such as .mmc directory and image file under /sdcard/app2sd.
- */
-int app2ext_usr_get_app_location(const char *pkgid, uid_t uid)
-{
- FILE *fp = NULL;
- char loopback_device[FILENAME_MAX] = { 0, };
- char application_path[FILENAME_MAX] = { 0, };
- char application_mmc_path[FILENAME_MAX] = { 0, };
- char *encoded_id = NULL;
-
- /* validate the function parameter received */
- if (pkgid == NULL) {
- _E("invalid func parameters");
- return -1;
- }
-
- if (_is_global(uid)) {
- snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
- tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
- snprintf(application_mmc_path, FILENAME_MAX - 1, "%s/%s/.mmc",
- 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);
- snprintf(application_mmc_path, FILENAME_MAX - 1, "%s/%s/.mmc",
- tzplatform_getenv(TZ_USER_APP), pkgid);
- tzplatform_reset_user();
- }
- encoded_id = _app2sd_get_encoded_name(pkgid, uid);
- if (encoded_id == NULL)
- return -1;
-
- snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
- APP2SD_PATH, encoded_id);
- free(encoded_id);
-
- /* check whether application is in external memory or not */
- fp = fopen(loopback_device, "r");
- if (fp != NULL) {
- fclose(fp);
- fp = NULL;
- _D("sd card");
- return APP2EXT_SD_CARD;
- }
-
- /* check whether application is in internal or not */
- fp = fopen(application_path, "r");
- if (fp == NULL) {
- _D("app_dir_path open failed, " \
- "package not installed");
- return APP2EXT_NOT_INSTALLED;
- } else {
- fclose(fp);
- /* check whether the application is installed in SD card
- * but SD card is not present
- */
- fp = fopen(application_mmc_path, "r");
- if (fp == NULL) {
- _D("internal mem");
- return APP2EXT_INTERNAL_MEM;
- } else {
- fclose(fp);
- _E("app_mmc_internal_path exists, " \
- "error mmc status");
- return -1;
- }
- }
-}
-
-int app2ext_get_app_location(const char *pkgid)
-{
- int ret = 0;
-
- ret = app2ext_usr_get_app_location(pkgid, getuid());
-
- return ret;
-}
-
int app2ext_usr_enable_external_pkg(const char *pkgid, uid_t uid)
{
FILE *fp = NULL;
printf("------------------------------------------------\n");
printf("\n");
printf("<MOVE PKG TEST>\n");
- printf("(at target_user)$test_app2ext --move\n");
- printf("------------------------------------------------\n");
- printf("\n");
- printf("<GET INSTALLED LOCATION (Ext/Internal)>\n");
- printf("(at target_user)$test_app2ext --getlocation\n");
+ printf("(at target_user)$test_app2ext --move-to-ext\n");
+ printf("(at target_user)$test_app2ext --move-to-int\n");
printf("------------------------------------------------\n");
printf("\n");
printf("<ENABLE(mount)/DISABLE(umount) TEST W/ Installed PKG>\n");
#define OPTVAL_POST_UNINSTALL 1003
#define OPTVAL_PRE_UPGRADE 1004
#define OPTVAL_POST_UPGRADE 1005
-#define OPTVAL_MOVE 1006
-#define OPTVAL_GET_LOCATION 1007
+#define OPTVAL_MOVE_TO_EXTERNAL 1006
+#define OPTVAL_MOVE_TO_INTERNAL 1007
#define OPTVAL_ENABLE_APP 1008
#define OPTVAL_DISABLE_APP 1009
#define OPTVAL_ENABLE_FULL 1010
{ "post-uninstall", 0, NULL, OPTVAL_POST_UNINSTALL },
{ "pre-upgrade", 0, NULL, OPTVAL_PRE_UPGRADE },
{ "post-upgrade", 0, NULL, OPTVAL_POST_UPGRADE },
- { "move", 0, NULL, OPTVAL_MOVE },
- { "getlocation", 0, NULL, OPTVAL_GET_LOCATION },
+ { "move-to-ext", 0, NULL, OPTVAL_MOVE_TO_EXTERNAL },
+ { "move-to-int", 0, NULL, OPTVAL_MOVE_TO_INTERNAL },
{ "enable", 0, NULL, OPTVAL_ENABLE_APP },
{ "disable", 0, NULL, OPTVAL_DISABLE_APP },
{ "enable-full", 0, NULL, OPTVAL_ENABLE_FULL },
return ret;
}
-static int app_move()
+static int app_move_to_external()
{
GList *dir_list = NULL;
int ret = -1;
- int ret_check = -1;
- printf("app_move %s\n", TEST_PKGNAME);
+ printf("app_move_to_external %s\n", TEST_PKGNAME);
dir_list = populate_dir_details();
if (dir_list == NULL) {
return -1;
}
- ret = app2ext_usr_get_app_location(TEST_PKGNAME, getuid());
- printf("return value = (%d)\n", ret);
- 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_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_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);
- } else {
- ret = APP2EXT_ERROR_INVALID_PACKAGE;
- printf("app_move failed (%s)\n", error_list[ret]);
- }
+ printf("pkg %s will be moved to sd card\n", 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);
clear_dir_list(dir_list);
return ret;
}
-static void app_get_location()
+static int app_move_to_internal()
{
- printf("app_get_location for pkg(%s)\n", TEST_PKGNAME);
+ GList *dir_list = NULL;
int ret = -1;
- ret = app2ext_usr_get_app_location(TEST_PKGNAME, getuid());
- if (ret == APP2EXT_SD_CARD)
- printf("pkg is in sd card\n");
- else if (ret == APP2EXT_INTERNAL_MEM)
- printf("pkg is in internal memory\n");
- else
- printf("pkg is not installed\n");
+ printf("app_move_to_internal %s\n", TEST_PKGNAME);
+
+ dir_list = populate_dir_details();
+ if (dir_list == NULL) {
+ printf("Error in populating the directory list\n");
+ return -1;
+ }
+
+ printf("pkg %s will be moved to internal memory\n", 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);
+
+ clear_dir_list(dir_list);
+
+ return ret;
}
int main(int argc, char **argv)
case OPTVAL_POST_UPGRADE:
post_app_upgrade();
break;
- case OPTVAL_MOVE:
- app_move();
+ case OPTVAL_MOVE_TO_EXTERNAL:
+ app_move_to_external();
break;
- case OPTVAL_GET_LOCATION:
- app_get_location();
+ case OPTVAL_MOVE_TO_INTERNAL:
+ app_move_to_internal();
break;
case OPTVAL_ENABLE_APP:
app_enable();