AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/src/transport SRCS)
AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/src/util SRCS)
+IF(BUILD_GCOV)
+ ADD_DEFINITIONS("-DTIZEN_TEST_GCOV")
+ENDIF(BUILD_GCOV)
+
INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs REQUIRED glib-2.0 capi-content-media-content
capi-media-metadata-extractor vconf dlog tapi capi-system-info storage libsystemd-daemon libsystemd)
ENDFOREACH(flag)
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -Werror-implicit-function-declaration")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fexceptions -fvisibility=hidden")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fexceptions -fvisibility=hidden -fprofile-arcs -ftest-coverage")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE")
SET(CMAKE_EXE_LINKER_FLAGS " -Wl,--as-needed -pie -Wl,--hash-style=both,-z,relroi ")
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/descs DESTINATION /etc/mtp-responder)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/strs DESTINATION /etc/mtp-responder)
+
+IF(BUILD_GTESTS)
+ ADD_SUBDIRECTORY(unittest)
+ENDIF(BUILD_GTESTS)
#ifndef _MTP_DEVICE_H_
#define _MTP_DEVICE_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "mtp_store.h"
#include "mtp_property.h"
#define MTP_VENDOR_EXTN_ID 0x06
#define MTP_VENDOR_EXTN_VERSION 0x64
-
/* This enumeration specifies the type of store. */
typedef enum {
MTP_STORAGE_INTERNAL = 0,
mtp_char *_device_get_sync_partner(void);
void _device_set_sync_partner(mtp_char *sync_ptr);
+
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _MTP_DEVICE_H_ */
#ifndef _MTP_OBJECT_H_
#define _MTP_OBJECT_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "mtp_list.h"
#include "ptp_datacodes.h"
#include "mtp_fs.h"
* obj_info_t structure : Contains object metadata related information
* Size = 26 Bytes
*/
+
typedef struct {
mtp_uint32 store_id; /* The storage the object resides */
mtp_uint16 obj_fmt; /* object format code */
mtp_bool _entity_remove_reference_child_array(mtp_obj_t *obj, mtp_uint32 handle);
void _entity_dealloc_mtp_obj(mtp_obj_t *obj);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _MTP_OBJECT_H_ */
#ifndef _MTP_PROPERTY_H_
#define _MTP_PROPERTY_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "mtp_list.h"
#include "mtp_object.h"
mtp_uint32 format_code, mtp_uchar *buf, mtp_uint32 size);
mtp_bool _get_oma_drm_status(void);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _MTP_PROPERTY_H_ */
#ifndef _MTP_STORE_H_
#define _MTP_STORE_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "mtp_object.h"
void _entity_list_modified_files(mtp_uint32 minutes);
void _entity_copy_store_data(mtp_store_t *dst, mtp_store_t *src);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _MTP_STORE_H_ */
#ifndef _MTP_CMD_HANDLER_H_
#define _MTP_CMD_HANDLER_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "mtp_object.h"
#include "mtp_device.h"
#include "ptp_container.h"
mtp_bool _cmd_hdlr_send_response_code(mtp_handler_t *hdlr, mtp_uint16 resp);
void _receive_mq_data_cb(mtp_char *buffer, mtp_int32 buf_len);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _MTP_CMD_HANDLER_H_ */
#ifndef _MTP_CMD_HANDLER_UTIL_H_
#define _MTP_CMD_HANDLER_UTIL_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "mtp_device.h"
typedef struct {
mtp_err_t _hutil_format_storage(mtp_uint32 store_id, mtp_uint32 fs_format);
mtp_uint32 _hutil_get_storage_info_size(store_info_t *store_info);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _MTP_CMD_HANDLER_UTIL_H_ */
#ifndef _MTP_EVENT_HANDLER_H_
#define _MTP_EVENT_HANDLER_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <vconf.h>
#include "mtp_datatype.h"
#include "mtp_util.h"
void _eh_send_event_req_to_eh_thread(event_code_t action, mtp_ulong param1,
mtp_ulong param2, void *param3);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _MTP_EVENT_HANDLER_H_ */
#ifndef __MTPMAIN_H_INCLUDED
#define __MTPMAIN_H_INCLUDED
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "mtp_store.h"
#define MTP_LOG_FILE "/var/log/mtp.log"
void _features_supported_info(void);
void mtp_end_event(void);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _MTP_MAIN_H_ */
#ifndef _MTP_INOTI_HANDLER_H_
#define _MTP_INOTI_HANDLER_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "mtp_config.h"
#ifdef MTP_SUPPORT_OBJECTADDDELETE_EVENT
#include <sys/inotify.h>
void _inoti_deinit_filesystem_events();
#endif /* MTP_SUPPORT_OBJECTADDDELETE_EVENT */
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _MTP_INOTI_HANDLER_H_ */
#ifndef _PTP_CONTAINER_H_
#define _PTP_CONTAINER_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "mtp_datatype.h"
#define MAX_MTP_PARAMS 5
void _hdlr_conv_cmd_container_byte_order(cmd_container_t *dst);
void _hdlr_conv_data_container_byte_order(data_container_t *dst);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _PTP_CONTAINER_H_ */
#ifndef _MTP_TRANSPORT_H_
#define _MTP_TRANSPORT_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "mtp_datatype.h"
#include "mtp_util.h"
void _transport_set_cancel_initialization(mtp_bool value);
mtp_bool _transport_get_cancel_initialization(void);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _MTP_TRANSPORT_H_ */
#ifndef _MTP_USB_DRIVER_H_
#define _MTP_USB_DRIVER_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "mtp_config.h"
#include "mtp_datatype.h"
#include "mtp_msgq.h"
mtp_uint32 _get_rx_pkt_size(void);
mtp_transport_type_t _transport_get_type(void);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _MTP_USB_DRIVER_H_ */
#ifndef _MTP_FS_H_
#define _MTP_FS_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <dirent.h>
#include "mtp_datatype.h"
#include "mtp_config.h"
mtp_uint32 size);
void FLOGD(const char *fmt, ...);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _MTP_FS_H_ */
#ifndef _MTP_LIST_H_
#define _MTP_LIST_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "mtp_datatype.h"
#include "mtp_util.h"
slist_node_t *_util_get_first_node(slist_t *l_ptr);
void _util_deinit_list_iterator(slist_iterator *iter);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _MTP_LIST_H_ */
#ifndef _MTP_MEDIA_INFO_H_
#define _MTP_MEDIA_INFO_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <glib.h>
#include <media_content.h>
#include "mtp_config.h"
void _util_free_video_meta(video_meta_t *video);
void _util_free_image_meta(image_meta_t *image);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _MTP_MEDIA_INFO_H_ */
#ifndef _MTP_MSGQ_H_
#define _MTP_MSGQ_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "mtp_datatype.h"
#include "mtp_util.h"
mtp_bool _util_rcv_msg_from_mq(msgq_id_t mq_id, unsigned char **pkt,
mtp_uint32 *pkt_len, msg_type_t *mtype);
+#ifdef __cplusplus
+}
+#endif
+
#endif/*_MTP_MSGQ_H_*/
#ifndef _MTP_SUPPORT_H_
#define _MTP_SUPPORT_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "mtp_datatype.h"
#include "mtp_config.h"
mtp_uint32 new_path_buf_len);
mtp_int32 _util_system_cmd_wait(const mtp_char *cmd);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _MTP_SUPPORT_H_ */
#ifndef _MTP_THREAD_H_
#define _MTP_THREAD_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <pthread.h>
#include "mtp_datatype.h"
#include "mtp_util.h"
mtp_bool _util_thread_cancel(pthread_t tid);
void _util_thread_exit(void *val_ptr);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_MTP_THREAD_H_*/
#ifndef _MTP_UTIL_H_
#define _MTP_UTIL_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <errno.h>
#include "mtp_config.h"
#include "mtp_datatype.h"
mtp_bool _util_media_content_connect();
void _util_media_content_disconnect();
+#ifdef __cplusplus
+}
+#endif
#endif /* _MTP_UTIL_H_ */
BuildRequires: pkgconfig(libsystemd)
Requires(post): /usr/bin/vconftool
+%if 0%{?gtests:1}
+BuildRequires: pkgconfig(gmock)
+%endif
+
%define upgrade_script_path /usr/share/upgrade/scripts
%description
%build
export CFLAGS="$CFLAGS -Wno-deprecated-declarations"
-%cmake .
+%if 0%{?gcov:1}
+export CFLAGS+=" -fprofile-arcs -ftest-coverage"
+export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
+export LDFLAGS+=" -lgcov"
+%endif
+
+%cmake . \
+%if 0%{?gtests:1}
+ -DBUILD_GTESTS=%{?gtests:1}%{!?gtests:0} \
+%endif
+%if 0%{?gcov:1}
+ -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0}
+%endif
make %{?jobs:-j%jobs}
%{upgrade_script_path}/500.%{name}-upgrade.sh
/etc/mtp-responder/descs
/etc/mtp-responder/strs
+
+%if 0%{?gtests:1}
+%{_bindir}/gtest*
+%endif
return;
}
+/* LCOV_EXCL_START */
mtp_uint32 _get_device_info_size(void)
{
mtp_uint32 size = 0;
g_device.phase = DEVICE_PHASE_IDLE;
return;
}
+/* LCOV_EXCL_STOP */
device_prop_desc_t *_device_get_device_property(mtp_uint32 prop_code)
{
* @param[in] store_type Store type
* @return TRUE if success, otherwise FALSE.
*/
+/* LCOV_EXCL_START */
static mtp_bool __remove_store_from_device(store_type_t store_type)
{
mtp_int32 ii = 0;
return g_device.is_mounted[store_type];
}
+/* LCOV_EXCL_STOP */
mtp_bool _device_install_storage(mtp_int32 type)
{
lock_status = _util_get_local_lock_status();
if (lock_status == MTP_PHONE_LOCK_OFF) {
+ /* LCOV_EXCL_START */
int_status = _device_is_store_mounted(MTP_STORAGE_INTERNAL);
if (int_status == FALSE)
__add_store_to_device(MTP_STORAGE_INTERNAL);
+ /* LCOV_EXCL_STOP */
}
mounted = _util_get_local_mmc_status();
if (mounted == MTP_PHONE_MMC_INSERTED) {
+ /* LCOV_EXCL_START */
ext_status =
_device_is_store_mounted(MTP_STORAGE_EXTERNAL);
if (ext_status == FALSE)
__add_store_to_device(MTP_STORAGE_EXTERNAL);
+ /* LCOV_EXCL_STOP */
}
break;
DBG(" case MTP_ADDREM_EXTERNAL:");
if (MTP_PHONE_MMC_INSERTED != _util_get_local_mmc_status())
break;
+ /* LCOV_EXCL_START */
mounted = _device_is_store_mounted(MTP_STORAGE_EXTERNAL);
if (mounted == FALSE) {
if (__add_store_to_device(MTP_STORAGE_EXTERNAL) == FALSE) {
return FALSE;
}
}
+ /* LCOV_EXCL_STOP */
break;
case MTP_ADDREM_ALL:
return TRUE;
}
+/* LCOV_EXCL_START */
mtp_bool _device_uninstall_storage(mtp_int32 type)
{
switch (type) {
}
return MTP_ERROR_GENERAL;
}
+/* LCOV_EXCL_STOP */
mtp_store_t *_device_get_store(mtp_uint32 store_id)
{
return num_objs;
}
+/* LCOV_EXCL_START */
mtp_uint32 _device_get_num_objects_with_format(mtp_uint32 store_id,
mtp_uint32 format)
{
return num_objs;
}
+/* LCOV_EXCL_STOP */
mtp_obj_t *_device_get_object_with_handle(mtp_uint32 obj_handle)
{
return obj;
}
+/* LCOV_EXCL_START */
mtp_obj_t* _device_get_object_with_path(mtp_char *full_path)
{
mtp_int32 i = 0;
}
return obj;
}
+/* LCOV_EXCL_STOP */
mtp_uint16 _device_delete_object(mtp_uint32 obj_handle, mtp_uint32 fmt)
{
if (store == NULL) {
response = PTP_RESPONSE_INVALID_OBJ_HANDLE;
} else {
+ /* LCOV_EXCL_START */
response = _entity_delete_obj_mtp_store(store,
obj_handle, fmt, TRUE);
}
response = PTP_RESPONSE_PARTIAL_DELETION;
return response;
+ /* LCOV_EXCL_STOP */
}
mtp_store_t *_device_get_store_containing_obj(mtp_uint32 obj_handle)
return &(g_device.store_list[index]);
}
+/* LCOV_EXCL_START */
device_prop_desc_t *_device_get_ref_prop_list(void)
{
return g_device.device_prop_list;
_hdlr_send_event_container(&event);
return TRUE;
}
+/* LCOV_EXCL_STOP */
void _device_get_serial(mtp_char *serial_no, mtp_uint32 len)
{
return;
}
+/* LCOV_EXCL_START */
void _device_set_phase(device_phase_t phase)
{
DBG("Devie phase is set [%d]\n", phase);
{
return g_device.phase;
}
+/* LCOV_EXCL_STOP */
mtp_uint32 _device_get_default_store_id(void)
{
return g_device.num_stores;
}
+/* LCOV_EXCL_START */
device_status_t _device_get_status(void)
{
return g_device.status;
}
+/* LCOV_EXCL_STOP */
mtp_char *_device_get_device_name(void)
{
extern mtp_bool g_is_full_enum;
+/* LCOV_EXCL_START */
mtp_bool _entity_get_file_times(mtp_obj_t *obj, ptp_time_string_t *create_tm,
ptp_time_string_t *modify_tm)
{
return TRUE;
}
+/* LCOV_EXCL_STOP */
obj_info_t *_entity_alloc_object_info(void)
{
memset(info, 0, sizeof(obj_info_t));
}
+/* LCOV_EXCL_START */
mtp_uint32 _entity_get_object_info_size(mtp_obj_t *obj, ptp_string_t *file_name)
{
int ret;
return (size);
}
+/* LCOV_EXCL_STOP */
void _entity_init_object_info_params(obj_info_t *info, mtp_uint32 store_id,
mtp_uint32 parent_handle, mtp_char *file_name, dir_entry_t *dir)
retv_if(buf == NULL, 0);
retvm_if(buf_sz < FIXED_LENGTH_MEMBERS_SIZE, 0, "buf_sz[%d] is less", buf_sz);
+ /* LCOV_EXCL_START */
/* Copy Obj Props from store_id till file_size */
memcpy(&(info->store_id), temp, (sizeof(mtp_uint16) * 2 + sizeof(mtp_uint32) * 2));
temp += (sizeof(mtp_uint16) * 2 + sizeof(mtp_uint32) * 2);
info = NULL;
return;
}
+/* LCOV_EXCL_STOP */
mtp_obj_t *_entity_alloc_mtp_object(void)
{
return TRUE;
}
+/* LCOV_EXCL_START */
mtp_bool _entity_check_child_obj_path(mtp_obj_t *obj,
mtp_char *src_path, mtp_char *dest_path)
{
}
_util_delete_file_from_db(child_obj->file_path);
- if (_entity_set_object_file_path(child_obj, dest_child_path,
- CHAR_TYPE) == FALSE) {
- ERR("Failed to set full path!!");
- _entity_remove_reference_child_array(obj,
- child_obj->obj_handle);
- _entity_dealloc_mtp_obj(child_obj);
- continue;
- }
+ _entity_set_object_file_path(child_obj, dest_child_path, CHAR_TYPE);
if (child_obj->obj_info == NULL) {
ERR("obj_info is NULL");
_prop_deinit_ptparray(&child_arr);
return TRUE;
}
+/* LCOV_EXCL_STOP */
mtp_bool _entity_add_reference_child_array(mtp_obj_t *obj, mtp_uint32 handle)
{
return TRUE;
}
+/* LCOV_EXCL_START */
ptp_array_t *_entity_get_reference_child_array(mtp_obj_t *obj)
{
return &(obj->child_array);
obj = NULL;
return;
}
+/* LCOV_EXCL_STOP */
/*
* FUNCTIONS
*/
+/* LCOV_EXCL_START */
static mtp_bool __check_object_propcode(obj_prop_desc_t *prop,
mtp_uint32 propcode, mtp_uint32 group_code)
{
return TRUE;
}
+/* LCOV_EXCL_STOP */
static void __build_supported_common_props(mtp_uchar *count,
obj_prop_desc_t *prop)
return (parray);
}
+/* LCOV_EXCL_START */
mtp_uint32 _prop_get_size_ptparray(ptp_array_t *parray)
{
mtp_uint16 size = 0;
return (size * parray->num_ele);
}
+/* LCOV_EXCL_STOP */
mtp_bool _prop_grow_ptparray(ptp_array_t *parray, mtp_uint32 new_size)
{
if (new_size < parray->arr_size)
return TRUE;
+ /* LCOV_EXCL_START */
parray->array_entry =
g_realloc(parray->array_entry, size * new_size);
if (parray->array_entry == NULL) {
parray->arr_size = new_size;
return TRUE;
+ /* LCOV_EXCL_STOP */
}
mtp_int32 _prop_find_ele_ptparray(ptp_array_t *parray, mtp_uint32 element)
retv_if(parray->array_entry == NULL, ELEMENT_NOT_FOUND);
switch (parray->type) {
+ /* LCOV_EXCL_START */
case UINT8_TYPE:
ptr8 = parray->array_entry;
for (ii = 0; ii < parray->num_ele; ii++) {
return ii;
}
break;
-
+ /* LCOV_EXCL_STOP */
case PTR_TYPE:
case UINT32_TYPE:
ptr32 = parray->array_entry;
return ELEMENT_NOT_FOUND;
}
+/* LCOV_EXCL_START */
mtp_bool _prop_get_ele_ptparray(ptp_array_t *parray, mtp_uint32 index, void *ele)
{
mtp_uchar *ptr8 = NULL;
}
return TRUE;
}
+/* LCOV_EXCL_STOP */
mtp_bool _prop_append_ele_ptparray(ptp_array_t *parray, mtp_uint32 element)
{
}
switch (parray->type) {
+ /* LCOV_EXCL_START */
case UINT8_TYPE:
ptr8 = parray->array_entry;
ptr8[parray->num_ele++] = (mtp_uchar)element;
ptr16 = parray->array_entry;
ptr16[parray->num_ele++] = (mtp_uint16) element;
break;
-
+ /* LCOV_EXCL_STOP */
case PTR_TYPE:
case UINT32_TYPE:
ptr32 = parray->array_entry;
return TRUE;
}
+/* LCOV_EXCL_START */
mtp_bool _prop_append_ele128_ptparray(ptp_array_t *parray, mtp_uint64 *element)
{
mtp_uchar *ptr = NULL;
g_free(parray);
return;
}
+/* LCOV_EXCL_STOP */
mtp_uint16 __get_ptp_array_elem_size(data_type_t type)
{
pwchar = (mtp_wchar *)str;
if (str == NULL) {
+ /* LCOV_EXCL_START */
pstring->num_chars = 0;
return;
}
ERR("Unknown character mode : %d\n", cmode);
pstring->num_chars = 0;
return;
+ /* LCOV_EXCL_STOP */
}
if (i == MAX_PTP_STRING_CHARS)
return;
}
+/* LCOV_EXCL_START */
void _prop_copy_time_to_ptptimestring(ptp_time_string_t *pstring,
system_time_t *sys_time)
{
}
return;
}
+/* LCOV_EXCL_STOP */
void _prop_copy_ptpstring(ptp_string_t *dst, ptp_string_t *src)
{
return;
}
+/* LCOV_EXCL_START */
void _prop_copy_ptptimestring(ptp_time_string_t *dst, ptp_time_string_t *src)
{
mtp_uint16 ii;
}
return TRUE;
}
+/* LCOV_EXCL_STOP */
mtp_uint32 _prop_size_ptpstring(ptp_string_t *pstring)
{
return (pstring->num_chars * sizeof(mtp_wchar) + 1);
}
+/* LCOV_EXCL_START */
mtp_uint32 _prop_size_ptptimestring(ptp_time_string_t *pstring)
{
if (pstring == NULL)
return _prop_size_ptpstring(pstring);
}
}
+/* LCOV_EXCL_STOP */
void _prop_destroy_ptpstring(ptp_string_t *pstring)
{
return FALSE;
}
} else if (prop_info->form_flag == ENUM_FORM) {
+ /* LCOV_EXCL_START */
slist_node_t *node = prop_info->supp_value_list.start;
mtp_uint32 ii;
for (ii = 0; ii < prop_info->supp_value_list.nnodes;
ii++, node = node->link) {
if (value == (mtp_uint32) node->value)
return TRUE;
+ /* LCOV_EXCL_STOP */
}
/* if it hits here, must be an invalid value */
return FALSE;
if (prop_info->form_flag == ENUM_FORM) {
+ /* LCOV_EXCL_START */
slist_node_t *node = NULL;
mtp_uint32 ii;
ptp_string_t *ele_str = NULL;
ERR("invalid data time format");
return FALSE;
}
+ /* LCOV_EXCL_STOP */
return TRUE;
} else if (prop_info->form_flag == REGULAR_EXPRESSION_FORM) {
return TRUE;
return FALSE;
/* Copies the data into the PTP array */
+ /* LCOV_EXCL_START */
if ((prop_info->default_val.array != NULL) && (num_ele != 0)) {
mtp_uchar *ptr8 = NULL;
mtp_uint16 *ptr16 = NULL;
}
return TRUE;
}
+ /* LCOV_EXCL_STOP */
return FALSE;
}
}
}
+/* LCOV_EXCL_START */
mtp_bool _prop_set_current_array(device_prop_desc_t *prop, mtp_uchar *arr)
{
mtp_uint32 num_ele = 0;
}
return FALSE;
}
+/* LCOV_EXCL_STOP */
#ifdef __BIG_ENDIAN__
mtp_bool _prop_set_current_array_val_usbrawdata(obj_prop_val_t *pval,
return;
}
+/* LCOV_EXCL_START */
mtp_uint32 _prop_size_device_prop_desc(device_prop_desc_t *prop)
{
/* size :PropCode,Datatype,Getset,formflag */
return;
}
+/* LCOV_EXCL_STOP */
static void __init_obj_prop_desc(obj_prop_desc_t *prop, mtp_uint16 propcode,
mtp_uint16 data_type, mtp_uchar get_set, mtp_uchar form_flag,
return;
}
+/* LCOV_EXCL_START */
static mtp_uint32 __get_size_default_val_obj_prop_desc(obj_prop_desc_t *prop)
{
mtp_uint32 size = 0;
return bytes_to_write;
}
+/* LCOV_EXCL_STOP */
obj_prop_desc_t *_prop_get_obj_prop_desc(mtp_uint32 format_code,
mtp_uint32 propcode)
}
switch (format_code) {
+ /* LCOV_EXCL_START */
case PTP_FMT_MP3:
case PTP_FMT_WAVE:
for (i = 0; i < NUM_OBJECT_PROP_DESC_MP3; i++) {
default:
break;
}
+ /* LCOV_EXCL_STOP */
ERR("No matched property[0x%x], format[0x%x]!!\n", propcode,
format_code);
return NULL;
}
+/* LCOV_EXCL_START */
static void __destroy_obj_prop_desc(obj_prop_desc_t *prop)
{
slist_node_t *node = NULL;
}
return;
}
+/* LCOV_EXCL_STOP */
mtp_bool _prop_add_supp_integer_val(prop_info_t *prop_info, mtp_uint32 value)
{
}
switch (format_code) {
+ /* LCOV_EXCL_START */
case PTP_FMT_MP3:
case PTP_FMT_WAVE:
for (i = 0; i < NUM_OBJECT_PROP_DESC_MP3; i++) {
default:
break;
}
+ /* LCOV_EXCL_STOP */
DBG("getsupp_props : format [0x%x], supported list [%d]\n",
format_code, supp_props->num_ele);
return supp_props->num_ele;
return TRUE;
}
+/* LCOV_EXCL_ST */
void _prop_destroy_supp_obj_props(void)
{
mtp_uint32 i = 0;
}
return count;
}
+/* LCOV_EXCL_STOP */
mtp_uint32 _prop_get_size_interdep_proplist(obj_interdep_proplist_t *config_list,
mtp_uint32 format_code)
node = config_list->plist.start;
for (ii = 0; ii < config_list->plist.nnodes; ii++) {
+ /* LCOV_EXCL_START */
prop_config = node->value;
if ((prop_config->format_code == format_code) ||
(prop_config->format_code == PTP_FORMATCODE_NOTUSED)) {
size += _prop_get_size_interdep_prop(prop_config);
}
+ /* LCOV_EXCL_STOP */
}
return size;
}
return 0;
}
+ /* LCOV_EXCL_START */
*(mtp_uint32 *)buf = __count_interdep_proplist(config_list,
format_code);
#ifdef __BIG_ENDIAN__
return (mtp_uint32)(temp - buf);
}
+/* LCOV_EXCL_STOP */
mtp_bool _get_oma_drm_status(void)
{
return;
}
+/* LCOV_EXCL_START */
mtp_bool _entity_get_store_path_by_id(mtp_uint32 store_id, mtp_char *path)
{
char sto_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
return store_id;
}
+/* LCOV_EXCL_STOP */
mtp_bool _entity_init_mtp_store(mtp_store_t *store, mtp_uint32 store_id,
mtp_char *store_path)
break;
case MTP_EXTERNAL_STORE_ID:
+ /* LCOV_EXCL_START */
store->is_hidden = FALSE;
_util_utf8_to_utf16(wtemp, sizeof(wtemp) / WCHAR_SIZ,
MTP_STORAGE_DESC_EXT);
ERR("store initialization Fail");
return FALSE;
}
-
+ /* LCOV_EXCL_STOP */
_util_init_list(&(store->obj_list));
return TRUE;
if (_entity_init_mtp_object_params(obj, store->store_id, h_parent,
file_path, file_name, file_info) == FALSE) {
+ /* LCOV_EXCL_START */
ERR("_entity_init_mtp_object_params Fail");
g_free(obj);
return NULL;
+ /* LCOV_EXCL_STOP */
}
_entity_add_object_to_store(store, obj);
if (_entity_init_mtp_object_params(obj, store->store_id, h_parent,
file_path, file_name, file_info) == FALSE) {
+ /* LCOV_EXCL_START */
ERR("_entity_init_mtp_object_params Fail");
g_free(obj);
return NULL;
+ /* LCOV_EXCL_STOP */
+
}
_entity_add_object_to_store(store, obj);
return NULL;
}
+/* LCOV_EXCL_START */
mtp_obj_t *_entity_get_last_object_from_store(mtp_store_t *store,
mtp_uint32 handle)
{
_prop_deinit_ptparray(&child_arr);
return FALSE;
}
+/* LCOV_EXCL_STOP */
mtp_uint32 _entity_generate_next_obj_handle(void)
{
return g_next_obj_handle++;
}
+/* LCOV_EXCL_START */
mtp_uint16 _entity_format_store(mtp_store_t *store, mtp_uint32 fs_format)
{
mtp_uint16 response;
_util_init_list(&(store->obj_list));
return;
}
+/* LCOV_EXCL_STOP */
void _entity_store_recursive_enum_folder_objects(mtp_store_t *store,
mtp_obj_t *pobj)
do {
if (TRUE == _transport_get_usb_discon_state()) {
+ /* LCOV_EXCL_START */
DBG("USB is disconnected");
if (closedir(h_dir) < 0)
ERR("Close directory Fail");
return;
+ /* LCOV_EXCL_STOP */
}
_util_get_file_name(entry.filename, file_name);
return;
}
+/* LCOV_EXCL_START */
void _entity_list_modified_files(mtp_uint32 minutes)
{
if (minutes == 0)
return;
}
+/* LCOV_EXCL_STOP */
#endif /* MTP_USE_SKIP_CONTINUOUS_OPENSESSION */
}
+/* LCOV_EXCL_START */
static void __process_commands(mtp_handler_t *hdlr, cmd_blk_t *cmd)
{
mtp_store_t *store = NULL;
}
return;
}
+/* LCOV_EXCL_STOP */
mtp_bool _cmd_hdlr_send_response(mtp_handler_t *hdlr, mtp_uint16 resp,
mtp_uint32 num_param, mtp_uint32 *params)
mtp_bool ret = FALSE;
resp_blk_t blk = { 0 };
+ if (hdlr == NULL)
+ return FALSE;
+ /* LCOV_EXCL_START */
_hdlr_resp_container_init(&blk, resp, hdlr->usb_cmd.tid);
ret = _hdlr_add_param_resp_container(&blk, num_param, params);
ERR("[%s], Opcode = [0x%4x] ResponseCode[0x%4x], NumParams[%u]\n",
"FAIL", hdlr->usb_cmd.code, resp, num_param);
}
+ /* LCOV_EXCL_STOP */
return ret;
}
return _cmd_hdlr_send_response(hdlr, resp, 0, NULL);
}
+/* LCOV_EXCL_START */
#ifdef MTP_SUPPORT_PRINT_COMMAND
static void __print_command(mtp_uint16 code)
{
mtp_word code = 0;
mtp_dword trid = 0;
+ if (buffer == NULL)
+ return;
+
for (i = 0; i < MAX_MTP_PARAMS; i++) { /* check size */
/* check number of parameter */
tmp = (cmd_container_t *)&buffer[buf_len -
return;
}
+/* LCOV_EXCL_STOP */
ERR("Not able to retrieve store");
return MTP_ERROR_GENERAL;
}
+ /* LCOV_EXCL_START */
_entity_update_store_info_run_time(&(store->store_info),
store->root_path);
info->store_type = store->store_info.store_type;
info->free_space_in_objs = store->store_info.free_space_in_objs;
return MTP_ERROR_NONE;
+ /* LCOV_EXCL_STOP */
}
mtp_err_t _hutil_get_storage_ids(ptp_array_t *store_ids)
prop = _device_get_device_property(prop_id);
if (prop == NULL)
return MTP_ERROR_GENERAL;
-
+/* LCOV_EXCL_START */
if (prop->propinfo.get_set == PTP_PROPGETSET_GETONLY)
return MTP_ERROR_ACCESS_DENIED;
return MTP_ERROR_INVALID_OBJ_PROP_VALUE;
return MTP_ERROR_NONE;
+/* LCOV_EXCL_STOP */
}
/*
mtp_uint16 ii = 0;
if (prop_id == 0xFFFFFFFF) {
-
+ /* LCOV_EXCL_START */
prop = _device_get_ref_prop_list();
if (prop == NULL) {
ERR("property reference is NULL");
}
for (ii = 0; ii < NUM_DEVICE_PROPERTIES; ii++)
_prop_reset_device_prop_desc(&prop[ii]);
+ /* LCOV_EXCL_STOP */
} else {
prop = _device_get_device_property(prop_id);
if (prop == NULL)
mtp_bool is_made_by_mtp = FALSE;
mtp_wchar w_file_name[MTP_MAX_FILENAME_SIZE + 1] = { 0 };
+ if (obj_info == NULL)
+ return MTP_ERROR_INVALID_PARAM;
+
if (obj_info->h_parent != PTP_OBJECTHANDLE_ROOT) {
+ /* LCOV_EXCL_START */
par_obj = _device_get_object_with_handle(obj_info->h_parent);
if (par_obj == NULL) {
ERR("parent is not existed.");
_entity_dealloc_obj_info(obj_info);
return MTP_ERROR_INVALID_PARENT;
}
+ /* LCOV_EXCL_STOP */
}
store = _device_get_store(obj_info->store_id);
obj_info->protcn_status = PTP_PROTECTIONSTATUS_NOPROTECTION;
}
+ if (file_name == NULL) {
+ _entity_dealloc_obj_info(obj_info);
+ _entity_dealloc_mtp_obj(obj);
+ return MTP_ERROR_INVALID_PARAM;
+ }
if (strlen(file_name) == 0) {
/* Generate a filename in 8.3 format for this object */
g_snprintf(utf8_temp, MTP_MAX_PATHNAME_SIZE + 1,
if (_util_create_path(new_f_path, sizeof(new_f_path),
store->root_path, utf8_temp) == FALSE) {
+ /* LCOV_EXCL_START */
_entity_dealloc_mtp_obj(obj);
return MTP_ERROR_GENERAL;
}
return MTP_ERROR_GENERAL;
}
}
-
+ /* LCOV_EXCL_STOP */
/*
* g_mgr->ftemp_st.filepath was allocated g_strdup("/tmp/.mtptemp.tmp");
* So if we need to change the path we need to allocate sufficient memory
#ifdef MTP_SUPPORT_ALBUM_ART
if (access(new_f_path, F_OK) == 0) {
+ /* LCOV_EXCL_START */
file_exist = TRUE;
/* if file is album, overwrite it. */
mtp_char alb_buf[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
alb_ext);
}
}
+ /* LCOV_EXCL_STOP */
}
#endif /*MTP_SUPPORT_ALBUM_ART*/
obj_info->obj_fmt > MTP_FMT_UNDEFINED_COLLECTION &&
obj_info->obj_fmt < MTP_FMT_UNDEFINED_DOC;
#endif /*MTP_USE_SELFMAKE_ABSTRACTION*/
+ /* LCOV_EXCL_START */
+ if (new_obj == NULL) {
+ _entity_dealloc_obj_info(obj_info);
+ _entity_dealloc_mtp_obj(obj);
+ return MTP_ERROR_INVALID_PARAM;
+ }
if (obj_info->obj_fmt == PTP_FMT_ASSOCIATION ||
is_made_by_mtp) {
*new_obj = _device_get_object_with_path(new_f_path);
_util_wchar_swprintf(temp_wfname,
MTP_MAX_PATHNAME_SIZE + 1, "COPY%d_%s", i, w_file_name);
}
-
+ /* LCOV_EXCL_STOP */
/* Save the full path to this object */
_entity_set_object_file_path(obj, new_f_path, CHAR_TYPE);
if (obj_info->obj_fmt == PTP_FMT_ASSOCIATION || is_made_by_mtp) {
/* Create the new object */
+ /* LCOV_EXCL_START */
DBG("[normal] create association file/folder[%s][0x%x]\n",
new_f_path, obj_info->association_type);
_entity_dealloc_mtp_obj(obj);
return MTP_ERROR_STORE_FULL;
}
+ /* LCOV_EXCL_STOP */
} else {
/* Reserve space for the object: Object itself, and probably
* some Filesystem-specific overhead
if (NULL == obj || NULL == obj->obj_info)
return MTP_ERROR_GENERAL;
+ if (obj_ptr == NULL)
+ return MTP_ERROR_INVALID_PARAM;
+
*obj_ptr = obj;
return MTP_ERROR_NONE;
}
return MTP_ERROR_GENERAL;
}
+ /* LCOV_EXCL_START */
if (h_parent > 0) {
if (keep_handle) {
/* two sam handle can occurs in folder copy case
return MTP_ERROR_NONE;
}
+/* LCOV_EXCL_STOP */
mtp_err_t _hutil_move_object_entry(mtp_uint32 dst_store_id, mtp_uint32 h_parent,
mtp_uint32 obj_handle)
ERR("object is [%p]\n", obj);
return MTP_ERROR_INVALID_OBJECTHANDLE;
}
+ /* LCOV_EXCL_START */
if (NULL == obj->obj_info) {
ERR("obj_info is [%p]\n", obj->obj_info);
return MTP_ERROR_GENERAL;
_util_add_file_to_db(new_obj->file_path);
return MTP_ERROR_NONE;
+ /* LCOV_EXCL_STOP */
}
return MTP_ERROR_GENERAL;
}
return MTP_ERROR_INVALID_OBJECTHANDLE;
}
+ /* LCOV_EXCL_START */
src = _device_get_store_containing_obj(obj_handle);
if (NULL == src) {
ERR("Source store not found");
return MTP_ERROR_NONE;
}
+/* LCOV_EXCL_STOP */
mtp_err_t _hutil_read_file_data_from_offset(mtp_uint32 obj_handle, off_t offset,
void *data, mtp_uint32 *data_sz)
return MTP_ERROR_INVALID_OBJECTHANDLE;
}
+ /* LCOV_EXCL_START */
if (obj->obj_info->protcn_status ==
MTP_PROTECTIONSTATUS_NONTRANSFERABLE_DATA) {
}
_util_file_close(h_file);
+ /* LCOV_EXCL_STOP */
return MTP_ERROR_NONE;
}
retv_if(obj == NULL, MTP_ERROR_INVALID_PARAM);
retv_if(obj->obj_info == NULL, MTP_ERROR_INVALID_PARAM);
-
+ /* LCOV_EXCL_START */
store = _device_get_store(store_id);
if (store == NULL) {
ERR("destination store is not valid");
#endif /*MTP_USE_RUNTIME_GETOBJECTPROPVALUE*/
_entity_add_object_to_store(store, obj);
-
+ /* LCOV_EXCL_STOP */
return MTP_ERROR_NONE;
}
}
}
+ /* LCOV_EXCL_START */
if (!h_parent) {
if (!format) {
*num_obj = _device_get_num_objects(store_id);
*num_obj = _entity_get_num_children(store, h_parent, format);
return MTP_ERROR_NONE;
}
+/* LCOV_EXCL_STOP */
mtp_err_t _hutil_get_object_handles(mtp_uint32 store_id, mtp_uint32 format,
mtp_uint32 h_parent, ptp_array_t *handle_arr)
}
if (store_id == PTP_STORAGEID_ALL && h_parent == PTP_OBJECTHANDLE_ROOT) {
- for (i = 0; i < _device_get_num_stores(); i++) {
- store = _device_get_store_at_index(i);
- _entity_get_objects_from_store_by_format(store, format, handle_arr);
+ for (i = 0; i < _device_get_num_stores(); i++) { // LCOV_EXCL_LINE
+ store = _device_get_store_at_index(i); // LCOV_EXCL_LINE
+ _entity_get_objects_from_store_by_format(store, format, handle_arr); // LCOV_EXCL_LINE
}
return MTP_ERROR_NONE;
} else if (store_id == PTP_STORAGEID_ALL && h_parent == PTP_OBJECTHANDLE_ALL) {
h_parent = PTP_OBJECTHANDLE_ROOT;
- for (i = 0; i < _device_get_num_stores(); i++) {
- store = _device_get_store_at_index(i);
- _entity_get_child_handles_with_same_format(store, h_parent, format, handle_arr);
+ for (i = 0; i < _device_get_num_stores(); i++) { // LCOV_EXCL_LINE
+ store = _device_get_store_at_index(i); // LCOV_EXCL_LINE
+ _entity_get_child_handles_with_same_format(store, h_parent, format, handle_arr); // LCOV_EXCL_LINE
}
return MTP_ERROR_NONE;
return MTP_ERROR_INVALID_STORE;
}
+ /* LCOV_EXCL_START */
_entity_get_objects_from_store_by_format(store, format, handle_arr);
return MTP_ERROR_NONE;
_entity_get_child_handles_with_same_format(store, h_parent, format, handle_arr);
return MTP_ERROR_NONE;
+ /* LCOV_EXCL_STOP */
}
mtp_err_t _hutil_construct_object_entry(mtp_uint32 store_id,
mtp_char file_name[MTP_MAX_FILENAME_SIZE + 1] = { 0 };
if (obj_data != NULL && obj_data->obj != NULL) {
+ /* LCOV_EXCL_START */
store = _device_get_store(obj_data->store_id);
if (store != NULL) {
DBG("check free size instead of re-calculation");
(store->root_path));
}
_entity_dealloc_mtp_obj(obj_data->obj);
+ /* LCOV_EXCL_STOP */
}
store = _device_get_store(store_id);
return MTP_ERROR_INVALID_STORE;
}
+ /* LCOV_EXCL_START */
if (store->store_info.access == PTP_STORAGEACCESS_R) {
ERR("Only read access allowed on store");
return MTP_ERROR_STORE_READ_ONLY;
#endif /* MTP_SUPPORT_ALBUM_ART */
if (obj_info != NULL)
_entity_dealloc_obj_info(obj_info);
-
+ /* LCOV_EXCL_STOP */
return resp;
}
return MTP_ERROR_INVALID_OBJECTHANDLE;
}
+ /* LCOV_EXCL_START */
tprop = _prop_get_prop_val(tobj, prop_code);
if (tprop != NULL) {
memcpy(prop_val, tprop, sizeof(obj_prop_val_t));
ERR("can not get the prop value for propcode [0x%x]\n", prop_code);
return MTP_ERROR_GENERAL;
+ /* LCOV_EXCL_STOP */
}
mtp_err_t _hutil_update_object_property(mtp_uint32 obj_handle,
return MTP_ERROR_INVALID_OBJECTHANDLE;
}
+ /* LCOV_EXCL_START */
obj_info = obj->obj_info;
/* Avoid to rename file/folder during file operating by phone side. */
if (_util_is_file_opened(obj->file_path) == TRUE) {
if (prop_sz != NULL)
*prop_sz = p_size;
-
+ /* LCOV_EXCL_STOP */
return MTP_ERROR_NONE;
}
if ((obj_handle != PTP_OBJECTHANDLE_UNDEFINED) &&
(obj_handle != PTP_OBJECTHANDLE_ALL)) {
/* Is this object handle valid? */
+ /* LCOV_EXCL_START */
store = _device_get_store_containing_obj(obj_handle);
if (store == NULL) {
ERR("invalid object handle");
return MTP_ERROR_INVALID_OBJECTHANDLE;
}
+ /* LCOV_EXCL_STOP */
}
if (prop_code == PTP_PROPERTY_UNDEFINED) {
}
}
+ /* LCOV_EXCL_START */
if (!(obj_handle == PTP_OBJECTHANDLE_ALL ||
obj_handle == PTP_OBJECTHANDLE_UNDEFINED) &&
!(format == PTP_FORMATCODE_NOTUSED ||
return MTP_ERROR_NO_SPEC_BY_FORMAT;
}
+ if (prop_list == NULL)
+ return MTP_ERROR_INVALID_PARAM;
+
_util_init_list(&(prop_list->prop_quad_list));
_prop_init_ptparray(obj_arr, UINT32_TYPE);
return MTP_ERROR_GENERAL;
}
}
+ /* LCOV_EXCL_STOP */
}
#ifndef MTP_USE_RUNTIME_GETOBJECTPROPVALUE
return MTP_ERROR_INVALID_OBJECTHANDLE;
}
+ /* LCOV_EXCL_START */
if (parray == NULL) {
*num_ele = 0;
return MTP_ERROR_GENERAL;
}
_prop_deinit_ptparray(&ref_arr);
+ /* LCOV_EXCL_STOP */
return MTP_ERROR_NONE;
}
retv_if(skip_param == 0, MTP_ERROR_INVALID_PARAM);
+/* LCOV_EXCL_START */
if (_device_get_playback_obj(&obj_handle) == FALSE) {
ERR("_device_get_playback_obj Fail");
return MTP_ERROR_GENERAL;
return MTP_ERROR_GENERAL;
}
+/* LCOV_EXCL_STOP */
mtp_err_t _hutil_format_storage(mtp_uint32 store_id, mtp_uint32 fs_format)
{
/*
* FUNCTIONS
*/
+/* LCOV_EXCL_START */
mtp_bool _eh_register_notification_callbacks(void)
{
mtp_int32 ret;
return TRUE;
}
+/* LCOV_EXCL_STOP */
* @param[out] None.
* @return None.
*/
+/* LCOV_EXCL_START */
static void __mtp_exit(void)
{
long cur_time;
return true;
}
+/* LCOV_EXCL_STOP */
void _mtp_init(add_rem_store_t sel)
{
/* Internal Storage */
if (MTP_PHONE_LOCK_OFF == _util_get_local_lock_status()) {
mtp_int32 ret;
+ /* LCOV_EXCL_START */
char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
ret = _util_media_content_connect();
goto MTP_INIT_FAIL;
}
}
+ /* LCOV_EXCL_STOP */
}
/* External Storage */
if (MTP_PHONE_MMC_INSERTED == _util_get_local_mmc_status()) {
+ /* LCOV_EXCL_START */
char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
_util_get_external_path(ext_path);
if (access(ext_path, F_OK) < 0) {
goto MTP_INIT_FAIL;
}
}
+ /* LCOV_EXCL_STOP */
}
/* Set mtpdeviceinfo */
fp = fopen(MTP_CONFIG_FILE_PATH, "r");
if (fp == NULL) {
+ /* LCOV_EXCL_START */
DBG("Default configuration is used");
g_conf.is_init = true;
__print_mtp_conf();
+ /* LCOV_EXCL_STOP */
return;
}
token = strtok_r(buf, "=", &saveptr);
if (token == NULL)
- continue;
+ continue; // LCOV_EXCL_LINE
if (strcasecmp(token, "mmap_threshold") == 0) {
token = strtok_r(NULL, "=", &saveptr);
if (token == NULL)
- continue;
+ continue; // LCOV_EXCL_LINE
g_conf.mmap_threshold = atoi(token);
} else if (strcasecmp(token, "init_rx_ipc_size") == 0) {
token = strtok_r(NULL, "=", &saveptr);
if (token == NULL)
- continue;
+ continue; // LCOV_EXCL_LINE
g_conf.init_rx_ipc_size = atoi(token);
} else if (strcasecmp(token, "init_tx_ipc_size") == 0) {
token = strtok_r(NULL, "=", &saveptr);
if (token == NULL)
- continue;
+ continue; // LCOV_EXCL_LINE
g_conf.init_tx_ipc_size = atoi(token);
} else if (strcasecmp(token, "max_rx_ipc_size") == 0) {
token = strtok_r(NULL, "=", &saveptr);
if (token == NULL)
- continue;
+ continue; // LCOV_EXCL_LINE
g_conf.max_rx_ipc_size = atoi(token);
} else if (strcasecmp(token, "max_tx_ipc_size") == 0) {
token = strtok_r(NULL, "=", &saveptr);
if (token == NULL)
- continue;
+ continue; // LCOV_EXCL_LINE
g_conf.max_tx_ipc_size = atoi(token);
} else if (strcasecmp(token, "read_usb_size") == 0) {
token = strtok_r(NULL, "=", &saveptr);
if (token == NULL)
- continue;
+ continue; // LCOV_EXCL_LINE
g_conf.read_usb_size = atoi(token);
} else if (strcasecmp(token, "write_usb_size") == 0) {
token = strtok_r(NULL, "=", &saveptr);
if (token == NULL)
- continue;
+ continue; // LCOV_EXCL_LINE
g_conf.write_usb_size = atoi(token);
} else if (strcasecmp(token, "read_file_size") == 0) {
+ /* LCOV_EXCL_START */
token = strtok_r(NULL, "=", &saveptr);
if (token == NULL)
- continue;
+ continue; // LCOV_EXCL_LINE
g_conf.read_file_size = atoi(token);
} else if (strcasecmp(token, "write_file_size") == 0) {
token = strtok_r(NULL, "=", &saveptr);
if (token == NULL)
- continue;
+ continue; // LCOV_EXCL_LINE
g_conf.write_file_size = atoi(token);
-
+ /* LCOV_EXCL_STOP */
} else if (strcasecmp(token, "max_io_buf_size") == 0) {
token = strtok_r(NULL, "=", &saveptr);
if (token == NULL)
- continue;
+ continue; // LCOV_EXCL_LINE
g_conf.max_io_buf_size = atoi(token);
} else if (strcasecmp(token, "read_file_delay") == 0) {
token = strtok_r(NULL, "=", &saveptr);
if (token == NULL)
- continue;
+ continue; // LCOV_EXCL_LINE
g_conf.read_file_delay = atoi(token);
} else if (strcasecmp(token, "support_pthread_sched") == 0) {
+ /* LCOV_EXCL_START */
token = strtok_r(NULL, "=", &saveptr);
if (token == NULL)
- continue;
+ continue; // LCOV_EXCL_LINE
g_conf.support_pthread_sched = atoi(token) ? true : false;
} else if (strcasecmp(token, "inheritsched") == 0) {
token = strtok_r(NULL, "=", &saveptr);
if (token == NULL)
- continue;
+ continue; // LCOV_EXCL_LINE
g_conf.inheritsched = *token;
} else if (strcasecmp(token, "schedpolicy") == 0) {
token = strtok_r(NULL, "=", &saveptr);
if (token == NULL)
- continue;
+ continue; // LCOV_EXCL_LINE
g_conf.schedpolicy = *token;
} else if (strcasecmp(token, "file_schedparam") == 0) {
token = strtok_r(NULL, "=", &saveptr);
if (token == NULL)
- continue;
+ continue; // LCOV_EXCL_LINE
g_conf.file_schedparam = atoi(token);
} else if (strcasecmp(token, "usb_schedparam") == 0) {
token = strtok_r(NULL, "=", &saveptr);
if (token == NULL)
- continue;
+ continue; // LCOV_EXCL_LINE
g_conf.usb_schedparam = atoi(token);
-
+ /* LCOV_EXCL_STOP */
} else {
ERR("Unknown option : %s\n", buf);
}
* It must not be called in gthr_mtp_event thread.
* It makes dead lock state if it is called in gthr_mtp_event thread.
*/
+/* LCOV_EXCL_START */
void mtp_end_event(void)
{
__mtp_exit();
}
+/* LCOV_EXCL_STOP */
static inline int _main_init()
{
return MTP_ERROR_NONE;
}
+#ifndef TIZEN_TEST_GTESTS
int main(int argc, char *argv[])
{
mtp_int32 ret;
+#ifdef TIZEN_TEST_GCOV
+ setenv("GCOV_PREFIX", "/tmp/daemon", 1);
+#endif
+
+#ifdef TIZEN_TEST_GCOV
+ void __gcov_flush(void); // if you use C++, you should declare extern "C" at out of the function.
+ __gcov_flush();
+#endif
+
if (_transport_select_driver() == FALSE) {
ERR("_transport_select_driver fail");
return MTP_ERROR_GENERAL;
return MTP_ERROR_NONE;
}
+#endif
errno = 0;
i = 0;
length = read(g_inoti_fd, buffer, sizeof(buffer));
+ /* LCOV_EXCL_START */
if (length < 0) {
ERR("read() Fail");
_util_print_error();
pthread_cleanup_pop(1);
return NULL;
+ /* LCOV_EXCL_STOP */
}
void _inoti_add_watch_for_fs_events(mtp_char *path)
if (g_cnt_watch_folder == INOTI_FOLDER_COUNT_MAX) {
/* find empty cell */
+ /* LCOV_EXCL_START */
for (i = 0; i < INOTI_FOLDER_COUNT_MAX; i++) {
/* If not empty */
if (g_inoti_watches[i].wd != 0)
IN_DELETE | IN_MOVED_FROM |
IN_MOVED_TO);
return;
+ /* LCOV_EXCL_STOP */
}
DBG("g_watch_folders[%d] add watch : %s\n", g_cnt_watch_folder, path);
ret = _util_thread_create(&g_inoti_thrd, "File system inotify thread\n",
PTHREAD_CREATE_JOINABLE, _thread_inoti, NULL);
if (FALSE == ret) {
+ /* LCOV_EXCL_START */
ERR("_util_thread_create() Fail");
_util_print_error();
close(g_inoti_fd);
return TRUE;
}
+/* LCOV_EXCL_STOP */
void _inoti_deinit_filesystem_events()
{
return;
}
+/* LCOV_EXCL_START */
static void __remove_inoti_watch(mtp_char *path)
{
mtp_int32 i = 0;
return TRUE;
}
+/* LCOV_EXCL_STOP */
static void __remove_recursive_inoti_watch(mtp_char *path)
{
return;
}
+/* LCOV_EXCL_START */
static void __delete_children_from_store_inoti(mtp_store_t *store,
mtp_obj_t *obj)
{
return;
}
+/* LCOV_EXCL_STOP */
static void __destroy_inoti_open_files_list()
{
ret_if(g_open_files_list == NULL);
+ /* LCOV_EXCL_START */
while (g_open_files_list) {
current = g_open_files_list;
g_open_files_list = g_open_files_list->previous;
g_open_files_list = NULL;
return;
+ /* LCOV_EXCL_STOP */
}
#endif /*MTP_SUPPORT_OBJECTADDDELETE_EVENT*/
return 0;
}
+/* LCOV_EXCL_START */
void _hdlr_copy_cmd_container_unknown_params(cmd_container_t *src,
cmd_container_t *dst)
{
return;
}
+/* LCOV_EXCL_STOP */
void _hdlr_copy_cmd_container(cmd_container_t *src, cmd_container_t *dst)
{
if (size < sizeof(header_container_t) || size > sizeof(cmd_container_t))
return FALSE;
+ /* LCOV_EXCL_START */
cmd_container_t *ptr = NULL;
ptr = (cmd_container_t *)blk;
}
return TRUE;
+ /* LCOV_EXCL_STOP */
}
void _hdlr_init_data_container(data_container_t *dst, mtp_uint16 code,
return (dst->data + sizeof(header_container_t));
}
+/* LCOV_EXCL_START */
mtp_bool _hdlr_send_data_container(data_container_t *dst)
{
mtp_uint32 sent;
return TRUE;
}
+/* LCOV_EXCL_STOP */
mtp_bool _hdlr_rcv_data_container(data_container_t *dst, mtp_uint32 size)
{
return TRUE;
}
+/* LCOV_EXCL_START */
mtp_bool _hdlr_rcv_file_in_data_container(data_container_t *dst,
mtp_char *filepath, mtp_uint32 path_len)
{
return TRUE;
}
+/* LCOV_EXCL_STOP */
mtp_uint32 _hdlr_get_payload_size(data_container_t *dst)
{
return;
}
+/* LCOV_EXCL_START */
mtp_bool _hdlr_send_resp_container(cmd_container_t *dst)
{
mtp_uint32 sent = 0;
return TRUE;
}
+/* LCOV_EXCL_STOP */
void _hdlr_init_event_container(cmd_container_t *dst, mtp_uint16 code,
mtp_uint32 tid, mtp_uint32 param1, mtp_uint32 param2)
#endif /* __BIG_ENDIAN__ */
return;
}
+
+/* LCOV_EXCL_START */
mtp_bool _hdlr_send_event_container(cmd_container_t *dst)
{
mtp_uint32 sent = 0;
return (retval == MTP_ERROR_NONE && sent == dst->len) ?
TRUE : FALSE;
}
+/* LCOV_EXCL_STOP */
void _hdlr_conv_cmd_container_byte_order(cmd_container_t *dst)
{
/*
* FUNCTIONS
*/
+/* LCOV_EXCL_START */
void _transport_save_cmd_buffer(mtp_char *buffer, mtp_uint32 size)
{
memcpy(g_mgr->ftemp_st.cmd_buf, buffer, size);
g_mgr->ftemp_st.data_count = 0;
return;
}
+/* LCOV_EXCL_STOP */
mtp_err_t _transport_rcv_temp_file_data(mtp_byte *buffer, mtp_uint32 size,
mtp_uint32 *count)
}
/*copy header */
+ /* LCOV_EXCL_START */
memcpy(buffer, g_mgr->ftemp_st.header_buf,
sizeof(header_container_t));
_util_thread_exit("__transport_thread_data_rcv is over");
return NULL;
}
+/* LCOV_EXCL_STOP */
void _transport_init_status_info(void)
{
return;
}
+/* LCOV_EXCL_START */
mtp_int32 _transport_get_control_event(void)
{
mtp_uint32 event_code;
{
return g_status.mtp_op_state;
}
+/* LCOV_EXCL_STOP */
void _transport_set_mtp_operation_state(mtp_state_t state)
{
return;
}
+/* LCOV_EXCL_START */
void _transport_set_usb_discon_state(mtp_bool is_usb_discon)
{
g_status.is_usb_discon = is_usb_discon;
return;
}
+/* LCOV_EXCL_STOP */
mtp_bool _transport_get_usb_discon_state(void)
{
return g_status.is_usb_discon;
}
+/* LCOV_EXCL_START */
void _transport_set_cancel_initialization(mtp_bool value)
{
g_status.cancel_intialization = value;
{
return g_status.cancel_intialization;
}
+/* LCOV_EXCL_STOP */
/*
* FUNCTIONS
*/
+/* LCOV_EXCL_START */
mtp_bool _transport_select_driver(void)
{
if (access(MTP_DRIVER_PATH, F_OK) == 0) {
return MTP_TRANSPORT_UNKNOWN;
}
+/* LCOV_EXCL_STOP */
* FUNCTIONS
*/
+/* LCOV_EXCL_START */
static mtp_bool __io_init()
{
int ret;
return MTP_MAX_PACKET_SIZE_SEND_HS;
}
+/* LCOV_EXCL_STOP */
const mtp_usb_driver_t mtp_usb_driver_ffs = {
/*
* FUNCTIONS
*/
+/* LCOV_EXCL_START */
static mtp_bool slp_transport_init_usb_device(void)
{
mtp_int32 status = 0;
return MTP_MAX_PACKET_SIZE_SEND_HS;
}
-
+/* LCOV_EXCL_STOP */
const mtp_usb_driver_t mtp_usb_driver_slp = {
.transport_init_usb_device = slp_transport_init_usb_device,
break;
case MTP_FILE_WRITE:
+/* LCOV_EXCL_START */
fmode = "w";
break;
*error = EINVAL;
return NULL;
}
+/* LCOV_EXCL_STOP */
fhandle = fopen(filename, fmode);
if (fhandle == NULL) {
return NULL;
}
+ /* LCOV_EXCL_START*/
fcntl(fileno(fhandle), F_SETFL, O_NOATIME);
return fhandle;
closedir(dir);
return ret;
}
+/* LCOV_EXCL_STOP */
/*
* mtp_bool _util_get_file_attrs(const mtp_char *filename, file_attr_t *attrs)
/*Reset attribute mode */
attrs->attribute = MTP_FILE_ATTR_MODE_NONE;
if (S_ISREG(fileinfo.st_mode)) {
+ /* LCOV_EXCL_START */
attrs->attribute |= MTP_FILE_ATTR_MODE_REG;
if (!((S_IWUSR & fileinfo.st_mode) ||
(S_IWGRP & fileinfo.st_mode) ||
}
return TRUE;
}
+/* LCOV_EXCL_STOP */
/*
* mtp_bool _util_ifind_first(mtp_char *dirname, DIR **dirp,
dir = opendir(dirname);
if (NULL == dir) {
+ /* LCOV_EXCL_START */
ERR("opendir(%s) Fail", dirname);
_util_print_error();
_util_print_error();
closedir(dir);
return FALSE;
+ /* LCOV_EXCL_STOP */
}
*dirp = dir;
case S_IFIFO:
case S_IFLNK:
case S_IFSOCK:
+ /* LCOV_EXCL_START */
dir_info->attrs.attribute |= MTP_FILE_ATTR_MODE_SYSTEM;
break;
ERR_SECURE("%s has unknown type. mode[0x%x]\n",
dir_info->filename, stat_buf.st_mode);
break;
+ /* LCOV_EXCL_STOP */
}
/* Directory Information */
return TRUE;
}
+/* LCOV_EXCL_START */
mtp_bool _util_get_filesystem_info_ext(mtp_char *storepath,
fs_info_t *fs_info)
{
return TRUE;
}
+/* LCOV_EXCL_STOP */
mtp_bool _util_get_filesystem_info_int(mtp_char *storepath, fs_info_t *fs_info)
{
return FALSE;
}
+/* LCOV_EXCL_START */
void _util_count_num_lines(FILE* fhandle, mtp_uint32 *num_lines)
{
if (fhandle == NULL)
fclose(fp);
return;
}
+/* LCOV_EXCL_STOP */
node = (slist_node_t *)g_malloc(sizeof(slist_node_t));
if (node == NULL) {
- ERR("g_malloc() Fail");
- return FALSE;
+ ERR("g_malloc() Fail"); // LCOV_EXCL_LINE
+ return FALSE; // LCOV_EXCL_LINE
}
node->value = data;
return TRUE;
}
+/* LCOV_EXCL_START */
slist_node_t* _util_delete_node(slist_t *l_ptr, void *data)
{
retv_if(data == NULL, NULL);
return temp;
}
+/* LCOV_EXCL_STOP */
/* This API will send NULL if list does not have elements */
slist_iterator* _util_init_list_iterator(slist_t *l_ptr)
temp = (slist_iterator *)g_malloc(sizeof(slist_iterator));
if (temp == NULL) {
- ERR("g_malloc() Fail");
- return NULL;
+ ERR("g_malloc() Fail"); // LCOV_EXCL_LINE
+ return NULL; // LCOV_EXCL_LINE
}
temp->node_ptr = l_ptr->start;
return temp->value;
}
+/* LCOV_EXCL_START */
slist_node_t* _util_get_first_node(slist_t *l_ptr)
{
retv_if(l_ptr == NULL, NULL);
return l_ptr->start;
}
+/* LCOV_EXCL_STOP */
void _util_deinit_list_iterator(slist_iterator *iter)
{
#include "mtp_support.h"
#include "mtp_fs.h"
+/* LCOV_EXCL_START */
static bool __fill_media_id_cb(media_info_h media, void *user_data)
{
mtp_int32 ret = MEDIA_CONTENT_ERROR_NONE;
MTP_PAL_SAFE_FREE(video->track);
return;
}
+/* LCOV_EXCL_STOP */
/*
* FUNCTIONS
*/
+/* LCOV_EXCL_START */
mtp_bool _util_msgq_init(msgq_id_t *mq_id, mtp_uint32 flags)
{
*mq_id = msgget(IPC_PRIVATE, 0666 | IPC_CREAT);
return TRUE;
}
+/* LCOV_EXCL_STOP */
/*
* FUNCTIONS
*/
+/* LCOV_EXCL_START */
void _util_conv_byte_order(void *data, mtp_int32 size)
{
mtp_int32 idx;
return;
}
+/* LCOV_EXCL_STOP */
/*
* If items_written is greater than or equal to dest_size,
utf8 = g_utf16_to_utf8(utf16, -1, &items_read, &items_written, &error);
if (utf8 == NULL) {
+ /* LCOV_EXCL_START */
ERR("%s\n", error->message);
g_error_free(error);
dest[0] = '\0';
items_written = 0;
+ /* LCOV_EXCL_STOP */
} else {
g_strlcpy(dest, (char *)utf8, dest_size);
g_free(utf8);
utf16 = g_utf8_to_utf16(src, -1, &items_read, &items_written, &error);
if (utf16 == NULL) {
+ /* LCOV_EXCL_START */
ERR("%s\n", error->message);
g_error_free(error);
error = NULL;
dest[0] = (mtp_wchar)'\0';
items_written = 0;
+ /* LCOV_EXCL_STOP */
} else {
_util_wchar_ncpy(dest, utf16, dest_items);
g_free(utf16);
* @param[out] dest Destination buffer
* @return None
*/
+/* LCOV_EXCL_START */
void _util_wchar_cpy(mtp_wchar *dest, const mtp_wchar *src)
{
ret_if(src == NULL);
return;
}
+/* LCOV_EXCL_STOP */
/*
* Copies a unicode string a given numbers of character.
pc1 = (char *)dest;
pc2 = (char *)src;
+ /* LCOV_EXCL_START */
while (n && (*pc2 || *(pc2 + 1))) {
--n;
*pc1++ = *pc2++;
return MTP_ERROR_NONE;
}
+/* LCOV_EXCL_STOP */
mtp_uint16 _util_get_fmtcode(const mtp_char *extn)
{
* @param[out] f_name gets filled with filename w/o extension
* @return True or False based on success or failure
*/
+/* LCOV_EXCL_START */
mtp_bool _util_get_file_name_wo_extn(const mtp_char *fullpath, mtp_char *f_name)
{
mtp_char *fname_ptr;
g_strlcpy(f_name, fname_ptr, ((mtp_uint32)(extn_ptr - fname_ptr) + 1));
return TRUE;
}
+/* LCOV_EXCL_STOP */
mtp_bool _util_is_path_len_valid(const mtp_char *path)
{
len = strlen(filename);
if (len > MTP_MAX_FILENAME_SIZE) {
+ /* LCOV_EXCL_START */
ERR("filename is too long :[%u] > [%u]\n", len,
MTP_MAX_FILENAME_SIZE);
return FALSE;
}
} while (1);
}
-
+/* LCOV_EXCL_STOP */
error = pthread_attr_init(&attr);
if (error != 0) {
- ERR("pthread_attr_init Fail [%d], errno [%d]\n", error, errno);
+ ERR("pthread_attr_init Fail [%d], errno [%d]\n", error, errno); // LCOV_EXCL_LINE
return FALSE;
}
error = pthread_attr_setdetachstate(&attr,
PTHREAD_CREATE_JOINABLE);
if (error != 0) {
+ /* LCOV_EXCL_START */
ERR("pthread_attr_setdetachstate Fail [%d], errno [%d]\n", error, errno);
pthread_attr_destroy(&attr);
return FALSE;
+ /* LCOV_EXCL_STOP */
}
}
error = pthread_create(tid, &attr, thread_func, arg);
if (error != 0) {
+ /* LCOV_EXCL_START */
ERR("Thread creation Fail [%d], errno [%d]\n", error, errno);
pthread_attr_destroy(&attr);
return FALSE;
+ /* LCOV_EXCL_STOP */
}
error = pthread_attr_destroy(&attr);
if (error != 0)
- ERR("pthread_attr_destroy Fail [%d] errno [%d]\n", error, errno);
+ ERR("pthread_attr_destroy Fail [%d] errno [%d]\n", error, errno); // LCOV_EXCL_LINE
return TRUE;
}
res = pthread_join(tid, data);
if (res != 0) {
ERR("pthread_join Fail res = [%d] for thread [%u] errno [%d]\n",
- res, tid, errno);
- return FALSE;
+ res, tid, errno); // LCOV_EXCL_LINE
+ return FALSE; // LCOV_EXCL_LINE
}
return TRUE;
return TRUE;
}
+/* LCOV_EXCL_START */
void _util_thread_exit(void *val_ptr)
{
pthread_exit(val_ptr);
return;
}
+/* LCOV_EXCL_STOP */
static phone_state_t g_ph_status = { 0 };
+/* LCOV_EXCL_START */
void _util_print_error()
{
/*In glibc-2.7, the longest error message string is 50 characters
strerror_r(errno, buff, sizeof(buff));
ERR("Error: [%d]:[%s]\n", errno, buff);
}
+/* LCOV_EXCL_STOP */
mtp_int32 _util_get_battery_level(void)
{
g_free(serial_no);
return TRUE;
}
+/* LCOV_EXCL_START */
g_free(serial_no);
handle = tel_init(NULL);
g_free(imei_no);
return TRUE;
}
+/* LCOV_EXCL_STOP */
void _util_get_vendor_ext_desc(mtp_char *vendor_ext_desc, mtp_uint32 len)
{
"http://tizen.org/feature/platform.version", &version);
if (ret != SYSTEM_INFO_ERROR_NONE) {
- ERR("system_info_get_value_string Fail : 0x%X\n", ret);
- g_strlcpy(vendor_ext_desc, MTP_VENDOR_EXTENSIONDESC_CHAR, len);
- return;
+ ERR("system_info_get_value_string Fail : 0x%X\n", ret); // LCOV_EXCL_LINE
+ g_strlcpy(vendor_ext_desc, MTP_VENDOR_EXTENSIONDESC_CHAR, len); // LCOV_EXCL_LINE
+ return; // LCOV_EXCL_LINE
}
g_snprintf(vendor_ext_desc, len, "%stizen.org:%s; ",
MTP_VENDOR_EXTENSIONDESC_CHAR, version);
"http://tizen.org/system/model_name", &model);
if (ret != SYSTEM_INFO_ERROR_NONE) {
- ERR("system_info_get_value_string Fail : 0x%X\n", ret);
- g_strlcpy(model_name, MTP_DEFAULT_MODEL_NAME, len);
- return;
+ ERR("system_info_get_value_string Fail : 0x%X\n", ret); // LCOV_EXCL_LINE
+ g_strlcpy(model_name, MTP_DEFAULT_MODEL_NAME, len); // LCOV_EXCL_LINE
+ return; // LCOV_EXCL_LINE
}
g_strlcpy(model_name, model, len);
g_free(model);
"http://tizen.org/feature/platform.version", &version);
if (ret != SYSTEM_INFO_ERROR_NONE) {
- ERR("system_info_get_value_string Fail : 0x%X\n", ret);
- g_strlcpy(device_version, MTP_DEFAULT_DEVICE_VERSION, len);
- return;
+ ERR("system_info_get_value_string Fail : 0x%X\n", ret); // LCOV_EXCL_LINE
+ g_strlcpy(device_version, MTP_DEFAULT_DEVICE_VERSION, len); // LCOV_EXCL_LINE
+ return; // LCOV_EXCL_LINE
}
ret = system_info_get_platform_string(
"http://tizen.org/system/build.string", &build_info);
if (ret != SYSTEM_INFO_ERROR_NONE) {
- ERR("system_info_get_value_string Fail : 0x%X\n", ret);
- g_strlcpy(device_version, MTP_DEFAULT_DEVICE_VERSION, len);
- g_free(version);
+ ERR("system_info_get_value_string Fail : 0x%X\n", ret); // LCOV_EXCL_LINE
+ g_strlcpy(device_version, MTP_DEFAULT_DEVICE_VERSION, len); // LCOV_EXCL_LINE
+ g_free(version); // LCOV_EXCL_LINE
return;
}
g_snprintf(device_version, len, "TIZEN %s (%s)", version, build_info);
return;
}
+/* LCOV_EXCL_START */
void _util_gen_alt_serial(mtp_char *serial, mtp_uint32 len)
{
struct timeval st;
*val = MTP_PHONE_MMC_INSERTED;
return;
}
+/* LCOV_EXCL_STOP */
phone_status_t _util_get_local_mmc_status(void)
{
return g_ph_status.mmc_state;
}
+/* LCOV_EXCL_START */
void _util_set_local_mmc_status(const phone_status_t val)
{
g_ph_status.mmc_state = val;
*val = MTP_PHONE_LOCK_OFF;
return;
}
+/* LCOV_EXCL_STOP */
phone_status_t _util_get_local_lock_status(void)
{
return g_ph_status.lock_state;
}
+/* LCOV_EXCL_START */
void _util_set_local_lock_status(const phone_status_t val)
{
g_ph_status.lock_state = val;
return TRUE;
}
+/* LCOV_EXCL_STOP */
void _util_get_external_path(char *external_path)
{
error = storage_foreach_device_supported(_util_device_external_supported_cb, external_path);
if (error != STORAGE_ERROR_NONE) {
+/* LCOV_EXCL_START */
ERR("get external storage path Fail");
if (external_path != NULL) {
strncpy(external_path, MTP_EXTERNAL_PATH_CHAR, sizeof(MTP_EXTERNAL_PATH_CHAR));
return 0;
}
+/* LCOV_EXCL_STOP */
uid_t _util_get_active_user()
{
user_cnt = sd_get_active_uids(&active_user_list);
if (user_cnt <= 0) {
+ /* LCOV_EXCL_START */
ret = _util_wait_for_user();
if (ret < 0)
return -1;
user_cnt = sd_get_active_uids(&active_user_list);
+ /* LCOV_EXCL_STOP */
}
if (user_cnt <= 0) {
+ /* LCOV_EXCL_START */
ERR("Active user not exists : %d", user_cnt);
if (active_user_list != NULL)
free(active_user_list);
return -1;
+ /* LCOV_EXCL_STOP */
}
if (active_user_list == NULL) {
active_name = pwd->pw_name;
if (active_name == NULL) {
+ /* LCOV_EXCL_START */
ERR("active_name is NULL");
strncpy(internal_path, MTP_USER_DIRECTORY, sizeof(MTP_USER_DIRECTORY));
internal_path[sizeof(MTP_USER_DIRECTORY) - 1] = 0;
return;
+ /* LCOV_EXCL_STOP */
}
if (internal_path != NULL) {
ERR("internal path is %s", internal_path);
}
+/* LCOV_EXCL_START */
mtp_bool _util_media_content_connect()
{
mtp_int32 ret = 0;
{
media_content_disconnect();
}
-
+/* LCOV_EXCL_STOP */
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(gtest-mtp-responder C CXX)
+
+SET(GTEST_TEST "gtest-mtp-responder")
+ADD_DEFINITIONS("-DUSE_DLOG")
+
+SET(REQUIRES_LIST ${REQUIRES_LIST}
+ glib-2.0
+ gio-2.0
+ gmock
+ dlog
+ capi-content-media-content
+ capi-media-metadata-extractor
+ vconf
+ dlog
+ tapi
+ capi-system-info
+ storage
+ libsystemd-daemon
+ libsystemd
+)
+
+IF(BUILD_GTESTS)
+ ADD_DEFINITIONS("-DTIZEN_TEST_GTESTS")
+ENDIF(BUILD_GTESTS)
+IF(BUILD_GCOV)
+ ADD_DEFINITIONS("-DTIZEN_TEST_GCOV")
+ENDIF(BUILD_GCOV)
+
+INCLUDE(FindPkgConfig)
+
+FILE(GLOB GTEST_TEST_SRCS *.cpp ${CMAKE_SOURCE_DIR}/src/*.c ${CMAKE_SOURCE_DIR}/src/entity/*.c ${CMAKE_SOURCE_DIR}/src/transport/*.c ${CMAKE_SOURCE_DIR}/src/util/*.c )
+
+PKG_CHECK_MODULES(GTEST_TEST_PKG REQUIRED ${REQUIRES_LIST})
+
+FOREACH(flag ${GTEST_TEST_PKG_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+INCLUDE_DIRECTORIES(${GTEST_TEST_PKG_INCLUDE_DIRS})
+LINK_DIRECTORIES(${GTEST_TEST_PKG_LIBRARY_DIRS})
+
+INCLUDE_DIRECTORIES(${pkgs_INCLUDE_DIRS})
+LINK_DIRECTORIES(${pkgs_LIBRARY_DIRS})
+
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -fPIE")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/entity)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/transport)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/util)
+
+#AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/src SRCS)
+#AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/src/entity SRCS)
+#AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/src/transport SRCS)
+#AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/src/util SRCS)
+
+ADD_EXECUTABLE(${GTEST_TEST} ${GTEST_TEST_SRCS})
+TARGET_LINK_LIBRARIES(${GTEST_TEST} ${GTEST_TEST_LDFLAGS} ${GTEST_TEST_PKG_LDFLAGS} ${LIBRARY} ${pkgs_LDFLAGS} -ldl -lgcov -lpthread -lrt -lgcrypt)
+INSTALL(TARGETS ${GTEST_TEST} RUNTIME DESTINATION bin)
--- /dev/null
+/*
+ * Copyright (c) 2017 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 <iostream>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include "mtpResponder.h"
+
+MtpResponder::MtpResponder(void)
+{
+
+}
+
+MtpResponder::~MtpResponder(void)
+{
+ _mtp_deinit();
+}
+
+
+int MtpResponder::mtp_init(add_rem_store_t sel)
+{
+ _mtp_init(sel);
+
+ return ERROR_NONE;
+}
+
+int MtpResponder::mtp_deinit(void)
+{
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ _mtp_deinit();
+
+ return ERROR_NONE;
+}
+
+int MtpResponder::hutil_get_storage_entry(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ ret = _hutil_get_storage_entry(0, NULL);
+
+ return ret;
+}
+
+int MtpResponder::hutil_get_storage_ids(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ ptp_array_t store_ids = {UINT32_TYPE, 0, 0, NULL};
+
+ ret = _hutil_get_storage_ids(&store_ids);
+
+ return ret;
+}
+
+int MtpResponder::hutil_get_device_property(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ ret = _hutil_get_device_property(0, NULL);
+
+ return ret;
+}
+
+int MtpResponder::hutil_set_device_property(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ ret = _hutil_set_device_property(0, NULL, 0);
+
+ return ret;
+}
+
+int MtpResponder::hutil_reset_device_entry(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ ret = _hutil_reset_device_entry(0);
+
+ return ret;
+}
+
+int MtpResponder::hutil_add_object_entry(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ ret = _hutil_add_object_entry(NULL, NULL, NULL);
+
+ return ret;
+}
+
+int MtpResponder::hutil_remove_object_entry(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ ret = _hutil_remove_object_entry(0, 0);
+
+ return ret;
+}
+
+int MtpResponder::hutil_get_object_entry(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ mtp_obj_t *ptr_mtp_obj = NULL;
+ ret = _hutil_get_object_entry(0, &ptr_mtp_obj);
+
+ return ret;
+}
+
+int MtpResponder::hutil_copy_object_entries(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ mtp_uint32 new_hobj = 0;
+ ret = _hutil_copy_object_entries(0, 0, 0, 0, &new_hobj, 0);
+
+ return ret;
+}
+
+int MtpResponder::hutil_move_object_entry(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ ret = _hutil_move_object_entry(0, 0, 0);
+
+ return ret;
+}
+
+int MtpResponder::hutil_duplicate_object_entry(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ mtp_uint32 new_handle = 0;
+ ret = _hutil_duplicate_object_entry(0, 0, 0, &new_handle);
+
+ return ret;
+}
+
+int MtpResponder::hutil_read_file_data_from_offset(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ mtp_uint32 data_sz = 0;
+ mtp_char data[] = "aaaaaaaaaa";
+ ret = _hutil_read_file_data_from_offset(0, (off_t)0, (void*)data, &data_sz);
+
+ return ret;
+}
+
+int MtpResponder::hutil_write_file_data(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ mtp_char fpath[] = "/Phone/DCIM/abc.txt";
+ ret = _hutil_write_file_data(0, NULL, fpath);
+
+ return ret;
+}
+
+int MtpResponder::hutil_get_object_entry_size(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ mtp_uint64 obj_sz = 0;
+ ret = _hutil_get_object_entry_size(0, &obj_sz);
+
+ return ret;
+}
+
+#ifdef MTP_SUPPORT_SET_PROTECTION
+int MtpResponder::hutil_set_protection(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ ret = _hutil_set_protection(0, 0);
+
+ return ret;
+}
+#endif /* MTP_SUPPORT_SET_PROTECTION */
+
+int MtpResponder::hutil_get_num_objects(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ mtp_uint32 num_obj = 0;
+ ret = _hutil_get_num_objects(0, 0, 0, &num_obj);
+
+ return ret;
+}
+
+int MtpResponder::hutil_get_object_handles(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ ptp_array_t handle_arr = {UINT32_TYPE, 0, 0, NULL};
+ ret = _hutil_get_object_handles(0, 0, 0, &handle_arr);
+
+ return ret;
+}
+
+int MtpResponder::hutil_construct_object_entry(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ obj_data_t obj_data = {0, 0, NULL};
+ mtp_obj_t *mtp_obj = NULL;
+ mtp_char data[] = "aaaaaaaaa";
+ ret = _hutil_construct_object_entry(0, 0, &obj_data, &mtp_obj, (void*)data, 0);
+
+ return ret;
+}
+
+//========================================
+
+int MtpResponder::hutil_construct_object_entry_prop_list(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ obj_data_t obj_data = {0, 0, NULL};
+ mtp_obj_t *mtp_obj = NULL;
+ mtp_char data[] = "aaaaaaaaa";
+ mtp_uint32 err_idx = 0;
+ ret = _hutil_construct_object_entry_prop_list(0, 0, 0, 0, &obj_data, &mtp_obj, (void*)data, 0, &err_idx);
+
+ return ret;
+}
+
+int MtpResponder::hutil_get_object_prop_value(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ mtp_obj_t *mtp_obj = NULL;
+ ret = _hutil_get_object_prop_value(0, 0, NULL, &mtp_obj);
+
+ return ret;
+}
+
+int MtpResponder::hutil_update_object_property(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ mtp_uint16 data_type = 0;
+ mtp_char buf[] = "aaaaaa";
+ mtp_uint32 prop_sz = 0;
+ ret = _hutil_update_object_property(0, 0, &data_type, (void*)buf, 0, &prop_sz);
+
+ return ret;
+}
+
+int MtpResponder::hutil_get_prop_desc(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ mtp_char data[] = "aaaaaa";
+ ret = _hutil_get_prop_desc(0, 0, &data);
+
+ return ret;
+}
+
+int MtpResponder::hutil_get_object_prop_supported(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ ptp_array_t prop_arr = {UINT32_TYPE, 0, 0, NULL};
+
+ ret = _hutil_get_object_prop_supported(0, &prop_arr);
+
+ return ret;
+}
+
+int MtpResponder::hutil_get_object_prop_list(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ ptp_array_t obj_arr = {UINT32_TYPE, 0, 0, NULL};
+
+ #ifdef MTP_USE_RUNTIME_GETOBJECTPROPVALUE
+ ret = _hutil_get_object_prop_list(0, 0, 0, 0, 0, NULL, &obj_arr);
+ #else /* MTP_USE_RUNTIME_GETOBJECTPROPVALUE */
+ ret = _hutil_get_object_prop_list(0, 0, 0, 0, 0, NULL);
+ #endif /* MTP_USE_RUNTIME_GETOBJECTPROPVALUE */
+
+ return ret;
+}
+
+int MtpResponder::hutil_add_object_references_enhanced(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ mtp_uchar buffer[] = "aaaaaaaa";
+ ret = _hutil_add_object_references_enhanced(0, buffer, 0);
+
+ return ret;
+}
+
+int MtpResponder::hutil_remove_object_reference(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ ret = _hutil_remove_object_reference(0, 0);
+
+ return ret;
+}
+
+int MtpResponder::hutil_get_object_references(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ ptp_array_t parray = {UINT32_TYPE, 0, 0, NULL};
+ mtp_uint32 num_ele = 0;
+ ret = _hutil_get_object_references(0, &parray, &num_ele);
+
+ return ret;
+}
+
+int MtpResponder::hutil_get_number_of_objects(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ mtp_uint32 num_obj = 0;
+ ret = _hutil_get_number_of_objects(0, &num_obj);
+
+ return ret;
+}
+
+int MtpResponder::hutil_get_interdep_prop_config_list_size(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ mtp_uint32 list_sz = 0;
+ ret = _hutil_get_interdep_prop_config_list_size(&list_sz, 0);
+
+ return ret;
+}
+
+int MtpResponder::hutil_get_interdep_prop_config_list_data(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ mtp_char data[] = "aaaaaaaa";
+ ret = _hutil_get_interdep_prop_config_list_data(data, 0, 0);
+
+ return ret;
+}
+
+int MtpResponder::hutil_get_playback_skip(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ ret = _hutil_get_playback_skip(0);
+
+ return ret;
+}
+
+int MtpResponder::hutil_format_storage(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ ret = _hutil_format_storage(0, 0);
+
+ return ret;
+}
+
+int MtpResponder::hutil_get_storage_info_size(void)
+{
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ int ret_size = -1;
+ store_info_t store_info;
+ ret_size = _hutil_get_storage_info_size(&store_info);
+
+ if (ret_size >= 0)
+ return ERROR_NONE;
+ return ERROR_OPERATION_FAILED;
+}
+
+//================== _MTP_CMD_HANDLER_H_ ======================
+
+int MtpResponder::cmd_hdlr_send_response(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ mtp_uint32 params = 0;
+ ret = _cmd_hdlr_send_response(NULL, 0, 0, ¶ms);
+
+ return ret;
+}
+
+int MtpResponder::cmd_hdlr_send_response_code(void)
+{
+ int ret = 0;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+ _mtp_init(sel);
+
+ ret = _cmd_hdlr_send_response_code(NULL, 0);
+
+ return ret;
+}
+
+//================== _MTP_EVENT_HANDLER_H_ ======================
+
+int MtpResponder::hdlr_get_param_cmd_container(void)
+{
+ int ret = 0;
+
+ cmd_container_t cntr;
+ mtp_uint32 index = 0;
+ _hdlr_init_cmd_container(&cntr);
+
+ ret = _hdlr_get_param_cmd_container(&cntr, index);
+
+ return ret;
+}
+
+int MtpResponder::hdlr_add_param_resp_container(void)
+{
+ int ret = 0;
+
+ cmd_container_t cntr;
+ cmd_container_t dst;
+ mtp_uint32 param = 0;
+ _hdlr_init_cmd_container(&cntr);
+ _hdlr_copy_cmd_container(&cntr, &dst);
+
+ ret = _hdlr_add_param_resp_container(&dst, 0, ¶m);
+
+ return (!ret);
+}
+
+int MtpResponder::hdlr_validate_cmd_container(void)
+{
+ int ret = 0;
+
+ cmd_container_t cntr;
+ _hdlr_init_cmd_container(&cntr);
+
+ ret = _hdlr_validate_cmd_container((mtp_uchar*)&cntr, 0);
+
+ return (!ret);
+}
+
+int MtpResponder::hdlr_alloc_buf_data_container(void)
+{
+ data_container_t dst;
+ _hdlr_init_data_container(&dst, 0, 0);
+
+ mtp_uchar *ptr = NULL;
+ ptr = _hdlr_alloc_buf_data_container(&dst, 0, 0);
+
+ if (ptr == NULL)
+ return ERROR_OPERATION_FAILED;
+ return ERROR_NONE;
+}
+
+int MtpResponder::hdlr_send_data_container(void)
+{
+ int ret = 0;
+
+ data_container_t dst;
+ _hdlr_init_data_container(&dst, 0, 0);
+ _hdlr_alloc_buf_data_container(&dst, 0, 0);
+
+ ret = _hdlr_send_data_container(&dst);
+
+ return ret;
+}
+
+int MtpResponder::hdlr_send_bulk_data(void)
+{
+ int ret = 0;
+
+ data_container_t dst;
+ _hdlr_init_data_container(&dst, 0, 0);
+
+ ret = _hdlr_send_bulk_data((mtp_uchar*)&dst, sizeof(data_container_t));
+
+ return ret;
+}
+
+int MtpResponder::hdlr_rcv_data_container(void)
+{
+ int ret = 0;
+
+ data_container_t dst;
+ _hdlr_init_data_container(&dst, 0, 0);
+
+ ret = _hdlr_rcv_data_container(&dst, 0);
+
+ return ret;
+}
+
+int MtpResponder::hdlr_get_payload_size(void)
+{
+ int payload_size = -1;
+
+ data_container_t dst;
+ _hdlr_init_data_container(&dst, 0, 0);
+
+ payload_size = _hdlr_get_payload_size(&dst);
+
+ if (payload_size >= 0)
+ return ERROR_NONE;
+ return ERROR_OPERATION_FAILED;
+}
+
+int MtpResponder::hdlr_get_payload_data(void)
+{
+ mtp_uchar *ptr = NULL;
+
+ data_container_t dst;
+ _hdlr_init_data_container(&dst, 0, 0);
+ _hdlr_alloc_buf_data_container(&dst, 0, 0);
+
+ ptr = _hdlr_get_payload_data(&dst);
+
+ if (ptr != NULL)
+ return ERROR_NONE;
+ return ERROR_OPERATION_FAILED;
+}
+
+int MtpResponder::hdlr_resp_container_init(void)
+{
+ cmd_container_t dst;
+ _hdlr_resp_container_init(&dst, 0, 0);
+
+ return ERROR_NONE;
+}
+
+int MtpResponder::hdlr_init_event_container(void)
+{
+ cmd_container_t dst;
+ _hdlr_init_event_container(&dst, 0, 0, 0, 0);
+
+ return ERROR_NONE;
+}
+
+int MtpResponder::hdlr_init_event_container_with_param(void)
+{
+ cmd_container_t dst;
+ _hdlr_init_event_container_with_param(&dst, 0, 0, 0, 0);
+
+ return ERROR_NONE;
+}
+
+int MtpResponder::hdlr_conv_cmd_container_byte_order(void)
+{
+ cmd_container_t dst;
+ _hdlr_conv_cmd_container_byte_order(&dst);
+
+ return ERROR_NONE;
+}
+
+int MtpResponder::hdlr_conv_data_container_byte_order(void)
+{
+ data_container_t dst;
+ _hdlr_conv_data_container_byte_order(&dst);
+
+ return ERROR_NONE;
+}
+
+
+
+
+
+
--- /dev/null
+/*
+ * Copyright (c) 2017 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 __MTP_RESPONDER_H__
+#define __MTP_RESPONDER_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "mtpconf.h"
+#include "mtp_init.h"
+
+#include "mtp_thread.h"
+#include "mtp_support.h"
+#include "mtp_device.h"
+#include "mtp_event_handler.h"
+#include "mtp_cmd_handler.h"
+#include "mtp_cmd_handler_util.h"
+#include "mtp_inoti_handler.h"
+#include "mtp_transport.h"
+#include "mtp_util.h"
+#include "mtp_media_info.h"
+#include "mtp_usb_driver.h"
+#include "mtp_descs_strings.h"
+
+class MtpResponder {
+ private:
+ public:
+ MtpResponder(void);
+ ~MtpResponder(void);
+
+ int mtp_init(add_rem_store_t sel);
+ int mtp_deinit(void);
+ int hutil_get_storage_entry(void);
+ int hutil_get_storage_ids(void);
+ int hutil_get_device_property(void);
+ int hutil_set_device_property(void);
+ int hutil_reset_device_entry(void);
+ int hutil_add_object_entry(void);
+ int hutil_remove_object_entry(void);
+ int hutil_get_object_entry(void);
+ int hutil_copy_object_entries(void);
+ int hutil_move_object_entry(void);
+ int hutil_duplicate_object_entry(void);
+ int hutil_read_file_data_from_offset(void);
+ int hutil_write_file_data(void);
+ int hutil_get_object_entry_size(void);
+ int hutil_set_protection(void);
+ int hutil_get_num_objects(void);
+ int hutil_get_object_handles(void);
+ int hutil_construct_object_entry(void);
+
+//========================================
+
+ int hutil_construct_object_entry_prop_list(void);
+ int hutil_get_object_prop_value(void);
+ int hutil_update_object_property(void);
+ int hutil_get_prop_desc(void);
+ int hutil_get_object_prop_supported(void);
+ int hutil_get_object_prop_list(void);
+ int hutil_add_object_references_enhanced(void);
+ int hutil_remove_object_reference(void);
+ int hutil_get_object_references(void);
+ int hutil_get_number_of_objects(void);
+ int hutil_get_interdep_prop_config_list_size(void);
+ int hutil_get_interdep_prop_config_list_data(void);
+ int hutil_get_playback_skip(void);
+ int hutil_format_storage(void);
+ int hutil_get_storage_info_size(void);
+
+//================== _MTP_CMD_HANDLER_H_ ======================
+
+ int cmd_hdlr_send_response(void);
+ int cmd_hdlr_send_response_code(void);
+
+//================== _MTP_EVENT_HANDLER_H_ ======================
+
+ int hdlr_get_param_cmd_container(void);
+ int hdlr_add_param_resp_container(void);
+ int hdlr_validate_cmd_container(void);
+ int hdlr_alloc_buf_data_container(void);
+ int hdlr_send_data_container(void);
+ int hdlr_send_bulk_data(void);
+ int hdlr_rcv_data_container(void);
+ int hdlr_get_payload_size(void);
+ int hdlr_get_payload_data(void);
+ int hdlr_resp_container_init(void);
+ int hdlr_init_event_container(void);
+ int hdlr_init_event_container_with_param(void);
+ int hdlr_conv_cmd_container_byte_order(void);
+ int hdlr_conv_data_container_byte_order(void);
+
+
+
+
+
+};
+#endif /* __MTP_RESPONDER_H__ */
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null
+/*
+ * Copyright (c) 2017 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 __MTPCONF_H__
+#define __MTPCONF_H__
+
+#include <glib.h>
+
+#ifdef USE_DLOG
+#include <dlog.h>
+#undef LOG_TAG
+#define LOG_TAG "MTP_RESPONDER_TEST"
+#define GLOGD(format, args...) LOGD(format, ##args)
+#else
+#define GLOGD(format, args...)
+#endif
+
+typedef enum {
+ ERROR_NONE = 0,
+ ERROR_NOT_PERMITTED = -1,
+ ERROR_OUT_OF_MEMORY = -2,
+ ERROR_PERMISSION_DENIED = -3,
+ ERROR_RESOURCE_BUSY = -4,
+ ERROR_INVALID_OPERATION = -5,
+ ERROR_INVALID_PARAMETER = -6,
+ ERROR_NOT_SUPPORTED = -7,
+ ERROR_OPERATION_FAILED = -8,
+ ERROR_NOT_INITIALIZED = -9,
+ ERROR_ALREADY_INITIALIZED = -10,
+ ERROR_IN_PROGRESS = -11,
+} error_e;
+#endif /* __MTPCONF_H__ */
+
--- /dev/null
+/*
+ * Copyright (c) 2017 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 <iostream>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <unistd.h>
+
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <glib.h>
+#include <glib-object.h>
+#include <malloc.h>
+#include <vconf.h>
+
+#include "mtpResponder.h"
+
+using ::testing::InitGoogleTest;
+using ::testing::Test;
+using ::testing::TestCase;
+
+#ifdef TIZEN_TEST_GCOV
+extern "C" void __gcov_flush(void);
+#endif
+
+TEST(MtpResponder_t, mtp_init_p0)
+{
+ int ret = 0;
+ MtpResponder mtp;
+ add_rem_store_t sel = MTP_ADDREM_AUTO;
+
+ ret = mtp.mtp_init(sel);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, mtp_init_p1)
+{
+ int ret = 0;
+ MtpResponder mtp;
+ add_rem_store_t sel = MTP_ADDREM_INTERNAL;
+
+ ret = mtp.mtp_init(sel);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, mtp_init_p2)
+{
+ int ret = 0;
+ MtpResponder mtp;
+ add_rem_store_t sel = MTP_ADDREM_EXTERNAL;
+
+ ret = mtp.mtp_init(sel);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, mtp_init_p3)
+{
+ int ret = 0;
+ MtpResponder mtp;
+ add_rem_store_t sel = MTP_ADDREM_ALL;
+
+ ret = mtp.mtp_init(sel);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, mtp_deinit_p0)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.mtp_deinit();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_get_storage_entry_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_get_storage_entry();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_get_storage_ids_p)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_get_storage_ids();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_get_device_property_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_get_device_property();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_set_device_property_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_set_device_property();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_reset_device_entry_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_reset_device_entry();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_add_object_entry_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_add_object_entry();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_remove_object_entry_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_remove_object_entry();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_get_object_entry_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_get_object_entry();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_copy_object_entries_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_copy_object_entries();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_move_object_entry_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_move_object_entry();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_duplicate_object_entry_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_duplicate_object_entry();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_read_file_data_from_offset_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_read_file_data_from_offset();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_write_file_data_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_write_file_data();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_get_object_entry_size_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_get_object_entry_size();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+#ifdef MTP_SUPPORT_SET_PROTECTION
+TEST(MtpResponder_t, hutil_set_protection_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_set_protection();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+#endif /* MTP_SUPPORT_SET_PROTECTION */
+
+TEST(MtpResponder_t, hutil_get_num_objects_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_get_num_objects();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_get_object_handles_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_get_object_handles();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_construct_object_entry_p)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_construct_object_entry();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+//========================================
+
+TEST(MtpResponder_t, hutil_construct_object_entry_prop_list_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_construct_object_entry_prop_list();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_get_object_prop_value_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_get_object_prop_value();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_update_object_property_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_update_object_property();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_get_prop_desc_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_get_prop_desc();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_get_object_prop_supported_p)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_get_object_prop_supported();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_get_object_prop_list_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_get_object_prop_list();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_add_object_references_enhanced_p)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_add_object_references_enhanced();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_remove_object_reference_p)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_remove_object_reference();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_get_object_references_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_get_object_references();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_get_number_of_objects_p)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_get_number_of_objects();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_get_interdep_prop_config_list_size_p)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_get_interdep_prop_config_list_size();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_get_interdep_prop_config_list_data_p)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_get_interdep_prop_config_list_data();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_get_playback_skip_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_get_playback_skip();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_format_storage_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_format_storage();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hutil_get_storage_info_size_p)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hutil_get_storage_info_size();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+//================== _MTP_CMD_HANDLER_H_ ======================
+
+TEST(MtpResponder_t, cmd_hdlr_send_response_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.cmd_hdlr_send_response();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, cmd_hdlr_send_response_code_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.cmd_hdlr_send_response_code();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+//================== _MTP_EVENT_HANDLER_H_ ======================
+
+TEST(MtpResponder_t, hdlr_get_param_cmd_container_p)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hdlr_get_param_cmd_container();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hdlr_add_param_resp_container_p)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hdlr_add_param_resp_container();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hdlr_validate_cmd_container_p)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hdlr_validate_cmd_container();
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hdlr_alloc_buf_data_container_p)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hdlr_alloc_buf_data_container();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+/*
+TEST(MtpResponder_t, hdlr_send_data_container_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hdlr_send_data_container();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hdlr_send_bulk_data_n)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hdlr_send_bulk_data();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+*/
+TEST(MtpResponder_t, hdlr_rcv_data_container_p)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hdlr_rcv_data_container();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hdlr_get_payload_size_p)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hdlr_get_payload_size();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hdlr_get_payload_data_p)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hdlr_get_payload_data();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hdlr_resp_container_init_p)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hdlr_resp_container_init();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hdlr_init_event_container_p)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hdlr_init_event_container();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hdlr_init_event_container_with_param_p)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hdlr_init_event_container_with_param();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hdlr_conv_cmd_container_byte_order_p)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hdlr_conv_cmd_container_byte_order();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(MtpResponder_t, hdlr_conv_data_container_byte_order_p)
+{
+ int ret = 0;
+ MtpResponder mtp;
+
+ ret = mtp.hdlr_conv_data_container_byte_order();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+//mtp_bool _hdlr_rcv_file_in_data_container(data_container_t *dst, mtp_char *filepath, mtp_uint32 path_len);
+
+
+
+//========================================
+
+int main(int argc, char **argv)
+{
+#ifdef TIZEN_TEST_GCOV
+ setenv("GCOV_PREFIX", "/tmp", 1);
+#endif
+
+ InitGoogleTest(&argc, argv);
+ int ret = RUN_ALL_TESTS();
+
+#ifdef TIZEN_TEST_GCOV
+ __gcov_flush();
+#endif
+ return ret;
+}
+
+
+
+
+