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