2013年8月9日星期五

Android Usb Host Problem seeking education (tuition 100)

 This post last edited by the SEH_CRACKER on 2013-07-04 11:31:55
achieve an Android phone Android Host operating procedures

code is the Android Sdk examples AdbTest

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


execution result, the 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 is a problem 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); / / executed after the device does not pop-up window
UsbDeviceConnection connection = mManager.openDevice (device); / / fails, an 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)


get a day yesterday, 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 my equally

http://stackoverflow.com/questions/10994848/android-usb-enumeration and I like
------ Solution ------------ --------------------------------
lz is due to method calls requestPermission not immediately get permission, but Time went openDevice, so reported permission error, the second site in the problems and solutions has been said quite clearly a
------ Solution ------------- -------------------------------


I think this should not be the case, if this is the case then the SDK examples of direct openDevice, Android whether there complete function, seeking example code
------ Solution --- -----------------------------------------

    
I think this should not be the case, if this is the case then the SDK examples of direct openDevice, Android whether there complete function, find examples of code    
  
  
  
Yes indeed sdk examples of direct openDevice.  

Which examples ah?
This permission should be able to get the right common app
------ Solution -------------------------- ------------------
SecurityException see this thing that this is a question of third-party software

The apk push to system / app under the bar or under the thread linked to systemproc


------ Solution ------------------------------------ --------

  
how to hang the shelf next to the systemproc, find an example method for solving  


amount of concrete realization ah I did just before encountering a similar demand, then we are doing Baidu's mobile phone directly push to system / app down

can refer to some of the system design is similar to android: shareid = media like

------ Solution ------------------------------------ --------
seemingly is a permissions issue, but you may have the authority android no linux permissions, you put system / app should be possible under
----- - Solution --------------------------------------------
count , 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
contents of the file:



recompile
------ For reference only -------------------------------- -------
their top, nobody look. . . . . .
------ For reference only -------------------------------------- -
User has not given permission to device UsbDevice
obviously do not have permission ah pro ~ ~ ~ ~
------ For reference only ------------------------ ---------------
So, English proficiency is very important, ah, use GOOGLE
------ For reference only -------- -------------------------------
User has not given permission to device UsbDevice
obviously do not have permission ah pro ~ ~ ~ ~

permissions are added, and that is still the case after the addition of permissions so only posts that
------ For reference only ---------------- -----------------------
So, English proficiency is very important, ah, use GOOGLE

Google is very much on the kind of problem, few address
------ For reference only --------------------- ------------------
lz is due to method calls requestPermission not immediately get permission, but then went openDevice, it reported a permission error, and the second URL problems and solutions has been said quite clearly the

say, I have no objection, but I certainly have the authority to call requestPermission window pops up, I've never. . .
------ For reference only -------------------------------------- -

---- - For reference only ---------------------------------------


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

UsbDevice device allowing the user does not give

AndroidManifest.xml permissions with no half dime wow
------ For reference only -------------------- -------------------

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


Yes indeed sdk examples of direct openDevice.
------ For reference only -------------------------------------- -

      
I think this should not be the case, if this is the case then the SDK examples of direct openDevice, Android whether there complete function, find examples of code      
    
    
    
Yes indeed sdk examples of direct openDevice.    
  
  
Which examples ah?   
This permission should be able to get the right common app  


      
      
I think this should not be the case, if this is the case then the SDK examples of direct openDevice, Android whether there complete function, find examples of code      
    
    
    
Yes indeed sdk examples of direct openDevice.    
  
  
Which examples ah?   
This permission should be able to get the right common app  


examples:
Project: AdbTest
Path: SDKRoot $ \ samples \ android-17 \ USB \ AdbTest
------ For reference only -------------------- -------------------
see, looked under the configuration file, which are not set permissions
Only this
<uses-feature android:name="android.hardware.usb.host" />

------ For reference only ----------------------------------- ----


yes ah this privilege is added, or error, in this case, when I'm debugging is the same.
------ For reference only -------------------------------------- -
http://download.csdn.net/detail/zhuyouleixuexi/4740798
today to see such a thing, I do not know there is no use for you.

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


------ For reference only ---------------------------------- -----


I've always done, or else getDeviceList is a failure. But thank
------ For reference only ----------------------------------- ----
csdn is no god do?
------ For reference only -------------------------------------- -
http://stackoverflow.com/questions/10994848/android-usb-enumeration guys here do not know whether there is an explanation of what you want

mManager.requestPermission (device, mPermissionIntent); sentence did not reach the results you want, is asynchronous, so the following does not have permission. Try to be delayed until the access permissions say

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


with this little, because I debugged directly example of it is the system. . .
------ For reference only -------------------------------------- -


how to hang the shelf next to the systemproc, seeking method for solving examples
------ For reference only ------------------ ---------------------

  
how to hang the shelf next to the systemproc, find an example method for solving  

try this it does not work I was no way we are directly compiled the rom image of
android: sharedUserId = "android.uid.system"

------ For reference only ---------------------------------- -----
lack of permissions! You should be the system / etc / permission / folder permissions less an xml file
------ For reference only ------------------- --------------------

can be specific? Which file is missing
------ For reference only ----------------------------------- ----

Oh, I did not try and put this directory how source code debugging?
------ For reference only -------------------------------------- -
I do not know the file, you can not use, because this is my own to add, in order to be able to get the usb device information!
you want, leaving the mailbox, I'll be back to you!
------ For reference only -------------------------------------- -


This I also added, 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");
                }

process go this way, without permission, access permissions, openDevce then fails, then an error.
------ For reference only -------------------------------------- -
have to get Results posted scattered points thanks for helping Although it did not work haha.

------ For reference only ----- ----------------------------------
landlord, ask how to engage? I am also here to connection problems. . .
------ For reference only -------------------------------------- -
also recently engaged in this, but the reader is not successful, the landlord do a good job you can give me a Demo, 312081300@qq.com Thank

没有评论:

发表评论