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

Commit 438fb544 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use libadb_auth to start/stop adbd wifi" into main

parents d2f03eaa 51ad097a
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -543,6 +543,8 @@ public class AdbDebuggingManager {
            }
        }

        // TODO: Change the name of this method. This is not always a response. It should be called
        // sendMessage.
        void sendResponse(String msg) {
            synchronized (this) {
                Slog.d(TAG, "Send packet " + msg);
@@ -772,6 +774,8 @@ public class AdbDebuggingManager {

        // === Messages we can send to adbd ===========
        static final String MSG_DISCONNECT_DEVICE = "DD";
        static final String MSG_START_ADB_WIFI = "W1";
        static final String MSG_STOP_ADB_WIFI = "W0";

        @Nullable @VisibleForTesting AdbKeyStore mAdbKeyStore;

@@ -822,6 +826,18 @@ public class AdbDebuggingManager {
            }
        }

        private void startAdbdWifi() {
            if (mThread != null) {
                mThread.sendResponse(MSG_START_ADB_WIFI);
            }
        }

        private void stopAdbdWifi() {
            if (mThread != null) {
                mThread.sendResponse(MSG_STOP_ADB_WIFI);
            }
        }

        private void startAdbDebuggingThread() {
            ++mAdbEnabledRefCount;
            Slog.i(TAG, "startAdbDebuggingThread ref=" + mAdbEnabledRefCount);
@@ -1058,9 +1074,9 @@ public class AdbDebuggingManager {
                    intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
                    mContext.registerReceiver(mBroadcastReceiver, intentFilter);

                    SystemProperties.set(AdbService.WIFI_PERSISTENT_CONFIG_PROPERTY, "1");

                    startAdbDebuggingThread();
                    startAdbdWifi();
                    mAdbWifiEnabled = true;

                    Slog.i(TAG, "adb start wireless adb");
@@ -1074,6 +1090,8 @@ public class AdbDebuggingManager {
                    setAdbConnectionInfo(null);
                    mContext.unregisterReceiver(mBroadcastReceiver);

                    stopAdbdWifi();

                    onAdbdWifiServerDisconnected(-1);
                    stopAdbDebuggingThread();
                    break;
@@ -1102,9 +1120,8 @@ public class AdbDebuggingManager {
                    intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
                    mContext.registerReceiver(mBroadcastReceiver, intentFilter);

                    SystemProperties.set(AdbService.WIFI_PERSISTENT_CONFIG_PROPERTY, "1");

                    startAdbDebuggingThread();
                    startAdbdWifi();
                    mAdbWifiEnabled = true;

                    Slog.i(TAG, "adb start wireless adb");
+6 −1
Original line number Diff line number Diff line
@@ -210,7 +210,12 @@ public class AdbService extends IAdbManager.Stub {
     * May also contain vendor-specific default functions for testing purposes.
     */
    private static final String USB_PERSISTENT_CONFIG_PROPERTY = "persist.sys.usb.config";
    static final String WIFI_PERSISTENT_CONFIG_PROPERTY = "persist.adb.tls_server.enable";

    /**
     * The system property used by both framework and adbd to set if ADB Wifi should be enabled
     * when either system starts up.
     */
    private static final String WIFI_PERSISTENT_CONFIG_PROPERTY = "persist.adb.tls_server.enable";

    private final Context mContext;
    private final ContentResolver mContentResolver;