SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
### Local include directories
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/inc ${CMAKE_SOURCE_DIR}/src)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/inc
+ ${CMAKE_SOURCE_DIR}/common/inc)
## build app2ext library
SET(app2ext_dir "${CMAKE_SOURCE_DIR}")
-SET(app2ext_inc_dir "${app2ext_dir}/inc")
SET(app2ext_src_dir "${app2ext_dir}/src")
SET(APP2EXT "app2ext")
-SET(libapp2ext_SOURCES ${app2ext_src_dir}/app2ext_interface.c)
+SET(libapp2ext_SOURCES
+ ${app2ext_src_dir}/app2ext_interface.c
+ ${CMAKE_SOURCE_DIR}/common/src/app2ext_utils.c)
SET(libapp2ext_LDFLAGS " -L${LIB_INSTALL_DIR} -module -avoid-version -ldl ")
-SET(libapp2ext_CFLAGS " ${CFLAGS} -fPIC -I${app2ext_inc_dir} ")
+SET(libapp2ext_CFLAGS " ${CFLAGS} -fPIC ")
ADD_DEFINITIONS("-DLIBPREFIX=\"${LIB_INSTALL_DIR}\"")
--- /dev/null
+/*
+ * app2ext
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _APP2EXT_UTILS_H
+#define _APP2EXT_UTILS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#ifndef _DEFAULT_SOURCE
+#define _DEFAULT_SOURCE
+#endif
+
+#include <dlog.h>
+#include <glib.h>
+#include <tzplatform_config.h>
+
+#define _E(fmt, arg...) LOGE(fmt, ##arg)
+#define _D(fmt, arg...) LOGD(fmt, ##arg)
+#define _W(fmt, arg...) LOGW(fmt, ##arg)
+#define _I(fmt, arg...) LOGI(fmt, ##arg)
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "APP2EXT"
+
+#define APP2EXT_SUCCESS 0
+
+#define OWNER_ROOT 0
+#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 APP2SD_BUS_NAME "org.tizen.app2sd"
+#define APP2SD_OBJECT_PATH "/org/tizen/app2sd"
+#define APP2SD_INTERFACE_NAME "org.tizen.app2sd"
+
+int _is_global(uid_t uid);
+char *_app2sd_get_encoded_name(const char *pkgid, uid_t uid);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
--- /dev/null
+/*
+ * app2ext
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "app2ext_utils.h"
+
+int _is_global(uid_t uid)
+{
+ if (uid == OWNER_ROOT || uid == GLOBAL_USER)
+ return 1;
+ else
+ return 0;
+}
+
+char *_app2sd_get_encoded_name(const char *pkgid, uid_t uid)
+{
+ char *new_name = NULL;
+ char *temp_string = NULL;
+ char source_name[FILENAME_MAX] = { 0, };
+ GChecksum *checksum;
+
+ snprintf(source_name, FILENAME_MAX - 1, "%s_%d", pkgid, uid);
+ checksum = g_checksum_new(G_CHECKSUM_MD5);
+ g_checksum_update(checksum, (const guchar *)source_name, strlen(source_name));
+ temp_string = (char *)g_checksum_get_string(checksum);
+ _D("temp_string(%s)", temp_string);
+ new_name = strdup(temp_string);
+ g_checksum_free(checksum);
+
+ _D("new_name(%s)", new_name);
+
+ return new_name;
+}
* @version 0.5
* @brief This file declares API of app2ext library
*/
+
/**
* @addtogroup APPLICATION_FRAMEWORK
* @{
#define API __attribute__ ((visibility("default")))
#endif
-#include <dlog/dlog.h>
#include <glib.h>
-/* for multi-user support */
-#include <tzplatform_config.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "APP2EXT"
-
-#define _E(fmt, arg...) LOGE(fmt, ##arg)
-#define _D(fmt, arg...) LOGD(fmt, ##arg)
-#define _W(fmt, arg...) LOGW(fmt, ##arg)
-#define _I(fmt, arg...) LOGI(fmt, ##arg)
-
-#define APP2EXT_SUCCESS 0
-
-#define OWNER_ROOT 0
-#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 APP2SD_BUS_NAME "org.tizen.app2sd"
-#define APP2SD_OBJECT_PATH "/org/tizen/app2sd"
-#define APP2SD_INTERFACE_NAME "org.tizen.app2sd"
-
/**
* Enum for application installation location
*/
*/
typedef enum app2ext_move_type_t {
APP2EXT_MOVE_TO_EXT = 1,
- APP2EXT_MOVE_TO_PHONE
+ APP2EXT_MOVE_TO_PHONE,
} app2ext_move_type;
/**
/**
* This structure defines the app2ext interfaces. Plugins have to implement these functions
*/
-typedef struct app2ext_interface_t{
+typedef struct app2ext_interface_t {
/* for library function */
app2ext_client_pre_install client_pre_install;
app2ext_client_post_install client_post_install;
* type : permission (rw/ro)
*/
typedef struct {
- char * name;
- app2ext_dir_type type;
+ char *name;
+ app2ext_dir_type type;
} app2ext_dir_details;
/**
* [Ex: SD card, MicroUSB, Cloud]
* @return app2ext_handle pointer if success, NULL if fail
*
- @code
- #include <app2ext_interface.h>
- app2ext_handle *handle = NULL;
- GLIst *dir_list = NULL;
- handle = app2ext_init(APP2EXT_SD_CARD); //Initializes SD card plug-in
- if(handle)
- {
- printf("\n SUCCESS");
- // Perform package install/uninstall/upgrade/move here
- // Packge install example
- // Package manager should polulate dir_list with directory structure information of the package
- ret = handle->interface.pre_install("com.samsung.calculator", dir_list, 20);
- if (ret) {
- printf("\n TC : pre app install API fail. Reason %s", error_list[ret]);
- return -1;
- }
-
- // Package manager installs the package
-
- ret = handle->interface.post_install("com.samsung.calculator", APP2EXT_STATUS_SUCCESS);
- if (ret) {
- printf("\n TC : post app install API fail Reason %s", error_list[ret]);
-
- return -1;
- }
- // Package manager should free dir_list
- return;
- } else
- printf("\n FAILURE");
- @endcode
*/
API app2ext_handle *app2ext_init(int storage_type);
* 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 code(>0) if fail
+ * @return 0 if success, error < 0 if fail
*
- @code
- #include <app2ext_interface.h>
- app2ext_handle *handle = NULL;
- handle = app2ext_init(APP2EXT_SD_CARD); //Initializes SD card plug-in
- int ret = -1;
- ret = app2ext_deinit(handle); // De-initializes the SD plugin
- if(!ret)
- {
- printf("\n SUCCESS");
- }
- else
- printf("\n FAILURE");
- @endcode
*/
API int app2ext_deinit(app2ext_handle *handle);
* @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 app is in internal memory
- * error code(>0) if fail
+ * 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);
### Local include directories
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/inc
- ${CMAKE_SOURCE_DIR}/src)
+ ${CMAKE_SOURCE_DIR}/common/inc
+ ${CMAKE_SOURCE_DIR}/plugin/app2sd/inc)
SET(app2sd_dir "${CMAKE_SOURCE_DIR}/plugin/app2sd")
-SET(app2sd_inc_dir "${app2sd_dir}/inc")
SET(app2sd_src_dir "${app2sd_dir}/src")
## build app2sd library
SET(libapp2sd_SOURCES
${app2sd_src_dir}/app2sd_client_interface.c)
SET(libapp2sd_LDFLAGS " -L${LIB_INSTALL_DIR} -lcrypto -module -avoid-version ")
-SET(libapp2sd_CFLAGS " ${CFLAGS} -fPIC -I${app2sd_inc_dir} ")
+SET(libapp2sd_CFLAGS " ${CFLAGS} -fPIC ")
ADD_LIBRARY(${APP2SD} SHARED ${libapp2sd_SOURCES})
SET_TARGET_PROPERTIES(${APP2SD} PROPERTIES SOVERSION ${VERSION_MAJOR})
${app2sd_src_dir}/app2sd_interface.c
${app2sd_src_dir}/app2sd_internals_registry.c
${app2sd_src_dir}/app2sd_internals_utils.c
- ${app2sd_src_dir}/app2sd_server.c)
+ ${app2sd_src_dir}/app2sd_server.c
+ ${CMAKE_SOURCE_DIR}/common/src/app2ext_utils.c)
ADD_EXECUTABLE(${APP2SD_SERVER} ${app2sd_server_SOURCES})
-SET_TARGET_PROPERTIES(${APP2SD_SERVER} PROPERTIES COMPILE_FLAGS ${CFLAGS} "-fPIE -I${app2sd_inc_dir} ")
+SET_TARGET_PROPERTIES(${APP2SD_SERVER} PROPERTIES COMPILE_FLAGS ${CFLAGS} "-fPIE ")
SET_TARGET_PROPERTIES(${APP2SD_SERVER} PROPERTIES LINK_FLAGS "-pie")
TARGET_LINK_LIBRARIES(${APP2SD_SERVER} app2sd ${pkgs_LDFLAGS})
extern "C" {
#endif
-#include <app2ext_interface.h>
+#include "app2ext_interface.h"
/**
* @brief : This API prepares the setup for installation in SD card.
extern "C" {
#endif
-#include <app2ext_interface.h>
+#include "app2ext_interface.h"
+#include "app2ext_utils.h"
int app2sd_usr_pre_app_install(const char *pkgid,
GList* dir_list, int size, uid_t uid);
/*Include Headers*/
#include <stdio.h>
+#include <stdlib.h>
#include <fcntl.h>
-#include <errno.h>
#include <string.h>
#include <stdarg.h>
#include <dirent.h>
#include <unistd.h>
-#include <malloc.h>
-#include <stdlib.h>
#include <sys/stat.h>
+#include <sys/statvfs.h>
#include <sys/types.h>
-#include <errno.h>
#include <sys/mount.h>
-#include <app2sd_interface.h>
+#include <sys/wait.h>
+#include <sys/xattr.h>
+#include <malloc.h>
#include <math.h>
+#include <errno.h>
+
+#include "app2sd_interface.h"
#define DIR_PERMS (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
/* This functions make result file */
void _app2sd_make_result_info_file(char *pkgid, int size, uid_t uid);
-int _is_global(uid_t uid);
-
-char *_app2sd_get_encoded_name(const char *pkgid, uid_t uid);
-
#endif
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
-#include <glib.h>
#include <gio/gio.h>
-#include <app2sd_client_interface.h>
+
+#include "app2sd_client_interface.h"
+#include "app2ext_utils.h"
static int app2sd_gdbus_shared_connection(GDBusConnection **connection)
{
*
*/
-#include <app2sd_internals.h>
-#include <app2sd_interface.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/wait.h>
#include <pkgmgr-info.h>
+#include "app2sd_internals.h"
+
static int __app2sd_create_app2sd_directories(uid_t uid)
{
int ret = 0;
tzplatform_reset_user();
}
free(encoded_id);
- _D("application_path = (%s)", application_path);
- _D("loopback_device = (%s)", loopback_device);
ret = __app2sd_create_app2sd_directories(uid);
if (ret) {
tzplatform_reset_user();
}
free(encoded_id);
- _D("application_path = (%s)", application_path);
- _D("loopback_device = (%s)", loopback_device);
/* get the associated device node for SD card applicationer */
device_name = _app2sd_find_associated_device_node(loopback_device);
tzplatform_reset_user();
}
free(encoded_id);
- _D("application_path = (%s)", application_path);
- _D("loopback_device = (%s)", loopback_device);
fp = fopen(loopback_device, "r+");
if (fp == NULL) {
tzplatform_reset_user();
}
free(encoded_id);
- _D("application_path = (%s)", application_path);
- _D("loopback_device = (%s)", loopback_device);
fp = fopen(loopback_device, "r+");
if (fp == NULL) {
tzplatform_reset_user();
}
free(encoded_id);
- _D("application_path = (%s)", application_path);
- _D("loopback_device = (%s)", loopback_device);
/* check app entry is there in sd card or not. */
fp = fopen(loopback_device, "r+");
tzplatform_reset_user();
}
free(encoded_id);
- _D("application_path = (%s)", application_path);
- _D("loopback_device = (%s)", loopback_device);
/* unmount the loopback encrypted pseudo device from
* the application installation path
tzplatform_reset_user();
}
free(encoded_id);
- _D("application_path = (%s)", application_path);
- _D("loopback_device = (%s)", loopback_device);
/* check app entry is there in sd card or not. */
fp = fopen(loopback_device, "r+");
tzplatform_reset_user();
}
free(encoded_id);
- _D("application_path = (%s)", application_path);
- _D("loopback_device = (%s)", loopback_device);
/* get the associated device node for SD card applicationer */
device_name = _app2sd_find_associated_device_node(loopback_device);
char *encoded_id = NULL;
int ret = APP2EXT_SUCCESS;
- _D("start force_clean [%s]", pkgid);
-
/* validate the function parameter recieved */
if (pkgid == NULL) {
_E("invalid func parameters");
tzplatform_reset_user();
}
free(encoded_id);
- _D("application_path = (%s)", application_path);
- _D("loopback_device = (%s)", loopback_device);
/* unmount the loopback encrypted pseudo device from the application installation path */
ret = _app2sd_unmount_app_content(application_path);
_E("cannot remove password from db");
}
- _D("finish force_clean");
-
return 0;
}
*
*/
-#include <sys/xattr.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
#include <dirent.h>
-#include <sys/stat.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
#include <openssl/sha.h>
-#include <fcntl.h>
#include <time.h>
-#include <dlog.h>
-#include <sys/statvfs.h>
#include <pwd.h>
-#include <app2sd_internals.h>
-#include <app2sd_interface.h>
-
-int _is_global(uid_t uid)
-{
- if (uid == OWNER_ROOT || uid == GLOBAL_USER)
- return 1;
- else
- return 0;
-}
+#include "app2sd_internals.h"
static int _app2sd_setup_path(const char* path, const char *label, uid_t uid)
{
*
*/
-#include <app2sd_internals.h>
-#include <app2sd_interface.h>
-
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/types.h>
#include <dirent.h>
-#include <sys/stat.h>
-#include <dlog.h>
#include <time.h>
#include <db-util.h>
-#include <tzplatform_config.h>
+
+#include "app2sd_internals.h"
#define MAX_QUERY_LEN 4096
#define PASSWORD_LENGTH 64
*
*/
-#include <app2sd_internals.h>
-#include <app2sd_interface.h>
-
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
#include <dirent.h>
-#include <sys/stat.h>
#include <time.h>
-#include <dlog.h>
-#include <sys/statvfs.h>
-#include <errno.h>
+
+#include "app2sd_internals.h"
#define PASSWD_LEN 21
#define ASCII_PASSWD_CHAR 93
return ret_result;
}
-
-char *_app2sd_get_encoded_name(const char *pkgid, uid_t uid)
-{
- char *new_name = NULL;
- char *temp_string = NULL;
- char source_name[FILENAME_MAX] = { 0, };
- GChecksum *checksum;
-
- snprintf(source_name, FILENAME_MAX - 1, "%s_%d", pkgid, uid);
- checksum = g_checksum_new(G_CHECKSUM_MD5);
- g_checksum_update(checksum, (const guchar *)source_name, strlen(source_name));
- temp_string = (char *)g_checksum_get_string(checksum);
- _D("temp_string(%s)", temp_string);
- new_name = strdup(temp_string);
- g_checksum_free(checksum);
-
- _D("new_name(%s)", new_name);
-
- return new_name;
-}
*
*/
-#include <app2sd_internals.h>
-#include <app2sd_interface.h>
-#include <glib.h>
#include <gio/gio.h>
+#include "app2sd_internals.h"
+
GMainLoop *app2sd_mainloop = NULL;
gboolean __exit_app2sd_server(void *data)
*
*/
-#include <app2ext_interface.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include <dirent.h>
-#define APP2EXT_SD_PLUGIN_PATH LIBPREFIX "/libapp2sd.so"
+#include "app2ext_interface.h"
+#include "app2ext_utils.h"
-int _is_global(uid_t uid)
-{
- if (uid == OWNER_ROOT || uid == GLOBAL_USER)
- return 1;
- else
- return 0;
-}
+#define APP2EXT_SD_PLUGIN_PATH LIBPREFIX "/libapp2sd.so"
app2ext_handle *app2ext_init(int storage_type)
{
/* validate the function parameter recieved */
if (handle == NULL || handle->plugin_handle == NULL){
_E("invalid function arguments");
- return APP2EXT_ERROR_INVALID_ARGUMENTS;
+ return -1;
}
/* close the plugin handle*/
/* free allocated memory during installtion*/
free(handle);
- return APP2EXT_SUCCESS;
+ return 0;
}
int app2ext_usr_get_app_location(const char *pkgid, uid_t uid)
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 APP2EXT_ERROR_INVALID_ARGUMENTS;
+ return -1;
}
if (_is_global(uid)) {
tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
snprintf(application_mmc_path, FILENAME_MAX - 1, "%s/%s/.mmc",
tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
- snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
- APP2SD_PATH, 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);
- snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
- APP2SD_PATH, tzplatform_getenv(TZ_USER_NAME), pkgid);
tzplatform_reset_user();
}
- _D("application_path = (%s)", application_path);
- _D("application_mmc_path = (%s)", application_mmc_path);
- _D("loopback_device = (%s)", loopback_device);
+ 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 */
+ /* check whether application is in external memory or not */
fp = fopen(loopback_device, "r");
if (fp != NULL) {
fclose(fp);
return APP2EXT_SD_CARD;
}
- /*check whether application is in internal or not */
+ /* check whether application is in internal or not */
fp = fopen(application_path, "r");
if (fp == NULL) {
_D("app_dir_path open failed, " \
fclose(fp);
_E("app_mmc_internal_path exists, " \
"error mmc status");
- return APP2EXT_ERROR_MMC_STATUS;
+ return -1;
}
}
}
+
int app2ext_get_app_location(const char *pkgid)
{
int ret = 0;
FILE *fp = NULL;
app2ext_handle *app2_handle = NULL;
char loopback_device[FILENAME_MAX] = { 0, };
+ char *encoded_id = NULL;
/* validate the function parameter received */
if (pkgid == NULL) {
return -1;
}
- if (_is_global(uid)) {
- snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
- APP2SD_PATH, pkgid);
- } else {
- tzplatform_set_user(uid);
- snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
- APP2SD_PATH, tzplatform_getenv(TZ_USER_NAME), pkgid);
- tzplatform_reset_user();
+ encoded_id = _app2sd_get_encoded_name(pkgid, uid);
+ if (encoded_id == NULL) {
+ return -1;
}
-
- _D("loopback_device = (%s)", loopback_device);
+ 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");
app2_handle = app2ext_init(APP2EXT_SD_CARD);
if (app2_handle == NULL) {
_E("app2ext init failed");
- return -2;
+ return -1;
}
app2_handle->interface.client_usr_enable(pkgid, uid);
app2ext_deinit(app2_handle);
}
+
return 0;
}
+
int app2ext_enable_external_pkg(const char *pkgid)
{
int ret = 0;
FILE *fp = NULL;
app2ext_handle *app2_handle = NULL;
char loopback_device[FILENAME_MAX] = { 0, };
+ char *encoded_id = NULL;
/* validate the function parameter received */
- if (pkgid == NULL) {
+ if (pkgid == NULL || uid < 0) {
_E("invalid func parameters");
return -1;
}
- if (_is_global(uid)) {
- snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
- APP2SD_PATH, pkgid);
- } else {
- tzplatform_set_user(uid);
- snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
- APP2SD_PATH, tzplatform_getenv(TZ_USER_NAME), pkgid);
- tzplatform_reset_user();
+ encoded_id = _app2sd_get_encoded_name(pkgid, uid);
+ if (encoded_id == NULL) {
+ return -1;
}
-
- _D("loopback_device = (%s)", loopback_device);
+ 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");
app2_handle = app2ext_init(APP2EXT_SD_CARD);
if (app2_handle == NULL) {
- _E("app2_handle : app2ext init failed");
- return -2;
+ _E("app2ext init failed");
+ return -1;
}
app2_handle->interface.client_usr_disable(pkgid, uid);
return 0;
}
+
int app2ext_disable_external_pkg(const char *pkgid)
{
int ret = 0;
{
FILE *fp = NULL;
app2ext_handle *app2_handle = NULL;
- char application_mmc_path[FILENAME_MAX] = { 0, };
/* validate the function parameter received */
- if (pkgid == NULL) {
+ if (pkgid == NULL || uid < 0) {
_E("invalid func parameters");
- return 0;
- }
-
- if (_is_global(uid)) {
- snprintf(application_mmc_path, FILENAME_MAX - 1, "%s/%s/.mmc",
- tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
- } else {
- tzplatform_set_user(uid);
- snprintf(application_mmc_path, FILENAME_MAX - 1, "%s/%s/.mmc",
- tzplatform_getenv(TZ_USER_APP), pkgid);
- tzplatform_reset_user();
- }
- _D("application_mmc_path = (%s)", application_mmc_path);
-
- fp = fopen(application_mmc_path, "r");
- if (fp == NULL) {
- return 0;
- } else {
- fclose(fp);
+ return -1;
}
app2_handle = app2ext_init(APP2EXT_SD_CARD);
if (app2_handle == NULL) {
_E("app2ext init failed");
- return 0;
+ return -1;
}
app2_handle->interface.client_usr_force_clean(pkgid, uid);
return 0;
}
+
int app2ext_force_clean_pkg(const char *pkgid)
{
int ret = 0;
#include <sys/types.h>
#include <getopt.h>
#include <unzip.h>
-#include <tzplatform_config.h>
-#include <app2ext_interface.h>
+
+#include "app2ext_interface.h"
+#include "app2ext_utils.h"
#define SUCCESS 0
#define FAIL 1