Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a3f85144 authored by Mike Lockwood's avatar Mike Lockwood
Browse files

MtpServer: Do not attempt to stop MTP if it has not been started



Fixes an ANR that occurred if we got a USB disconnected event
before the MTP service had started.

Bug: 4118033

Change-Id: I6cad4281a5911a9926cae923f34d3a6bf98346c5
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent f8d1533b
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -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() {
        synchronized (mLock) {
            native_start();
            mStarted = true;
        }
    }

    public void stop() {
        synchronized (mLock) {
            if (mStarted) {
                native_stop();
                mStarted = false;
            }
        }
    }

    public void sendObjectAdded(int handle) {