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);
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 {
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_ */
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) {
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;
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;
}
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;
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!");
}
/* 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()) {
}
}
}
-#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();
_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) {
_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);
{
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;
#include "mtp_support.h"
#include "mtp_fs.h"
#include <storage/storage.h>
+#include <sys/stat.h>
static phone_state_t g_ph_status = { 0 };
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)
{