diff options
-rw-r--r-- | media/java/android/mtp/MtpServer.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/media/java/android/mtp/MtpServer.java b/media/java/android/mtp/MtpServer.java index fe734e1..006fa6d 100644 --- a/media/java/android/mtp/MtpServer.java +++ b/media/java/android/mtp/MtpServer.java @@ -24,6 +24,9 @@ import android.util.Log; */ public class MtpServer { + private final Object mLock = new Object(); + private boolean mStarted; + private static final String TAG = "MtpServer"; static { @@ -35,11 +38,19 @@ public class MtpServer { } public void start() { - native_start(); + synchronized (mLock) { + native_start(); + mStarted = true; + } } public void stop() { - native_stop(); + synchronized (mLock) { + if (mStarted) { + native_stop(); + mStarted = false; + } + } } public void sendObjectAdded(int handle) { |