棋子 · 2020年02月24日

Running native codes on USB arrival

Hi Experts,

In Linux environment I use native codes cross compiled for ARM processor in the user space. The requirement is when on a USB device arrival, udevd will invoke the binary in association with rules containing VID/PID.

In Android environment I would like to do the same. I tried cross compiling the native codes for the same ARM development board and able to execute it manually using adb.

Also I developed a sample Android application with JNI interface to manually execute it.

  1. How to auto execute the native binary in Android environment, since udev is missing in Android for USB devices ?
  2. Writing Android app with JNI native code or straight away native code like GNU utils which one is the best way to satisfy the above needs

Regards,

1 个回答 得票排序 · 时间排序
极术小姐姐 · 2020年02月24日

Android may run on the Linux kernel but it does not use a conventional Linux desktop configuration for managing USB host class drivers and associations. Your question has nothing to do with ARM but with the OSes device management system. You can execute binaries from the shell or from an application just fine but if the APIs that your code rely on in the kernel aren't there, it won't matter. You should see errors reported in LogCat when this happens stating this. If you want to ensure your USB host application will work across a range of Android devices and future versions of Android, it is highly suggested that you use Androids native methods for USB host management.

USB Host | Android Developers

你的回答
关注数
1
收藏数
0
浏览数
1819
极术小姐姐
极术微信服务号
关注极术微信号
实时接收点赞提醒和评论通知
安谋科技学堂公众号
关注安谋科技学堂
实时获取安谋科技及 Arm 教学资源
安谋科技招聘公众号
关注安谋科技招聘
实时获取安谋科技中国职位信息