Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
Posts: 39
Registered: ‎06-18-2009
My Device: BlackBerry Bold
My Carrier: Airtel

Disable USB, Possible?

Hi all,
  Is it possible to disable the USB port through API so that whenever I connect my device to the Computer it would not detect the device even with the Desktop Manager also.


New Developer
Posts: 2
Registered: ‎04-13-2009
My Device: Not Specified

Re: Disable USB, Possible?

Any suggestions?

Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: Disable USB, Possible?

As far as I know there is no API to do that.
New Developer
Posts: 39
Registered: ‎06-18-2009
My Device: BlackBerry Bold
My Carrier: Airtel

Re: Disable USB, Possible?


tbilisoft wrote:
As far as I know there is no API to do that.

Hi,

   Thank you for your response. But please have a look at the following thread mentioned, in which the guy is claiming that he has done it using USBPortListene. I don't know how he has done it.

 

http://supportforums.blackberry.com/rim/board/message?board.id=8300&message.id=59646

 

Regards

Hitangshu

Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: Disable USB, Possible?

I think he listens for requested usb-connection via Listener.

 

Gets the channel, opens it via net.rim.device.api.system.USBPort class and immediately closes it via close() method of the same class.

Developer
Posts: 155
Registered: ‎02-18-2009
My Device: Not Specified

Re: Disable USB, Possible?

[ Edited ]

As there is no official API to disable USB connections you should experiment whether you can use some sort of unoffical way to terminate the USB connection. One thing you can try is to register a USBPortListener with the Application instance. Make sure that USBPortListener#getChannel returns -1 (get events for all channels). The big question now is whether you can force the USB connection to not connect. You can try to throw some RuntimeException in USBPortListener#connectionRequested and hope that it cancels the USB connection.

 

Note: everything I have written above is just an idea and I have not tested any code

 

Post note: tbilisoft's suggestion is much better :smileyhappy:

Message Edited by martijnbrinkers on 10-13-2009 07:14 AM
Message Edited by martijnbrinkers on 10-13-2009 07:14 AM
New Developer
Posts: 122
Registered: ‎09-04-2008
My Device: Storm II Model 9550
My Carrier: Developer

Re: Disable USB, Possible?

Hello All,

 

I am also doing the same  thing.

 

If we implement USBPortlistner, then we need to override all the methods, then what should i write in getChannel() method?

 

Tiblisoft, Can you please explain in more detail what you suggested.

 

:

 

I tried what you suggest, but device is getting connected through USB.

 

-Shekhar.

Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: Disable USB, Possible?

I did not check it by myself.

 

Try to use channel #0 in your listener implementation.

 

 

New Developer
Posts: 39
Registered: ‎06-18-2009
My Device: BlackBerry Bold
My Carrier: Airtel

Re: Disable USB, Possible?

Hi

  I have tried to in the both way, that is return -1 and 0 from the getChannel() method, but no luck yet. I am still trying to find some way. If anyone can find anything regarding this please post it here.

 

Regards

Hitangshu

New Contributor
Posts: 7
Registered: ‎06-02-2010
My Device: --
My Carrier: BB dev

Re: Disable USB, Possible?

close() method of USBPort works only on simulator but on device it wont.

any suggestions for it?