{ "id": "173809", "key": "TIMOB-27186", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2019-06-26T14:01:42.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2019-10-28T17:12:56.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "13715", "name": "Hyperloop", "description": "Hyperloop project" } ], "description": "Hello,\r\n\r\nOne of our customer is using android.hardware.usb.UsbManager.getDeviceList() to get a list of connected us devices.\r\nThe code calls this OK, but the log shows the following error.\r\n\r\n{code}ERROR] JNIUtil: !!! Unable to convert unknown Java object class 'android.hardware.usb.UsbDevice' to JS value !!!{code}\r\n\r\n*The test code is:*\r\n{code}var AndroidAppPkg = require('android.app.*');\r\nvar Activity = AndroidAppPkg.Activity;\r\nvar Context = require('android.content.Context');\r\n\r\nvar Usb = require('android.hardware.usb.*');\r\nvar UsbManager = Usb.UsbManager;\r\nvar UsbDevice = require('android.hardware.usb.UsbDevice');\r\n\r\nfunction init() {\r\nTi.API.info(\"actionRS232.init\");\r\nvar activity = new Activity(Titanium.App.Android.getTopActivity());\r\nvar appContext = activity.getApplicationContext();\r\nvar obj = appContext.getSystemService(Context.USB_SERVICE);\r\nvar mgr = UsbManager.cast(obj);\r\nvar list = mgr.getDeviceList();\r\n\r\nvar devices = {};\r\nfor (var k in list) {\r\nTi.API.info(k + \": \" + typeof list[k]);\r\n}\r\n}{code}\r\n\r\ninit() being called from the Window onOpen event.\r\n\r\n*The output is:*\r\n{code}[INFO] /dev/bus/usb/002/003: undefined{code}\r\n\r\n*Test Environment:*\r\nSDK: 8.0.2.GA\r\nHyperloop: 4.0.2 (Android) \r\nTesting on Tablet Android 7\r\n\r\nPlease let us know if you need any more information. Thanks\r\n\r\n", "attachment": [], "flagged": false, "summary": "Android: Getting error when calling the getDeviceList() using hyperloop ", "creator": { "name": "fhaque", "key": "fhaque", "displayName": "Fazlul Haque", "active": false, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "fhaque", "key": "fhaque", "displayName": "Fazlul Haque", "active": false, "timeZone": "America/Los_Angeles" }, "environment": "Android, android.hardware.usb.UsbManager, getDeviceList()", "comment": { "comments": [ { "id": "449451", "author": { "name": "andybingham", "key": "andybingham", "displayName": "Andy Bingham", "active": true, "timeZone": "Europe/London" }, "body": "Worth pointing out here that the error only occurs if you have a USB slave device attached to the android unit. \r\nI have replicated this on two tablets, \r\none using an OTG cable from the single mini-usb port, \r\nthe other has a separate full USB 2 port.\r\nThe connected devices used were a USB gamepad and a USB to serial convertor (which is my actual use case here)\r\n\r\nIf you need any more, do let me know\r\n\r\nAndy", "updateAuthor": { "name": "andybingham", "key": "andybingham", "displayName": "Andy Bingham", "active": true, "timeZone": "Europe/London" }, "created": "2019-06-28T15:36:47.000+0000", "updated": "2019-06-28T15:36:47.000+0000" }, { "id": "450439", "author": { "name": "andybingham", "key": "andybingham", "displayName": "Andy Bingham", "active": true, "timeZone": "Europe/London" }, "body": "Is there any update on this issue? It has been a few weeks and is holding up a customer project, so is a priority for me. If nothing is likely to be done to help me, then I will have to look for another solution for the customer. ", "updateAuthor": { "name": "andybingham", "key": "andybingham", "displayName": "Andy Bingham", "active": true, "timeZone": "Europe/London" }, "created": "2019-08-13T15:24:44.000+0000", "updated": "2019-08-13T15:24:44.000+0000" }, { "id": "450440", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~andybingham] do you need to use Hyperloop for this? You can always write a normal Android module and pass the date to your app e.g. using an event:\r\n\r\n{code}\r\n\t// Methods\r\n\t@Kroll.method\r\n\tpublic void getDeviceList()\r\n\t{\r\n\t\tmanager = (UsbManager) activity.getSystemService(activity.USB_SERVICE);\r\n\t\tdeviceList = manager.getDeviceList();\r\n\t\tIterator deviceIterator = deviceList.values().iterator();\r\n\t\t\r\n\t\tHashMap listDevices = new HashMap();\r\n\t\t\r\n\t\twhile (deviceIterator.hasNext()) {\r\n\t\t UsbDevice device = deviceIterator.next();\r\n\t\t listDevices.put(\"deviceId\", device.getDeviceId());\r\n\t\t listDevices.put(\"name\", device.getDeviceName());\r\n\t\t listDevices.put(\"class\", device.getDeviceClass());\r\n\t\t listDevices.put(\"subclass\", device.getDeviceSubclass());\r\n\t\t listDevices.put(\"vendorId\", device.getVendorId());\r\n\t\t listDevices.put(\"productId\", device.getProductId());\r\n\t\t}\r\n\t\tKrollDict kd = new KrollDict();\r\n\t\tkd.put(\"devices\", listDevices);\r\n\t\tfireEvent(\"complete\", kd);\r\n\t}\r\n{code}\r\n\r\n", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-08-13T15:32:38.000+0000", "updated": "2019-08-13T15:32:38.000+0000" }, { "id": "450441", "author": { "name": "andybingham", "key": "andybingham", "displayName": "Andy Bingham", "active": true, "timeZone": "Europe/London" }, "body": "Michael, thanks for this, \r\n\r\nI guess you idea might work, but I have no experience with native code or module development, so had turned to hyperloop as it seemed to be a way to access the native library from titanium without having to do a module.\r\n\r\nIf they cannot fix this issue, then I guess I will have to start to teach myself how to do this in a native module?\r\n\r\nAndy\r\n", "updateAuthor": { "name": "andybingham", "key": "andybingham", "displayName": "Andy Bingham", "active": true, "timeZone": "Europe/London" }, "created": "2019-08-13T15:42:58.000+0000", "updated": "2019-08-13T15:42:58.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }