USB_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,
USB_ERROR_NOT_CONNECTED = TIZEN_ERROR_ENDPOINT_NOT_CONNECTED,
USB_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED,
- USB_ERROR_OPERATION_FAILED = TIZEN_ERROR_SYSTEM_CLASS | 0x62
+ USB_ERROR_OPERATION_FAILED = TIZEN_ERROR_SYSTEM_CLASS | 0x62,
+ USB_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORT_API
} usb_error_e;
/**
#ifndef __TIZEN_SYSTEM_USB_ACCESSORY_PRIVATE_H__
#define __TIZEN_SYSTEM_USB_ACCESSORY_PRIVATE_H__
+#define _GNU_SOURCE
#include <stdio.h>
#include <libintl.h>
#include <stdbool.h>
#include <aul.h>
#include <vconf.h>
#include <stdlib.h>
-//#include <Ecore.h>
+#include <sys/utsname.h>
#include <glib.h>
#define ACC_ELEMENT_LEN 256
} IPC_SIMPLE_RESULT;
typedef enum {
- LAUNCH_APP = 0,
- REQUEST_PERMISSION,
- HAS_PERMISSION,
- REQ_PERM_NOTI_YES_BTN,
- REQ_PERM_NOTI_NO_BTN,
- GET_ACC_INFO,
- ERROR_POPUP_OK_BTN,
- KIESWIFI_POPUP_YES_BTN,
- KIESWIFI_POPUP_NO_BTN
+ /* General */
+ ERROR_POPUP_OK_BTN = 0,
+ IS_EMUL_BIN,
+
+ /* for Accessory */
+ LAUNCH_APP_FOR_ACC = 20,
+ REQ_ACC_PERMISSION,
+ HAS_ACC_PERMISSION,
+ REQ_ACC_PERM_NOTI_YES_BTN,
+ REQ_ACC_PERM_NOTI_NO_BTN,
+ GET_ACC_INFO
} REQUEST_TO_USB_MANGER;
typedef enum {
int ipc_noti_client_init(void);
int ipc_noti_client_close(int *sock_remote);
gboolean ipc_noti_client_cb(GIOChannel *g_io_ch, GIOCondition condition, gpointer data);
+bool is_emul_bin();
#endif /* __TIZEN_SYSTEM_USB_ACCESSORY_PRIVATE_H__ */
{
__USB_FUNC_ENTER__ ;
if (!handle) return USB_ERROR_INVALID_PARAMETER;
+ if (is_emul_bin()) {
+ USB_LOG("FAIL:USB Accessory is not available with emulator.");
+ return USB_ERROR_NOT_SUPPORTED;
+ }
if (!cloned_handle || *cloned_handle) return USB_ERROR_INVALID_PARAMETER;
*cloned_handle = (usb_accessory_h)malloc(sizeof(struct usb_accessory_s));
snprintf((*cloned_handle)->manufacturer, strlen(handle->manufacturer), "%s", handle->manufacturer);
{
__USB_FUNC_ENTER__ ;
if (!handle) return USB_ERROR_INVALID_PARAMETER;
+ if (is_emul_bin()) {
+ USB_LOG("FAIL:USB Accessory is not available with emulator.");
+ return USB_ERROR_NOT_SUPPORTED;
+ }
FREE(handle);
__USB_FUNC_EXIT__ ;
return USB_ERROR_NONE;
int usb_accessory_foreach_attached(usb_accessory_attached_cb callback, void *user_data)
{
__USB_FUNC_ENTER__ ;
+ if (callback == NULL) return USB_ERROR_INVALID_PARAMETER;
+ if (is_emul_bin()) {
+ USB_LOG("FAIL:USB Accessory is not available with emulator.");
+ return USB_ERROR_NOT_SUPPORTED;
+ }
struct usb_accessory_list *accList = NULL;
struct usb_accessory_list *tmpList = NULL;
bool ret = false;
int usb_accessory_set_connection_changed_cb(usb_accessory_connection_changed_cb callback, void* user_data)
{
__USB_FUNC_ENTER__ ;
+ if (is_emul_bin()) {
+ USB_LOG("FAIL:USB Accessory is not available with emulator.");
+ return USB_ERROR_NOT_SUPPORTED;
+ }
int ret = -1;
accCbData = (struct AccCbData *)malloc(sizeof(struct AccCbData));
accCbData->user_data = user_data;
int usb_accessory_connection_unset_cb()
{
__USB_FUNC_ENTER__ ;
+ if (is_emul_bin()) {
+ USB_LOG("FAIL:USB Accessory is not available with emulator.");
+ return USB_ERROR_NOT_SUPPORTED;
+ }
if (accCbData != NULL) {
FREE(accCbData);
int ret = vconf_ignore_key_changed(VCONFKEY_USB_ACCESSORY_STATUS, accessory_status_changed_cb);
{
__USB_FUNC_ENTER__ ;
if (!accessory) return USB_ERROR_INVALID_PARAMETER;
+ if (is_emul_bin()) {
+ USB_LOG("FAIL:USB Accessory is not available with emulator.");
+ return USB_ERROR_NOT_SUPPORTED;
+ }
if (accessory->accPermission == true) {
__USB_FUNC_EXIT__ ;
return USB_ERROR_NONE;
}
ret = ipc_request_client_init(&sock_remote);
- um_retvm_if(ret < 0, USB_ERROR_PERMISSION_DENIED, "FAIL: ipc_request_client_init(&sock_remote)\n");
+ um_retvm_if(ret < 0, USB_ERROR_PERMISSION_DENIED, "FAIL: ipc_request_client_init()\n");
- ret = request_to_usb_server(sock_remote, HAS_PERMISSION, buf, app_id);
- um_retvm_if(ret < 0, USB_ERROR_PERMISSION_DENIED, "FAIL: request_to_usb_server(HAS_PERMISSION)\n");
+ ret = request_to_usb_server(sock_remote, HAS_ACC_PERMISSION, buf, app_id);
+ um_retvm_if(ret < 0, USB_ERROR_PERMISSION_DENIED, "FAIL: request_to_usb_server()\n");
ret = ipc_request_client_close(&sock_remote);
- um_retvm_if(ret < 0, USB_ERROR_PERMISSION_DENIED, "FAIL: ipc_request_client_close(&sock_remote)\n");
+ um_retvm_if(ret < 0, USB_ERROR_PERMISSION_DENIED, "FAIL: ipc_request_client_close()\n");
FREE(app_id);
{
__USB_FUNC_ENTER__ ;
if (!accessory) return USB_ERROR_INVALID_PARAMETER;
+ if (is_emul_bin()) {
+ USB_LOG("FAIL:USB Accessory is not available with emulator.");
+ return USB_ERROR_NOT_SUPPORTED;
+ }
if (accessory->accPermission == true) {
*fd = fopen(USB_ACCESSORY_NODE, "r+");
USB_LOG("file pointer: %d", *fd);
{
__USB_FUNC_ENTER__ ;
if (!accessory) return USB_ERROR_INVALID_PARAMETER;
+ if (is_emul_bin()) {
+ USB_LOG("FAIL:USB Accessory is not available with emulator.");
+ return USB_ERROR_NOT_SUPPORTED;
+ }
*description = strdup(accessory->description);
__USB_FUNC_ENTER__ ;
return USB_ERROR_NONE;
{
__USB_FUNC_ENTER__ ;
if (!accessory) return USB_ERROR_INVALID_PARAMETER;
+ if (is_emul_bin()) {
+ USB_LOG("FAIL:USB Accessory is not available with emulator.");
+ return USB_ERROR_NOT_SUPPORTED;
+ }
*manufacturer = strdup(accessory->manufacturer);
__USB_FUNC_ENTER__ ;
return USB_ERROR_NONE;
{
__USB_FUNC_ENTER__ ;
if (!accessory) return USB_ERROR_INVALID_PARAMETER;
+ if (is_emul_bin()) {
+ USB_LOG("FAIL:USB Accessory is not available with emulator.");
+ return USB_ERROR_NOT_SUPPORTED;
+ }
*model = strdup(accessory->model);
__USB_FUNC_ENTER__ ;
return USB_ERROR_NONE;
{
__USB_FUNC_ENTER__ ;
if (!accessory) return USB_ERROR_INVALID_PARAMETER;
+ if (is_emul_bin()) {
+ USB_LOG("FAIL:USB Accessory is not available with emulator.");
+ return USB_ERROR_NOT_SUPPORTED;
+ }
*serial = strdup(accessory->serial);
__USB_FUNC_ENTER__ ;
return USB_ERROR_NONE;
{
__USB_FUNC_ENTER__ ;
if (!accessory) return USB_ERROR_INVALID_PARAMETER;
+ if (is_emul_bin()) {
+ USB_LOG("FAIL:USB Accessory is not available with emulator.");
+ return USB_ERROR_NOT_SUPPORTED;
+ }
*version = strdup(accessory->version);
__USB_FUNC_ENTER__ ;
return USB_ERROR_NONE;
int usb_accessory_is_connected(usb_accessory_h accessory, bool* is_connected)
{
__USB_FUNC_ENTER__ ;
+ if (is_emul_bin()) {
+ USB_LOG("FAIL:USB Accessory is not available with emulator.");
+ return USB_ERROR_NOT_SUPPORTED;
+ }
int ret = -1;
int val = -1;
ret = vconf_get_int(VCONFKEY_USB_ACCESSORY_STATUS, &val);
__USB_FUNC_ENTER__ ;
if (!accessory) return USB_ERROR_INVALID_PARAMETER;
if (!callback) return USB_ERROR_INVALID_PARAMETER;
+ if (is_emul_bin()) {
+ USB_LOG("FAIL:USB Accessory is not available with emulator.");
+ return USB_ERROR_NOT_SUPPORTED;
+ }
int ret = -1;
guint g_ret = 0;
int sock_remote;
return USB_ERROR_PERMISSION_DENIED;
}
- ret = request_to_usb_server(sock_remote, REQUEST_PERMISSION, buf, app_id);
+ ret = request_to_usb_server(sock_remote, REQ_ACC_PERMISSION, buf, app_id);
if(ret < 0) {
- USB_LOG("FAIL: request_to_usb_server(REQUEST_PERMISSION)\n");
+ USB_LOG("FAIL: request_to_usb_server(REQ_ACC_PERMISSION)\n");
ret = ipc_request_client_close(&sock_remote);
if (ret < 0) USB_LOG("FAIL: ipc_request_client_close(&sock_remote)\n");
ret = ipc_noti_client_close(&fd);
USB_LOG("Input: %d\n", input);
switch (input) {
- case REQ_PERM_NOTI_YES_BTN:
+ case REQ_ACC_PERM_NOTI_YES_BTN:
permCbData->accessory->accPermission = true;
permCbData->request_perm_cb_func((struct usb_accessory_s*)(permCbData->user_data), true);
break;
- case REQ_PERM_NOTI_NO_BTN:
+ case REQ_ACC_PERM_NOTI_NO_BTN:
permCbData->accessory->accPermission = false;
permCbData->request_perm_cb_func((struct usb_accessory_s*)(permCbData->user_data), false);
break;
ret = vconf_get_int(VCONFKEY_USB_ACCESSORY_STATUS, &val);
um_retm_if(ret < 0, "FAIL: vconf_get_int(VCONFKEY_USB_ACCESSORY_STATUS)\n");
- ret = getChangedAcc(&changedAcc);
- um_retm_if(ret < 0, "FAIL: getChangedAcc(&changedAcc)\n");
-
switch (val) {
case VCONFKEY_USB_ACCESSORY_STATUS_DISCONNECTED:
- conCbData->connection_cb_func(changedAcc, false, conCbData->user_data);
+ conCbData->connection_cb_func(NULL, false, conCbData->user_data);
break;
case VCONFKEY_USB_ACCESSORY_STATUS_CONNECTED:
+ ret = getChangedAcc(&changedAcc);
+ um_retm_if(ret < 0, "FAIL: getChangedAcc(&changedAcc)\n");
+
conCbData->connection_cb_func(changedAcc, true, conCbData->user_data);
+
+ ret = freeChangedAcc(&changedAcc);
+ um_retm_if(ret < 0, "FAIL: freeChangedAcc(&changedAcc)\n");
break;
default:
USB_LOG("ERROR: The value of VCONFKEY_USB_ACCESSORY_STATUS is invalid\n");
break;
}
- ret = freeChangedAcc(&changedAcc);
- um_retm_if(ret < 0, "FAIL: freeChangedAcc(&changedAcc)\n");
-
__USB_FUNC_EXIT__ ;
}
__USB_FUNC_EXIT__ ;
return true;
}
+
+bool is_emul_bin()
+{
+ __USB_FUNC_ENTER__ ;
+ int ret = -1;
+ struct utsname name;
+ ret = uname(&name);
+ if (ret < 0) {
+ __USB_FUNC_EXIT__ ;
+ return true;
+ } else {
+ USB_LOG("Machine name: %s", name.machine);
+ if (strcasestr(name.machine, "emul")) {
+ __USB_FUNC_EXIT__ ;
+ return true;
+ } else {
+ __USB_FUNC_EXIT__ ;
+ return false;
+ }
+ }
+
+}
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(acc_test C)
SET(SRCS acc_test.c)
+INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs REQUIRED eina elementary ecore-x appcore-efl aul capi-system-usb-accessory)
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g ")
TARGET_LINK_LIBRARIES(acc_test ${pkgs_LDFLAGS} capi-system-usb-accessory)
INSTALL(TARGETS acc_test DESTINATION /opt/apps/acc_test/bin)
-# install desktop file
-CONFIGURE_FILE(acc_test.desktop.in ${CMAKE_CURRENT_SOURCE_DIR}/acc_test.desktop)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/acc_test.desktop DESTINATION /opt/share/applications/)
+# install manifest file
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/acc_test.xml DESTINATION /opt/share/packages/)
-#include "usb_accessory.h"
+#include <usb_accessory.h>
#include <Elementary.h>
#include <dlog.h>
+++ /dev/null
-Name=Acc_test
-Exec=/opt/apps/acc_test/bin/acc_test
-Type=Application
-Comment=Usb accessory test application
-NoDisplay=true
-X-TIZEN-Removable=true
-X-TIZEN-TaskManage=true
-Version=0.1.0-0
--- /dev/null
+<?xml version="1.0" encoding="utf-8" ?>
+<manifest xmlns="http://tizen.org/ns/packages" package="acc_test" version="0.0.1" install-location="internal-only">
+ <label>acc_test</label>
+ <author email="ty317.kim@samsung.com" href="www.samsung.com">Taeyoung Kim</author>
+ <description>USB accessory test application</description>
+ <ui-application appid="acc_test" exec="/opt/apps/acc_test/bin/acc_test" nodisplay="true" multiple="false" type="capp" taskmanage="false">
+ <label>acc_test</label>
+ <label xml:lang="en-us">acc_test</label>
+ </ui-application>
+</manifest>
/usr/lib/lib*.so*
/opt/apps/acc_test/bin/acc_test
-/opt/share/applications/acc_test.desktop
+/opt/share/packages/acc_test.xml
-acc-test (0.0.1-1) unstable; urgency=low
+acc_test (0.0.1-1) unstable; urgency=low
* Initial release.
* Git: slp-source.sec.samsung.net:slp/api/usb-accessory
- * Tag: acc-test_0.0.1-1
+ * Tag: acc_test_0.0.1-1
-- Taeyoung Kim <ty317.kim@samsung.com> Tue, 05 Jun 2012 00:19:00 +0900
Maintainer: Taeyoung Kim <ty317.kim@samsung.com> Taesoo Jun <steve.jun@samsung.com>
Build-Depends: debhelper (>= 5), dlog-dev, libglib2.0-dev, capi-system-usb-accessory-dev, libelm-dev, libappcore-efl-dev, libecore-dev, libevas-dev
-Package: acc-test
+Package: acc_test
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: A test package for usb accessory
-Package: acc-test-dbg
+Package: acc_test-dbg
Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, acc-test (= ${Source-Version})
+Depends: ${shlibs:Depends}, ${misc:Depends}, acc_test (= ${Source-Version})
Description: A test package for testing usb accessory
dh_install --sourcedir=debian/tmp
dh_installman
dh_link
- dh_strip --dbg-package=acc-test-dbg
+ dh_strip --dbg-package=acc_test-dbg
dh_fixperms
dh_makeshlibs
dh_installdeb
-Name: acc-test
+Name: acc_test
Summary: A test program for usb accessory
Version: 0.0.1
Release: 1
BuildRequires: pkgconfig(elementary)
BuildRequires: pkgconfig(appcore-efl)
+%description
+
%prep
%setup -q
%files
-%attr(644,root,root) /opt/share/applications/acc_test.desktop
+%attr(644,root,root) /opt/share/packages/acc_test.xml
%attr(555,root,root) /opt/apps/acc_test/bin/acc_test