android: Allow wireless debugging over Ethernet

Signed-off-by: hmz007 <hmz007@gmail.com>
master
hmz007 7 months ago
parent e7f219df81
commit fa03c0384b

@ -71,3 +71,5 @@ ro.boot.log_battery u:object_r:vendor_system_public_prop:s0
ro.updater.next_device u:object_r:vendor_system_public_prop:s0
ro.product.version u:object_r:vendor_system_public_prop:s0
ro.product.releasetype u:object_r:vendor_system_public_prop:s0
persist.adb.ethernet.enable u:object_r:system_adbd_prop:s0

@ -1371,6 +1371,10 @@ public class AdbDebuggingManager {
WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
if (wifiInfo == null || wifiInfo.getNetworkId() == -1) {
if (SystemProperties.getBoolean("persist.adb.ethernet.enable", false)) {
return new AdbConnectionInfo("unspecified", "Ethernet");
}
Slog.i(TAG, "Not connected to any wireless network. Not enabling adbwifi.");
return null;
}

@ -480,6 +480,10 @@ ScopedAStatus UsbGadget::setCurrentUsbFunctions(int64_t functions,
goto error;
}
// Notify adbd usb_ffs_open_thread()
static const char* kPropertyUsbDisabled = "sys.usb.adb.disabled";
SetProperty(kPropertyUsbDisabled, (functions & GadgetFunction::ADB) ? "0" : "1");
#if 0
/**
* Check if we really need to bind irq to big core or medium core.

@ -25,6 +25,7 @@ import android.net.NetworkCapabilities;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemProperties;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.provider.Settings;
@ -145,6 +146,8 @@ public class WirelessDebuggingPreferenceController extends DeveloperOptionsPrefe
if (cm == null) {
return false;
}
final boolean allowEthernet = SystemProperties.getBoolean(
"persist.adb.ethernet.enable", false);
for (Network network : cm.getAllNetworks()) {
final NetworkCapabilities nc = cm.getNetworkCapabilities(network);
if (nc == null) {
@ -153,6 +156,10 @@ public class WirelessDebuggingPreferenceController extends DeveloperOptionsPrefe
if (nc.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
return true;
}
if (allowEthernet && nc.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET)) {
Log.d(TAG, "Enabling ADB over Ethernet");
return true;
}
}
return false;
}

Loading…
Cancel
Save