Wednesday, February 5, 2014

Android Usb Host question seeking education (tuition 100 points)


posts by SEH_CRACKER edited 2013-07-04 11:31:55
Achieve an Android phone Android Host operating procedures

Code is Android Sdk examples in AdbTest

 mApplicationContext = this.getApplicationContext (); 
if (mApplicationContext.getPackageManager (). hasSystemFeature ("android.hardware.usb.host")) {
Log.d ("Shit", ">>>> FOUND!");
}


The results output Shit >>>> FOUND, support usb host
 for (UsbDevice device: mManager.getDeviceList () values ​​().) {
UsbInterface intf = findAdbInterface (device);
if (setAdbInterface (device, intf)) {
break;
}
}


Get to the usb device, but there are problems in setAdbInterface function,
 if (mManager.hasPermission (device) == true) {
log ("has access");
} Else {
mManager.requestPermission (device, mPermissionIntent);
}
if (device! = null && intf! = null) {
UsbDeviceConnection connection = mManager.openDevice (device);
if (connection! = null) {
log ("open succeeded");


mManager.requestPermission (device, mPermissionIntent); / / execution, the device does not pop
UsbDeviceConnection connection = mManager.openDevice (device); / / execution failed, error
Specific error message:
01-01 02:38:46.468: E / UsbManager (4043): exception in UsbManager.openDevice
01-01 02:38:46.468: E / UsbManager (4043): java.lang.SecurityException: User has not given permission to device UsbDevice [mName = / dev/bus/usb/001/003, mVendorId = 1060, mProductId = 60416, mClass = 255, mSubclass = 0, mProtocol = 1, mInterfaces = [Landroid.hardware.usb.UsbInterface; @ 4146c080]
01-01 02:38:46.468: E / UsbManager (4043): at android.os.Parcel.readException (Parcel.java: 1425)
01-01 02:38:46.468: E / UsbManager (4043): at android.os.Parcel.readException (Parcel.java: 1379)
01-01 02:38:46.468: E / UsbManager (4043): at android.hardware.usb.IUsbManager $ Stub $ Proxy.openDevice (IUsbManager.java: 340)
01-01 02:38:46.468: E / UsbManager (4043): at android.hardware.usb.UsbManager.openDevice (UsbManager.java: 265)
01-01 02:38:46.468: E / UsbManager (4043): at com.example.scanvirus.MainActivity.setAdbInterface (MainActivity.java: 159)
01-01 02:38:46.468: E / UsbManager (4043): at com.example.scanvirus.MainActivity.onCreate (MainActivity.java: 89)
01-01 02:38:46.468: E / UsbManager (4043): at android.app.Activity.performCreate (Activity.java: 5008)
01-01 02:38:46.468: E / UsbManager (4043): at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java: 1079)
01-01 02:38:46.468: E / UsbManager (4043): at android.app.ActivityThread.performLaunchActivity (ActivityThread.java: 2023)
01-01 02:38:46.468: E / UsbManager (4043): at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java: 2084)
01-01 02:38:46.468: E / UsbManager (4043): at android.app.ActivityThread.access $ 600 (ActivityThread.java: 130)
01-01 02:38:46.468: E / UsbManager (4043): at android.app.ActivityThread $ H.handleMessage (ActivityThread.java: 1195)
01-01 02:38:46.468: E / UsbManager (4043): at android.os.Handler.dispatchMessage (Handler.java: 99)
01-01 02:38:46.468: E / UsbManager (4043): at android.os.Looper.loop (Looper.java: 137)
01-01 02:38:46.468: E / UsbManager (4043): at android.app.ActivityThread.main (ActivityThread.java: 4745)
01-01 02:38:46.468: E / UsbManager (4043): at java.lang.reflect.Method.invokeNative (Native Method)
01-01 02:38:46.468: E / UsbManager (4043): at java.lang.reflect.Method.invoke (Method.java: 511)
01-01 02:38:46.468: E / UsbManager (4043): at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java: 786)
01-01 02:38:46.468: E / UsbManager (4043): at com.android.internal.os.ZygoteInit.main (ZygoteInit.java: 553)
01-01 02:38:46.468: E / UsbManager (4043): at dalvik.system.NativeStart.main (Native Method)


Yesterday, get a day, found that many such errors:
http://www.w3c.com.cn/% E5% 9C% A8% E6% 89% 93% E5% BC% 80usb% E6% 97% B6% E5% 80% 99% E5% 87% BA% E7 % 8E% B0% E6% 9D% 83% E9% 99% 90% E9% 97% AE% E9% A2% 98% EF% BC% 81% E4% B8% 8D% E7% 9F% A5% E5% 88 % B0% E6% 80% 8E% E4% B9% 88% E8% A7% A3% E5% 86% B3% EF% BC% 81% E6% B1% 82 and I like

http://stackoverflow.com/questions/10994848/android-usb-enumeration and I like
Reply:
Their top, nobody look. . . . . .
Reply:
User has not given permission to device UsbDevice
Obviously do not have permission ah pro ~ ~ ~ ~
Reply:
So, English proficiency is very important, ah, use GOOGLE
Reply:
lz is due to call requestPermission method does not immediately get permission, but then went openDevice, it reported a permissions error, the second URL problems and solutions has been said quite clearly the
Reply:
User has not given permission to device UsbDevice
Obviously do not have permission ah pro ~ ~ ~ ~

Permissions are together, that is still the case after adding the permissions so only made posts
Reply:
So, English proficiency is very important, ah, use GOOGLE

Google is very much on such issues, few addressed
Reply:
lz is due to call requestPermission method does not immediately get permission, but then went openDevice, it reported a permissions error, the second URL problems and solutions has been said quite clearly the

Say, I have no objection, but I will definitely call requestPermission authorized window pops up, I have not here. . .
Reply:

Reply:
reference to the second floor bcf102 reply:
User has not given permission to device UsbDevice
Obviously do not have permission ah pro ~ ~ ~ ~


User has not given permission to device UsbDevice
Obviously do not have permission ah pro ~ ~ ~ ~

The user does not give UsbDevice device allows

AndroidManifest.xml permissions with no half dime wow
Reply:
references, 4th Floor a1150247879 reply:
lz get permission because there was no immediate post-call requestPermission method, but then went openDevice, it reported a permissions error The second URL problems and solutions has been said quite clearly a


I think this should not be the case, if that is the case then the SDK examples of direct openDevice, Android completion function if there is, find examples of code
Reply:
reference to the 10th floor u011303789 reply:
Quote: references to the 4th floor a1150247879 reply:

lz is due to call requestPermission method does not immediately get permission, but then went openDevice, it reported a permissions error, the second URL problems and solutions has been said quite clearly a


I think this should not be the case, if that is the case then the SDK examples of direct openDevice, Android completion function if there is, find sample code


Yes indeed sdk examples in the direct openDevice.
Reply:
reference to the 11th floor SEH_CRACKER reply:
Quote: references to the 10th floor u011303789 reply:

Quote: references to the 4th floor a1150247879 reply:

lz is due to call requestPermission method does not immediately get permission, but then went openDevice, it reported a permissions error, the second URL problems and solutions has been said quite clearly a


I think this should not be the case, if that is the case then the SDK examples of direct openDevice, Android completion function if there is, find sample code


Yes indeed sdk examples in the direct openDevice.

Which examples ah?
This authority should be able to get the right common app
Reply:
reference to the 12th floor guoyoulei520 reply:
Quote: references to the 11th floor SEH_CRACKER reply:

Quote: references to the 10th floor u011303789 reply:

Quote: references to the 4th floor a1150247879 reply:

lz is due to call requestPermission method does not immediately get permission, but then went openDevice, it reported a permissions error, the second URL problems and solutions has been said quite clearly a


I think this should not be the case, if that is the case then the SDK examples of direct openDevice, Android completion function if there is, find sample code


Yes indeed sdk examples in the direct openDevice.

Which examples ah?
This authority should be able to get the right common app


reference to the 12th floor guoyoulei520 reply:
Quote: references to the 11th floor SEH_CRACKER reply:

Quote: references to the 10th floor u011303789 reply:

Quote: references to the 4th floor a1150247879 reply:

lz is due to call requestPermission method does not immediately get permission, but then went openDevice, it reported a permissions error, the second URL problems and solutions has been said quite clearly a


I think this should not be the case, if that is the case then the SDK examples of direct openDevice, Android completion function if there is, find sample code


Yes indeed sdk examples in the direct openDevice.

Which examples ah?
This authority should be able to get the right common app


Examples:
Engineering: AdbTest
Path: SDKRoot $ \ samples \ android-17 \ USB \ AdbTest
Reply:
See, looked under the configuration files, which are not set permissions
Only this
  

Reply:
reference to the 14th floor guoyoulei520 reply:
saw, looked under the configuration files, which are not set permissions
Only this
  


Yes, ah this authority also added, or error, in this example, when I debug is the same.
Reply:
http://download.csdn.net/detail/zhuyouleixuexi/4740798
Today saw such a thing, I do not know you have no use.

Enable xml file android usb host function.
This file needs to be added to the next device / system / etc / permissions / directory, to open android device usb host privileges.


Reply:
reference to the 16th floor bcf102 reply:
http://download.csdn.net/detail/zhuyouleixuexi/4740798
Today saw such a thing, I do not know you have no use.

Enable xml file android usb host function.
This file needs to be added to the next device / system / etc / permissions / directory, to open android device usb host privileges.


I would have done this, or else getDeviceList is a failure. But thank
Reply:
No big csdn on God?
Reply:
Here is an explanation http://stackoverflow.com/questions/10994848/android-usb-enumeration buddies do not know if you want

mManager.requestPermission (device, mPermissionIntent); sentence does not meet your desired effect, asynchronous, so there is no authority below. Try to be delayed until obtaining permission to say

Reference Posts
http://www.eoeandroid.com/thread-228679-1-1.html
Reply:
SecurityException see this thing that this is a problem of third-party software

The apk push to the system / app or thread to hang it to the next systemproc


Reply:
cited 19th floor shen332401890 reply:
http://stackoverflow.com/questions/10994848/android-usb-enumeration guys here do not know whether there is an explanation what you want is

mManager.requestPermission (device, mPermissionIntent); sentence does not meet your desired effect, asynchronous, so there is no authority below. Try to be delayed until obtaining permission to say

Reference Posts
http://www.eoeandroid.com/thread-228679-1-1.html


This has little to do with, because I debugged the system of direct examples so. . .
Reply:
cited 20 floor tanwei4199 reply:
SecurityException see this thing that this is a problem of third-party software

The apk push to the system / app or thread to hang it to the next systemproc


How to hang the shelf next to systemproc seeking seeking examples of methods
Reply:
cited 22 floor SEH_CRACKER reply:
Quote: 20th Floor tanwei4199 cited reply:

SecurityException see this thing that this is a problem of third-party software

The apk push to the system / app or thread to hang it to the next systemproc


How to hang the shelf next systemproc, seeking methods seek examples


I did not realize the amount of concrete ah just before encountered a similar demand, then we are doing Baidu's mobile phone directly push to system / app under


Shareid = media like: Some design is similar to the reference system android
Reply:
cited 22 floor SEH_CRACKER reply:
Quote: 20th Floor tanwei4199 cited reply:

SecurityException see this thing that this is a problem of third-party software

The apk push to the system / app or thread to hang it to the next systemproc


How to hang the shelf next systemproc, seeking methods seek examples

Try this it will not do me no way that we are directly compiled rom the image of
android: sharedUserId = "android.uid.system"

Reply:
Appears to be a permissions problem, but you might have android permission, no linux permissions, you put under system / app should be able to
Reply:
Lack of permission! You should be the system / etc / permission / folder permissions less of a xml file
Reply:
cited 26 floor f839903061 reply:
lack of permission! You should be the system / etc / permission / folder permissions less of a xml file

Can specific? Which file is missing
Reply:
reference to the 25th floor lieri111 reply:
appears to be a permissions problem, but you might have permission android, without permission linux you into system / app The following should be able

Oh, I did not try and put this directory how to debug the source code?
Reply:
I do not know this file, you can not use, because this is my own to add, for the usb device is able to obtain the information!
You want, leaving the mailbox, to the time I sent you!
Reply:
Well, you do not give me a mail, I wrote to you directly
Into folders ystem / etc / permissions under
File name: android.hardware.usb.host.xml
File contents:



Recompile
Reply:
reference to the 30th floor f839903061 reply:
Well, you do not give me a mail, I wrote to you directly
Into folders ystem / etc / permissions under
File name: android.hardware.usb.host.xml
File contents:



Recompile


I also added this, I can get to the device, the detection permissions, access permissions, openDevice being given here.
 if (mManager.hasPermission (device) == true) {
log ("has access");
} Else {
mManager.requestPermission (device, mPermissionIntent);
}
if (device! = null && intf! = null) {
UsbDeviceConnection connection = mManager.openDevice (device);
if (connection! = null) {
log ("open succeeded");
}

Such processes go without permission, access permissions, openDevce then fails, then an error.
Reply:
Results posted already get scattered points, thank you for helping Although it did not work haha.

Reply:
The landlord, ask how you do that? I am also here to connection problems. . .
Reply:
Also recently engaged in this, but reading and writing is unsuccessful, the landlord can give me a good Demo yet, 312081300@qq.com thank you
Reply:
How to solve? Qq can leave it? Thank you

No comments:

Post a Comment