Handle the case where null is returned for USB_STATE intent.
USB_STATE is not received if USB_STATE has not changed from the initial state. This CL adds handling for that case. BUG: 22163689 Change-Id: I232a558caaac4f4984f7629e2574d478fc7ad432
This commit is contained in:
@@ -47,7 +47,8 @@ public class UsbBackend {
|
|||||||
public UsbBackend(Context context) {
|
public UsbBackend(Context context) {
|
||||||
Intent intent = context.registerReceiver(null,
|
Intent intent = context.registerReceiver(null,
|
||||||
new IntentFilter(UsbManager.ACTION_USB_STATE));
|
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);
|
mUserManager = UserManager.get(context);
|
||||||
mUsbManager = context.getSystemService(UsbManager.class);
|
mUsbManager = context.getSystemService(UsbManager.class);
|
||||||
@@ -151,4 +152,4 @@ public class UsbBackend {
|
|||||||
// No port, support sink modes only.
|
// No port, support sink modes only.
|
||||||
return (mode & MODE_POWER_MASK) != MODE_POWER_SOURCE;
|
return (mode & MODE_POWER_MASK) != MODE_POWER_SOURCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user