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

Commit 99335b98 authored by Danesh M's avatar Danesh M Committed by Raj Yengisetty
Browse files

UsbDebuggingManager : Handle race condition when toggling rapidly

When toggling adb enable/disable rapidly, you can have the situation where the thread's
run() gets invoked but mAdbEnabled is already set to false, hence listenToSocket() never even
gets invoked in which case mOutputStream/mSocket are both null. This patchset adds checks
around that.

Change-Id: Iba56e7409435e22d690432fa663bc0a04a1a447d
parent 541a09ec
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -119,13 +119,13 @@ public class UsbDebuggingManager implements Runnable {
    private void closeSocket() {
        try {
            mOutputStream.close();
        } catch (IOException e) {
        } catch (Exception e) {
            Slog.e(TAG, "Failed closing output stream: " + e);
        }

        try {
            mSocket.close();
        } catch (IOException ex) {
        } catch (Exception ex) {
            Slog.e(TAG, "Failed closing socket: " + ex);
        }
    }