Nreal Device Connection Infomation

We are implementing logic to determine if Nreal Light is connected to Android devices.
I was able to find out the USB Device Information that is displayed when connecting to Nreal Light through the source code that was implemented below.

However, I can’t determine which information is the unique ID of Nreal Light. Can I get information about this?

using System;
using UnityEngine;

public class ModeSwitcher : MonoBehaviour
{
    private  static AndroidJavaObject[] javaObject;
    // Start is called before the first frame update
    void Start()
    {
        GetDevicesInfo();
        
        foreach (var obj in javaObject)
        {
            Debug.Log($"[AndroidUSBDevices] android DeviceName : {obj.Call<String>("getDeviceName")}");
            Debug.Log($"[AndroidUSBDevices] android DeviceId : {obj.Call<int>("getDeviceId")}");
            Debug.Log($"[AndroidUSBDevices] android ProductName : {obj.Call<String>("getProductName")}");
            Debug.Log($"[AndroidUSBDevices] android VID : {obj.Call<int>("getVendorId")}");
            Debug.Log($"[AndroidUSBDevices] android PID : {obj.Call<int>("getProductId")}\n");
        }
    }
    public static void GetDevicesInfo()
    {
        if (AndroidJNI.AttachCurrentThread() == 0)
        {
            javaObject = new AndroidJavaClass("com.unity3d.player.UnityPlayer")
                    .GetStatic<AndroidJavaObject>("currentActivity")
                    .Call<AndroidJavaObject>("getSystemService", new object[] { "usb" })
                    .Call<AndroidJavaObject>("getDeviceList")
                    .Call<AndroidJavaObject>("values")
                    .Call<AndroidJavaObject[]>("toArray");
        }
    }
}

Hi, the PID and VID you printed are not the unique ID, maybe you can use ‘ProductName: Light’ as the reference to detect the device connection.

1 Like