From c1662279272ef4801b0e522cb4ee484759451a2e Mon Sep 17 00:00:00 2001 From: iflyhere <57563846+iflyhere@users.noreply.github.com> Date: Wed, 2 Sep 2026 19:24:26 +0200 Subject: [PATCH] Log the ids of attached usb devices, and make wirelessInfo() safe "No compatible wifi adapter found." is a common report, and the one thing needed to act on it - the adapter's vendor and product id - could not be obtained. sysfs is not readable by the shell on some devices (Horizon OS for one) and dumpsys usb does not list host devices there either, so the app is the only thing in a position to report it. getAttachedAdapters() now logs every attached device with its ids, manufacturer and product name, and whether usb_device_filter.xml matched: usb devices attached: 1 /dev/bus/usb/001/002 0BDA:8812 Realtek 802.11n NIC -> supported which turns "it does not work" into a line that can be pasted into a filter entry. Relevant to the standing requests for new adapters (#82, #91, #93, #105). Also fixes a landmine in the same code path: wirelessInfo() is static and reads a static WifiManager that only VideoActivity.initializeUI() ever assigns, yet it is called from WfbLinkManager.refreshAdapters(). Any other caller, or this one before onCreate has got that far, gets a NullPointerException. It now takes a Context, fetches the service itself and null checks both the manager and the WifiInfo; the static field is gone, so it cannot come back through a different entry point. --- .../com/openipc/pixelpilot/VideoActivity.java | 25 ++++++++++++++++--- .../openipc/pixelpilot/WfbLinkManager.java | 17 +++++++++++-- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/openipc/pixelpilot/VideoActivity.java b/app/src/main/java/com/openipc/pixelpilot/VideoActivity.java index cacfc1ba..2bbe6615 100644 --- a/app/src/main/java/com/openipc/pixelpilot/VideoActivity.java +++ b/app/src/main/java/com/openipc/pixelpilot/VideoActivity.java @@ -16,6 +16,7 @@ import android.hardware.usb.UsbManager; import android.net.Uri; import android.net.VpnService; +import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.BatteryManager; import android.os.Build; @@ -114,7 +115,6 @@ public class VideoActivity extends AppCompatActivity implements IVideoParamsChan private static final long MODEL_LITE2_BYTES = 23096891L; private static final String PREF_OD_CUSTOM_MODEL_URI = "od_custom_model_uri"; private static final String PREF_OD_CUSTOM_MODEL_NAME = "od_custom_model_name"; - private static WifiManager wifiManager; final Handler handler = new Handler(Looper.getMainLooper()); final Runnable runnable = new Runnable() { public void run() { @@ -170,8 +170,26 @@ public static int getBandwidth(Context context) { Context.MODE_PRIVATE).getInt("bandwidth", 20); } - public static String wirelessInfo() { - int address = wifiManager.getConnectionInfo().getIpAddress(); + /** + * IPv4 address on the device's own wifi, used to tell the user where to push a stream + * when no adapter is attached. Returns null when there is nothing to report. + * + *
Takes a Context rather than reading a static WifiManager that only
+ * {@link #initializeUI()} assigns: any other caller - or this one before onCreate has got
+ * that far - hits a NullPointerException, and this is called from
+ * WfbLinkManager.refreshAdapters().
+ */
+ public static String wirelessInfo(Context context) {
+ WifiManager manager =
+ (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
+ if (manager == null) {
+ return null;
+ }
+ WifiInfo info = manager.getConnectionInfo();
+ if (info == null) {
+ return null;
+ }
+ int address = info.getIpAddress();
return (address == 0) ? null : Formatter.formatIpAddress(address);
}
@@ -324,7 +342,6 @@ private void initializeUI() {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
- wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
}
// ----------------------------------------------------------------------------
diff --git a/app/src/main/java/com/openipc/pixelpilot/WfbLinkManager.java b/app/src/main/java/com/openipc/pixelpilot/WfbLinkManager.java
index 8580be69..7a3b7995 100644
--- a/app/src/main/java/com/openipc/pixelpilot/WfbLinkManager.java
+++ b/app/src/main/java/com/openipc/pixelpilot/WfbLinkManager.java
@@ -102,7 +102,13 @@ public Map