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

Commit 1220a22c authored by Fabien Sanglard's avatar Fabien Sanglard
Browse files

Fix AdbService/AdbDebuggingManager race conditon

There is an infinite loop caused by AdbService and adbd fighting each
other when setting and listening the value of system property
ADB_WIFI_ENABLED.

The infinite loop only breaks when a race condition allows adbd to
finish before AdbService, resulting in tls port = 0 (which cause the UI
to not display a port).

This bug occurs 100% of the time if "Always allow" is not checked,
since the only way for the loop to exit is when the verifyWifi and sys
property ADB_WIFI_ENABLED "agree" on zero.

If "Always allow" is checked the loop is allowed to run again which
results in a the port number not being displayed sporadically.

Solution: Both the infinite loop and the race condition can be avoided
if adbd message don't set ADB_WIFI_ENABLED (this was already obvserved
in AdbService).

Test: manual
Fixes: 413335715
Flag: EXEMPT bugfix
Change-Id: If7655959db7e4b42bff1188a132203449e13bec7
parent 6e3a5d12
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -1204,8 +1204,6 @@ public class AdbDebuggingManager {
                    synchronized (mAdbConnectionInfo) {
                        mAdbConnectionInfo.setPort(port);
                    }
                    Settings.Global.putInt(mContentResolver,
                            Settings.Global.ADB_WIFI_ENABLED, 1);
                    break;
                }
                case MSG_SERVER_DISCONNECTED: {
@@ -1214,8 +1212,6 @@ public class AdbDebuggingManager {
                    }
                    int port = (int) msg.obj;
                    onAdbdWifiServerDisconnected(port);
                    Settings.Global.putInt(mContentResolver,
                            Settings.Global.ADB_WIFI_ENABLED, 0);
                    stopAdbDebuggingThread();
                    break;
                }