Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development > Developer 101

Developer 101 101 Tutorials



Reply
 
LinkBack Thread Tools
Old November 10th, 2011, 04:36 AM   #1 (permalink)
New Member
 
Join Date: Nov 2011
Posts: 6
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to kick event on MTP Responder

Hi,

Please tell me how to kick event from MTP Responder to MTP Initiator using "RequestObjectTransfer" command? (MTP connection mode)

I would like to push data from MTP Responder(smartphone) to Initiator(WinPC) when I select any music/photo files.

In short, I want to take an event notification on PC(Initiator) when I use smartphone(Responder).
In my study, it may use "RequestObjectTransfer" command (PTP/MTP).

Could you please tell me about kick event from my App??

envirnment:
Smartphone : Android3.1 or over
PC : Windows XP/Vista/7

Thanks,
ptrao.

ptaro is offline  
Reply With Quote
Sponsors
Old November 10th, 2011, 05:03 AM   #2 (permalink)
Premium Member
 
Join Date: Oct 2011
Location: Sydney, Australia
Posts: 193
 
Device(s): Galaxy Nexus GSM
Thanks: 2
Thanked 37 Times in 33 Posts
Default

RequestObjectTransfer is an operation, not an event. And I quote section 4.1 of the MTP Spec 1.0:
Quote:
The Responder may not initiate any actions, and may only send responses to operations sent by the Initiator or send events.
You could try sending an ObjectAdded event, but again I quote the MTP Spec 1.0 , this time section 4.8:
Quote:
Although events may be sent by either the Initiator or the Responder, they are primarily sent by the Responder as a way of proactively transmitting information or alerts. Unlike operations, events are not acknowledged, and need not be acted upon.
So I don't know if what you want to do will be possible with MTP.


If you want to read the MTP specification for yourself, version 1.0 is available from here.
jiminaus is offline  
Last edited by jiminaus; November 10th, 2011 at 05:16 AM. Reason: Added link to spec
Reply With Quote
Old November 10th, 2011, 05:55 AM   #3 (permalink)
New Member
 
Join Date: Nov 2011
Posts: 6
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi jiminaus,

Let me check again. I alerady read "Media Transfer Protocol Rev1.1".

In this doc, "RequestObjectTransfer" command treats as "EVENT".
Please refer to this doc. (277p)
It also defined as "EVENT" on PTP spec(PIMA15740).

In this spec,
Quote:
This event can be used by a responder to ask the initiator to initiate a GetObject Operation on the handle specified in the first parameter. This allows for push-mode to be enabled on devices that intrinsically use pull mode.
I still not able to understand how to use "RequestObjectTransfer" command.

How is this command used by Responder??
Can this event be called from an app??

Thanks,
ptaro.
ptaro is offline  
Reply With Quote
Old November 11th, 2011, 12:00 AM   #4 (permalink)
Premium Member
 
Join Date: Oct 2011
Location: Sydney, Australia
Posts: 193
 
Device(s): Galaxy Nexus GSM
Thanks: 2
Thanked 37 Times in 33 Posts
Default

You're right, I screwed that up, sorry.

You'd send an object ID up to the Initiator with the event. The Initiator would then send down a GetObject operation with that same object ID.

Object IDs are intrinsically meaningless. They're just numbers that are assigned to things by the device and only have meaning within a session. So basically you'd need to come up a numbering system.

What transport are you using? Are you using an existing MTP codebase on the Android side? What MTP service are you using on the Window side? Do you know if the MTP service on the Windows side will actually act upon a RequestObjectTransfer event?
jiminaus is offline  
Reply With Quote
Old November 11th, 2011, 02:06 AM   #5 (permalink)
New Member
 
Join Date: Nov 2011
Posts: 6
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Quote:
Originally Posted by jiminaus View Post
What transport are you using? Are you using an existing MTP codebase on the Android side? What MTP service are you using on the Window side? Do you know if the MTP service on the Windows side will actually act upon a RequestObjectTransfer event?
I intend to use an existing MTP codebase on the Android side(pre-installed MTP API). but, I do not know whether my app can call an existing MTP API on the Android side.

ummm...

Can I call an existing MTP API from my app?

I also refer to android.mpt package(API level12)
http://developer.android.com/reference/android/mtp/package-summary.html

OR, possibly, isn't MTP API prepared?

Thanks,
ptaro.
ptaro is offline  
Last edited by ptaro; November 11th, 2011 at 02:31 AM.
Reply With Quote
Old November 11th, 2011, 05:51 AM   #6 (permalink)
Premium Member
 
Join Date: Oct 2011
Location: Sydney, Australia
Posts: 193
 
Device(s): Galaxy Nexus GSM
Thanks: 2
Thanked 37 Times in 33 Posts
Default

As you know there's an android.mtp package, but that's only useful for when the Android device is acting as an initiator. The Android sources include libmtp, but again that's an initiator MTP library.

I know that with introduction of Andriod 3.0, Android devices stopped presenting themselves as USB mass storage devices and instead started presenting themselves as MTP devices. So Android 3.0 is going to have kernel support for MTP being an MTP responder. I don't know (and would doubt) if the Android 2.x kernel has such support.

I don't know if you can use the likes of libusb to do this in userland. I've never used libusb.
jiminaus is offline  
Reply With Quote
Old November 14th, 2011, 11:01 PM   #7 (permalink)
New Member
 
Join Date: Nov 2011
Posts: 6
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Thank you for your info.

Quote:
Originally Posted by jiminaus View Post
As you know there's an android.mtp package, but that's only useful for when the Android device is acting as an initiator. The Android sources include libmtp, but again that's an initiator MTP library.

I know that with introduction of Andriod 3.0, Android devices stopped presenting themselves as USB mass storage devices and instead started presenting themselves as MTP devices. So Android 3.0 is going to have kernel support for MTP being an MTP responder. I don't know (and would doubt) if the Android 2.x kernel has such support.

I don't know if you can use the likes of libusb to do this in userland. I've never used libusb.
I tried to check about MTP Responder event by using "ICONIA Tab(Acer A500)" and USB packet capture/analyzer.
As I installed of "ES file explorer" on my tab, tried to connect to PC, and deleted my music/photo file.
And then, MTP Responder(ICONIA Tab) issues the "ObjectRemoved(0x4003)" command to PC using interrupt endpoint.
Furthermore, "ObjectAdded(0x4002)" command issues to PC when I tried to capture photo by build-in camera app.

It may be issued event.
Are these command issued from app level? middle level? OS/kernel level?
It seems to me that it is not application level, basically because, MTP Responder API does not expose by Google.

Anyone can explain of these phenomena?

Thanks,
ptaro.
ptaro is offline  
Last edited by ptaro; November 15th, 2011 at 03:01 AM.
Reply With Quote
Reply

Bookmarks


Go Back   Android Forums > Android Development > Application Development > Developer 101 User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 08:13 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo