mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-06-16 22:01:14 +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
|
// 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);
|
||||||
for (UsbDevice dev : usbManager.getDeviceList().values()) {
|
if (usbManager != null) {
|
||||||
// We explicitly check not to claim devices that appear as InputDevices
|
for (UsbDevice dev : usbManager.getDeviceList().values()) {
|
||||||
// otherwise we will double count them.
|
// We explicitly check not to claim devices that appear as InputDevices
|
||||||
if (UsbDriverService.shouldClaimDevice(dev, false) &&
|
// otherwise we will double count them.
|
||||||
!UsbDriverService.isRecognizedInputDevice(dev)) {
|
if (UsbDriverService.shouldClaimDevice(dev, false) &&
|
||||||
LimeLog.info("Counting UsbDevice: "+dev.getDeviceName());
|
!UsbDriverService.isRecognizedInputDevice(dev)) {
|
||||||
mask |= 1 << count++;
|
LimeLog.info("Counting UsbDevice: "+dev.getDeviceName());
|
||||||
|
mask |= 1 << count++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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