From 5ef7d20d11ca6c38db03c21c79c088cc9d8f1807 Mon Sep 17 00:00:00 2001 From: Hyihong Chae Date: Wed, 2 Mar 2016 13:55:06 +0900 Subject: [PATCH 01/16] remove dependency of 'libprivilege-control' Change-Id: I0ad1c6e456552386ceb0b82642b7d52d44f6d2ec Signed-off-by: HyiHong Chae --- CMakeLists.txt | 2 +- packaging/mtp-responder.spec | 1 - src/mtp_init.c | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7346a98..5154fb0 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/src/util SRCS) INCLUDE(FindPkgConfig) pkg_check_modules(pkgs REQUIRED glib-2.0 capi-content-media-content - capi-media-metadata-extractor vconf dlog tapi libprivilege-control capi-system-info) + capi-media-metadata-extractor vconf dlog tapi capi-system-info) FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/packaging/mtp-responder.spec b/packaging/mtp-responder.spec index c702ea7..534cde6 100755 --- a/packaging/mtp-responder.spec +++ b/packaging/mtp-responder.spec @@ -17,7 +17,6 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(tapi) -BuildRequires: pkgconfig(libprivilege-control) BuildRequires: pkgconfig(capi-content-media-content) BuildRequires: pkgconfig(capi-media-metadata-extractor) BuildRequires: pkgconfig(capi-system-info) diff --git a/src/mtp_init.c b/src/mtp_init.c index 55b8fde..ca2455c 100755 --- a/src/mtp_init.c +++ b/src/mtp_init.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include -- 2.7.4 From a825fd201d976b966a9ba94e932f449f84ac815f Mon Sep 17 00:00:00 2001 From: Hyihong Chae Date: Fri, 11 Mar 2016 16:13:29 +0900 Subject: [PATCH 02/16] fix build warning Change-Id: Ia8d8ab4c829a019923d83486f28be3debc61dc5e Signed-off-by: HyiHong Chae --- include/util/mtp_util.h | 5 ----- packaging/mtp-responder.spec | 2 +- src/mtp_cmd_handler.c | 5 ++--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/include/util/mtp_util.h b/include/util/mtp_util.h index 22a39fb..f2e0af4 100755 --- a/include/util/mtp_util.h +++ b/include/util/mtp_util.h @@ -33,11 +33,6 @@ "-o -iname '*.wmv' -o -iname '*.avi' -o -iname '*.wma' " \ "-o -iname '*.mp3' \\) -mmin -%d >> %s" -#define VCONFKEY_MTP_PREFIX "db/private/mtp" -#define VCONFKEY_MTP_SERIAL_NUMBER_STR VCONFKEY_MTP_PREFIX"/serial_number" -#define VCONFKEY_MTP_SYNC_PARTNER_STR VCONFKEY_MTP_PREFIX"/sync_partner" -#define VCONFKEY_MTP_SYNC_TIME_INT VCONFKEY_MTP_PREFIX"/sync_time" - #define DBG(format, args...) SLOGD(format, ##args) #define ERR(format, args...) SLOGE(format, ##args) #define DBG_SECURE(format, args...) SECURE_SLOGD(format, ##args) diff --git a/packaging/mtp-responder.spec b/packaging/mtp-responder.spec index 534cde6..4885f2d 100755 --- a/packaging/mtp-responder.spec +++ b/packaging/mtp-responder.spec @@ -5,7 +5,7 @@ ExcludeArch: %arm aarch64 Name: mtp-responder Summary: Media Transfer Protocol daemon (responder) -Version: 0.0.3 +Version: 0.0.4 Release: 1 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/src/mtp_cmd_handler.c b/src/mtp_cmd_handler.c index 48908fc..282ac32 100755 --- a/src/mtp_cmd_handler.c +++ b/src/mtp_cmd_handler.c @@ -1078,7 +1078,6 @@ static void __format_store(mtp_handler_t *hdlr) { mtp_uint32 store_id = 0; mtp_uint32 fs_fmt = 0; - mtp_uint16 ret = 0; if (_hdlr_get_param_cmd_container(&(hdlr->usb_cmd), 2)) { _cmd_hdlr_send_response_code(hdlr, @@ -1089,8 +1088,8 @@ static void __format_store(mtp_handler_t *hdlr) store_id = _hdlr_get_param_cmd_container(&(hdlr->usb_cmd), 0); fs_fmt = _hdlr_get_param_cmd_container(&(hdlr->usb_cmd), 1); - ret = _hutil_format_storage(store_id, fs_fmt); - + _hutil_format_storage(store_id, fs_fmt); + /* although there is remain file, send OK */ _cmd_hdlr_send_response_code(hdlr, PTP_RESPONSE_OK); } -- 2.7.4 From 0d8a6234ff7cea499b33f9f6a01a4ba1096e46da Mon Sep 17 00:00:00 2001 From: Hyihong Chae Date: Tue, 22 Mar 2016 16:19:56 +0900 Subject: [PATCH 03/16] fix svace issue. Change-Id: I31c40c86ba1628f46fdd9acce8467298f59e3604 Signed-off-by: HyiHong Chae --- packaging/mtp-responder.spec | 2 +- src/mtp_init.c | 35 ++++++++++++++++++----------------- src/mtp_inoti_handler.c | 2 +- src/util/mtp_fs.c | 6 +++--- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/packaging/mtp-responder.spec b/packaging/mtp-responder.spec index 4885f2d..7c79f6e 100755 --- a/packaging/mtp-responder.spec +++ b/packaging/mtp-responder.spec @@ -5,7 +5,7 @@ ExcludeArch: %arm aarch64 Name: mtp-responder Summary: Media Transfer Protocol daemon (responder) -Version: 0.0.4 +Version: 0.0.5 Release: 1 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/src/mtp_init.c b/src/mtp_init.c index ca2455c..8210d79 100755 --- a/src/mtp_init.c +++ b/src/mtp_init.c @@ -252,6 +252,7 @@ static void __read_mtp_conf(void) FILE *fp; char buf[256]; char *token; + char *saveptr = NULL; g_conf.mmap_threshold = MTP_MMAP_THRESHOLD; @@ -298,73 +299,73 @@ static void __read_mtp_conf(void) } *token = '\0'; - token = strtok(buf, "="); + token = strtok_r(buf, "=", &saveptr); if (token == NULL) { continue; } if (strcasecmp(token, "mmap_threshold") == 0) { - token = strtok(NULL, "="); + token = strtok_r(NULL, "=", &saveptr); g_conf.mmap_threshold = atoi(token); } else if (strcasecmp(token, "init_rx_ipc_size") == 0) { - token = strtok(NULL, "="); + token = strtok_r(NULL, "=", &saveptr); g_conf.init_rx_ipc_size = atoi(token); } else if (strcasecmp(token, "init_tx_ipc_size") == 0) { - token = strtok(NULL, "="); + token = strtok_r(NULL, "=", &saveptr); g_conf.init_tx_ipc_size = atoi(token); } else if (strcasecmp(token, "max_rx_ipc_size") == 0) { - token = strtok(NULL, "="); + token = strtok_r(NULL, "=", &saveptr); g_conf.max_rx_ipc_size = atoi(token); } else if (strcasecmp(token, "max_tx_ipc_size") == 0) { - token = strtok(NULL, "="); + token = strtok_r(NULL, "=", &saveptr); g_conf.max_tx_ipc_size = atoi(token); } else if (strcasecmp(token, "read_usb_size") == 0) { - token = strtok(NULL, "="); + token = strtok_r(NULL, "=", &saveptr); g_conf.read_usb_size = atoi(token); } else if (strcasecmp(token, "write_usb_size") == 0) { - token = strtok(NULL, "="); + token = strtok_r(NULL, "=", &saveptr); g_conf.write_usb_size = atoi(token); } else if (strcasecmp(token, "read_file_size") == 0) { - token = strtok(NULL, "="); + token = strtok_r(NULL, "=", &saveptr); g_conf.read_file_size = atoi(token); } else if (strcasecmp(token, "write_file_size") == 0) { - token = strtok(NULL, "="); + token = strtok_r(NULL, "=", &saveptr); g_conf.write_file_size = atoi(token); } else if (strcasecmp(token, "max_io_buf_size") == 0) { - token = strtok(NULL, "="); + token = strtok_r(NULL, "=", &saveptr); g_conf.max_io_buf_size = atoi(token); } else if (strcasecmp(token, "read_file_delay") == 0) { - token = strtok(NULL, "="); + token = strtok_r(NULL, "=", &saveptr); g_conf.read_file_delay = atoi(token); } else if (strcasecmp(token, "support_pthread_sched") == 0) { - token = strtok(NULL, "="); + token = strtok_r(NULL, "=", &saveptr); g_conf.support_pthread_sched = atoi(token) ? true : false; } else if (strcasecmp(token, "inheritsched") == 0) { - token = strtok(NULL, "="); + token = strtok_r(NULL, "=", &saveptr); g_conf.inheritsched = *token; } else if (strcasecmp(token, "schedpolicy") == 0) { - token = strtok(NULL, "="); + token = strtok_r(NULL, "=", &saveptr); g_conf.schedpolicy = *token; } else if (strcasecmp(token, "file_schedparam") == 0) { - token = strtok(NULL, "="); + token = strtok_r(NULL, "=", &saveptr); g_conf.file_schedparam = atoi(token); } else if (strcasecmp(token, "usb_schedparam") == 0) { - token = strtok(NULL, "="); + token = strtok_r(NULL, "=", &saveptr); g_conf.usb_schedparam = atoi(token); } else { diff --git a/src/mtp_inoti_handler.c b/src/mtp_inoti_handler.c index 64aeafc..b4daf28 100755 --- a/src/mtp_inoti_handler.c +++ b/src/mtp_inoti_handler.c @@ -579,7 +579,7 @@ static void __process_object_added_event(mtp_char *fullpath, g_strlcpy(dir_info.filename, fullpath, MTP_MAX_PATHNAME_SIZE + 1); dir_info.attrs.mtime = stat_buf.st_mtime; - dir_info.attrs.fsize = stat_buf.st_size; + dir_info.attrs.fsize = (mtp_uint64)stat_buf.st_size; /* Reset the attributes */ dir_info.attrs.attribute = MTP_FILE_ATTR_MODE_NONE; diff --git a/src/util/mtp_fs.c b/src/util/mtp_fs.c index 4257446..ba9e3b2 100755 --- a/src/util/mtp_fs.c +++ b/src/util/mtp_fs.c @@ -588,7 +588,7 @@ mtp_bool _util_get_file_attrs(const mtp_char *filename, file_attr_t *attrs) } memset(attrs, 0, sizeof(file_attr_t)); - attrs->fsize = fileinfo.st_size; + attrs->fsize = (mtp_uint64)fileinfo.st_size; attrs->ctime = fileinfo.st_ctime; attrs->mtime = fileinfo.st_mtime; @@ -749,7 +749,7 @@ mtp_bool _util_ifind_next(mtp_char *dir_name, DIR *dirp, dir_entry_t *dir_info) /* Directory Information */ dir_info->attrs.mtime = stat_buf.st_mtime; - dir_info->attrs.fsize = stat_buf.st_size; + dir_info->attrs.fsize = (mtp_uint64)stat_buf.st_size; return TRUE; } @@ -766,7 +766,7 @@ mtp_bool _util_get_filesystem_info(mtp_char *storepath, fs_info_t *fs_info) return FALSE; } - capacity = used_size = avail_size = buf.f_bsize; + capacity = used_size = avail_size = (mtp_uint64)buf.f_bsize; DBG("Block size : %d\n", buf.f_bsize); capacity *= buf.f_blocks; used_size *= (buf.f_blocks - buf.f_bavail); -- 2.7.4 From 9caeb6109447c8eb959e845033c32b27ada7d865 Mon Sep 17 00:00:00 2001 From: Hyihong Chae Date: Tue, 12 Apr 2016 14:08:11 +0900 Subject: [PATCH 04/16] fix directory path error Change-Id: Ia15bdf906f9a2af2e2a1a6c447de27d47919f505 Signed-off-by: HyiHong Chae --- CMakeLists.txt | 2 +- include/mtp_config.h | 3 ++- packaging/mtp-responder.spec | 3 ++- src/entity/mtp_device.c | 2 +- src/mtp_inoti_handler.c | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5154fb0..e3ce4d5 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/src/util SRCS) INCLUDE(FindPkgConfig) pkg_check_modules(pkgs REQUIRED glib-2.0 capi-content-media-content - capi-media-metadata-extractor vconf dlog tapi capi-system-info) + capi-media-metadata-extractor vconf dlog tapi capi-system-info libtzplatform-config) FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/include/mtp_config.h b/include/mtp_config.h index 87bedac..9d166c3 100755 --- a/include/mtp_config.h +++ b/include/mtp_config.h @@ -18,6 +18,7 @@ #define _MTP_CONFIG_H_ #include +#include /* Function Features */ #define MTP_USE_INFORMATION_REGISTRY /* for get and set some information value */ @@ -80,7 +81,7 @@ #define MTP_STORE_PATH_CHAR "/home/owner/content" /* External Storage */ -#define MTP_EXTERNAL_PATH_CHAR "/usr/storage/sdcard" +#define MTP_EXTERNAL_PATH_CHAR tzplatform_mkpath(TZ_SYS_MEDIA, "/sdcard") #define MTP_DEVICE_ICON "/usr/share/mtp/device_icon.ico" /* File For WMP extesions */ diff --git a/packaging/mtp-responder.spec b/packaging/mtp-responder.spec index 7c79f6e..95b6ab6 100755 --- a/packaging/mtp-responder.spec +++ b/packaging/mtp-responder.spec @@ -5,7 +5,7 @@ ExcludeArch: %arm aarch64 Name: mtp-responder Summary: Media Transfer Protocol daemon (responder) -Version: 0.0.5 +Version: 0.0.6 Release: 1 Group: Network & Connectivity/Other License: Apache-2.0 @@ -20,6 +20,7 @@ BuildRequires: pkgconfig(tapi) BuildRequires: pkgconfig(capi-content-media-content) BuildRequires: pkgconfig(capi-media-metadata-extractor) BuildRequires: pkgconfig(capi-system-info) +Buildrequires: pkgconfig(libtzplatform-config) Requires(post): /usr/bin/vconftool diff --git a/src/entity/mtp_device.c b/src/entity/mtp_device.c index dad5fcb..5c4a870 100755 --- a/src/entity/mtp_device.c +++ b/src/entity/mtp_device.c @@ -610,7 +610,7 @@ static mtp_bool __add_store_to_device(store_type_t store_type) store_id = MTP_INTERNAL_STORE_ID; break; case MTP_STORAGE_EXTERNAL: - storage_path = MTP_EXTERNAL_PATH_CHAR; + storage_path = (mtp_char *)MTP_EXTERNAL_PATH_CHAR; store_id = MTP_EXTERNAL_STORE_ID; break; default: diff --git a/src/mtp_inoti_handler.c b/src/mtp_inoti_handler.c index b4daf28..6c8f767 100755 --- a/src/mtp_inoti_handler.c +++ b/src/mtp_inoti_handler.c @@ -486,7 +486,7 @@ static void __remove_recursive_inoti_watch(mtp_char *path) static void __clean_up_inoti(void *data) { __remove_recursive_inoti_watch(MTP_STORE_PATH_CHAR); - __remove_recursive_inoti_watch(MTP_EXTERNAL_PATH_CHAR); + __remove_recursive_inoti_watch((mtp_char *)MTP_EXTERNAL_PATH_CHAR); __destroy_inoti_open_files_list(); close(g_inoti_fd); -- 2.7.4 From 5645e5cd68625048a558d6e908657792ac6a3520 Mon Sep 17 00:00:00 2001 From: Hyihong Chae Date: Wed, 27 Apr 2016 16:21:13 +0900 Subject: [PATCH 05/16] add rules file in order to get permission to usb_mtp_gadget. Change-Id: Ife3c8b0c631d3415ca717a0e90f867fdde13ba6b Signed-off-by: HyiHong Chae --- packaging/99-mtp-responder.rules | 1 + packaging/mtp-responder.spec | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100755 packaging/99-mtp-responder.rules diff --git a/packaging/99-mtp-responder.rules b/packaging/99-mtp-responder.rules new file mode 100755 index 0000000..afd3867 --- /dev/null +++ b/packaging/99-mtp-responder.rules @@ -0,0 +1 @@ +KERNEL=="usb_mtp_gadget", MODE="0666", SECLABEL{smack}="*" diff --git a/packaging/mtp-responder.spec b/packaging/mtp-responder.spec index 95b6ab6..7e6faad 100755 --- a/packaging/mtp-responder.spec +++ b/packaging/mtp-responder.spec @@ -5,7 +5,7 @@ ExcludeArch: %arm aarch64 Name: mtp-responder Summary: Media Transfer Protocol daemon (responder) -Version: 0.0.6 +Version: 0.0.7 Release: 1 Group: Network & Connectivity/Other License: Apache-2.0 @@ -42,6 +42,9 @@ make %{?jobs:-j%jobs} %install %make_install +mkdir -p %{buildroot}%{_libdir}/udev/rules.d +cp packaging/99-mtp-responder.rules %{buildroot}%{_libdir}/udev/rules.d/99-mtp-responder.rules + install -D -m 0644 mtp-responder.service %{buildroot}%{_libdir}/systemd/system/mtp-responder.service %post @@ -57,5 +60,6 @@ ln -sf %{_libdir}/systemd/system/mtp-responder.service %{_sysconfdir}/systemd/de %defattr(-,system,system,-) %{_bindir}/mtp-responder %{_libdir}/systemd/system/mtp-responder.service +%{_libdir}/udev/rules.d/99-mtp-responder.rules /opt/var/lib/misc/mtp-responder.conf #%license LICENSE.APLv2 -- 2.7.4 From d20a2ec2bed8739c141e8355461229d7aaf5090c Mon Sep 17 00:00:00 2001 From: Hyihong Chae Date: Mon, 2 May 2016 21:54:54 +0900 Subject: [PATCH 06/16] fix svace issue (WGID 28023) Change-Id: I07c3bef9ce60e78555fcdcab8129fdbea811c6c2 Signed-off-by: HyiHong Chae --- packaging/mtp-responder.spec | 2 +- src/util/mtp_media_info.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packaging/mtp-responder.spec b/packaging/mtp-responder.spec index 7e6faad..d3b9e53 100755 --- a/packaging/mtp-responder.spec +++ b/packaging/mtp-responder.spec @@ -5,7 +5,7 @@ ExcludeArch: %arm aarch64 Name: mtp-responder Summary: Media Transfer Protocol daemon (responder) -Version: 0.0.7 +Version: 0.0.8 Release: 1 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/src/util/mtp_media_info.c b/src/util/mtp_media_info.c index eb0421e..befff54 100755 --- a/src/util/mtp_media_info.c +++ b/src/util/mtp_media_info.c @@ -730,8 +730,10 @@ mtp_bool _util_get_video_meta_from_extractor(const mtp_char *filepath, ERR("METADATA_VIDEO_FPS Fail"); goto ERROR_EXIT; } - video_data->videometa.video_fps = atoi(temp); - MTP_PAL_SAFE_FREE(temp); + if (NULL != temp) { + video_data->videometa.video_fps = atoi(temp); + MTP_PAL_SAFE_FREE(temp); + } ret = metadata_extractor_get_metadata(metadata, METADATA_VIDEO_HEIGHT, &temp); -- 2.7.4 From 2e4469776fd2da243c0721f788c8cd18e116d550 Mon Sep 17 00:00:00 2001 From: Hyihong Chae Date: Wed, 15 Jun 2016 11:41:54 +0900 Subject: [PATCH 07/16] [TSAM-4115] modify external storage(sdcard) path. Change-Id: Ie204dd8b01207006788fba83b2fecb1a6cf0bb9d Signed-off-by: HyiHong Chae --- CMakeLists.txt | 2 +- include/mtp_config.h | 3 +-- include/util/mtp_util.h | 1 + packaging/mtp-responder.spec | 4 +-- src/entity/mtp_device.c | 4 ++- src/entity/mtp_store.c | 62 ++++++++++++++++++++++++++------------------ src/mtp_cmd_handler_util.c | 5 +++- src/mtp_init.c | 8 +++--- src/mtp_inoti_handler.c | 10 +++++-- src/util/mtp_support.c | 8 ++++-- src/util/mtp_util.c | 25 ++++++++++++++++++ 11 files changed, 93 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e3ce4d5..5dc968a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/src/util SRCS) INCLUDE(FindPkgConfig) pkg_check_modules(pkgs REQUIRED glib-2.0 capi-content-media-content - capi-media-metadata-extractor vconf dlog tapi capi-system-info libtzplatform-config) + capi-media-metadata-extractor vconf dlog tapi capi-system-info storage) FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/include/mtp_config.h b/include/mtp_config.h index 9d166c3..561e5d9 100755 --- a/include/mtp_config.h +++ b/include/mtp_config.h @@ -18,7 +18,6 @@ #define _MTP_CONFIG_H_ #include -#include /* Function Features */ #define MTP_USE_INFORMATION_REGISTRY /* for get and set some information value */ @@ -81,7 +80,7 @@ #define MTP_STORE_PATH_CHAR "/home/owner/content" /* External Storage */ -#define MTP_EXTERNAL_PATH_CHAR tzplatform_mkpath(TZ_SYS_MEDIA, "/sdcard") +#define MTP_EXTERNAL_PATH_CHAR "/opt/media/SDCardA1" #define MTP_DEVICE_ICON "/usr/share/mtp/device_icon.ico" /* File For WMP extesions */ diff --git a/include/util/mtp_util.h b/include/util/mtp_util.h index f2e0af4..4e825a3 100755 --- a/include/util/mtp_util.h +++ b/include/util/mtp_util.h @@ -141,5 +141,6 @@ void _util_set_local_mmc_status(const phone_status_t val); void _util_get_usbmode_status(phone_status_t *val); phone_status_t _util_get_local_usbmode_status(void); void _util_set_local_usbmode_status(const phone_status_t val); +void _util_get_external_path(char *ext_path); #endif /* _MTP_UTIL_H_ */ diff --git a/packaging/mtp-responder.spec b/packaging/mtp-responder.spec index d3b9e53..366cf69 100755 --- a/packaging/mtp-responder.spec +++ b/packaging/mtp-responder.spec @@ -5,7 +5,7 @@ ExcludeArch: %arm aarch64 Name: mtp-responder Summary: Media Transfer Protocol daemon (responder) -Version: 0.0.8 +Version: 0.0.9 Release: 1 Group: Network & Connectivity/Other License: Apache-2.0 @@ -20,7 +20,7 @@ BuildRequires: pkgconfig(tapi) BuildRequires: pkgconfig(capi-content-media-content) BuildRequires: pkgconfig(capi-media-metadata-extractor) BuildRequires: pkgconfig(capi-system-info) -Buildrequires: pkgconfig(libtzplatform-config) +Buildrequires: pkgconfig(storage) Requires(post): /usr/bin/vconftool diff --git a/src/entity/mtp_device.c b/src/entity/mtp_device.c index 5c4a870..c2e6f6b 100755 --- a/src/entity/mtp_device.c +++ b/src/entity/mtp_device.c @@ -603,6 +603,7 @@ static mtp_bool __add_store_to_device(store_type_t store_type) mtp_char *storage_path = NULL; mtp_uint32 store_id = 0; file_attr_t attrs = { 0, }; + char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; switch (store_type) { case MTP_STORAGE_INTERNAL: @@ -610,7 +611,8 @@ static mtp_bool __add_store_to_device(store_type_t store_type) store_id = MTP_INTERNAL_STORE_ID; break; case MTP_STORAGE_EXTERNAL: - storage_path = (mtp_char *)MTP_EXTERNAL_PATH_CHAR; + _util_get_external_path(ext_path); + storage_path = (mtp_char *)ext_path; store_id = MTP_EXTERNAL_STORE_ID; break; default: diff --git a/src/entity/mtp_store.c b/src/entity/mtp_store.c index dbf744e..814d062 100755 --- a/src/entity/mtp_store.c +++ b/src/entity/mtp_store.c @@ -90,13 +90,16 @@ void _entity_update_store_info_run_time(store_info_t *info, mtp_bool _entity_get_store_path_by_id(mtp_uint32 store_id, mtp_char *path) { + char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; + switch(store_id) { case MTP_INTERNAL_STORE_ID : g_strlcpy(path, MTP_STORE_PATH_CHAR, MTP_MAX_PATHNAME_SIZE + 1); break; case MTP_EXTERNAL_STORE_ID : - g_strlcpy(path, MTP_EXTERNAL_PATH_CHAR, + _util_get_external_path(ext_path); + g_strlcpy(path, ext_path, MTP_MAX_PATHNAME_SIZE + 1); break; default : @@ -174,14 +177,17 @@ mtp_uint32 _entity_pack_store_info(store_info_t *info, mtp_uchar *buf, mtp_uint32 _entity_get_store_id_by_path(const mtp_char *path_name) { mtp_uint32 store_id = 0; + char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; retv_if(NULL == path_name, FALSE); + _util_get_external_path(ext_path); + if (!strncmp(path_name, MTP_STORE_PATH_CHAR, strlen(MTP_STORE_PATH_CHAR))) { store_id = MTP_INTERNAL_STORE_ID; - } else if (!strncmp(path_name, MTP_EXTERNAL_PATH_CHAR, - strlen(MTP_EXTERNAL_PATH_CHAR))) { + } else if (!strncmp(path_name, ext_path, + strlen(ext_path))) { store_id = MTP_EXTERNAL_STORE_ID; } @@ -940,27 +946,30 @@ mtp_uint16 _entity_delete_obj_mtp_store(mtp_store_t *store, DBG("object handle is not PTP_OBJECTHANDLE_ALL. [%ld]\n", obj_handle); obj = _entity_get_object_from_store(store, obj_handle); - if (_entity_remove_object_mtp_store(store, obj, PTP_FORMATCODE_NOTUSED, - &response, &atleas_one, read_only)) { - slist_node_t *temp = NULL; - - temp = _util_delete_node(&(store->obj_list), obj); - g_free(temp); - _util_delete_file_from_db(obj->file_path); - _entity_dealloc_mtp_obj(obj); - } else { - switch (response) { - case PTP_RESPONSE_PARTIAL_DELETION: - all_del = FALSE; - break; - case PTP_RESPONSE_OBJ_WRITEPROTECTED: - case PTP_RESPONSE_ACCESSDENIED: - all_del = FALSE; - break; - case PTP_RESPONSE_UNDEFINED: - default: - /* do nothing */ - break; + + if (NULL != obj) { + if (_entity_remove_object_mtp_store(store, obj, PTP_FORMATCODE_NOTUSED, + &response, &atleas_one, read_only)) { + slist_node_t *temp = NULL; + + temp = _util_delete_node(&(store->obj_list), obj); + g_free(temp); + _util_delete_file_from_db(obj->file_path); + _entity_dealloc_mtp_obj(obj); + } else { + switch (response) { + case PTP_RESPONSE_PARTIAL_DELETION: + all_del = FALSE; + break; + case PTP_RESPONSE_OBJ_WRITEPROTECTED: + case PTP_RESPONSE_ACCESSDENIED: + all_del = FALSE; + break; + case PTP_RESPONSE_UNDEFINED: + default: + /* do nothing */ + break; + } } } } @@ -1202,8 +1211,11 @@ void _entity_list_modified_files(mtp_uint32 minutes) } } if (TRUE == _device_is_store_mounted(MTP_STORAGE_EXTERNAL)) { + char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; + _util_get_external_path(ext_path); + g_snprintf(command, FIND_CMD_LEN, FIND_CMD, - MTP_EXTERNAL_PATH_CHAR, minutes, + ext_path, minutes, MTP_FILES_MODIFIED_FILES); DBG("find query is [%s]\n", command); ret = system(command); diff --git a/src/mtp_cmd_handler_util.c b/src/mtp_cmd_handler_util.c index 5b1b7c5..a3661ef 100755 --- a/src/mtp_cmd_handler_util.c +++ b/src/mtp_cmd_handler_util.c @@ -286,6 +286,9 @@ mtp_err_t _hutil_add_object_entry(obj_info_t *obj_info, mtp_char *file_name, "%s/%s", MTP_STORE_PATH_CHAR, MTP_FILE_NAME_WMPINFO_XML); } else { + char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; + _util_get_external_path(ext_path); + g_snprintf(wmp_hidden_path, MTP_MAX_PATHNAME_SIZE + 1, "%s/%s/%s", MTP_USER_DIRECTORY, @@ -293,7 +296,7 @@ mtp_err_t _hutil_add_object_entry(obj_info_t *obj_info, mtp_char *file_name, MTP_FILE_NAME_WMPINFO_XML); g_snprintf(wmp_info_path, MTP_MAX_PATHNAME_SIZE + 1, - "%s/%s", MTP_EXTERNAL_PATH_CHAR, + "%s/%s", ext_path, MTP_FILE_NAME_WMPINFO_XML); } diff --git a/src/mtp_init.c b/src/mtp_init.c index 8210d79..bd98a3e 100755 --- a/src/mtp_init.c +++ b/src/mtp_init.c @@ -155,10 +155,12 @@ void _mtp_init(add_rem_store_t sel) } /* External Storage */ if (MTP_PHONE_MMC_INSERTED == _util_get_local_mmc_status()) { - if (access(MTP_EXTERNAL_PATH_CHAR, F_OK) < 0) { - if (FALSE == _util_dir_create(MTP_EXTERNAL_PATH_CHAR, &error)) { + char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; + _util_get_external_path(ext_path); + if (access(ext_path, F_OK) < 0) { + if (FALSE == _util_dir_create(ext_path, &error)) { ERR("Cannot make directory!! [%s]\n", - MTP_EXTERNAL_PATH_CHAR); + ext_path); goto MTP_INIT_FAIL; } } diff --git a/src/mtp_inoti_handler.c b/src/mtp_inoti_handler.c index 6c8f767..56dcdd4 100755 --- a/src/mtp_inoti_handler.c +++ b/src/mtp_inoti_handler.c @@ -485,8 +485,11 @@ static void __remove_recursive_inoti_watch(mtp_char *path) static void __clean_up_inoti(void *data) { + char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; + _util_get_external_path(ext_path); + __remove_recursive_inoti_watch(MTP_STORE_PATH_CHAR); - __remove_recursive_inoti_watch((mtp_char *)MTP_EXTERNAL_PATH_CHAR); + __remove_recursive_inoti_watch((mtp_char *)ext_path); __destroy_inoti_open_files_list(); close(g_inoti_fd); @@ -557,8 +560,11 @@ static void __process_object_added_event(mtp_char *fullpath, } parent_obj = _entity_get_object_from_store_by_path(store, parent_path); if (NULL == parent_obj) { + char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; + _util_get_external_path(ext_path); + if (!g_strcmp0(parent_path, MTP_STORE_PATH_CHAR) || - !g_strcmp0(parent_path, MTP_EXTERNAL_PATH_CHAR)) + !g_strcmp0(parent_path, ext_path)) { DBG("parent is the root folder"); h_parent = 0; diff --git a/src/util/mtp_support.c b/src/util/mtp_support.c index b5e01da..4f715ba 100755 --- a/src/util/mtp_support.c +++ b/src/util/mtp_support.c @@ -468,12 +468,16 @@ mtp_bool _util_is_path_len_valid(const mtp_char *path) static mtp_uint32 internal_store_len = 0; static mtp_uint32 external_store_len = 0; + char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; + retv_if(path == NULL, FALSE); + _util_get_external_path(ext_path); + if (!is_initialized) { is_initialized = TRUE; internal_store_len = strlen(MTP_STORE_PATH_CHAR); - external_store_len = strlen(MTP_EXTERNAL_PATH_CHAR); + external_store_len = strlen(ext_path); max_store_len = internal_store_len > external_store_len ? internal_store_len : external_store_len; @@ -483,7 +487,7 @@ mtp_bool _util_is_path_len_valid(const mtp_char *path) if (!strncmp(path, MTP_STORE_PATH_CHAR, internal_store_len)) { root_path_len = internal_store_len; - } else if (!strncmp(path, MTP_EXTERNAL_PATH_CHAR, external_store_len)) { + } else if (!strncmp(path, ext_path, external_store_len)) { root_path_len = external_store_len; } else { diff --git a/src/util/mtp_util.c b/src/util/mtp_util.c index 5b0ee9c..afea4f8 100755 --- a/src/util/mtp_util.c +++ b/src/util/mtp_util.c @@ -28,6 +28,7 @@ #include "mtp_util.h" #include "mtp_support.h" #include "mtp_fs.h" +#include static phone_state_t g_ph_status = { 0 }; @@ -291,3 +292,27 @@ void _util_set_local_usbmode_status(const phone_status_t val) g_ph_status.usb_mode_state = val; return; } + +static bool _util_device_supported_cb(int storage_id, storage_type_e type, + storage_state_e state, const char *path, void *user_data) +{ + char *ext_path = (char *)user_data; + + if (type == STORAGE_TYPE_EXTERNAL && path != NULL) { + strncpy(ext_path, path, strlen(path)); + DBG("external storage path : %s", ext_path); + } + + return TRUE; +} + +void _util_get_external_path(char *ext_path) +{ + int error = STORAGE_ERROR_NONE; + error = storage_foreach_device_supported(_util_device_supported_cb, ext_path); + + if (error != STORAGE_ERROR_NONE) { + ERR("get external storage path Fail"); + strncpy(ext_path, MTP_EXTERNAL_PATH_CHAR, strlen(MTP_EXTERNAL_PATH_CHAR)); + } +} -- 2.7.4 From 8c7fe76f84a3b128e098f3d949cd5103722248dc Mon Sep 17 00:00:00 2001 From: Hyihong Chae Date: Thu, 16 Jun 2016 16:30:30 +0900 Subject: [PATCH 08/16] change path of .service file Change-Id: I010ed39495bef5fde05743f8b601fbb3c8791140 Signed-off-by: HyiHong Chae --- mtp-responder.service | 4 +--- packaging/mtp-responder.spec | 10 +++++----- src/util/mtp_util.c | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/mtp-responder.service b/mtp-responder.service index 9fcc7fe..2f2773e 100755 --- a/mtp-responder.service +++ b/mtp-responder.service @@ -2,8 +2,6 @@ Description=MTP responder [Service] -User=owner -Group=users Type=simple ExecStart=/usr/bin/mtp-responder -KillMode=process +KillMode=process \ No newline at end of file diff --git a/packaging/mtp-responder.spec b/packaging/mtp-responder.spec index 366cf69..6136f07 100755 --- a/packaging/mtp-responder.spec +++ b/packaging/mtp-responder.spec @@ -5,7 +5,7 @@ ExcludeArch: %arm aarch64 Name: mtp-responder Summary: Media Transfer Protocol daemon (responder) -Version: 0.0.9 +Version: 0.0.10 Release: 1 Group: Network & Connectivity/Other License: Apache-2.0 @@ -45,7 +45,7 @@ make %{?jobs:-j%jobs} mkdir -p %{buildroot}%{_libdir}/udev/rules.d cp packaging/99-mtp-responder.rules %{buildroot}%{_libdir}/udev/rules.d/99-mtp-responder.rules -install -D -m 0644 mtp-responder.service %{buildroot}%{_libdir}/systemd/system/mtp-responder.service +install -D -m 0644 mtp-responder.service %{buildroot}%{_libdir}/systemd/user/mtp-responder.service %post /usr/bin/vconftool set -t string db/private/mtp/serial_number "" -u 5000 -g 5000 -i -f -s tizen::vconf::platform::rw @@ -53,13 +53,13 @@ install -D -m 0644 mtp-responder.service %{buildroot}%{_libdir}/systemd/system/m /usr/bin/vconftool set -t int db/private/mtp/sync_time 0 -u 5000 -g 5000 -i -f -s tizen::vconf::platform::rw mkdir -p %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/ -ln -sf %{_libdir}/systemd/system/mtp-responder.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/ +ln -sf %{_libdir}/systemd/user/mtp-responder.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/ %files %manifest mtp-responder.manifest -%defattr(-,system,system,-) +%defattr(-,root,root,-) %{_bindir}/mtp-responder -%{_libdir}/systemd/system/mtp-responder.service +%{_libdir}/systemd/user/mtp-responder.service %{_libdir}/udev/rules.d/99-mtp-responder.rules /opt/var/lib/misc/mtp-responder.conf #%license LICENSE.APLv2 diff --git a/src/util/mtp_util.c b/src/util/mtp_util.c index afea4f8..ef614c6 100755 --- a/src/util/mtp_util.c +++ b/src/util/mtp_util.c @@ -297,7 +297,7 @@ static bool _util_device_supported_cb(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data) { char *ext_path = (char *)user_data; - + if (type == STORAGE_TYPE_EXTERNAL && path != NULL) { strncpy(ext_path, path, strlen(path)); DBG("external storage path : %s", ext_path); -- 2.7.4 From 7fe700e3649464fc0434e5bb74656d84ca93b0d8 Mon Sep 17 00:00:00 2001 From: Hyihong Chae Date: Fri, 17 Jun 2016 10:57:33 +0900 Subject: [PATCH 09/16] fix permission error for browsing directory Change-Id: I0244d614444248a3d0224d23a7fdc0d6bdaa617c Signed-off-by: HyiHong Chae --- mtp-responder.service | 3 +++ packaging/mtp-responder.spec | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/mtp-responder.service b/mtp-responder.service index 2f2773e..4d55d75 100755 --- a/mtp-responder.service +++ b/mtp-responder.service @@ -2,6 +2,9 @@ Description=MTP responder [Service] +User=owner +Group=users +SupplementaryGroups=priv_mediastorage priv_externalstorage Type=simple ExecStart=/usr/bin/mtp-responder KillMode=process \ No newline at end of file diff --git a/packaging/mtp-responder.spec b/packaging/mtp-responder.spec index 6136f07..a6dd0e3 100755 --- a/packaging/mtp-responder.spec +++ b/packaging/mtp-responder.spec @@ -5,7 +5,7 @@ ExcludeArch: %arm aarch64 Name: mtp-responder Summary: Media Transfer Protocol daemon (responder) -Version: 0.0.10 +Version: 0.0.11 Release: 1 Group: Network & Connectivity/Other License: Apache-2.0 @@ -45,7 +45,7 @@ make %{?jobs:-j%jobs} mkdir -p %{buildroot}%{_libdir}/udev/rules.d cp packaging/99-mtp-responder.rules %{buildroot}%{_libdir}/udev/rules.d/99-mtp-responder.rules -install -D -m 0644 mtp-responder.service %{buildroot}%{_libdir}/systemd/user/mtp-responder.service +install -D -m 0644 mtp-responder.service %{buildroot}%{_libdir}/systemd/system/mtp-responder.service %post /usr/bin/vconftool set -t string db/private/mtp/serial_number "" -u 5000 -g 5000 -i -f -s tizen::vconf::platform::rw @@ -53,13 +53,13 @@ install -D -m 0644 mtp-responder.service %{buildroot}%{_libdir}/systemd/user/mtp /usr/bin/vconftool set -t int db/private/mtp/sync_time 0 -u 5000 -g 5000 -i -f -s tizen::vconf::platform::rw mkdir -p %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/ -ln -sf %{_libdir}/systemd/user/mtp-responder.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/ +ln -sf %{_libdir}/systemd/system/mtp-responder.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/ %files %manifest mtp-responder.manifest %defattr(-,root,root,-) %{_bindir}/mtp-responder -%{_libdir}/systemd/user/mtp-responder.service +%{_libdir}/systemd/system/mtp-responder.service %{_libdir}/udev/rules.d/99-mtp-responder.rules /opt/var/lib/misc/mtp-responder.conf #%license LICENSE.APLv2 -- 2.7.4 From 7e543083d1cb401ab671a8d87bac082bd642f317 Mon Sep 17 00:00:00 2001 From: Hyihong Chae Date: Thu, 30 Jun 2016 22:00:40 +0900 Subject: [PATCH 10/16] modify internal storage path Change-Id: Ie1360521b69392ef926f17b9a2bc140afb177874 Signed-off-by: HyiHong Chae --- include/mtp_config.h | 2 +- include/util/mtp_util.h | 4 ++-- src/entity/mtp_device.c | 9 +++++---- src/entity/mtp_store.c | 20 ++++++++++++------- src/mtp_cmd_handler_util.c | 5 ++++- src/mtp_init.c | 12 +++++++----- src/mtp_inoti_handler.c | 8 ++++++-- src/util/mtp_support.c | 6 ++++-- src/util/mtp_util.c | 49 +++++++++++++++++++++++++++++++++++++++------- 9 files changed, 84 insertions(+), 31 deletions(-) diff --git a/include/mtp_config.h b/include/mtp_config.h index 561e5d9..b4249e1 100755 --- a/include/mtp_config.h +++ b/include/mtp_config.h @@ -77,7 +77,7 @@ * Transport related configuration */ /* Internal Storage */ -#define MTP_STORE_PATH_CHAR "/home/owner/content" +#define MTP_STORE_PATH_CHAR "/opt/home/owner/content" /* External Storage */ #define MTP_EXTERNAL_PATH_CHAR "/opt/media/SDCardA1" diff --git a/include/util/mtp_util.h b/include/util/mtp_util.h index 4e825a3..45064be 100755 --- a/include/util/mtp_util.h +++ b/include/util/mtp_util.h @@ -141,6 +141,6 @@ void _util_set_local_mmc_status(const phone_status_t val); void _util_get_usbmode_status(phone_status_t *val); phone_status_t _util_get_local_usbmode_status(void); void _util_set_local_usbmode_status(const phone_status_t val); -void _util_get_external_path(char *ext_path); - +void _util_get_external_path(char *external_path); +void _util_get_internal_path(char *internal_path); #endif /* _MTP_UTIL_H_ */ diff --git a/src/entity/mtp_device.c b/src/entity/mtp_device.c index c2e6f6b..0539974 100755 --- a/src/entity/mtp_device.c +++ b/src/entity/mtp_device.c @@ -603,16 +603,17 @@ static mtp_bool __add_store_to_device(store_type_t store_type) mtp_char *storage_path = NULL; mtp_uint32 store_id = 0; file_attr_t attrs = { 0, }; - char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; + char sto_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; switch (store_type) { case MTP_STORAGE_INTERNAL: - storage_path = MTP_STORE_PATH_CHAR; + _util_get_internal_path(sto_path); + storage_path = (mtp_char *)sto_path; store_id = MTP_INTERNAL_STORE_ID; break; case MTP_STORAGE_EXTERNAL: - _util_get_external_path(ext_path); - storage_path = (mtp_char *)ext_path; + _util_get_external_path(sto_path); + storage_path = (mtp_char *)sto_path; store_id = MTP_EXTERNAL_STORE_ID; break; default: diff --git a/src/entity/mtp_store.c b/src/entity/mtp_store.c index 814d062..7b9cba8 100755 --- a/src/entity/mtp_store.c +++ b/src/entity/mtp_store.c @@ -90,16 +90,17 @@ void _entity_update_store_info_run_time(store_info_t *info, mtp_bool _entity_get_store_path_by_id(mtp_uint32 store_id, mtp_char *path) { - char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; + char sto_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; switch(store_id) { case MTP_INTERNAL_STORE_ID : - g_strlcpy(path, MTP_STORE_PATH_CHAR, + _util_get_internal_path(sto_path); + g_strlcpy(path, sto_path, MTP_MAX_PATHNAME_SIZE + 1); break; case MTP_EXTERNAL_STORE_ID : - _util_get_external_path(ext_path); - g_strlcpy(path, ext_path, + _util_get_external_path(sto_path); + g_strlcpy(path, sto_path, MTP_MAX_PATHNAME_SIZE + 1); break; default : @@ -178,13 +179,15 @@ mtp_uint32 _entity_get_store_id_by_path(const mtp_char *path_name) { mtp_uint32 store_id = 0; char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; + char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; retv_if(NULL == path_name, FALSE); _util_get_external_path(ext_path); + _util_get_internal_path(inter_path); - if (!strncmp(path_name, MTP_STORE_PATH_CHAR, - strlen(MTP_STORE_PATH_CHAR))) { + if (!strncmp(path_name, inter_path, + strlen(inter_path))) { store_id = MTP_INTERNAL_STORE_ID; } else if (!strncmp(path_name, ext_path, strlen(ext_path))) { @@ -1198,8 +1201,11 @@ void _entity_list_modified_files(mtp_uint32 minutes) mtp_char command[FIND_CMD_LEN] = { 0 }; if (TRUE == _device_is_store_mounted(MTP_STORAGE_INTERNAL)) { + char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; + _util_get_internal_path(inter_path); + g_snprintf(command, FIND_CMD_LEN, FIND_CMD, - MTP_STORE_PATH_CHAR, minutes, + inter_path, minutes, MTP_FILES_MODIFIED_FILES); DBG("find query is [%s]\n", command); ret = system(command); diff --git a/src/mtp_cmd_handler_util.c b/src/mtp_cmd_handler_util.c index a3661ef..a0c9927 100755 --- a/src/mtp_cmd_handler_util.c +++ b/src/mtp_cmd_handler_util.c @@ -276,6 +276,9 @@ mtp_err_t _hutil_add_object_entry(obj_info_t *obj_info, mtp_char *file_name, mtp_char wmp_hidden_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; if (obj_info->store_id == MTP_INTERNAL_STORE_ID) { + char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; + _util_get_internal_path(inter_path); + g_snprintf(wmp_hidden_path, MTP_MAX_PATHNAME_SIZE + 1, "%s/%s/%s", MTP_USER_DIRECTORY, @@ -283,7 +286,7 @@ mtp_err_t _hutil_add_object_entry(obj_info_t *obj_info, mtp_char *file_name, MTP_FILE_NAME_WMPINFO_XML); g_snprintf(wmp_info_path, MTP_MAX_PATHNAME_SIZE + 1, - "%s/%s", MTP_STORE_PATH_CHAR, + "%s/%s", inter_path, MTP_FILE_NAME_WMPINFO_XML); } else { char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; diff --git a/src/mtp_init.c b/src/mtp_init.c index bd98a3e..0cfe46f 100755 --- a/src/mtp_init.c +++ b/src/mtp_init.c @@ -95,6 +95,7 @@ void _mtp_init(add_rem_store_t sel) mtp_bool ret = 0; int vconf_ret = 0; mtp_int32 error = 0; + char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; DBG("Initialization start!"); @@ -146,10 +147,11 @@ void _mtp_init(add_rem_store_t sel) } /* Internal Storage */ - if (access(MTP_STORE_PATH_CHAR, F_OK) < 0) { - if (FALSE == _util_dir_create(MTP_STORE_PATH_CHAR, &error)) { + _util_get_internal_path(inter_path); + if (access(inter_path, F_OK) < 0) { + if (FALSE == _util_dir_create((const mtp_char *)inter_path, &error)) { ERR("Cannot make directory!! [%s]\n", - MTP_STORE_PATH_CHAR); + inter_path); goto MTP_INIT_FAIL; } } @@ -158,7 +160,7 @@ void _mtp_init(add_rem_store_t sel) char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; _util_get_external_path(ext_path); if (access(ext_path, F_OK) < 0) { - if (FALSE == _util_dir_create(ext_path, &error)) { + if (FALSE == _util_dir_create((const mtp_char *)ext_path, &error)) { ERR("Cannot make directory!! [%s]\n", ext_path); goto MTP_INIT_FAIL; @@ -168,7 +170,7 @@ void _mtp_init(add_rem_store_t sel) #ifndef MTP_SUPPORT_HIDE_WMPINFO_XML /* Update WMPInfo.xml for preventing frequent saving */ ret = _util_create_path(wmpinfopath, sizeof(wmpinfopath), - MTP_STORE_PATH_CHAR, MTP_FILE_NAME_WMPINFO_XML); + (const mtp_char *)inter_path, MTP_FILE_NAME_WMPINFO_XML); if (FALSE == ret) { ERR("szWMPInfoPath is too long"); goto MTP_INIT_FAIL; diff --git a/src/mtp_inoti_handler.c b/src/mtp_inoti_handler.c index 56dcdd4..47faeaa 100755 --- a/src/mtp_inoti_handler.c +++ b/src/mtp_inoti_handler.c @@ -486,9 +486,11 @@ static void __remove_recursive_inoti_watch(mtp_char *path) static void __clean_up_inoti(void *data) { char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; + char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; _util_get_external_path(ext_path); + _util_get_internal_path(inter_path); - __remove_recursive_inoti_watch(MTP_STORE_PATH_CHAR); + __remove_recursive_inoti_watch((mtp_char *)inter_path); __remove_recursive_inoti_watch((mtp_char *)ext_path); __destroy_inoti_open_files_list(); @@ -561,9 +563,11 @@ static void __process_object_added_event(mtp_char *fullpath, parent_obj = _entity_get_object_from_store_by_path(store, parent_path); if (NULL == parent_obj) { char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; + char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; _util_get_external_path(ext_path); + _util_get_internal_path(inter_path); - if (!g_strcmp0(parent_path, MTP_STORE_PATH_CHAR) || + if (!g_strcmp0(parent_path, inter_path) || !g_strcmp0(parent_path, ext_path)) { DBG("parent is the root folder"); diff --git a/src/util/mtp_support.c b/src/util/mtp_support.c index 4f715ba..144c2cd 100755 --- a/src/util/mtp_support.c +++ b/src/util/mtp_support.c @@ -469,14 +469,16 @@ mtp_bool _util_is_path_len_valid(const mtp_char *path) static mtp_uint32 external_store_len = 0; char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; + char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; retv_if(path == NULL, FALSE); _util_get_external_path(ext_path); + _util_get_internal_path(inter_path); if (!is_initialized) { is_initialized = TRUE; - internal_store_len = strlen(MTP_STORE_PATH_CHAR); + internal_store_len = strlen(inter_path); external_store_len = strlen(ext_path); max_store_len = internal_store_len > external_store_len ? @@ -485,7 +487,7 @@ mtp_bool _util_is_path_len_valid(const mtp_char *path) DBG("max store len : [%u]\n", max_store_len); } - if (!strncmp(path, MTP_STORE_PATH_CHAR, internal_store_len)) { + if (!strncmp(path, inter_path, internal_store_len)) { root_path_len = internal_store_len; } else if (!strncmp(path, ext_path, external_store_len)) { root_path_len = external_store_len; diff --git a/src/util/mtp_util.c b/src/util/mtp_util.c index ef614c6..83731f1 100755 --- a/src/util/mtp_util.c +++ b/src/util/mtp_util.c @@ -293,26 +293,61 @@ void _util_set_local_usbmode_status(const phone_status_t val) return; } -static bool _util_device_supported_cb(int storage_id, storage_type_e type, +static bool _util_device_external_supported_cb(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data) { - char *ext_path = (char *)user_data; + char *storage_path = (char *)user_data; + + DBG("storage id: %d, path: %s", storage_id, path); if (type == STORAGE_TYPE_EXTERNAL && path != NULL) { - strncpy(ext_path, path, strlen(path)); - DBG("external storage path : %s", ext_path); + strncpy(storage_path, path, strlen(path)); + DBG("external storage path : %s", storage_path); } return TRUE; } -void _util_get_external_path(char *ext_path) +void _util_get_external_path(char *external_path) { int error = STORAGE_ERROR_NONE; - error = storage_foreach_device_supported(_util_device_supported_cb, ext_path); + error = storage_foreach_device_supported(_util_device_external_supported_cb, external_path); if (error != STORAGE_ERROR_NONE) { ERR("get external storage path Fail"); - strncpy(ext_path, MTP_EXTERNAL_PATH_CHAR, strlen(MTP_EXTERNAL_PATH_CHAR)); + strncpy(external_path, MTP_EXTERNAL_PATH_CHAR, strlen(MTP_EXTERNAL_PATH_CHAR)); + } +} + +static bool _util_device_internal_supported_cb(int storage_id, storage_type_e type, + storage_state_e state, const char *path, void *user_data) +{ + char *storage_path = (char *)user_data; + + DBG("storage id: %d, path: %s", storage_id, path); + + if (type == STORAGE_TYPE_INTERNAL && path != NULL) { + strncpy(storage_path, path, strlen(path)); + DBG("internal storage path : %s", storage_path); + + if (storage_get_root_directory(storage_id, &storage_path) != STORAGE_ERROR_NONE) { + ERR("get internal storage path Fail"); + return FALSE; + } else { + DBG("get internal storage path : %s", storage_path); + } + } + + return TRUE; +} + +void _util_get_internal_path(char *internal_path) +{ + int error = STORAGE_ERROR_NONE; + error = storage_foreach_device_supported(_util_device_internal_supported_cb, internal_path); + + if (error != STORAGE_ERROR_NONE) { + ERR("get internal storage path Fail"); + strncpy(internal_path, MTP_STORE_PATH_CHAR, strlen(MTP_STORE_PATH_CHAR)); } } -- 2.7.4 From 2bb96d5d1719c5cf1ad97e20274ba86a5442aa28 Mon Sep 17 00:00:00 2001 From: jooseong lee Date: Wed, 20 Jul 2016 20:40:46 +0900 Subject: [PATCH 11/16] Set the SMACK security label to run given executable file in systemd services Change-Id: I129a05ae3a5de2f6d6c675093c006b9d01e130fc Signed-off-by: jooseong lee --- mtp-responder.service | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mtp-responder.service b/mtp-responder.service index 4d55d75..8941a90 100755 --- a/mtp-responder.service +++ b/mtp-responder.service @@ -4,7 +4,8 @@ Description=MTP responder [Service] User=owner Group=users +SmackProcessLabel=System SupplementaryGroups=priv_mediastorage priv_externalstorage Type=simple ExecStart=/usr/bin/mtp-responder -KillMode=process \ No newline at end of file +KillMode=process -- 2.7.4 From 021f20554339b53de765216c2e43bfaa64595129 Mon Sep 17 00:00:00 2001 From: taeyoung Date: Tue, 26 Jul 2016 13:35:48 +0900 Subject: [PATCH 12/16] usb: exchange vconf key for the usb mode - The vconf key VCONFKEY_SETAPPL_USB_MODE_INT is one of the legacy vconf keys. Thus is is exchanged to new one. Change-Id: I3f274fb4d07112bfbfa7f7582fc76c86c0dea040 Signed-off-by: taeyoung --- src/mtp_event_handler.c | 6 +++--- src/util/mtp_util.c | 11 ++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/mtp_event_handler.c b/src/mtp_event_handler.c index 2be6496..72c3f3f 100755 --- a/src/mtp_event_handler.c +++ b/src/mtp_event_handler.c @@ -71,10 +71,10 @@ mtp_bool _eh_register_notification_callbacks(void) _util_get_usbmode_status(&val); _util_set_local_usbmode_status(val); - ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_USB_MODE_INT, + ret = vconf_notify_key_changed(VCONFKEY_USB_CUR_MODE, __handle_usb_mode_notification, NULL); if (ret < 0) { - ERR("vconf_notify_key_changed(%s) Fail", VCONFKEY_SETAPPL_USB_MODE_INT); + ERR("vconf_notify_key_changed(%s) Fail", VCONFKEY_USB_CUR_MODE); return FALSE; } @@ -397,7 +397,7 @@ void _eh_deregister_notification_callbacks(void) { vconf_ignore_key_changed(VCONFKEY_SYSMAN_USB_STATUS, __handle_usb_notification); - vconf_ignore_key_changed(VCONFKEY_SETAPPL_USB_MODE_INT, + vconf_ignore_key_changed(VCONFKEY_USB_CUR_MODE, __handle_usb_mode_notification); return; diff --git a/src/util/mtp_util.c b/src/util/mtp_util.c index 83731f1..4518a1f 100755 --- a/src/util/mtp_util.c +++ b/src/util/mtp_util.c @@ -273,12 +273,17 @@ void _util_get_usbmode_status(phone_status_t *val) mtp_int32 ret = 0; mtp_int32 state = 0; - ret = vconf_get_int(VCONFKEY_SETAPPL_USB_MODE_INT, + ret = vconf_get_int(VCONFKEY_USB_CUR_MODE, &state); - if (ret < 0) + if (ret < 0) { *val = MTP_PHONE_USB_MODE_OTHER; + return; + } + + if (state == SET_USB_NONE) + *val = MTP_PHONE_USB_DISCONNECTED; else - *val = state; + *val = MTP_PHONE_USB_CONNECTED; return; } -- 2.7.4 From 7628c4859c56b988ac5b6a6b2bfc391b8d890167 Mon Sep 17 00:00:00 2001 From: Jihoon Jung Date: Thu, 18 Aug 2016 20:02:00 +0900 Subject: [PATCH 13/16] Apply implementation for /opt/usr lazy mount Signed-off-by: Jihoon Jung Change-Id: I07725206ab00e6bee75faa1d089560d9694cb960 --- include/mtp_event_handler.h | 1 + include/util/mtp_util.h | 5 ++++ src/entity/mtp_device.c | 13 ++++++++--- src/mtp_event_handler.c | 39 ++++++++++++++++++++++++++++--- src/mtp_init.c | 57 ++++++++++++++++++++++++++++----------------- src/util/mtp_util.c | 32 +++++++++++++++++++++++++ 6 files changed, 119 insertions(+), 28 deletions(-) diff --git a/include/mtp_event_handler.h b/include/mtp_event_handler.h index 2a20cea..e6d4c16 100755 --- a/include/mtp_event_handler.h +++ b/include/mtp_event_handler.h @@ -58,6 +58,7 @@ mtp_bool _eh_register_notification_callbacks(void); mtp_bool _eh_handle_usb_events(mtp_uint32 type); void _eh_deregister_notification_callbacks(void); void _handle_mmc_notification(keynode_t *key, void *data); +void _handle_lock_status_notification(keynode_t *key, void *data); void _eh_send_event_req_to_eh_thread(event_code_t action, mtp_ulong param1, mtp_ulong param2, void *param3); diff --git a/include/util/mtp_util.h b/include/util/mtp_util.h index 45064be..b0c7bb2 100755 --- a/include/util/mtp_util.h +++ b/include/util/mtp_util.h @@ -76,6 +76,8 @@ typedef enum { MTP_PHONE_MMC_INSERTED, MTP_PHONE_MMC_NONE, MTP_PHONE_USB_MODE_OTHER, + MTP_PHONE_LOCK_ON, + MTP_PHONE_LOCK_OFF, } phone_status_t; typedef struct { @@ -141,6 +143,9 @@ void _util_set_local_mmc_status(const phone_status_t val); void _util_get_usbmode_status(phone_status_t *val); phone_status_t _util_get_local_usbmode_status(void); void _util_set_local_usbmode_status(const phone_status_t val); +void _util_get_lock_status(phone_status_t *val); +phone_status_t _util_get_local_lock_status(void); +void _util_set_local_lock_status(const phone_status_t val); void _util_get_external_path(char *external_path); void _util_get_internal_path(char *internal_path); #endif /* _MTP_UTIL_H_ */ diff --git a/src/entity/mtp_device.c b/src/entity/mtp_device.c index 0539974..8bf6485 100755 --- a/src/entity/mtp_device.c +++ b/src/entity/mtp_device.c @@ -705,13 +705,18 @@ mtp_bool _device_install_storage(mtp_int32 type) mtp_int32 int_status = TRUE; mtp_int32 ext_status = TRUE; mtp_bool mounted; + mtp_bool lock_status; switch (type) { case MTP_ADDREM_AUTO: DBG(" case MTP_ADDREM_AUTO:"); - int_status = _device_is_store_mounted(MTP_STORAGE_INTERNAL); - if (int_status == FALSE) - __add_store_to_device(MTP_STORAGE_INTERNAL); + + lock_status = _util_get_local_lock_status(); + if (lock_status == MTP_PHONE_LOCK_OFF) { + int_status = _device_is_store_mounted(MTP_STORAGE_INTERNAL); + if (int_status == FALSE) + __add_store_to_device(MTP_STORAGE_INTERNAL); + } mounted = _util_get_local_mmc_status(); if (mounted == MTP_PHONE_MMC_INSERTED) { @@ -725,6 +730,8 @@ mtp_bool _device_install_storage(mtp_int32 type) case MTP_ADDREM_INTERNAL: DBG("case MTP_ADDREM_INTERNAL:"); + if (MTP_PHONE_LOCK_OFF != _util_get_local_lock_status()) + break; if (FALSE == _device_is_store_mounted(MTP_STORAGE_INTERNAL)) __add_store_to_device(MTP_STORAGE_INTERNAL); break; diff --git a/src/mtp_event_handler.c b/src/mtp_event_handler.c index 72c3f3f..ccab66a 100755 --- a/src/mtp_event_handler.c +++ b/src/mtp_event_handler.c @@ -78,13 +78,14 @@ mtp_bool _eh_register_notification_callbacks(void) return FALSE; } + _util_get_lock_status(&val); + _util_set_local_lock_status(val); _util_get_mmc_status(&val); _util_set_local_mmc_status(val); - DBG("Phone status: USB = [%d] MMC = [%d] USB_MODE = [%d]\n", + DBG("Phone status: USB = [%d] MMC = [%d] USB_MODE = [%d] LOCK_STATUS = [%d]\n", _util_get_local_usb_status(), _util_get_local_mmc_status(), - _util_get_local_usbmode_status()); - + _util_get_local_usbmode_status(), _util_get_local_lock_status()); return TRUE; } @@ -371,6 +372,38 @@ static void __handle_usb_mode_notification(keynode_t *key, void *data) return; } +void _handle_lock_status_notification(keynode_t *key, void *data) +{ + phone_status_t previous_val = MTP_PHONE_LOCK_ON; + phone_status_t current_val = MTP_PHONE_LOCK_ON; + + previous_val = _util_get_local_lock_status(); + _util_get_lock_status(¤t_val); + + if (previous_val == current_val) { + return; + } + + _util_set_local_lock_status(current_val); + + if (MTP_PHONE_LOCK_OFF == current_val) { + _device_install_storage(MTP_ADDREM_INTERNAL); + __send_events_from_device_to_pc(MTP_INTERNAL_STORE_ID, + PTP_EVENTCODE_STOREADDED, 0, 0); + + media_content_connect(); + } else if (MTP_PHONE_LOCK_ON == current_val) { + _device_uninstall_storage(MTP_ADDREM_INTERNAL); + + __send_events_from_device_to_pc(MTP_INTERNAL_STORE_ID, + PTP_EVENTCODE_STOREREMOVED, 0, 0); + + media_content_disconnect(); + } + + return; +} + void _handle_mmc_notification(keynode_t *key, void *data) { phone_status_t val = MTP_PHONE_MMC_NONE; diff --git a/src/mtp_init.c b/src/mtp_init.c index 0cfe46f..85aa18a 100755 --- a/src/mtp_init.c +++ b/src/mtp_init.c @@ -87,15 +87,20 @@ static void __mtp_exit(void) return; } +static gboolean __check_internal_storage (gpointer user_data) +{ + _handle_lock_status_notification(NULL, NULL); + + return true; +} + void _mtp_init(add_rem_store_t sel) { - mtp_char wmpinfopath[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; mtp_char *device_name = NULL; mtp_char *sync_partner = NULL; mtp_bool ret = 0; int vconf_ret = 0; mtp_int32 error = 0; - char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; DBG("Initialization start!"); @@ -147,13 +152,24 @@ void _mtp_init(add_rem_store_t sel) } /* Internal Storage */ - _util_get_internal_path(inter_path); - if (access(inter_path, F_OK) < 0) { - if (FALSE == _util_dir_create((const mtp_char *)inter_path, &error)) { - ERR("Cannot make directory!! [%s]\n", - inter_path); + if (MTP_PHONE_LOCK_OFF == _util_get_local_lock_status()) { + mtp_int32 ret; + char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 }; + + ret = media_content_connect(); + if (MEDIA_CONTENT_ERROR_NONE != ret) { + ERR("media_content_connect() Fail(%d)", ret); goto MTP_INIT_FAIL; } + + _util_get_internal_path(inter_path); + if (access(inter_path, F_OK) < 0) { + if (FALSE == _util_dir_create((const mtp_char *)inter_path, &error)) { + ERR("Cannot make directory!! [%s]\n", + inter_path); + goto MTP_INIT_FAIL; + } + } } /* External Storage */ if (MTP_PHONE_MMC_INSERTED == _util_get_local_mmc_status()) { @@ -167,15 +183,6 @@ void _mtp_init(add_rem_store_t sel) } } } -#ifndef MTP_SUPPORT_HIDE_WMPINFO_XML - /* Update WMPInfo.xml for preventing frequent saving */ - ret = _util_create_path(wmpinfopath, sizeof(wmpinfopath), - (const mtp_char *)inter_path, MTP_FILE_NAME_WMPINFO_XML); - if (FALSE == ret) { - ERR("szWMPInfoPath is too long"); - goto MTP_INIT_FAIL; - } -#endif /*MTP_SUPPORT_HIDE_WMPINFO_XML*/ /* Set mtpdeviceinfo */ _init_mtp_device(); @@ -189,6 +196,15 @@ void _mtp_init(add_rem_store_t sel) _inoti_init_filesystem_evnts(); #endif /*MTP_SUPPORT_OBJECTADDDELETE_EVENT*/ + vconf_ret = vconf_notify_key_changed(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, + _handle_lock_status_notification, NULL); + if (vconf_ret < 0) { + ERR("vconf_notify_key_changed(%s) Fail", VCONFKEY_IDLE_LOCK_STATE_READ_ONLY); + goto MTP_INIT_FAIL; + } + + g_timeout_add(1000, __check_internal_storage, NULL); + vconf_ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, _handle_mmc_notification, NULL); if (vconf_ret < 0) { @@ -220,6 +236,9 @@ void _mtp_deinit(void) _inoti_deinit_filesystem_events(); #endif /*MTP_SUPPORT_OBJECTADDDELETE_EVENT*/ + vconf_ignore_key_changed(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, + _handle_lock_status_notification); + vconf_ignore_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, _handle_mmc_notification); @@ -470,12 +489,6 @@ int main(int argc, char *argv[]) { mtp_int32 ret; - ret = media_content_connect(); - if (MEDIA_CONTENT_ERROR_NONE != ret) { - ERR("media_content_connect() Fail(%d)", ret); - return MTP_ERROR_GENERAL; - } - if (_eh_register_notification_callbacks() == FALSE) { ERR("_eh_register_notification_callbacks() Fail"); return MTP_ERROR_GENERAL; diff --git a/src/util/mtp_util.c b/src/util/mtp_util.c index 4518a1f..b9c8e18 100755 --- a/src/util/mtp_util.c +++ b/src/util/mtp_util.c @@ -29,6 +29,7 @@ #include "mtp_support.h" #include "mtp_fs.h" #include +#include static phone_state_t g_ph_status = { 0 }; @@ -298,6 +299,37 @@ void _util_set_local_usbmode_status(const phone_status_t val) return; } +void _util_get_lock_status(phone_status_t *val) +{ + mtp_int32 ret = 0; + + struct stat st; +/* + mtp_int32 state = 0; + + ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, + &state); +*/ + ret = stat("/opt/usr/home", &st); + + if (ret == -1) + *val = MTP_PHONE_LOCK_ON; + else + *val = MTP_PHONE_LOCK_OFF; + return; +} + +phone_status_t _util_get_local_lock_status(void) +{ + return g_ph_status.lock_state; +} + +void _util_set_local_lock_status(const phone_status_t val) +{ + g_ph_status.lock_state = val; + return; +} + static bool _util_device_external_supported_cb(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data) { -- 2.7.4 From f12b9ceb58ccdf6aab06c7b1e6127db2dddb0e82 Mon Sep 17 00:00:00 2001 From: Hyihong Chae Date: Fri, 26 Aug 2016 13:56:38 +0900 Subject: [PATCH 14/16] remove unnecessary codes from spec file. Change-Id: I10849e79cae056bd0611a4b94f202b3698fdc269 Signed-off-by: HyiHong Chae --- packaging/mtp-responder.spec | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packaging/mtp-responder.spec b/packaging/mtp-responder.spec index a6dd0e3..2f951f5 100755 --- a/packaging/mtp-responder.spec +++ b/packaging/mtp-responder.spec @@ -5,7 +5,7 @@ ExcludeArch: %arm aarch64 Name: mtp-responder Summary: Media Transfer Protocol daemon (responder) -Version: 0.0.11 +Version: 0.0.12 Release: 1 Group: Network & Connectivity/Other License: Apache-2.0 @@ -48,10 +48,6 @@ cp packaging/99-mtp-responder.rules %{buildroot}%{_libdir}/udev/rules.d/99-mtp-r install -D -m 0644 mtp-responder.service %{buildroot}%{_libdir}/systemd/system/mtp-responder.service %post -/usr/bin/vconftool set -t string db/private/mtp/serial_number "" -u 5000 -g 5000 -i -f -s tizen::vconf::platform::rw -/usr/bin/vconftool set -t string db/private/mtp/sync_partner "" -u 5000 -g 5000 -i -f -s tizen::vconf::platform::rw -/usr/bin/vconftool set -t int db/private/mtp/sync_time 0 -u 5000 -g 5000 -i -f -s tizen::vconf::platform::rw - mkdir -p %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/ ln -sf %{_libdir}/systemd/system/mtp-responder.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/ -- 2.7.4 From c55198302b3a4eeca0bef77dd0b63a83dc801e0b Mon Sep 17 00:00:00 2001 From: Hyihong Chae Date: Fri, 9 Sep 2016 09:20:52 +0900 Subject: [PATCH 15/16] fix build warning. Change-Id: I15a1db6655c5b9026d72be569da50e72a9023e5e Signed-off-by: HyiHong Chae --- src/mtp_init.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mtp_init.c b/src/mtp_init.c index 85aa18a..981bfe4 100755 --- a/src/mtp_init.c +++ b/src/mtp_init.c @@ -98,7 +98,6 @@ void _mtp_init(add_rem_store_t sel) { mtp_char *device_name = NULL; mtp_char *sync_partner = NULL; - mtp_bool ret = 0; int vconf_ret = 0; mtp_int32 error = 0; -- 2.7.4 From 88043b65cbbd76971a3677eadd6f6d9235a934d4 Mon Sep 17 00:00:00 2001 From: Jihoon Jung Date: Mon, 12 Sep 2016 19:26:39 +0900 Subject: [PATCH 16/16] Add OS upgrade script Signed-off-by: Jihoon Jung Change-Id: I4f967960b351178af67dd073ee04a99ca60e47b1 --- packaging/mtp-responder.spec | 7 ++++++- scripts/mtp-responder-upgrade.sh | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100755 scripts/mtp-responder-upgrade.sh diff --git a/packaging/mtp-responder.spec b/packaging/mtp-responder.spec index 2f951f5..d21811b 100755 --- a/packaging/mtp-responder.spec +++ b/packaging/mtp-responder.spec @@ -5,7 +5,7 @@ ExcludeArch: %arm aarch64 Name: mtp-responder Summary: Media Transfer Protocol daemon (responder) -Version: 0.0.12 +Version: 0.0.13 Release: 1 Group: Network & Connectivity/Other License: Apache-2.0 @@ -23,6 +23,7 @@ BuildRequires: pkgconfig(capi-system-info) Buildrequires: pkgconfig(storage) Requires(post): /usr/bin/vconftool +%define upgrade_script_path /usr/share/upgrade/scripts %description This package includes a daemon which processes Media Transper Protocol(MTP) commands as MTP responder role. @@ -45,6 +46,9 @@ make %{?jobs:-j%jobs} mkdir -p %{buildroot}%{_libdir}/udev/rules.d cp packaging/99-mtp-responder.rules %{buildroot}%{_libdir}/udev/rules.d/99-mtp-responder.rules +mkdir -p %{buildroot}%{upgrade_script_path} +cp -f scripts/%{name}-upgrade.sh %{buildroot}%{upgrade_script_path} + install -D -m 0644 mtp-responder.service %{buildroot}%{_libdir}/systemd/system/mtp-responder.service %post @@ -58,4 +62,5 @@ ln -sf %{_libdir}/systemd/system/mtp-responder.service %{_sysconfdir}/systemd/de %{_libdir}/systemd/system/mtp-responder.service %{_libdir}/udev/rules.d/99-mtp-responder.rules /opt/var/lib/misc/mtp-responder.conf +%{upgrade_script_path}/%{name}-upgrade.sh #%license LICENSE.APLv2 diff --git a/scripts/mtp-responder-upgrade.sh b/scripts/mtp-responder-upgrade.sh new file mode 100755 index 0000000..468d41d --- /dev/null +++ b/scripts/mtp-responder-upgrade.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +#----------------------------------------------# +# mtp-responder patch for upgrade (2.4 -> 3.0) # +#----------------------------------------------# + +# Macro +MTP_RESPONDER_CONF=/opt/var/lib/misc/mtp-responder.conf + +chown owner:users $MTP_RESPONDER_CONF +chsmack -a "_" $MTP_RESPONDER_CONF -- 2.7.4