Skip to content

Log the ids of attached usb devices, and make wirelessInfo() safe - #118

Merged
vertexodessa merged 1 commit into
OpenIPC:masterfrom
iflyhere:fix/log-usb-device-ids
Sep 2, 2026
Merged

Log the ids of attached usb devices, and make wirelessInfo() safe#118
vertexodessa merged 1 commit into
OpenIPC:masterfrom
iflyhere:fix/log-usb-device-ids

Conversation

@iflyhere

@iflyhere iflyhere commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

The problem

"No compatible wifi adapter found." is a common report, and the one piece of information
needed to act on it — the adapter's vendor and product id — cannot be obtained by the person
reporting it.

There is no way around the app for this. On some devices sysfs is not readable by the shell
(Horizon OS for one), and dumpsys usb does not list host devices there either:

$ adb shell 'cat /sys/bus/usb/devices/*/idVendor'      # nothing
$ adb shell 'dumpsys usb | grep -i UsbDevice'          # nothing

The app enumerates the devices and matches them against usb_device_filter.xml, and then
throws that away.

The change

getAttachedAdapters() logs every attached device with its ids, manufacturer and product
name, and whether the filter matched:

usb devices attached: 1
  /dev/bus/usb/001/002  0BDA:8812  Realtek 802.11n NIC  -> supported

or, for something not in the list:

  /dev/bus/usb/001/003  2357:012D  TP-Link Archer T3U  -> NOT in usb_device_filter.xml

which turns "it does not work" into a line that can go straight into a filter entry.
Relevant to the standing adapter requests: #82, #91, #93, #105.

Also in here

wirelessInfo() is reached from exactly this code path and is a landmine: it is static and
reads a static WifiManager field that only VideoActivity.initializeUI() ever assigns.
WfbLinkManager.refreshAdapters() calls it from the "no adapter" branch, so any other host
of WfbLinkManager — or this one before onCreate has got that far — gets

NullPointerException: WifiManager.getConnectionInfo() on a null object reference
    at VideoActivity.wirelessInfo(VideoActivity.java:183)
    at WfbLinkManager.refreshAdapters(WfbLinkManager.java:174)

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.

Note

On master this NPE is latent — VideoActivity is the only host of WfbLinkManager and it
does assign the field. It is a real crash as soon as anything else hosts it, which is how I
ran into it.

Compile tested for arm64-v8a + armeabi-v7a; the logging verified on a Quest 3.


Part of a series of independent fixes found while building an immersive (OpenXR) mode on a
Quest 3, each standalone and mergeable in any order:

#113 and #116 are now confirmed on hardware (Quest 3, Horizon OS, Android 14).

"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 (OpenIPC#82, OpenIPC#91, OpenIPC#93, OpenIPC#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.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Log USB device IDs and make Wi-Fi lookup null-safe

🐞 Bug fix ✨ Enhancement 🕐 10-20 Minutes

Grey Divider

AI Description

• Logs attached USB identifiers, metadata, and adapter-filter support status.
• Resolves Wi-Fi information through context with null-safe Android service handling.
Diagram

graph TD
  A["USB Manager"] --> B["Enumerate Devices"] --> C{"Filter Match"}
  C -->|Yes| D["Log Supported"] --> E["Adapter Map"] --> F["Refresh Adapters"]
  C -->|No| G["Log Unsupported"]
  F -->|No adapters| H["Safe Wireless Info"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Dedicated network information provider
  • ➕ Decouples WfbLinkManager from VideoActivity
  • ➕ Allows service behavior to be unit tested or mocked
  • ➕ Supports additional WfbLinkManager hosts cleanly
  • ➖ Adds an abstraction for a single current call site
  • ➖ Broadens the scope of this focused fix
2. User-facing USB diagnostics
  • ➕ Makes identifiers accessible without collecting application logs
  • ➕ Could streamline adapter-support reports from end users
  • ➖ Requires new UI, localization, and support workflows
  • ➖ Exposes hardware details beyond the existing diagnostic channel

Recommendation: The PR's focused logging and context-based lookup are appropriate for a low-risk fix and should be retained. If WfbLinkManager gains additional hosts, move wireless address resolution from VideoActivity into an injectable network-information provider; a user-facing diagnostics screen is better treated as a separate enhancement.

Files changed (2) +36 / -6

Enhancement (1) +15 / -2
WfbLinkManager.javaLog attached USB metadata and adapter support status +15/-2

Log attached USB metadata and adapter support status

• Logs the attached USB device count plus each device's path, vendor/product IDs, names, and filter-match status. The no-adapter flow now passes its context into the null-safe wirelessInfo lookup.

app/src/main/java/com/openipc/pixelpilot/WfbLinkManager.java

Bug fix (1) +21 / -4
VideoActivity.javaMake wireless information lookup context-scoped and null-safe +21/-4

Make wireless information lookup context-scoped and null-safe

• Removes the activity-initialized static WifiManager field. wirelessInfo now obtains WifiManager from the application context, handles unavailable manager or connection information, and continues returning null when no IPv4 address exists.

app/src/main/java/com/openipc/pixelpilot/VideoActivity.java

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (1) 📜 Skill insights (0)

Grey Divider


Action required

1. 2357:0115 remains unsupported 📎 Requirement gap ≡ Correctness
Description
The new enumeration path only logs that devices absent from usb_device_filter.xml are unsupported;
it does not recognize TP-Link Archer T4U v3.2 VID 2357 / PID 0115. The adapter is therefore
excluded before driver startup, violating the required T4U v3.2 support.
Code

app/src/main/java/com/openipc/pixelpilot/WfbLinkManager.java[125]

+                    allowed ? "supported" : "NOT in usb_device_filter.xml"));
Evidence
Rules 1 and 3 require functional TP-Link Archer T4U v3.2 support, with Rule 1 specifically
identifying VID 2357 and PID 0115. The current filter contains other 2357 products but not PID
0115; getAttachedAdapters() consequently labels the device as absent from the filter and
excludes it before adapter startup.

Support TP-Link Archer T4U v3.2 with RTL8812BU
Support TP-Link Archer T4U v3.2
app/src/main/res/xml/usb_device_filter.xml[13-23]
app/src/main/java/com/openipc/pixelpilot/WfbLinkManager.java[111-131]
app/src/main/java/com/openipc/pixelpilot/WfbLinkManager.java[167-172]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
TP-Link Archer T4U v3.2 with VID `2357` and PID `0115` remains absent from the supported-device filter and is excluded from adapter startup.

## Issue Context
The logging change helps diagnose an unsupported device but does not satisfy the requirement for functional RTL8812BU support. Confirm that the native driver path supports RTL8812BU before adding the USB filter entry, and add or integrate the required driver support if it does not.

## Fix Focus Areas
- app/src/main/res/xml/usb_device_filter.xml[13-23]
- app/src/main/java/com/openipc/pixelpilot/WfbLinkManager.java[111-131]
- app/wfbngrtl8812/src/main/cpp/WfbngLink.cpp[119-134]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources

Grey Divider

Tip of the day
💡 Did you know, you can turn on the rule miner and Qodo learns your standards from review history

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants