2012-06-25 22 views
24

मैं एक एंड्रॉइड एप्लिकेशन विकसित कर रहा हूं जिसमें मुझे एक यूएसबी डिवाइस से संवाद करना है। मैंने अपने ऐप में स्टैंडआर्ट गूगल एपीआई का उपयोग करने की कोशिश की, लेकिन उपकरणों की सूची हमेशा खाली है।एंड्रॉइड यूएसबी होस्ट और छुपे हुए डिवाइस

वही चीजें अगर मैं Google एपीआई के साथ यूएसबी डिवाइस जानकारी का उपयोग करता हूं। Google API द्वारा खोजा गया उपकरणों की सूची खाली है,

lsusb निम्नलिखित परिणाम देता है:

Bus 001 Device 001: ID 1d6b:0001 
Bus 002 Device 001: ID 1d6b:0002 
Bus 003 Device 001: ID 1d6b:0001 
Bus 002 Device 002: ID 2226:0014 

मेरे डिवाइस है 2226: ग्रहण का 0014

लॉग:

I/USB3G(92): event { 'add', '/devices/platform/sw-ehci.1/usb2/2-1', 'usb', '', 189, 133 } 
I/USB3G(92): path : '/sys/devices/platform/sw-ehci.1/usb2/2-1' 
I/USB3G(92): VID :size 5,vid_path '/sys/devices/platform/sw-ehci.1/usb2/2-1/idVendor',VID '2226 
I/USB3G(92): '. 
I/USB3G(92): PID :size 5,Pid_path '/sys/devices/platform/sw-ehci.1/usb2/2-1/idProduct',PID '0014 
I/USB3G(92): '. 
I/USB3G(92): cmd=/system/etc/usb_modeswitch.sh /system/etc/usb_modeswitch.d/2226_0014 &, 
I/USB3G(92): excute ret : 0,err:No such file or directory 

तो मैं प्लग आरएस 232 एडेप्टर, ब्लूटूथ डोंगल जैसे उपकरणों में, कुछ नहीं होता है, और एपीआई और एलएसयूएसबी से कोई परिणाम नहीं होता है।

डिवाइस का प्रेटोकॉल ezusb लाइब्रेरी पर आधारित है। एंड्रॉयड वी .: 4.0.3 गिरी वी .: 3.0.8 फर्मवेयर निर्माण: crane_evb-eng 4.0.3 IMLK74k 20120330

एपीआई के माध्यम से छिपा यूएसबी उपकरणों का उपयोग करने के लिए किसी भी तरह देखते हैं, या मैं समर्थन को लागू करना चाहिए इस डिवाइस का ड्राइवर लिखकर और इसे फर्मवेयर में पैच करके?

अद्यतन: मैं * प्रणाली/आदि में जानकारी फ़ाइल बनाने भले ही/usb_modeswitch.d/* नाम 2226_0014 युक्त

DefaultVendor= 0x2226 
DefaultProduct=0x0014 
TargetVendor= 0x2226 
TargetProductList="0014" 
MessageEndpoint="0x00" 
NeedResponse=1 
CheckSuccess=20 

मैं एक ही त्रुटि मिलती है साथ: "ऐसा कोई फ़ाइल या निर्देशिका"

उत्तर

44

USB होस्ट API समर्थन सक्षम करने के लिए आप नाम की एक फ़ाइल जोड़ना चाहिए
android.hardware.usb.host.xml और युक्त निम्नलिखित लाइनों:

<permissions> 
<feature name="android.hardware.usb.host"/> 
</permissions> 

फ़ोल्डर

/system/etc/permissions 

उस फ़ोल्डर में में

handheld_core_hardware.xml or tablet_core_hardware.xml 

नामक फ़ाइल खोजने के लिए और <permissions> अनुभाग में

<feature name="android.hardware.usb.host" /> 

जोड़ें।

अपने डिवाइस को रीबूट करें। यूएसबी मेजबान एपीआई काम करना चाहिए।

एंड्रॉयड 4.

+0

धन्यवाद दोस्त! यह मेरे यार्विक TAB464 पर भी काम किया! –

+0

उत्कृष्ट) सबकुछ बढ़िया काम कर रहा है) –

+0

धन्यवाद, मेरे लिए काम कर रहा है – Marijn

6

बहुत बढ़िया साथ घन U30GT पर परीक्षण किया गया! यह एंड्रॉइड 4.0.4 चलाने वाले मेरे एनविज़न वी 700 एनए पर काम करता था।

माइनर टाइपो: <feature name="android.hardware.usb.host">

होना चाहिए: <feature name="android.hardware.usb.host"/>

प्रक्रिया:

  1. adb pull /system/etc/permissions/tablet_core_hardware.xml
  2. अद्यतन है कि फाइल और एंड्रॉयड पैदा करते हैं। greg-q द्वारा निर्दिष्ट हार्डवेयर.usb.host.xml।
  3. एडीबी धक्का android.hardware.usb.host.xml/प्रणाली/etc/अनुमतियाँ
  4. एडीबी धक्का tablet_core_hardware.xml/प्रणाली/etc/अनुमतियाँ
  5. रीबूट।
1

मैं MK809, Android 4.1 Jelly Bean पर एडीबी का उपयोग किया है, और आदेश हैं:

एडीबी रिमाउंट /../../file.xml rw एडीबी धक्का ...

सामान्य आदेश i'vent अनुमति और फाइल के साथ पढ़ा जाता है केवल

मेरा बुरा अंग्रेजी के लिए क्षमा करें: पी

2

एक माइक्रोमैक्स A120 कैनवस 2 फोन पर एक आकर्षण की तरह काम किया (किटकैट 4.4.2)। अब मैं अपने Arduino को नियंत्रित कर सकते हैं! मैंने सभी कमांड लाइन काम करने के लिए busybox टूल का उपयोग किया (अन्यथा chmod काम नहीं करेगा)। मेरे कदम (शायद कुछ आवश्यक नहीं थे):

(0) मेरे विंडोज 8 कंप्यूटर पर पीडीएनेट ड्राइवर (http://pdanet.co/a/) स्थापित करें। (1) http://www.mgyun.com/m/en पर Vroot (जिसे अब iRoot कहा जाता है) का उपयोग कर फ़ोन रूट करें। बहुत सरल, केवल पकड़ यह है कि सु अनुदान/अस्वीकार पृष्ठ आंशिक रूप से चीनी में है, कोई बड़ा सौदा नहीं है। (2) बिजीबॉक्स स्थापित करने और jackpal के Android टर्मिनल एम्यूलेटर (GitHub https://github.com/jackpal/Android-Terminal-Emulator देख या दुकान https://play.google.com/store/apps/details?id=jackpal.androidterm&hl=en खेलने)

(3) एक टर्मिनल विंडो खोलें और सुपर उपयोगकर्ता बन:

# su 

(4) फ़ाइल प्रणाली केवल पढ़ने के लिए किया जा सकता है, ताकि आप इसे पुन: माउंट करना पड़ सकता है:

# mount -o rw,remount -t yaffs2/

या

# mount -o rw,remount -t rootfs/

या

# mount -o rw,remount -t rootfs rootfs /system 

http://www.pocketmagic.net/write-on-the-android-read-only-file-system/ भी देखते हैं, Android 2.3 : Read-Only file system stuck भी देख https://ckirbach.wordpress.com/2012/11/27/how-to-remount-system-as-read-write-in-android/

(5) पढ़ने/लिखने default.prop बनाने:

chmod 666 /default.prop 

(6) संपादित करें/डिफ़ॉल्ट ।

ro.secure=0 
ro.debuggable=1 
persist.service.adb.enable=1 

, अंत में https://android.stackexchange.com/questions/28653/obtaining-root-by-modifying-default-propro-secure या http://bclary.com/blog/2014/04/14/splitting-and-packing-android-boot-images/

देखते हैं, सिर्फ पूर्णता के लिए जवाब के रूप में ऊपर का कहना है (https://stackoverflow.com/a/11992683/979369):

(7) को सक्षम करने के USB होस्ट एपीआई प्रोप, निम्न परिवर्तन करें समर्थन आपको औरroid.hardware.usb.host.xml नामक फ़ाइल जोड़नी चाहिए और निम्न पंक्तियां शामिल हैं:

<permissions> 
<feature name="android.hardware.usb.host"/> 
</permissions> 

फ़ोल्डर

/system/etc/permissions 

उस फ़ोल्डर खोजने

handheld_core_hardware.xml or tablet_core_hardware.xml 

और नाम की फ़ाइल में में अनुभाग में

<feature name="android.hardware.usb.host" /> 

जोड़ें।

(8) अपने डिवाइस को रीबूट करें। यूएसबी मेजबान एपीआई काम करना चाहिए।