diff options
author | Mike Lockwood <lockwood@android.com> | 2010-06-12 21:31:36 -0400 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2010-06-12 21:35:27 -0400 |
commit | 74f094fe22ca1cde637210e023874ab740a7a8d7 (patch) | |
tree | 650e442f33abb8c8c6776744450ffb31e0a28a58 /media/java | |
parent | 0c330e26e853e478bf1c3d63eae98a42a1c12bad (diff) | |
download | frameworks_base-74f094fe22ca1cde637210e023874ab740a7a8d7.zip frameworks_base-74f094fe22ca1cde637210e023874ab740a7a8d7.tar.gz frameworks_base-74f094fe22ca1cde637210e023874ab740a7a8d7.tar.bz2 |
MTP: Add interface to MtpClient for receiving device added/removed events.
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'media/java')
-rw-r--r-- | media/java/android/media/MtpClient.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/media/java/android/media/MtpClient.java b/media/java/android/media/MtpClient.java index a6d3ec9..95182bd 100644 --- a/media/java/android/media/MtpClient.java +++ b/media/java/android/media/MtpClient.java @@ -25,12 +25,18 @@ public class MtpClient { private static final String TAG = "MtpClient"; + private final Listener mListener; + static { System.loadLibrary("media_jni"); } - public MtpClient() { + public MtpClient(Listener listener) { native_setup(); + if (listener == null) { + throw new NullPointerException("MtpClient: listener is null"); + } + mListener = listener; } @Override @@ -73,12 +79,24 @@ public class MtpClient { } } + public interface Listener { + // called when a new MTP device has been discovered + void deviceAdded(int id); + + // called when an MTP device has been removed + void deviceRemoved(int id); + } + + // called from native code private void deviceAdded(int id) { Log.d(TAG, "deviceAdded " + id); + mListener.deviceAdded(id); } + // called from native code private void deviceRemoved(int id) { Log.d(TAG, "deviceRemoved " + id); + mListener.deviceRemoved(id); } private MtpEventThread mEventThread; |