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

Commit 2025947d authored by Shaju Mathew's avatar Shaju Mathew Committed by Gerrit Code Review
Browse files

Merge "Fix the concurrency issue in AdbDebuggingManager that leads to Watchdog" into main

parents bc91eb24 a21ab8dd
Loading
Loading
Loading
Loading
+22 −10
Original line number Diff line number Diff line
@@ -246,16 +246,6 @@ public class AdbDebuggingManager {

        @Override
        public void run() {
            if (mGuid.isEmpty()) {
                Slog.e(TAG, "adbwifi guid was not set");
                return;
            }
            mPort = native_pairing_start(mGuid, mPairingCode);
            if (mPort <= 0 || mPort > 65535) {
                Slog.e(TAG, "Unable to start pairing server");
                return;
            }

            // Register the mdns service
            NsdServiceInfo serviceInfo = new NsdServiceInfo();
            serviceInfo.setServiceName(mServiceName);
@@ -288,6 +278,28 @@ public class AdbDebuggingManager {
            mHandler.sendMessage(message);
        }

        @Override
        public void start() {
            /*
             * If a user is fast enough to click cancel, native_pairing_cancel can be invoked
             * while native_pairing_start is running which run the destruction of the object
             * while it is being constructed. Here we start the pairing server on foreground
             * Thread so native_pairing_cancel can never be called concurrently. Then we let
             * the pairing server run on a background Thread.
             */
            if (mGuid.isEmpty()) {
                Slog.e(TAG, "adbwifi guid was not set");
                return;
            }
            mPort = native_pairing_start(mGuid, mPairingCode);
            if (mPort <= 0) {
                Slog.e(TAG, "Unable to start pairing server");
                return;
            }

            super.start();
        }

        public void cancelPairing() {
            native_pairing_cancel();
        }