[TBT][usbhost][ACR-917][DPTTIZEN-2780,Added new module of usb host and tpk files] 31/130631/4
authorjihun park <jihun87.park@samsung.com>
Tue, 23 May 2017 07:04:15 +0000 (16:04 +0900)
committerjihun park <jihun87.park@samsung.com>
Fri, 26 May 2017 04:07:32 +0000 (13:07 +0900)
Change-Id: I32e83b192106f2ed64e5feabd2186f8b2c506ae3
Signed-off-by: jihun park <jihun87.park@samsung.com>
release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk [changed mode: 0755->0644]
release/binary-x86/org.tizen.tbtcoreapp-1.0.0-x86.tpk [changed mode: 0755->0644]
tbtcoreapp/inc/model/tbt-info.h
tbtcoreapp/inc/utils/app_module_config.h
tbtcoreapp/inc/view/tbt-usb-host-view.h [new file with mode: 0755]
tbtcoreapp/res/edje/4.0/mobile/usb_host_viewer.edc [new file with mode: 0755]
tbtcoreapp/src/model/tbt-list.c
tbtcoreapp/src/view/tbt-d2d-view.c
tbtcoreapp/src/view/tbt-genlist-view.c
tbtcoreapp/src/view/tbt-usb-host-view.c [new file with mode: 0755]

old mode 100755 (executable)
new mode 100644 (file)
index 9c0a834..0b3ec34
Binary files a/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk and b/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk differ
old mode 100755 (executable)
new mode 100644 (file)
index 6e0e8d2..e61c27c
Binary files a/release/binary-x86/org.tizen.tbtcoreapp-1.0.0-x86.tpk and b/release/binary-x86/org.tizen.tbtcoreapp-1.0.0-x86.tpk differ
index a34d425..135fca1 100755 (executable)
@@ -306,7 +306,9 @@ typedef enum {
 
        TBT_APP_DALI_WIDGET,
 
-       TBT_APP_MULTICLASS
+       TBT_APP_MULTICLASS,
+
+       TBT_APP_USBHOST
        //TBT_APP_DALI_SCROLL_BAR
 
 } tbt_app_type_e;
index 2f2d3b7..fa715b7 100755 (executable)
 #define TBT_MODULE_APP_DALI_SCROLL
 #define TBT_MODULE_APP_DALI_WIDGET
 //#define TBT_MODULE_APP_DALI_SCROLL_BAR
-
 //#define TBT_MODULE_APP_DALI_HOVER_EVENT
 //#define TBT_MODULE_APP_DALI_KEY_EVENT
 //#define TBT_MODULE_APP_DALI_LONGPRESS_GESTURE_DETECTOR
 //#define TBT_MODULE_APP_DALI_SLIDER
 #define TBT_MODULE_MULTICLASS
 #define TBT_MODULE_APP_MULTICLASS
+#define TBT_MODULE_USBHOST
+#define TBT_MODULE_APP_USBHOST
+
 #endif
diff --git a/tbtcoreapp/inc/view/tbt-usb-host-view.h b/tbtcoreapp/inc/view/tbt-usb-host-view.h
new file mode 100755 (executable)
index 0000000..0094a1e
--- /dev/null
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ *  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.
+ *
+ *******************************************************************************/
+/**
+ * @file       tbt-usb-host-view.h
+ * @brief      retrieves usb host info
+ * @since_tizen 4.0
+ * @author     Nibha Sharma(nibha.sharma@samsung.com)
+ * @date       April, 2017
+ * @bug                none
+ * @credit
+ * @credit
+ *
+ */
+
+#ifndef __TBT_USB_HOST_VIEW_H__
+#define __TBT_USB_HOST_VIEW_H__
+
+#include "utils/app_module_config.h"
+#ifdef TBT_MODULE_USBHOST
+
+#include <Evas.h>
+#include "model/tbt-list.h"
+#include <usb_host.h>
+
+
+/**
+ * @typedef usb_host_viewer view
+ * @since_tizen 4.0
+ * @brief A usb host viewer view handle.
+ */
+typedef struct _usbhost_view usbhost_view;
+
+/**
+ * @brief Create usbhost view
+ * @since_tizen 2.3 
+ * @param[in] navi Parent naviframe
+ * @param[in] custom structute to hold tbt application information
+ * @param[in] item of the main tbt menu
+ * @return Pointer of runtimeinfo on success, otherwise NULL
+ */
+usbhost_view *usbhost_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_Item *item);
+
+#endif
+#endif // __TBT_USB_HOST_VIEW_H__
\ No newline at end of file
diff --git a/tbtcoreapp/res/edje/4.0/mobile/usb_host_viewer.edc b/tbtcoreapp/res/edje/4.0/mobile/usb_host_viewer.edc
new file mode 100755 (executable)
index 0000000..ff3c156
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2014 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.
+ */
+
+#define TEXT_HEIGHT 0.08
+
+collections
+{
+   base_scale: 1.8;
+   group
+   {
+      name: "usb_host_viewer";
+      parts{
+         part{
+            name: "info_text";
+            type: SWALLOW;
+            description{
+               state: "default" 0.0;
+               align: 0.0 0.0;
+               visible: 1;
+               rel1 {relative: 0.0 0.0; }
+               rel2 {relative: 1.0 TEXT_HEIGHT; }
+            }
+         }
+      part{
+            name: "btn_part";
+            type: SWALLOW;
+            description{
+               state: "default" 0.0;
+               align: 0.0 0.0;
+               visible: 1;
+               rel1 {
+                  relative: 0.0 0.9;
+               }
+               rel2 {
+                  relative: 1.0 1.0;
+               }
+            }
+         }
+      }
+   }
+}
index df4b91d..8a4f2aa 100755 (executable)
@@ -1842,9 +1842,9 @@ static tbt_info tbtapps[] =
                        .parent = "Runtime Info",
                        .apptype = TBT_APP_USB_CONNECTED,
                        .icon_name = "dummy",
-                       .info = "1. Initially <b>USB Not Connected</b> message will be shown.<br/>"
-                                       "2. Connect Device to a USB port.<br/>"
-                                       "3. <b>USB is Connected</b> message will be shown.",
+                       .info = "1. Initially <b>Callback not hit message will be shown.<br/>"
+                                       "2. In sdb shell run command devicectl usb-host-test start or devicectl usb-host-test stop.<br/>"
+                                       "3. <b>Callback hit</b> message will be shown.",
                        .result = 0
                },
        #endif
@@ -2827,10 +2827,25 @@ static tbt_info tbtapps[] =
                        .icon_name = "dummy",
                        .info = "1. Please install multiclass org.example.multiclass tpk file <br/>2. Click View Widget UI button<br/>3.Multiple Widget class app gets launched.<br/>4.Please refer info section",
                        .result = 0
-               }
+               },
        #endif
 #endif
+#ifdef TBT_MODULE_USBHOST
+               #ifdef TBT_MODULE_APP_USBHOST
 
+               //Usb Host Test
+               {
+                       .name = "Usb HotPlug App",
+                       .parent = "USB Host",
+                       .apptype = TBT_APP_USBHOST,
+                       .icon_name = "dummy",
+                       .info = "1. Please run devicectl usb-host-test start or usb-host-test start in device shell <br/>2. Callback Hit will be displayer<br/>",
+                       .result = 0,
+                       .required_features_count = 1,
+                       .features_required = { FEATURE_USB_HOST }
+               }
+       #endif
+#endif
 };
 
 #ifdef TBT_MODULE_SENSOR
index a9b375e..1fda27a 100644 (file)
@@ -23,6 +23,7 @@
  *
  */
 
+#if 0
 #include "utils/app_module_config.h"
 #ifdef TBT_MODULE_D2D
 
@@ -403,3 +404,4 @@ static void _app_destroy_cb(void* this)
 }
 
 #endif
+#endif
index 69a342f..4c3efd7 100755 (executable)
 #include "view/tbt-ui-viewmgr-view.h"
 #include "view/tbt-dali-view.h"
 #include "view/tbt-multiclass-view.h"
+#include "view/tbt-usb-host-view.h"
 
 typedef struct
 {
@@ -1128,8 +1129,7 @@ static void _gl_item_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void
                        case TBT_APP_D2D_SERVER:
                                d2d_view_add(view->navi, info, it);
                                break;
-               #endif*/
-               
+               #endif*/                
                #ifdef TBT_MODULE_TTS
                        case TBT_APP_TTS:
                        tts_view_add(view->navi, info, it);
@@ -1250,7 +1250,12 @@ static void _gl_item_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void
                #ifdef TBT_MODULE_MULTICLASS
                        case TBT_APP_MULTICLASS:
                                multiclass_view_add(view->navi, info, it);
-                               break;
+                       break;
+               #endif
+               #ifdef TBT_MODULE_USB_HOST
+                       case TBT_APP_USBHOST:
+                               usbhost_view_add(view->navi, info, it);
+                       break;
                #endif
                default:
                        assert(false);
diff --git a/tbtcoreapp/src/view/tbt-usb-host-view.c b/tbtcoreapp/src/view/tbt-usb-host-view.c
new file mode 100755 (executable)
index 0000000..0584f83
--- /dev/null
@@ -0,0 +1,217 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ *  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.
+ *******************************************************************************/
+/**
+ * @file       tbt-usb-host-view.c
+ * @brief      retrieves usb-host info
+ *
+ * @author     Nibha Sharma(nibha.sharma@samsung.com)
+ * @date       June, 2016
+ * @bug                none
+ * @credit
+ *
+ */
+#include "utils/app_module_config.h"
+#ifdef TBT_MODULE_USBHOST
+
+#include <Elementary.h>
+#include <locations.h>
+#include <notification.h>
+
+#include "utils/logger.h"
+#include "utils/config.h"
+#include "utils/ui-utils.h"
+#include "view/tbt-usb-host-view.h"
+#include "view/tbt-common-view.h"
+
+struct _usbhost_view
+{
+       common_view* view;
+       Evas_Object *info_label;
+       Evas_Object *device_label;
+};
+
+static void _app_destroy_cb(void* this);
+void _usb_host_hotplug_cb(usb_host_device_h dev, void *user_data);
+
+static bool is_not_supported = false;
+bool usb_cb_hit = false;
+usb_host_context_h hCtxHandle;
+usb_host_hotplug_h hHandle;
+
+/**
+ * @function           get_usbhost_error
+ * @since_tizen                4.0
+ * @description                Get Usb-Host Error
+ * @parameter          int: Int
+ * @return                     char*
+ */
+char* get_usbhost_error(int ret)
+{
+       char* err_msg = NULL;
+
+       switch (ret) {
+       case USB_HOST_ERROR_NONE:
+               err_msg = "USB_HOST_ERROR_NONE";
+               break;
+       case USB_HOST_ERROR_IO_ERROR:
+               err_msg = "USB_HOST_ERROR_IO_ERROR";
+               break;
+       case USB_HOST_ERROR_INVALID_PARAMETER:
+               err_msg = "USB_HOST_ERROR_INVALID_PARAMETER";
+               break;
+       case USB_HOST_ERROR_PERMISSION_DENIED:
+               err_msg = "USB_HOST_ERROR_PERMISSION_DENIED";
+               break;
+       case USB_HOST_ERROR_NO_SUCH_DEVICE:
+               err_msg = "USB_HOST_ERROR_NO_SUCH_DEVICE";
+               break;
+       case USB_HOST_ERROR_NOT_FOUND:
+               err_msg = "USB_HOST_ERROR_NOT_FOUND";
+               break;
+       case USB_HOST_ERROR_RESOURCE_BUSY:
+               err_msg = "USB_HOST_ERROR_RESOURCE_BUSY";
+               break;
+       case USB_HOST_ERROR_TIMED_OUT:
+               err_msg = "USB_HOST_ERROR_TIMED_OUT";
+               break;
+       case USB_HOST_ERROR_OVERFLOW:
+               err_msg = "USB_HOST_ERROR_OVERFLOW";
+               break;
+       case USB_HOST_ERROR_DEVICE_NOT_OPENED:
+               err_msg = "USB_HOST_ERROR_DEVICE_NOT_OPENED";
+               break;
+       case USB_HOST_ERROR_BROKEN_PIPE:
+               err_msg = "USB_HOST_ERROR_BROKEN_PIPE";
+               break;
+       case USB_HOST_ERROR_INTERRUPTED_SYS_CALL:
+               err_msg = "USB_HOST_ERROR_INTERRUPTED_SYS_CALL";
+               break;
+       case USB_HOST_ERROR_OUT_OF_MEMORY:
+               err_msg = "USB_HOST_ERROR_OUT_OF_MEMORY";
+               break;
+       case USB_HOST_ERROR_NOT_SUPPORTED:
+               err_msg = "USB_HOST_ERROR_NOT_SUPPORTED";
+               break;
+       default:
+               err_msg = "Unknown Error";
+       }
+       return err_msg;
+}
+
+
+/**
+ * @function           usbhost_view_add
+ * @since_tizen                4.0
+ * @description                usb host View Add
+ * @parameter          Evas_Object*: Evas Object Pointer, tbt_info*: Tbt Info Pointer, Elm_Object_Item*: Elm Object Item Pointer
+ * @return             usbhost_view*
+ */
+usbhost_view *usbhost_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_Item *item)
+{
+       RETVM_IF(NULL == navi, NULL, "navi is null");
+       int ret, value;
+       usbhost_view *this = NULL;
+       this = calloc(1, sizeof(usbhost_view));
+       RETVM_IF(!this, NULL, "calloc failed");
+
+       this->view = calloc(1, sizeof(common_view));
+       RETVM_IF(!this->view, NULL, "calloc failed");
+
+       tbt_info->layout_group = "usb_host_viewer";
+       tbt_info->layout_file = get_edje_path("usb_host_viewer.edj");
+
+       common_view_add(navi, tbt_info, item, this->view, _app_destroy_cb, this);
+       RETVM_IF(NULL == this->view, NULL, "navi is null");
+
+       //ui_utils_guide_instruction_popup_button(navi, "* Please run "devicectl usb-host-test start" or "devicectl usb-host-test stop" command in sdb shell<br/><b>Note:You can also refer info section</b><br/>");
+
+       ret = usb_host_create(&hCtxHandle);
+       RETVM_IF(ret != USB_HOST_ERROR_NONE && ret != USB_HOST_ERROR_NOT_SUPPORTED, NULL, "usb_host_create failed : %s", get_usbhost_error(ret));
+       if(ret == USB_HOST_ERROR_NOT_SUPPORTED)
+       {
+               is_not_supported = true;
+               Evas_Object *popup = ui_utils_popup_add(this->view->navi, "Message");
+               elm_object_text_set(popup, "Usb Hotplug is not supported");
+               RETVM_IF(!this->view, NULL,"Usb Hotplug is not supported");
+       }
+
+       ret =  usb_host_set_hotplug_cb(hCtxHandle, _usb_host_hotplug_cb, USB_HOST_HOTPLUG_EVENT_ANY, this, &hHandle);
+       RETVM_IF(ret != USB_HOST_ERROR_NONE , NULL, "usb_host_set_hotplug_cb failed : %s", get_usbhost_error(ret));
+
+       this->info_label = ui_utils_label_add(this->view->layout, "Please run usb host command in shell");
+       elm_label_line_wrap_set(this->info_label, ELM_WRAP_WORD);
+
+       if(usb_cb_hit == true)
+       {
+               ui_utils_label_set_text(this->info_label, "Callback Hit !!!", "left");
+       }
+       else
+       {
+               ui_utils_label_set_text(this->info_label, "Callback Not Hit !!!", "left");
+       }
+
+       elm_object_part_content_set(this->view->layout, "info_text", this->info_label);
+       return this;
+}
+
+/**
+ * @function           _app_destroy_cb
+ * @since_tizen                2.3
+ * @description                 App Destroy Cb
+ * @parameter          void*: Void Pointer
+ * @return             static void
+ */
+static void _app_destroy_cb(void* this)
+{
+
+       RETM_IF(NULL == this, "data is NULL");
+
+       usbhost_view *view = NULL;
+       view = (usbhost_view*)this;
+       RETM_IF(NULL == view, "view is NULL");
+       usb_cb_hit = false;
+       if(is_not_supported == true)
+       {
+               view->view->tbt_info->result = TBT_INFO_RESULT_NOT_SUPPORTED;
+               elm_genlist_item_update(view->view->item);
+       }
+       if(hHandle)
+       {
+               int ret =  usb_host_unset_hotplug_cb(hHandle);
+               RETM_IF(ret != USB_HOST_ERROR_NONE ,"usb_host_unset_hotplug_cb failed : %s", get_usbhost_error(ret));
+       }
+
+       SAFE_DELETE(view->view);
+       SAFE_DELETE(view);
+}
+
+/**
+ * @function           _usb_host_hotplug_cb
+ * @since_tizen                4.0
+ * @description                Usb Host hotplug Cb
+ * @parameter          usb_host_device_h dev, void *user_data
+ * @return             void
+ */
+void _usb_host_hotplug_cb(usb_host_device_h dev, void *user_data)
+{
+       usb_cb_hit = true;
+       RETM_IF(NULL == user_data, "user_data is null");
+       usbhost_view *this = NULL;
+       this = (usbhost_view*) user_data;
+       ui_utils_label_set_text(this->info_label, "Callback Hit !!!", "left");
+}
+
+#endif