Merge "Handle the case where null is returned for USB_STATE intent."
This commit is contained in:
committed by
Android (Google) Code Review
commit
a5c73b423d
@@ -47,7 +47,8 @@ public class UsbBackend {
|
||||
public UsbBackend(Context context) {
|
||||
Intent intent = context.registerReceiver(null,
|
||||
new IntentFilter(UsbManager.ACTION_USB_STATE));
|
||||
mIsUnlocked = intent.getBooleanExtra(UsbManager.USB_DATA_UNLOCKED, false);
|
||||
mIsUnlocked = intent == null ?
|
||||
false : intent.getBooleanExtra(UsbManager.USB_DATA_UNLOCKED, false);
|
||||
|
||||
mUserManager = UserManager.get(context);
|
||||
mUsbManager = context.getSystemService(UsbManager.class);
|
||||
@@ -151,4 +152,4 @@ public class UsbBackend {
|
||||
// No port, support sink modes only.
|
||||
return (mode & MODE_POWER_MASK) != MODE_POWER_SOURCE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user