mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-06-17 14:21:08 +00:00
Check for a null UsbManager object
Apparently this can happen on some (broken?) devices
This commit is contained in:
@@ -365,6 +365,7 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
|||||||
// Count all USB devices that match our drivers
|
// Count all USB devices that match our drivers
|
||||||
if (PreferenceConfiguration.readPreferences(context).usbDriver) {
|
if (PreferenceConfiguration.readPreferences(context).usbDriver) {
|
||||||
UsbManager usbManager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
|
UsbManager usbManager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
|
||||||
|
if (usbManager != null) {
|
||||||
for (UsbDevice dev : usbManager.getDeviceList().values()) {
|
for (UsbDevice dev : usbManager.getDeviceList().values()) {
|
||||||
// We explicitly check not to claim devices that appear as InputDevices
|
// We explicitly check not to claim devices that appear as InputDevices
|
||||||
// otherwise we will double count them.
|
// otherwise we will double count them.
|
||||||
@@ -375,6 +376,7 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (PreferenceConfiguration.readPreferences(context).onscreenController) {
|
if (PreferenceConfiguration.readPreferences(context).onscreenController) {
|
||||||
LimeLog.info("Counting OSC gamepad");
|
LimeLog.info("Counting OSC gamepad");
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ public class UsbDriverService extends Service implements UsbDriverListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void start() {
|
private void start() {
|
||||||
if (started) {
|
if (started || usbManager == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user